@m4l/components 9.3.15-BE091725-beta.2 → 9.3.15-BE091725-beta.3
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/Card/Card.js +2 -2
- package/components/Card/Card.styles.js +39 -43
- package/components/Card/constants.js +7 -1
- package/components/Card/helpers/getSizeSpacing.d.ts +3 -4
- package/components/Card/helpers/getSizeSpacing.js +5 -5
- package/components/Card/slots/CardSlots.js +1 -1
- package/components/Card/types.d.ts +3 -5
- package/components/areas/icons.js +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +3 -35
- package/components/hook-form/RHFAutocomplete/types.d.ts +1 -6
- package/components/index.d.ts +1 -1
- package/components/mui_extended/Autocomplete/Autocomplete.js +12 -6
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +48 -5
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.d.ts +1 -0
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +4 -3
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +4 -4
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +39 -4
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.d.ts +3 -1
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.js +2 -0
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +6 -0
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +11 -1
- package/components/mui_extended/Autocomplete/types.d.ts +1 -1
- package/components/mui_extended/Button/ButtonStyles.js +3 -6
- package/components/mui_extended/Popper/Popper.js +9 -2
- package/components/mui_extended/Popper/types.d.ts +1 -0
- package/components/mui_extended/Select/Select.js +17 -10
- package/components/mui_extended/Select/Select.styles.js +17 -10
- package/components/mui_extended/Select/types.d.ts +1 -1
- package/components/mui_extended/TextField/TextField.d.ts +2 -1
- package/components/mui_extended/TextField/TextField.js +25 -4
- package/components/mui_extended/TextField/TextField.styles.js +132 -125
- package/components/mui_extended/TextField/slots/TextFieldSlots.d.ts +3 -9
- package/components/mui_extended/TextField/slots/TextFieldSlots.js +2 -1
- package/components/mui_extended/Typography/Typography.js +2 -4
- package/components/mui_extended/Typography/constants.d.ts +0 -4
- package/components/mui_extended/Typography/types.d.ts +0 -6
- package/components/mui_extended/Typography/typography.styles.js +0 -1
- package/index.js +4 -4
- package/package.json +1 -1
- package/test/mocks/dictionary-mock.d.ts +433 -0
package/components/Card/Card.js
CHANGED
|
@@ -6,14 +6,14 @@ const Card = (props) => {
|
|
|
6
6
|
const {
|
|
7
7
|
className,
|
|
8
8
|
variant = "text",
|
|
9
|
-
gap,
|
|
9
|
+
gap = "standard",
|
|
10
10
|
height = "auto",
|
|
11
11
|
children,
|
|
12
12
|
direction = "row",
|
|
13
13
|
justifyContent = "center",
|
|
14
14
|
alignItems = "center",
|
|
15
15
|
selected = false,
|
|
16
|
-
padding,
|
|
16
|
+
padding = "standard",
|
|
17
17
|
...others
|
|
18
18
|
} = props;
|
|
19
19
|
const ownerState = {
|
|
@@ -3,53 +3,49 @@ const cardStyles = {
|
|
|
3
3
|
/**
|
|
4
4
|
* Estilos para el contenedor principal del card.
|
|
5
5
|
*/
|
|
6
|
-
root: ({ theme, ownerState }) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
cursor: "pointer",
|
|
27
|
-
"&:hover": {
|
|
28
|
-
backgroundColor: theme.vars.palette.background.base
|
|
29
|
-
},
|
|
30
|
-
"&:active": {
|
|
31
|
-
backgroundColor: theme.vars.palette.default.activeOpacity
|
|
32
|
-
},
|
|
33
|
-
"&:focus-visible, &:focus-within": {
|
|
34
|
-
border: theme.vars.size.borderStroke.container,
|
|
35
|
-
borderColor: `${theme.vars.palette.primary.focusVisible}!important`,
|
|
36
|
-
outline: "unset!important"
|
|
37
|
-
}
|
|
6
|
+
root: ({ theme, ownerState }) => ({
|
|
7
|
+
display: "flex",
|
|
8
|
+
justifyContent: ownerState?.justifyContent ?? "center",
|
|
9
|
+
alignItems: ownerState?.alignItems ?? "center",
|
|
10
|
+
flexDirection: ownerState?.direction ?? "column",
|
|
11
|
+
gap: getSizeSpacing(ownerState?.gap),
|
|
12
|
+
padding: getSizeSpacing(ownerState?.padding),
|
|
13
|
+
transition: "all 0.2s ease-in-out",
|
|
14
|
+
width: "100%",
|
|
15
|
+
outline: "unset!important",
|
|
16
|
+
borderRadius: theme.vars.size.borderRadius.r2,
|
|
17
|
+
backgroundColor: theme.palette.background.paper,
|
|
18
|
+
height: ownerState?.height ?? "auto",
|
|
19
|
+
minHeight: ownerState?.height ?? "auto",
|
|
20
|
+
maxHeight: ownerState?.height ?? "auto",
|
|
21
|
+
overflow: "hidden",
|
|
22
|
+
...ownerState?.onClick && {
|
|
23
|
+
cursor: "pointer",
|
|
24
|
+
"&:hover": {
|
|
25
|
+
backgroundColor: theme.vars.palette.background.base
|
|
38
26
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
borderColor: theme.vars.palette.border.disabled
|
|
42
|
-
},
|
|
43
|
-
...ownerState?.variant === "text" && {
|
|
44
|
-
border: theme.vars.size.borderStroke.container,
|
|
45
|
-
borderColor: "transparent"
|
|
27
|
+
"&:active": {
|
|
28
|
+
backgroundColor: theme.vars.palette.default.activeOpacity
|
|
46
29
|
},
|
|
47
|
-
|
|
30
|
+
"&:focus-visible, &:focus-within": {
|
|
48
31
|
border: theme.vars.size.borderStroke.container,
|
|
49
|
-
borderColor: theme.vars.palette.primary.
|
|
32
|
+
borderColor: `${theme.vars.palette.primary.focusVisible}!important`,
|
|
33
|
+
outline: "unset!important"
|
|
50
34
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
35
|
+
},
|
|
36
|
+
...ownerState?.variant === "outlined" && {
|
|
37
|
+
border: theme.vars.size.borderStroke.container,
|
|
38
|
+
borderColor: theme.vars.palette.border.disabled
|
|
39
|
+
},
|
|
40
|
+
...ownerState?.variant === "text" && {
|
|
41
|
+
border: theme.vars.size.borderStroke.container,
|
|
42
|
+
borderColor: "transparent"
|
|
43
|
+
},
|
|
44
|
+
...ownerState?.selected && {
|
|
45
|
+
border: theme.vars.size.borderStroke.container,
|
|
46
|
+
borderColor: theme.vars.palette.primary.enabled
|
|
47
|
+
}
|
|
48
|
+
})
|
|
53
49
|
};
|
|
54
50
|
export {
|
|
55
51
|
cardStyles as c
|
|
@@ -11,7 +11,13 @@ const COMBINED_CLASSES = {
|
|
|
11
11
|
selected: "selected"
|
|
12
12
|
};
|
|
13
13
|
const CARD_CLASSES = getComponentClasses(CARD_KEY, COMBINED_CLASSES);
|
|
14
|
+
const CARD_SIZES = {
|
|
15
|
+
compact: 8,
|
|
16
|
+
standard: 16,
|
|
17
|
+
comfortable: 24
|
|
18
|
+
};
|
|
14
19
|
export {
|
|
15
20
|
CARD_CLASSES as C,
|
|
16
|
-
|
|
21
|
+
CARD_SIZES as a,
|
|
22
|
+
CARD_KEY as b
|
|
17
23
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Theme } from '@mui/material';
|
|
1
|
+
import { CardProps } from '../types';
|
|
3
2
|
/**
|
|
4
3
|
* Obtiene el tamaño del gap de la tarjeta.
|
|
5
|
-
* @param
|
|
4
|
+
* @param gap - El gap de la tarjeta.
|
|
6
5
|
* @returns El tamaño del gap de la tarjeta.
|
|
7
6
|
*/
|
|
8
|
-
export declare const getSizeSpacing: (
|
|
7
|
+
export declare const getSizeSpacing: (gap: CardProps["gap"] | number | undefined | null) => number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { a as CARD_SIZES } from "../constants.js";
|
|
2
|
+
const getSizeSpacing = (gap) => {
|
|
3
|
+
if (typeof gap === "number") {
|
|
4
|
+
return gap;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
return theme.vars.size.density[densityKey];
|
|
6
|
+
return CARD_SIZES[gap ?? "standard"];
|
|
7
7
|
};
|
|
8
8
|
export {
|
|
9
9
|
getSizeSpacing as g
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styled } from "@mui/material/styles";
|
|
2
|
-
import {
|
|
2
|
+
import { b as CARD_KEY } from "../constants.js";
|
|
3
3
|
import { C as CardSlots } from "./CardEnum.js";
|
|
4
4
|
import { c as cardStyles } from "../Card.styles.js";
|
|
5
5
|
const CardRootStyled = styled("div", {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Theme } from '@mui/material
|
|
1
|
+
import { Theme } from '@mui/material';
|
|
2
2
|
import { M4LOverridesStyleRules } from '../../@types/augmentations';
|
|
3
3
|
import { CARD_KEY } from './constants';
|
|
4
4
|
import { CardSlots } from './slots/CardEnum';
|
|
5
|
-
import { Density } from '@m4l/styles';
|
|
6
|
-
export type SpacingsCard = number | keyof Density;
|
|
7
5
|
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
6
|
/**
|
|
9
7
|
* Contenido de la tarjeta.
|
|
@@ -16,11 +14,11 @@ export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
16
14
|
/**
|
|
17
15
|
* Espacio entre los elementos de la tarjeta.
|
|
18
16
|
*/
|
|
19
|
-
gap?:
|
|
17
|
+
gap?: number | 'compact' | 'standard' | 'comfortable';
|
|
20
18
|
/**
|
|
21
19
|
* Espacio entre los elementos de la tarjeta.
|
|
22
20
|
*/
|
|
23
|
-
padding?:
|
|
21
|
+
padding?: number | 'compact' | 'standard' | 'comfortable';
|
|
24
22
|
/**
|
|
25
23
|
* Dirección de la tarjeta.
|
|
26
24
|
*/
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { getPropertyByString } from "@m4l/core";
|
|
3
|
-
import { useIsMobile } from "@m4l/graphics";
|
|
4
|
-
import { useTheme } from "@mui/material";
|
|
5
2
|
import { useId, useState, useCallback, useEffect } from "react";
|
|
6
3
|
import { useFormContext, Controller } from "react-hook-form";
|
|
7
4
|
import { A as AutocompleteRootStyled, L as LabelStyled } from "./slots/RHFAutocompleteSlots.js";
|
|
@@ -13,28 +10,22 @@ function RHFAutocomplete(props) {
|
|
|
13
10
|
getOptionLabel,
|
|
14
11
|
isOptionEqualToValue,
|
|
15
12
|
label,
|
|
16
|
-
color,
|
|
17
13
|
options,
|
|
18
14
|
disabled,
|
|
19
15
|
onOpen,
|
|
20
16
|
onClose,
|
|
21
17
|
loading,
|
|
22
|
-
variant,
|
|
23
18
|
helperMessage,
|
|
24
19
|
size,
|
|
25
20
|
onChangeFilterParmsLocal,
|
|
26
21
|
mandatory,
|
|
27
22
|
mandatoryMessage,
|
|
28
23
|
multiple,
|
|
29
|
-
imageScale = true,
|
|
30
|
-
imageRepeat,
|
|
31
24
|
refresh
|
|
32
25
|
// onChange: onChangeRHF,
|
|
33
26
|
} = props;
|
|
34
27
|
const htmlForId = useId();
|
|
35
|
-
const theme = useTheme();
|
|
36
28
|
const [open, setOpen] = useState(false);
|
|
37
|
-
const isDesktop = !useIsMobile();
|
|
38
29
|
const onCloseLocal = useCallback((event, reason) => {
|
|
39
30
|
setOpen(false);
|
|
40
31
|
if (onClose) {
|
|
@@ -59,34 +50,11 @@ function RHFAutocomplete(props) {
|
|
|
59
50
|
},
|
|
60
51
|
[getOptionLabel]
|
|
61
52
|
);
|
|
62
|
-
const paletteColor = getPropertyByString(
|
|
63
|
-
theme.vars.palette,
|
|
64
|
-
disabled ? "default" : color || "default",
|
|
65
|
-
theme.vars.palette.default
|
|
66
|
-
);
|
|
67
53
|
const {
|
|
68
|
-
control
|
|
69
|
-
formState: { errors }
|
|
54
|
+
control
|
|
70
55
|
} = useFormContext();
|
|
71
|
-
const [currentVariant, setCurrentVariant] = useState(null);
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
const hasError = errors[nameRHF];
|
|
74
|
-
if (hasError) {
|
|
75
|
-
setCurrentVariant("error");
|
|
76
|
-
} else if (variant) {
|
|
77
|
-
setCurrentVariant(variant);
|
|
78
|
-
} else {
|
|
79
|
-
setCurrentVariant(null);
|
|
80
|
-
}
|
|
81
|
-
}, [errors, nameRHF, variant, control]);
|
|
82
56
|
const ownerState = {
|
|
83
|
-
|
|
84
|
-
semantics: currentVariant,
|
|
85
|
-
disabled,
|
|
86
|
-
multiple: Boolean(multiple),
|
|
87
|
-
imageScale: Boolean(imageScale),
|
|
88
|
-
imageRepeat: Boolean(imageRepeat),
|
|
89
|
-
paletteColor
|
|
57
|
+
disabled
|
|
90
58
|
};
|
|
91
59
|
return /* @__PURE__ */ jsx(
|
|
92
60
|
AutocompleteRootStyled,
|
|
@@ -147,7 +115,7 @@ function RHFAutocomplete(props) {
|
|
|
147
115
|
htmlFor: htmlForId
|
|
148
116
|
}
|
|
149
117
|
),
|
|
150
|
-
|
|
118
|
+
error?.message ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
|
|
151
119
|
] });
|
|
152
120
|
}
|
|
153
121
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutocompleteCloseReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme,
|
|
1
|
+
import { AutocompleteCloseReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme, PopperProps } from '@mui/material';
|
|
2
2
|
import { ComponentPalletColor, Sizes } from '@m4l/styles';
|
|
3
3
|
import { TextFieldProps } from '../../mui_extended/TextField/types';
|
|
4
4
|
import { RFHAUTOCOMPLETE_KEY_COMPONENT } from './constants';
|
|
@@ -52,11 +52,6 @@ export interface RHFAutocompleteProps<T = any, Multiple extends boolean | undefi
|
|
|
52
52
|
*/
|
|
53
53
|
export interface RHFAutocompleteOwnerState extends Pick<RHFAutocompleteProps<any>, 'size' | 'disabled' | 'variant'> {
|
|
54
54
|
disabled?: boolean;
|
|
55
|
-
semantics: RHFAutocompleteVariants | 'error' | null;
|
|
56
|
-
multiple: boolean;
|
|
57
|
-
imageScale?: boolean;
|
|
58
|
-
imageRepeat?: boolean;
|
|
59
|
-
paletteColor: PaletteColor;
|
|
60
55
|
}
|
|
61
56
|
/**
|
|
62
57
|
* Defines the types of Slots available for the Autocomplete.
|
package/components/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export * from './AppBar';
|
|
|
4
4
|
export * from './AppBar/AppBar';
|
|
5
5
|
export * from './areas';
|
|
6
6
|
export * from './BaseModule';
|
|
7
|
-
export * from './Card';
|
|
8
7
|
export * from './Chip';
|
|
8
|
+
export * from './Card';
|
|
9
9
|
export * from './commercial';
|
|
10
10
|
export * from './CommonActions/';
|
|
11
11
|
export * from './ContainerFlow';
|
|
@@ -21,7 +21,9 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
21
21
|
// Diferencia
|
|
22
22
|
refresh,
|
|
23
23
|
error = false,
|
|
24
|
-
htmlFor
|
|
24
|
+
htmlFor,
|
|
25
|
+
readOnly = false,
|
|
26
|
+
placeholder
|
|
25
27
|
} = props;
|
|
26
28
|
const { getLabel } = useModuleDictionary();
|
|
27
29
|
const isSkeleton = useModuleSkeleton();
|
|
@@ -47,8 +49,9 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
47
49
|
variant,
|
|
48
50
|
disabled,
|
|
49
51
|
multiple: Boolean(multiple),
|
|
50
|
-
error
|
|
51
|
-
|
|
52
|
+
error,
|
|
53
|
+
readOnly
|
|
54
|
+
}), [adjustedSize, disabled, error, multiple, variant, readOnly]);
|
|
52
55
|
const startAdornments = useStartAdornments({
|
|
53
56
|
selectedValue,
|
|
54
57
|
multiple,
|
|
@@ -66,7 +69,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
66
69
|
handleRefresh,
|
|
67
70
|
disabled,
|
|
68
71
|
onOpenLocal,
|
|
69
|
-
open
|
|
72
|
+
open,
|
|
73
|
+
readOnly
|
|
70
74
|
});
|
|
71
75
|
if (isSkeleton) {
|
|
72
76
|
return /* @__PURE__ */ jsx(
|
|
@@ -158,12 +162,14 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
158
162
|
InputProps: {
|
|
159
163
|
...otherInputProps,
|
|
160
164
|
startAdornment: startAdornments,
|
|
161
|
-
endAdornment: endAdornments
|
|
165
|
+
endAdornment: endAdornments,
|
|
166
|
+
readOnly
|
|
162
167
|
},
|
|
163
168
|
SelectProps: { native: true },
|
|
164
169
|
size: adjustedSize,
|
|
165
170
|
fullWidth: true,
|
|
166
|
-
disabled
|
|
171
|
+
disabled,
|
|
172
|
+
placeholder
|
|
167
173
|
}
|
|
168
174
|
);
|
|
169
175
|
}
|
|
@@ -10,7 +10,20 @@ const autocompleteSyles = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Styles for the icon button component.
|
|
12
12
|
*/
|
|
13
|
-
iconButton: {}
|
|
13
|
+
iconButton: ({ ownerState }) => ({
|
|
14
|
+
...ownerState?.readOnly && {
|
|
15
|
+
"&:hover": {
|
|
16
|
+
backgroundColor: "unset!important"
|
|
17
|
+
},
|
|
18
|
+
"&:active": {
|
|
19
|
+
backgroundColor: "unset!important"
|
|
20
|
+
},
|
|
21
|
+
"&:focus-visible": {
|
|
22
|
+
backgroundColor: "unset!important",
|
|
23
|
+
outline: "none!important"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
14
27
|
/**
|
|
15
28
|
* Styles for the input component.
|
|
16
29
|
*/
|
|
@@ -79,10 +92,22 @@ const autocompleteSyles = {
|
|
|
79
92
|
/**
|
|
80
93
|
* Styles for the popper component.
|
|
81
94
|
*/
|
|
82
|
-
popper: (
|
|
83
|
-
|
|
95
|
+
popper: () => ({
|
|
96
|
+
width: "fit-content!important",
|
|
97
|
+
maxWidth: "calc(100vw - 20px)",
|
|
84
98
|
"& .MuiPaper-root": {
|
|
85
|
-
|
|
99
|
+
minWidth: "100%",
|
|
100
|
+
maxHeight: "200px",
|
|
101
|
+
"& .MuiAutocomplete-listbox": {
|
|
102
|
+
height: "100%",
|
|
103
|
+
"& .M4LMenuItem-root ": {
|
|
104
|
+
width: "fit-content",
|
|
105
|
+
"& .M4LTypography-root": {
|
|
106
|
+
width: "fit-content",
|
|
107
|
+
overflow: "unset"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
86
111
|
}
|
|
87
112
|
}),
|
|
88
113
|
/**
|
|
@@ -106,7 +131,25 @@ const autocompleteSyles = {
|
|
|
106
131
|
)
|
|
107
132
|
};
|
|
108
133
|
},
|
|
109
|
-
renderInputText: {}
|
|
134
|
+
renderInputText: {},
|
|
135
|
+
/**
|
|
136
|
+
* Styles for the container multiple values component.
|
|
137
|
+
*/
|
|
138
|
+
containerMultipleValues: () => ({
|
|
139
|
+
display: "flex",
|
|
140
|
+
overflow: "auto",
|
|
141
|
+
width: "100%",
|
|
142
|
+
flex: 1,
|
|
143
|
+
maxHeight: "80px"
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Styles for the container wrapper component.
|
|
147
|
+
*/
|
|
148
|
+
containerWrapper: ({ theme }) => ({
|
|
149
|
+
display: "flex",
|
|
150
|
+
flexWrap: "wrap",
|
|
151
|
+
gap: theme.vars.size.baseSpacings.sp1
|
|
152
|
+
})
|
|
110
153
|
};
|
|
111
154
|
export {
|
|
112
155
|
autocompleteSyles as a
|
|
@@ -11,7 +11,8 @@ function useEndAdornments(props) {
|
|
|
11
11
|
handleRefresh,
|
|
12
12
|
disabled,
|
|
13
13
|
onOpenLocal,
|
|
14
|
-
open
|
|
14
|
+
open,
|
|
15
|
+
readOnly
|
|
15
16
|
} = props;
|
|
16
17
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
17
18
|
return /* @__PURE__ */ jsxs(AdormentsStyled, { children: [
|
|
@@ -26,7 +27,7 @@ function useEndAdornments(props) {
|
|
|
26
27
|
{
|
|
27
28
|
ownerState: { ...ownerState },
|
|
28
29
|
icon: `${host_static_assets}/${environment_assets}/${icons.refresh}`,
|
|
29
|
-
onClick: handleRefresh,
|
|
30
|
+
onClick: !readOnly ? handleRefresh : void 0,
|
|
30
31
|
disabled,
|
|
31
32
|
size: adjustedSize
|
|
32
33
|
}
|
|
@@ -36,7 +37,7 @@ function useEndAdornments(props) {
|
|
|
36
37
|
{
|
|
37
38
|
ownerState: { ...ownerState },
|
|
38
39
|
icon: `${host_static_assets}/${environment_assets}/${icons.chevronDown}`,
|
|
39
|
-
onClick: (event) => onOpenLocal(event),
|
|
40
|
+
onClick: (event) => !readOnly ? onOpenLocal(event) : void 0,
|
|
40
41
|
disabled,
|
|
41
42
|
size: adjustedSize,
|
|
42
43
|
rotationAngle: open ? 180 : 0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { b as ChipStyled } from "../slots/AutocompleteSlots.js";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { b as ContainerMultipleValuesStyled, c as ContainerWrapperStyled, d as ChipStyled } from "../slots/AutocompleteSlots.js";
|
|
3
3
|
function useStartAdornments(props) {
|
|
4
4
|
const {
|
|
5
5
|
selectedValue,
|
|
@@ -13,7 +13,7 @@ function useStartAdornments(props) {
|
|
|
13
13
|
if (!(Array.isArray(selectedValue) && multiple)) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
-
return /* @__PURE__ */ jsx(
|
|
16
|
+
return /* @__PURE__ */ jsx(ContainerMultipleValuesStyled, { children: /* @__PURE__ */ jsx(ContainerWrapperStyled, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
|
|
17
17
|
ChipStyled,
|
|
18
18
|
{
|
|
19
19
|
size: adjustedSize,
|
|
@@ -24,7 +24,7 @@ function useStartAdornments(props) {
|
|
|
24
24
|
ownerState: { ...ownerState }
|
|
25
25
|
},
|
|
26
26
|
`${option}-${index}`
|
|
27
|
-
)) });
|
|
27
|
+
)) }) });
|
|
28
28
|
}
|
|
29
29
|
export {
|
|
30
30
|
useStartAdornments as u
|
|
@@ -4,7 +4,7 @@ function useValuesAndHandlers(props) {
|
|
|
4
4
|
const {
|
|
5
5
|
getOptionLabel,
|
|
6
6
|
isOptionEqualToValue,
|
|
7
|
-
options,
|
|
7
|
+
options = [],
|
|
8
8
|
onOpen,
|
|
9
9
|
onClose,
|
|
10
10
|
onChangeFilterParmsLocal,
|
|
@@ -13,7 +13,8 @@ function useValuesAndHandlers(props) {
|
|
|
13
13
|
// Diferencia
|
|
14
14
|
refresh,
|
|
15
15
|
onChange,
|
|
16
|
-
value
|
|
16
|
+
value,
|
|
17
|
+
readOnly
|
|
17
18
|
} = props;
|
|
18
19
|
const [open, setOpen] = useState(false);
|
|
19
20
|
const scrollPositionOptionsRef = useRef(0);
|
|
@@ -39,6 +40,9 @@ function useValuesAndHandlers(props) {
|
|
|
39
40
|
[isOptionEqualToValue]
|
|
40
41
|
);
|
|
41
42
|
const handleDelete = useCallback((optionToDelete) => {
|
|
43
|
+
if (readOnly) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
42
46
|
if (Array.isArray(selectedValue)) {
|
|
43
47
|
const updatedValue = selectedValue.filter(
|
|
44
48
|
(val) => !isOptionEqualToValueLocal(val, optionToDelete)
|
|
@@ -50,7 +54,7 @@ function useValuesAndHandlers(props) {
|
|
|
50
54
|
"removeOption"
|
|
51
55
|
);
|
|
52
56
|
}
|
|
53
|
-
}, [selectedValue, isOptionEqualToValueLocal, onChange]);
|
|
57
|
+
}, [selectedValue, isOptionEqualToValueLocal, onChange, readOnly]);
|
|
54
58
|
const handleRefresh = useCallback(() => {
|
|
55
59
|
refresh?.();
|
|
56
60
|
setOpen(true);
|
|
@@ -64,6 +68,9 @@ function useValuesAndHandlers(props) {
|
|
|
64
68
|
onChange?.(event, updatedValue, reason);
|
|
65
69
|
};
|
|
66
70
|
const handleInputChange = (_event, newValue, reason) => {
|
|
71
|
+
if (readOnly) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
67
74
|
setInputValue(newValue);
|
|
68
75
|
if (onChangeFilterParmsLocal && reason === "input") {
|
|
69
76
|
onChangeFilterParmsLocal(newValue, reason);
|
|
@@ -85,11 +92,14 @@ function useValuesAndHandlers(props) {
|
|
|
85
92
|
}
|
|
86
93
|
};
|
|
87
94
|
const onOpenLocal = useCallback((event) => {
|
|
95
|
+
if (readOnly) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
88
98
|
setOpen((currentState) => !currentState);
|
|
89
99
|
if (onOpen) {
|
|
90
100
|
onOpen(event);
|
|
91
101
|
}
|
|
92
|
-
}, [onOpen]);
|
|
102
|
+
}, [onOpen, readOnly]);
|
|
93
103
|
const getOptionLabelLocal = useCallback(
|
|
94
104
|
(option) => {
|
|
95
105
|
if (typeof option === "string") {
|
|
@@ -109,6 +119,14 @@ function useValuesAndHandlers(props) {
|
|
|
109
119
|
return getOptionUrlImage(option);
|
|
110
120
|
}, [getOptionUrlImage]);
|
|
111
121
|
const [inputValue, setInputValue] = useState("");
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (readOnly && value !== null && value !== void 0 && !multiple) {
|
|
124
|
+
const displayValue = getOptionLabelLocal(value);
|
|
125
|
+
setInputValue(displayValue);
|
|
126
|
+
} else if (readOnly && multiple) {
|
|
127
|
+
setInputValue("");
|
|
128
|
+
}
|
|
129
|
+
}, [readOnly, value, getOptionLabelLocal, multiple]);
|
|
112
130
|
useEffect(() => {
|
|
113
131
|
if (open === false && value === null && inputValue !== "") {
|
|
114
132
|
setInputValue("");
|
|
@@ -118,6 +136,23 @@ function useValuesAndHandlers(props) {
|
|
|
118
136
|
if (e.code === "Enter") {
|
|
119
137
|
e.preventDefault();
|
|
120
138
|
}
|
|
139
|
+
if (readOnly) {
|
|
140
|
+
const allowedKeys = [
|
|
141
|
+
"Tab",
|
|
142
|
+
"Escape",
|
|
143
|
+
"ArrowUp",
|
|
144
|
+
"ArrowDown",
|
|
145
|
+
"ArrowLeft",
|
|
146
|
+
"ArrowRight",
|
|
147
|
+
"Home",
|
|
148
|
+
"End",
|
|
149
|
+
"PageUp",
|
|
150
|
+
"PageDown"
|
|
151
|
+
];
|
|
152
|
+
if (!allowedKeys.includes(e.key) && !e.ctrlKey && !e.metaKey) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
121
156
|
};
|
|
122
157
|
const selectedOption = options.find((option) => {
|
|
123
158
|
return isOptionEqualToValueLocal(option, selectedValue);
|
|
@@ -11,5 +11,7 @@ export declare enum AutocompleteSlots {
|
|
|
11
11
|
circularProgress = "circularProgress",
|
|
12
12
|
textField = "textField",
|
|
13
13
|
image = "image",
|
|
14
|
-
renderInputText = "renderInputText"
|
|
14
|
+
renderInputText = "renderInputText",
|
|
15
|
+
containerMultipleValues = "containerMultipleValues",
|
|
16
|
+
containerWrapper = "containerWrapper"
|
|
15
17
|
}
|
|
@@ -12,6 +12,8 @@ var AutocompleteSlots = /* @__PURE__ */ ((AutocompleteSlots2) => {
|
|
|
12
12
|
AutocompleteSlots2["textField"] = "textField";
|
|
13
13
|
AutocompleteSlots2["image"] = "image";
|
|
14
14
|
AutocompleteSlots2["renderInputText"] = "renderInputText";
|
|
15
|
+
AutocompleteSlots2["containerMultipleValues"] = "containerMultipleValues";
|
|
16
|
+
AutocompleteSlots2["containerWrapper"] = "containerWrapper";
|
|
15
17
|
return AutocompleteSlots2;
|
|
16
18
|
})(AutocompleteSlots || {});
|
|
17
19
|
export {
|
|
@@ -39,3 +39,9 @@ export declare const RenderInputTextStyled: import('@emotion/styled').StyledComp
|
|
|
39
39
|
export declare const AdormentsStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
40
40
|
ownerState?: (Partial<import('../types').AutocompleteOwnerState> & Record<string, unknown>) | undefined;
|
|
41
41
|
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
42
|
+
export declare const ContainerMultipleValuesStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
43
|
+
ownerState?: (Partial<import('../types').AutocompleteOwnerState> & Record<string, unknown>) | undefined;
|
|
44
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
45
|
+
export declare const ContainerWrapperStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
46
|
+
ownerState?: (Partial<import('../types').AutocompleteOwnerState> & Record<string, unknown>) | undefined;
|
|
47
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
@@ -64,6 +64,14 @@ const AdormentsStyled = styled("div", {
|
|
|
64
64
|
name: AUTOCOMPLETE_KEY_COMPONENT,
|
|
65
65
|
slot: AutocompleteSlots.adorments
|
|
66
66
|
})(autocompleteSyles?.adorments);
|
|
67
|
+
const ContainerMultipleValuesStyled = styled("div", {
|
|
68
|
+
name: AUTOCOMPLETE_KEY_COMPONENT,
|
|
69
|
+
slot: AutocompleteSlots.containerMultipleValues
|
|
70
|
+
})(autocompleteSyles?.containerMultipleValues);
|
|
71
|
+
const ContainerWrapperStyled = styled("div", {
|
|
72
|
+
name: AUTOCOMPLETE_KEY_COMPONENT,
|
|
73
|
+
slot: AutocompleteSlots.containerWrapper
|
|
74
|
+
})(autocompleteSyles?.containerWrapper);
|
|
67
75
|
export {
|
|
68
76
|
AutocompleteRootStyled as A,
|
|
69
77
|
CircularProgressStyled as C,
|
|
@@ -72,5 +80,7 @@ export {
|
|
|
72
80
|
RenderInputStyled as R,
|
|
73
81
|
SkeletonAutocompleteStyled as S,
|
|
74
82
|
AdormentsStyled as a,
|
|
75
|
-
|
|
83
|
+
ContainerMultipleValuesStyled as b,
|
|
84
|
+
ContainerWrapperStyled as c,
|
|
85
|
+
ChipStyled as d
|
|
76
86
|
};
|
|
@@ -25,7 +25,7 @@ export interface BaseAutocompleteProps {
|
|
|
25
25
|
* Props for the unified Autocomplete component.
|
|
26
26
|
* Supports both single and multiple selection, and two types: `text` and `image`.
|
|
27
27
|
*/
|
|
28
|
-
export interface AutocompleteProps<T, Multiple extends boolean | undefined> extends Pick<MUIAutocompleteProps<T, Multiple, undefined, false>, 'options' | 'onOpen' | 'onClose' | 'loading' | 'disabled'
|
|
28
|
+
export interface AutocompleteProps<T, Multiple extends boolean | undefined> extends Pick<MUIAutocompleteProps<T, Multiple, undefined, false>, 'options' | 'onOpen' | 'onClose' | 'loading' | 'disabled'>, Pick<TextFieldProps, 'error'>, BaseAutocompleteProps {
|
|
29
29
|
/**
|
|
30
30
|
* Indica si el campo de texto está en modo de solo lectura.
|
|
31
31
|
* readOnly={true}
|