@m4l/components 9.1.34 → 9.1.35

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.
@@ -60,9 +60,7 @@ function TabsGpsTools() {
60
60
  {
61
61
  value: tab.id,
62
62
  icon: /* @__PURE__ */ jsx(Icon, { src: tab.iconUrl }),
63
- className: clsx(gpsToolsClasses.gpsToolsTab, tab.className),
64
- SKTWidth: "100px",
65
- SKTHeight: "14px"
63
+ className: clsx(gpsToolsClasses.gpsToolsTab, tab.className)
66
64
  },
67
65
  tab.id
68
66
  ))
@@ -52,9 +52,7 @@ function MyTabs() {
52
52
  {
53
53
  value: tab.id,
54
54
  icon: /* @__PURE__ */ jsx(Icon, { src: tab.iconUrl }),
55
- label: "",
56
- SKTWidth: "100px",
57
- SKTHeight: "14px"
55
+ label: ""
58
56
  },
59
57
  tab.id
60
58
  ))
@@ -4,6 +4,5 @@
4
4
  */
5
5
  export declare enum TabSlots {
6
6
  root = "root",
7
- icon = "icon",
8
7
  tipography = "tipography"
9
8
  }
@@ -1,6 +1,5 @@
1
1
  var TabSlots = /* @__PURE__ */ ((TabSlots2) => {
2
2
  TabSlots2["root"] = "root";
3
- TabSlots2["icon"] = "icon";
4
3
  TabSlots2["tipography"] = "tipography";
5
4
  return TabSlots2;
6
5
  })(TabSlots || {});
@@ -16,11 +16,3 @@ export declare const RootStyled: import('@emotion/styled').StyledComponent<Pick<
16
16
  export declare const TypographyStyled: import('@emotion/styled').StyledComponent<Pick<import('../../Typography/types').TypographyProps, keyof import('../../Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Partial<import('../types').TabOwnerState> & Record<string, unknown> & {
17
17
  ownerState: Partial<import('../types').TabOwnerState> & Record<string, unknown>;
18
18
  }, {}, {}>;
19
- /**
20
- * `IconStyled`:
21
- * Componente de ícono estilizado basado en `Icon`, utilizado para mostrar un ícono en cada pestaña.
22
- * Usa el slot `icon` para modificar o añadir estilos específicos a los íconos en las pestañas.
23
- */
24
- export declare const IconStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../Icon').IconProps, keyof import('../../../Icon').IconProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Partial<import('../types').TabOwnerState> & Record<string, unknown> & {
25
- ownerState: Partial<import('../types').TabOwnerState> & Record<string, unknown>;
26
- }, {}, {}>;
@@ -4,7 +4,6 @@ import { t as tabStyles } from "../Tab.styles.js";
4
4
  import { T as TAB_KEY_COMPONENT } from "../constants.js";
5
5
  import { T as TabSlots } from "./TabEnum.js";
6
6
  import { T as Typography } from "../../Typography/Typography.js";
