@m4l/components 9.2.47 → 9.2.48
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/mui_extended/Button/Button.js +2 -1
- package/components/mui_extended/Button/ButtonStyles.js +40 -126
- package/components/mui_extended/Button/types.d.ts +1 -12
- package/package.json +1 -1
- package/storybook/components/extended/mui/Button/Button.stories.d.ts +0 -8
- package/components/mui_extended/Button/classes/constants.d.ts +0 -1
- package/components/mui_extended/Button/classes/index.d.ts +0 -10
- package/components/mui_extended/Button/classes/types.d.ts +0 -29
|
@@ -15,7 +15,7 @@ const Button = forwardRef((props, ref) => {
|
|
|
15
15
|
disabled = false,
|
|
16
16
|
size = "small",
|
|
17
17
|
variant = "contained",
|
|
18
|
-
skeletonWidth = "
|
|
18
|
+
skeletonWidth = "15%",
|
|
19
19
|
...others
|
|
20
20
|
} = props;
|
|
21
21
|
const { currentSize } = useComponentSize(size);
|
|
@@ -74,6 +74,7 @@ const Button = forwardRef((props, ref) => {
|
|
|
74
74
|
size,
|
|
75
75
|
disabled,
|
|
76
76
|
disableRipple: true,
|
|
77
|
+
tabIndex: 0,
|
|
77
78
|
ownerState: { ...ownerState },
|
|
78
79
|
ref,
|
|
79
80
|
...others,
|
|
@@ -5,14 +5,36 @@ const buttonStyles = {
|
|
|
5
5
|
*/
|
|
6
6
|
buttonRoot: ({ theme, ownerState }) => ({
|
|
7
7
|
display: "flex",
|
|
8
|
+
flexWrap: "wrap",
|
|
8
9
|
alignItems: "center",
|
|
9
10
|
gap: theme.vars.size.baseSpacings.sp1,
|
|
10
11
|
padding: `0px ${theme.vars.size.baseSpacings.sp1}`,
|
|
11
12
|
boxShadow: "none",
|
|
12
13
|
borderRadius: theme.vars.size.borderRadius.r1,
|
|
14
|
+
"&:hover": {
|
|
15
|
+
backgroundColor: ownerState.paletteColor?.hoverOpacity,
|
|
16
|
+
borderColor: ownerState.paletteColor?.hover
|
|
17
|
+
},
|
|
18
|
+
"&:active": {
|
|
19
|
+
boxShadow: "none",
|
|
20
|
+
borderColor: ownerState.paletteColor?.active,
|
|
21
|
+
backgroundColor: ownerState.paletteColor?.activeOpacity
|
|
22
|
+
},
|
|
23
|
+
"&:focus-visible": {
|
|
24
|
+
boxShadow: "none",
|
|
25
|
+
outline: theme.vars.size.borderStroke.container,
|
|
26
|
+
outlineColor: theme.vars.palette.border.main,
|
|
27
|
+
outlineOffset: theme.vars.size.baseSpacings["sp0-5"],
|
|
28
|
+
backgroundColor: ownerState.paletteColor?.activeOpacity
|
|
29
|
+
},
|
|
13
30
|
"&:disabled": {
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
backgroundColor: "none",
|
|
32
|
+
"&&& .M4LIcon-icon": {
|
|
33
|
+
backgroundColor: theme.vars.palette.text.disabled
|
|
34
|
+
},
|
|
35
|
+
...ownerState.variant === "contained" && {
|
|
36
|
+
backgroundColor: ownerState.paletteColor?.enabled
|
|
37
|
+
}
|
|
16
38
|
},
|
|
17
39
|
...ownerState.variant === "contained" && {
|
|
18
40
|
backgroundColor: ownerState.paletteColor?.enabled,
|
|
@@ -20,109 +42,46 @@ const buttonStyles = {
|
|
|
20
42
|
backgroundColor: ownerState.paletteColor?.hover
|
|
21
43
|
},
|
|
22
44
|
"&:active": {
|
|
23
|
-
backgroundColor: ownerState.paletteColor?.active
|
|
24
|
-
},
|
|
25
|
-
"&:focus-visible": {
|
|
26
45
|
boxShadow: "none",
|
|
27
|
-
outline: theme.vars.size.borderStroke.container,
|
|
28
|
-
outlineColor: theme.vars.palette.border.main,
|
|
29
|
-
outlineOffset: theme.vars.size.baseSpacings["sp0-5"],
|
|
30
46
|
backgroundColor: ownerState.paletteColor?.active
|
|
31
47
|
}
|
|
32
48
|
},
|
|
33
49
|
...ownerState.variant === "outlined" && {
|
|
34
|
-
color: ownerState.paletteColor?.enabled,
|
|
35
50
|
borderColor: ownerState.paletteColor?.enabled,
|
|
36
|
-
backgroundColor: "transparent",
|
|
37
51
|
"&&& .M4LIcon-icon": {
|
|
38
52
|
backgroundColor: ownerState.paletteColor?.semanticText
|
|
39
|
-
},
|
|
40
|
-
...ownerState.color === "default" && {
|
|
41
|
-
borderColor: theme.vars.palette.border.default
|
|
42
|
-
},
|
|
43
|
-
"&&&:hover": {
|
|
44
|
-
borderColor: ownerState.paletteColor?.enabled,
|
|
45
|
-
backgroundColor: ownerState.paletteColor?.hoverOpacity
|
|
46
|
-
},
|
|
47
|
-
"&&&:active": {
|
|
48
|
-
borderColor: ownerState.paletteColor?.active,
|
|
49
|
-
backgroundColor: ownerState.paletteColor?.activeOpacity
|
|
50
|
-
},
|
|
51
|
-
"&&&:focus-visible": {
|
|
52
|
-
boxShadow: "none",
|
|
53
|
-
outline: theme.vars.size.borderStroke.container,
|
|
54
|
-
outlineColor: theme.vars.palette.border.main,
|
|
55
|
-
outlineOffset: theme.vars.size.baseSpacings["sp0-5"],
|
|
56
|
-
backgroundColor: ownerState.paletteColor?.activeOpacity
|
|
57
53
|
}
|
|
58
54
|
},
|
|
59
55
|
...ownerState.variant === "text" && {
|
|
60
56
|
color: ownerState.paletteColor?.semanticText,
|
|
61
57
|
borderColor: ownerState.paletteColor?.enabled,
|
|
62
|
-
backgroundColor: "transparent",
|
|
63
58
|
"&&& .M4LIcon-icon": {
|
|
64
59
|
backgroundColor: ownerState.paletteColor?.semanticText
|
|
65
|
-
},
|
|
66
|
-
"&&&:hover": {
|
|
67
|
-
backgroundColor: ownerState.paletteColor?.hoverOpacity
|
|
68
|
-
},
|
|
69
|
-
"&&&:active": {
|
|
70
|
-
backgroundColor: ownerState.paletteColor?.activeOpacity
|
|
71
|
-
},
|
|
72
|
-
"&:focus-visible": {
|
|
73
|
-
boxShadow: "none",
|
|
74
|
-
outline: theme.vars.size.borderStroke.container,
|
|
75
|
-
outlineColor: theme.vars.palette.border.main,
|
|
76
|
-
outlineOffset: theme.vars.size.baseSpacings["sp0-5"],
|
|
77
|
-
backgroundColor: ownerState.paletteColor?.activeOpacity
|
|
78
60
|
}
|
|
79
61
|
},
|
|
80
62
|
"& span": {
|
|
81
63
|
margin: "0px"
|
|
82
64
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"action"
|
|
87
|
-
)
|
|
88
|
-
// // Estilos específicos para el tamaño small
|
|
89
|
-
// ...(ownerState.size === 'small' && {
|
|
90
|
-
// ...(theme.generalSettings.isMobile
|
|
91
|
-
// ? {
|
|
92
|
-
// height: theme.vars.size.mobile.small.action,
|
|
93
|
-
// minHeight: theme.vars.size.mobile.small.action,
|
|
94
|
-
// }
|
|
95
|
-
// : {
|
|
96
|
-
// height: theme.vars.size.desktop.small.action,
|
|
97
|
-
// minHeight: theme.vars.size.desktop.small.action,
|
|
98
|
-
// }),
|
|
99
|
-
// }),
|
|
100
|
-
// // Estilos específicos para el tamaño medium
|
|
101
|
-
// ...(ownerState.size === 'medium' && {
|
|
102
|
-
// ...(theme.generalSettings.isMobile
|
|
103
|
-
// ? {
|
|
104
|
-
// height: theme.vars.size.mobile.medium.action,
|
|
105
|
-
// minHeight: theme.vars.size.mobile.medium.action,
|
|
106
|
-
// }
|
|
107
|
-
// : {
|
|
108
|
-
// height: theme.vars.size.desktop.medium.action,
|
|
109
|
-
// minHeight: theme.vars.size.desktop.medium.action,
|
|
110
|
-
// }),
|
|
111
|
-
// }),
|
|
65
|
+
maxWidth: "100%",
|
|
66
|
+
height: "auto !important",
|
|
67
|
+
minHeight: theme.generalSettings?.isMobile ? theme.vars.size.mobile[ownerState.size || "medium"].action : theme.vars.size.desktop[ownerState.size || "medium"].action
|
|
112
68
|
}),
|
|
113
|
-
buttonIcon: {},
|
|
114
69
|
/**
|
|
115
70
|
* Styles for the text of the button component.
|
|
116
71
|
*/
|
|
117
72
|
textButton: ({ theme, ownerState }) => ({
|
|
73
|
+
cursor: ownerState.disabled ? "not-allowed" : "pointer",
|
|
118
74
|
...theme.typography.bodyDens,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
75
|
+
whiteSpace: "normal",
|
|
76
|
+
wordBreak: "break-word",
|
|
77
|
+
...ownerState.variant === "contained" && {
|
|
78
|
+
color: ownerState.paletteColor?.contrastText
|
|
79
|
+
},
|
|
80
|
+
...(ownerState.variant === "outlined" || ownerState.variant === "text") && {
|
|
81
|
+
color: ownerState.paletteColor?.semanticText
|
|
82
|
+
},
|
|
83
|
+
...ownerState.disabled && {
|
|
84
|
+
color: theme.vars.palette.text.disabled
|
|
126
85
|
}
|
|
127
86
|
}),
|
|
128
87
|
/**
|
|
@@ -141,54 +100,9 @@ const buttonStyles = {
|
|
|
141
100
|
minHeight: sizeValue
|
|
142
101
|
})
|
|
143
102
|
)
|
|
144
|
-
// // Estilos específicos para el tamaño small
|
|
145
|
-
// ...(ownerState.size === 'small' && {
|
|
146
|
-
// ...(theme.generalSettings.isMobile
|
|
147
|
-
// ? {
|
|
148
|
-
// height: theme.vars.size.mobile.small.action,
|
|
149
|
-
// minHeight: theme.vars.size.mobile.small.action,
|
|
150
|
-
// }
|
|
151
|
-
// : {
|
|
152
|
-
// height: theme.vars.size.desktop.small.action,
|
|
153
|
-
// minHeight: theme.vars.size.desktop.small.action,
|
|
154
|
-
// }),
|
|
155
|
-
// [theme.breakpoints.up('sm')]: {
|
|
156
|
-
// ...(theme.generalSettings.isMobile
|
|
157
|
-
// ? {
|
|
158
|
-
// height: theme.vars.size.mobile.small.action,
|
|
159
|
-
// minHeight: theme.vars.size.mobile.small.action,
|
|
160
|
-
// }
|
|
161
|
-
// : {
|
|
162
|
-
// height: theme.vars.size.desktop.small.action,
|
|
163
|
-
// minHeight: theme.vars.size.desktop.small.action,
|
|
164
|
-
// }),
|
|
165
|
-
// },
|
|
166
|
-
// }),
|
|
167
|
-
// // Estilos específicos para el tamaño medium
|
|
168
|
-
// ...(ownerState.size === 'medium' && {
|
|
169
|
-
// ...(theme.generalSettings.isMobile
|
|
170
|
-
// ? {
|
|
171
|
-
// height: theme.vars.size.mobile.medium.action,
|
|
172
|
-
// minHeight: theme.vars.size.mobile.medium.action,
|
|
173
|
-
// }
|
|
174
|
-
// : {
|
|
175
|
-
// height: theme.vars.size.desktop.medium.action,
|
|
176
|
-
// minHeight: theme.vars.size.desktop.medium.action,
|
|
177
|
-
// }),
|
|
178
|
-
// [theme.breakpoints.up('md')]: {
|
|
179
|
-
// ...(theme.generalSettings.isMobile
|
|
180
|
-
// ? {
|
|
181
|
-
// height: theme.vars.size.mobile.small.action,
|
|
182
|
-
// minHeight: theme.vars.size.mobile.small.action,
|
|
183
|
-
// }
|
|
184
|
-
// : {
|
|
185
|
-
// height: theme.vars.size.desktop.small.action,
|
|
186
|
-
// minHeight: theme.vars.size.desktop.small.action,
|
|
187
|
-
// }),
|
|
188
|
-
// },
|
|
189
|
-
// }),
|
|
190
103
|
}
|
|
191
|
-
})
|
|
104
|
+
}),
|
|
105
|
+
buttonIcon: {}
|
|
192
106
|
};
|
|
193
107
|
export {
|
|
194
108
|
buttonStyles as b
|
|
@@ -8,17 +8,6 @@ import { ReactNode } from 'react';
|
|
|
8
8
|
* [ButtonVariants] - Defines the possible variants for the `Button` component.
|
|
9
9
|
*/
|
|
10
10
|
export type ButtonVariants = 'contained' | 'outlined' | 'text';
|
|
11
|
-
/**
|
|
12
|
-
* Props for the `Button` component, extending the original properties of Material UI.
|
|
13
|
-
* [startIcon] - Optional prop for the icon on the left in the `Button`.
|
|
14
|
-
* [endIcon] - Optional prop for the icon on the right in the `Button`.
|
|
15
|
-
* label - Text describing the `Button`.
|
|
16
|
-
* [disabled] - Indicates if the `Button` is disabled.
|
|
17
|
-
* [size] - Size of the `Button` (default 'medium').
|
|
18
|
-
* [error] - Indicates if the `Button` is in an error state.
|
|
19
|
-
* [variant] - Defines the variant of the `Button` (default 'contained').
|
|
20
|
-
* [color] - Defines the color of the `Button`.
|
|
21
|
-
*/
|
|
22
11
|
export interface ButtonProps extends Omit<MUIButtonProps, 'size' | 'variant' | 'color'> {
|
|
23
12
|
startIcon?: ReactNode;
|
|
24
13
|
endIcon?: ReactNode;
|
|
@@ -43,4 +32,4 @@ export type ButtonSlotsType = keyof typeof ButtonSlots;
|
|
|
43
32
|
/**
|
|
44
33
|
* Styles applicable to the `Button` using themes and custom slots.
|
|
45
34
|
*/
|
|
46
|
-
export type ButtonStyles =
|
|
35
|
+
export type ButtonStyles = OverridesStyleRules<ButtonSlotsType, typeof BUTTON_KEY_COMPONENT, Theme>;
|
package/package.json
CHANGED
|
@@ -6,14 +6,6 @@ type Story = StoryObj<typeof Button>;
|
|
|
6
6
|
* Base story for `Button` in standard mode.
|
|
7
7
|
*/
|
|
8
8
|
export declare const Default: Story;
|
|
9
|
-
/**
|
|
10
|
-
* Base story for `Button` with start icon.
|
|
11
|
-
*/
|
|
12
|
-
export declare const WithStartIcon: Story;
|
|
13
|
-
/**
|
|
14
|
-
* Base story for `Button` with end icon.
|
|
15
|
-
*/
|
|
16
|
-
export declare const WithEndIcon: Story;
|
|
17
9
|
/**
|
|
18
10
|
* Base story for `Button` with start and end icon.
|
|
19
11
|
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const componentName = "M4LButton";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ButtonClassesType, OwnerState } from './types';
|
|
2
|
-
export declare const buttonClasses: ButtonClassesType;
|
|
3
|
-
export declare function getButtonUtilityClass(slot: string): string;
|
|
4
|
-
/**
|
|
5
|
-
* TODO: Documentar
|
|
6
|
-
*/
|
|
7
|
-
export declare const useUtilityClasses: (onwerState: OwnerState) => {
|
|
8
|
-
skeleton: string;
|
|
9
|
-
root: string;
|
|
10
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ButtonProps as MUIButtonProps } from '@mui/material';
|
|
2
|
-
import { useUtilityClasses } from '.';
|
|
3
|
-
export interface ButtonClassesType {
|
|
4
|
-
root: string;
|
|
5
|
-
skeleton: string;
|
|
6
|
-
sizeSmall: string;
|
|
7
|
-
sizeMedium: string;
|
|
8
|
-
variantOutlined: string;
|
|
9
|
-
variantContained: string;
|
|
10
|
-
variantText: string;
|
|
11
|
-
isDisabled: string;
|
|
12
|
-
colorError: string;
|
|
13
|
-
colorSuccess: string;
|
|
14
|
-
colorWarning: string;
|
|
15
|
-
/**Toggle */
|
|
16
|
-
togglePressed: string;
|
|
17
|
-
toggleNotPressed: string;
|
|
18
|
-
}
|
|
19
|
-
export type ButtonClassesKey = keyof ButtonClassesType;
|
|
20
|
-
export type Classes = ReturnType<typeof useUtilityClasses>;
|
|
21
|
-
export interface ButtonProps extends Omit<MUIButtonProps, 'size'> {
|
|
22
|
-
size?: 'small' | 'medium';
|
|
23
|
-
skeletonWidth?: number | string;
|
|
24
|
-
skeletonHeight?: number | string;
|
|
25
|
-
colorState?: 'error' | 'success' | 'warning';
|
|
26
|
-
}
|
|
27
|
-
export interface OwnerState extends Pick<ButtonProps, 'size' | 'variant' | 'colorState'> {
|
|
28
|
-
isDisabled?: boolean;
|
|
29
|
-
}
|