7
- import { I as Icon } from "../../../Icon/Icon.js";
8
7
  const RootStyled = styled(Tab, {
9
8
  name: TAB_KEY_COMPONENT,
10
9
  slot: TabSlots.root
@@ -13,12 +12,7 @@ const TypographyStyled = styled(Typography, {
13
12
  name: TAB_KEY_COMPONENT,
14
13
  slot: TabSlots.tipography
15
14
  })(tabStyles?.tipography);
16
- const IconStyled = styled(Icon, {
17
- name: TAB_KEY_COMPONENT,
18
- slot: TabSlots.icon
19
- })(tabStyles?.icon);
20
15
  export {
21
- IconStyled as I,
22
16
  RootStyled as R,
23
17
  TypographyStyled as T
24
18
  };
@@ -1,15 +1,14 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { clsx } from "clsx";
3
- import { useModuleSkeleton, getPropertyByString } from "@m4l/core";
4
- import { useTheme } from "@mui/material";
5
- import { a as TYPOGRAPHY_KEY, b as TAB_SPECIFY, I as ICON_KEY } from "./constants.js";
6
- import { useRef, useMemo } from "react";
3
+ import { useModuleSkeleton } from "@m4l/core";
4
+ import { T as TabSlots } from "./Slots/TabEnum.js";
5
+ import { a as TYPOGRAPHY_KEY, b as TAB_SPECIFY, I as ICON_KEY, T as TAB_KEY_COMPONENT } from "./constants.js";
6
+ import { a as getComponentClasses } from "../../../utils/getComponentSlotRoot.js";
7
7
  import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
8
- import { R as RootStyled, T as TypographyStyled, I as IconStyled } from "./Slots/TabSlots.js";
8
+ import { R as RootStyled, T as TypographyStyled } from "./Slots/TabSlots.js";
9
+ import { I as Icon } from "../../Icon/Icon.js";
9
10
  function Tab(props) {
10
11
  const {
11
- SKTWidth,
12
- SKTHeight,
13
12
  size = "medium",
14
13
  // Tamaño del tab, por defecto 'medium'.
15
14
  disabled,
@@ -19,45 +18,40 @@ function Tab(props) {
19
18
  urlIcon,
20
19
  // URL del icono a mostrar en el tab.
21
20
  value,
21
+ // Valor del tab en posición.
22
+ color = "default",
23
+ // Color del tab.
24
+ className,
22
25
  ...other
23
26
  // Otras propiedades que se pasan al componente.
24
27
  } = props;
25
- const refMuiTab = useRef(null);
26
- const isSelected = useMemo(() => {
27
- if (refMuiTab.current) {
28
- return refMuiTab.current?.classList?.contains("Mui-selected");
29
- }
30
- return false;
31
- }, [refMuiTab.current]);
32
28
  const { currentSize } = useComponentSize(size);
33
29
  const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
34
30
  const isSkeleton = useModuleSkeleton();
35
- const theme = useTheme();
36
- const paletteColor = getPropertyByString(theme.vars.palette, disabled || !isSelected || isSkeleton ? "default" : "primary", theme.vars.palette.default);
37
31
  const OwnerState = {
38
- paletteColor,
39
- size: adjustedSize,
40
- disabled,
41
- skeleton: isSkeleton
32
+ tabColor: color,
33
+ tabSize: adjustedSize,
34
+ tabDisabled: disabled,
35
+ tabSkeleton: isSkeleton
42
36
  };
37
+ const classes = getComponentClasses(TAB_KEY_COMPONENT, TabSlots);
43
38
  return /* @__PURE__ */ jsx(
44
39
  RootStyled,
45
40
  {
46
- ref: refMuiTab,
47
- label: label ? /* @__PURE__ */ jsx(TypographyStyled, { className: clsx(TYPOGRAPHY_KEY, TAB_SPECIFY), skeletonWidth: 40, ownerState: { OwnerState }, variant: "body", children: label }) : void 0,
48
- disabled,
41
+ label: label ? /* @__PURE__ */ jsx(TypographyStyled, { className: clsx(TYPOGRAPHY_KEY, TAB_SPECIFY), ownerState: { ...OwnerState }, variant: "body", children: label }) : void 0,
42
+ disabled: isSkeleton || disabled,
49
43
  ownerState: { ...OwnerState },
50
44
  icon: urlIcon ? /* @__PURE__ */ jsx(
51
- IconStyled,
45
+ Icon,
52
46
  {
53
47
  className: clsx(ICON_KEY, TAB_SPECIFY),
54
- ownerState: { OwnerState },
55
48
  src: urlIcon,
56
49
  size
57
50
  }
58
51
  ) : void 0,
59
52
  value,
60
53
  tabIndex: 0,
54
+ className: clsx(classes.root, className),
61
55
  ...other
62
56
  }
63
57
  );
@@ -28,17 +28,17 @@ const tabStyles = {
28
28
  position: "relative",
29
29
  // Altura para vista móvil y de escritorio basada en el tamaño
30
30
  ...theme.generalSettings.isMobile ? {
31
- ...ownerState.size === "medium" && {
31
+ ...ownerState.tabSize === "medium" && {
32
32
  height: theme.vars.size.mobile.medium.container
33
33
  },
34
- ...ownerState.size === "small" && {
34
+ ...ownerState.tabSize === "small" && {
35
35
  height: theme.vars.size.mobile.small.container
36
36
  }
37
37
  } : {
38
- ...ownerState.size === "medium" && {
38
+ ...ownerState.tabSize === "medium" && {
39
39
  height: theme.vars.size.desktop.medium.container
40
40
  },
41
- ...ownerState.size === "small" && {
41
+ ...ownerState.tabSize === "small" && {
42
42
  height: theme.vars.size.desktop.small.container
43
43
  }
44
44
  },
@@ -46,33 +46,22 @@ const tabStyles = {
46
46
  "& .MuiTab-iconWrapper": {
47
47
  marginBottom: 1
48
48
  },
49
+ // Default o disabled
50
+ ".icon.M4lclassCssSpecificity div": {
51
+ backgroundColor: ownerState.tabDisabled ? theme.vars.palette.text.disabled : theme.vars.palette.text.secondary
52
+ },
53
+ "span.M4lclassCssSpecificity": {
54
+ color: ownerState.tabDisabled ? theme.vars.palette.text.disabled : theme.vars.palette.text.secondary
55
+ },
49
56
  /**
50
57
  * **Pseudoclases**:
51
58
  * - Estilos para los estados hover, focus-visible y active.
52
59
  */
53
60
  "&:hover": {
54
- background: theme.vars.palette.background.hover
55
- },
56
- "&:focus-visible": {
57
- background: ownerState.paletteColor?.hoverOpacity,
58
- "&::before": {
59
- content: '""',
60
- position: "absolute",
61
- top: `-${theme.size.baseSpacings.sp1}`,
62
- left: `-${theme.size.baseSpacings.sp1}`,
63
- right: `-${theme.size.baseSpacings.sp1}`,
64
- bottom: 0,
65
- boxSizing: "border-box",
66
- border: theme.vars.size.borderStroke.container,
67
- borderBottom: 0,
68
- borderColor: theme.vars.palette.border.main,
69
- borderRadius: theme.vars.size.borderRadius.r1,
70
- borderBottomRightRadius: 0,
71
- borderBottomLeftRadius: 0
72
- }
61
+ background: theme.vars.palette[ownerState.tabColor || "default"].hover
73
62
  },
74
63
  "&:active": {
75
- background: ownerState.paletteColor?.activeOpacity
64
+ background: theme.vars.palette[ownerState.tabColor || "default"].activeOpacity
76
65
  },
77
66
  /**
78
67
  * **Estado Seleccionado**:
@@ -80,15 +69,15 @@ const tabStyles = {
80
69
  * - Incluye estilos específicos para el icono y la tipografía.
81
70
  */
82
71
  "&.Mui-selected": {
72
+ background: theme.vars.palette.background.default,
83
73
  border: theme.vars.size.borderStroke.container,
84
74
  borderColor: theme.vars.palette.border.secondary,
85
75
  borderBottom: 0,
86
76
  ".icon.M4lclassCssSpecificity div": {
87
- backgroundColor: !ownerState.disabled ? ownerState.paletteColor?.main : theme.vars.palette.text.secondary
77
+ backgroundColor: ownerState.tabDisabled ? theme.vars.palette.text.disabled : theme.vars.palette.primary.enabled
88
78
  },
89
79
  "span": {
90
- color: !ownerState.disabled ? theme.vars.palette.primary.main : theme.vars.palette.text.secondary
91
- //ownerState.paletteColor?.main
80
+ color: ownerState.tabDisabled ? theme.vars.palette.text.disabled : theme.vars.palette.primary.enabled
92
81
  },
93
82
  // Efecto ripple en estado seleccionado
94
83
  "& .MuiTouchRipple-root": {
@@ -102,44 +91,81 @@ const tabStyles = {
102
91
  height: theme.vars.size.borderRadius["r0-5"],
103
92
  left: 0,
104
93
  top: -1,
105
- backgroundColor: ownerState.skeleton ? theme.vars.palette.background.surface : ownerState.disabled ? theme.vars.palette.background.surface : ownerState.paletteColor?.main,
106
- borderEndStartRadius: theme.vars.size.borderRadius["r0-5"],
107
- borderEndEndRadius: theme.vars.size.borderRadius["r0-5"],
94
+ backgroundColor: ownerState.tabSkeleton ? theme.vars.palette.background.surface : ownerState.tabDisabled ? theme.vars.palette.background.surface : theme.vars.palette.primary.main,
95
+ borderEndStartRadius: theme.vars.size.borderRadius["r1"],
96
+ borderEndEndRadius: theme.vars.size.borderRadius["r1"],
108
97
  position: "absolute"
98
+ },
99
+ "&:hover": {
100
+ backgroundColor: theme.vars.palette.primary.hoverOpacity
101
+ },
102
+ "&:active": {
103
+ background: theme.vars.palette.primary.activeOpacity,
104
+ ".icon.M4lclassCssSpecificity div": {
105
+ backgroundColor: theme.vars.palette.primary.active
106
+ },
107
+ "span": {
108
+ color: theme.vars.palette.primary.active
109
+ },
110
+ "&::after": {
111
+ background: theme.vars.palette.primary.active
112
+ }
109
113
  }
110
114
  },
111
- "&.Mui-selected:hover": {
112
- backgroundColor: ownerState.paletteColor?.hoverOpacity
113
- },
114
- "&.Mui-selected:active": {
115
- background: ownerState.paletteColor?.activeOpacity,
116
- ".icon.M4lclassCssSpecificity div": {
117
- backgroundColor: ownerState.paletteColor?.active
115
+ "&.Mui-selected:focus-visible": {
116
+ background: theme.vars.palette.primary.activeOpacity,
117
+ "&::before": {
118
+ zIndex: 1,
119
+ content: '""',
120
+ position: "absolute",
121
+ top: `-${theme.size.baseSpacings.sp1}`,
122
+ left: `-${theme.size.baseSpacings.sp1}`,
123
+ right: `-${theme.size.baseSpacings.sp1}`,
124
+ bottom: 0,
125
+ boxSizing: "border-box",
126
+ border: theme.vars.size.borderStroke.container,
127
+ borderBottom: 0,
128
+ borderColor: theme.vars.palette.primary.focusVisible,
129
+ borderRadius: theme.vars.size.borderRadius["r1-5"],
130
+ borderBottomRightRadius: 0,
131
+ borderBottomLeftRadius: 0
118
132
  },
119
- "span": {
120
- color: ownerState.paletteColor?.active
133
+ "&:hover": {
134
+ backgroundColor: theme.vars.palette.primary.activeOpacity
135
+ }
136
+ },
137
+ "&:focus-visible": {
138
+ background: theme.vars.palette[ownerState.tabColor || "default"].activeOpacity,
139
+ "&::before": {
140
+ zIndex: 1,
141
+ content: '""',
142
+ position: "absolute",
143
+ top: `-${theme.size.baseSpacings.sp1}`,
144
+ left: `-${theme.size.baseSpacings.sp1}`,
145
+ right: `-${theme.size.baseSpacings.sp1}`,
146
+ bottom: 0,
147
+ boxSizing: "border-box",
148
+ border: theme.vars.size.borderStroke.container,
149
+ borderBottom: 0,
150
+ borderColor: theme.vars.palette[ownerState.tabColor || "default"].focusVisible,
151
+ borderRadius: theme.vars.size.borderRadius["r1-5"],
152
+ borderBottomRightRadius: 0,
153
+ borderBottomLeftRadius: 0
121
154
  },
122
- "&::after": {
123
- background: ownerState.paletteColor?.active
155
+ "&:hover": {
156
+ backgroundColor: theme.vars.palette[ownerState.tabColor || "default"].activeOpacity
124
157
  }
125
158
  }
126
159
  }),
127
- /**
128
- * Slot de Icono:
129
- * - **Estilos Generales**: Configura el color base del ícono, con especificidad adicional para clases específicas.
130
- */
131
- icon: ({ theme }) => ({
132
- "&.M4lclassCssSpecificity div": {
133
- backgroundColor: theme.vars.palette.text.secondary
134
- }
135
- }),
136
160
  /**
137
161
  * Slot de Tipografía:
138
162
  * - **Estilos Generales**: Configura el color base del texto, aplicando especificidad para clases específicas.
139
163
  */
140
- tipography: ({ theme }) => ({
164
+ tipography: ({ ownerState }) => ({
141
165
  "&.M4lclassCssSpecificity": {
142
- color: theme.vars.palette.text.secondary
166
+ ...ownerState.tabSkeleton && {
167
+ width: "32px !important"
168
+ }
143
169
  }
144
170
  })
145
171
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,22 +1,12 @@
1
- import { TabProps as MUITabProps, PaletteColor, Theme } from '@mui/material';
1
+ import { TabProps as MUITabProps, Theme } from '@mui/material';
2
2
  import { OverridesStyleRules } from '@mui/material/styles/overrides';
3
- import { Sizes } from '@m4l/styles';
3
+ import { ComponentPalletColor, Sizes } from '@m4l/styles';
4
4
  import { TabSlots } from './Slots/TabEnum';
5
5
  import { TAB_KEY_COMPONENT } from './constants';
6
6
  /**
7
7
  * Propiedades personalizadas para el componente `Tab`, extendiendo algunas propiedades de MUI.
8
8
  */
9
9
  export interface TabProps extends Omit<MUITabProps, 'size' | 'label' | 'color'> {
10
- /**
11
- * Anchura del componente en estado Skeleton.
12
- * Puede ser un valor numérico o un string con unidades CSS (por ejemplo, `px`, `%`, etc.).
13
- */
14
- SKTWidth: string | number;
15
- /**
16
- * Altura del componente en estado Skeleton.
17
- * Puede ser un valor numérico o un string con unidades CSS (por ejemplo, `px`, `%`, etc.).
18
- */
19
- SKTHeight: string | number;
20
10
  /**
21
11
  * Identificador único para pruebas unitarias.
22
12
  */
@@ -33,6 +23,10 @@ export interface TabProps extends Omit<MUITabProps, 'size' | 'label' | 'color'>
33
23
  * Texto a mostrar en el `Tab`.
34
24
  */
35
25
  label?: string;
26
+ /**
27
+ * Paleta de color
28
+ */
29
+ color?: Extract<ComponentPalletColor, 'default'>;
36
30
  }
37
31
  /**
38
32
  * Tipo de slot del `Tab`, basado en las opciones definidas en `TabSlots`.
@@ -45,13 +39,21 @@ export interface TabOwnerState extends Pick<TabProps, 'size' | 'disabled'> {
45
39
  /**
46
40
  * Indica si el `Tab` está en estado Skeleton.
47
41
  */
48
- skeleton: boolean;
42
+ tabSkeleton: boolean;
49
43
  /**
50
44
  * Color de la paleta asociado al `Tab`.
51
45
  */
52
- paletteColor: PaletteColor;
46
+ tabColor: TabProps['color'];
47
+ /**
48
+ * Tab disabled
49
+ */
50
+ tabDisabled: TabProps['disabled'];
51
+ /**
52
+ * Tab disabled
53
+ */
54
+ tabSize: TabProps['size'];
53
55
  }
54
56
  /**
55
57
  * Estilos personalizados para el `Tab`, sobreescribiendo las reglas de estilo.
56
58
  */
57
- export type TabStyles = Partial<OverridesStyleRules<TabSlots, typeof TAB_KEY_COMPONENT, Theme> | undefined> | undefined;
59
+ export type TabStyles = OverridesStyleRules<TabSlots, typeof TAB_KEY_COMPONENT, Theme>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.1.34",
3
+ "version": "9.1.35",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
@@ -54,7 +54,7 @@
54
54
  "peerDependencies": {
55
55
  "@m4l/core": "^2.0.12",
56
56
  "@m4l/graphics": "^7.0.2",
57
- "@m4l/styles": "^7.0.1",
57
+ "@m4l/styles": "^7.1.18",
58
58
  "@mui/lab": "5.0.0-alpha.173",
59
59
  "@mui/material": "5.16.7",
60
60
  "@mui/x-date-pickers": "6.20.2"
@@ -1 +0,0 @@
1
- export declare const ICON_PREFIX = "M4LTab";