@m4l/components 9.1.62 → 9.1.63

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.
@@ -10,12 +10,4 @@ import { LabelProps } from './types';
10
10
  * @updatedAt 2025-01-08 10:36:40 - automatic
11
11
  * @updatedUser Andrés Quintero - automatic
12
12
  */
13
- /**
14
- * Label component that displays a label with optional mandatory and helper messages.
15
- * @returns {JSX.Element} The rendered Label component.
16
- * @author Bruce Escobar - automatic
17
- * @createdAt 2024-10-22 09:34:39 - automatic
18
- * @updatedAt 2025-01-08 10:36:40 - automatic
19
- * @updatedUser Andrés Quintero - automatic
20
- */
21
13
  export declare const Label: (props: LabelProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,48 +1,65 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useEnvironment, useModuleSkeleton } from "@m4l/core";
3
3
  import clsx from "clsx";
4
- import { L as LABEL_KEY_COMPONENT } from "./constants.js";
5
- import { a as getComponentSlotRoot } from "../../utils/getComponentSlotRoot.js";
4
+ import { L as LABEL_KEY_COMPONENT, c as classLabelRoot, a as LAB_SPECIFY } from "./constants.js";
5
+ import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
6
6
  import { L as LabelRootStyled, T as TypographyStyled, a as TypographyMandatoryMessageStyled, I as IconHelperMessageStyled, S as SkeletonStyled } from "./slots/LabelSlots.js";
7
7
  const Label = (props) => {
8
- const { helperMessage, label, mandatory, mandatoryMessage, htmlFor, id, error, size = "medium", disabled, className } = props;
8
+ const { helperMessage, label, mandatory, mandatoryMessage, htmlFor, id, error, size = "medium", disabled, className, helperText } = props;
9
9
  const { host_static_assets, environment_assets } = useEnvironment();
10
10
  const isSkeleton = useModuleSkeleton();
11
- const classRoot = getComponentSlotRoot(LABEL_KEY_COMPONENT);
11
+ const { currentSize } = useComponentSize(size);
12
+ const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
13
+ const ownerState = {
14
+ disabled,
15
+ size
16
+ };
12
17
  return /* @__PURE__ */ jsx(
13
18
  LabelRootStyled,
14
19
  {
15
- className: clsx(classRoot, className),
16
20
  "aria-label": LABEL_KEY_COMPONENT,
17
- ownerState: { disabled },
21
+ ownerState: { ...ownerState },
18
22
  htmlFor,
19
23
  id,
20
- label: "",
21
24
  children: !isSkeleton ? /* @__PURE__ */ jsxs(Fragment, { children: [
22
- /* @__PURE__ */ jsx(TypographyStyled, { ownerState: { size, disabled }, variant: "body", className: "", children: label }),
25
+ /* @__PURE__ */ jsx(
26
+ TypographyStyled,
27
+ {
28
+ className: clsx(classLabelRoot, LAB_SPECIFY, "M4lclassCssSpecificity", className),
29
+ ownerState: { ...ownerState },
30
+ variant: "body",
31
+ size: adjustedSize,
32
+ disabled,
33
+ children: label
34
+ }
35
+ ),
23
36
  mandatory && /* @__PURE__ */ jsx(
24
37
  TypographyMandatoryMessageStyled,
25
38
  {
26
- ownerState: { size, disabled },
39
+ ownerState: { ...ownerState },
27
40
  variant: "body",
28
41
  className: mandatoryMessage ? "mandatoryMessage" : "mandatoryAsterisk",
42
+ size: adjustedSize,
43
+ disabled,
29
44
  children: mandatoryMessage ? mandatoryMessage : "*"
30
45
  }
31
46
  ),
32
47
  helperMessage && /* @__PURE__ */ jsx(
33
48
  IconHelperMessageStyled,
34
49
  {
35
- tooltipContent: helperMessage,
36
- ownerState: { disabled },
50
+ tooltipContent: helperText,
51
+ ownerState: { ...ownerState },
37
52
  placement: "right",
53
+ size: adjustedSize,
38
54
  className: error ? "helper-icon-error" : "helper-icon",
55
+ disabled,
39
56
  src: `${host_static_assets}/${environment_assets}/frontend/components/LabelMessage/assets/icons/infoSmall.svg`
40
57
  }
41
58
  )
42
59
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
43
- /* @__PURE__ */ jsx(SkeletonStyled, { ownerState: {}, variant: "text", width: "30%", height: "14px" }),
44
- mandatory && /* @__PURE__ */ jsx(SkeletonStyled, { ownerState: {}, variant: "text", width: "10px", height: "14px" }),
45
- helperMessage && /* @__PURE__ */ jsx(SkeletonStyled, { ownerState: { type: "helperMessage" }, variant: "rounded", width: "14px", height: "14px" })
60
+ /* @__PURE__ */ jsx(SkeletonStyled, { ownerState: { ...ownerState }, variant: "text", className: "SkeletonWidthLabel" }),
61
+ mandatory && /* @__PURE__ */ jsx(SkeletonStyled, { ownerState: { ...ownerState }, variant: "circular", className: "MandatoryLabel" }),
62
+ helperMessage && /* @__PURE__ */ jsx(SkeletonStyled, { ownerState: { ...ownerState }, variant: "circular", className: "HelperIconLabel" })
46
63
  ] })
47
64
  }
48
65
  );
@@ -1,3 +1,5 @@
1
+ import { g as getTypographyStyles } from "../../utils/getTypographyStyles.js";
2
+ import { g as getHeightSizeStyles } from "../../utils/getHeightSizeStyles.js";
1
3
  const labelStyles = {
2
4
  /**
3
5
  * Estilos para el contenedor raíz del Label.
@@ -6,129 +8,118 @@ const labelStyles = {
6
8
  * @updatedAt 2025-01-08 10:36:40 - automatic
7
9
  * @updatedUser Andrés Quintero - automatic
8
10
  */
9
- root: ({ ownerState, theme }) => ({
11
+ root: ({ theme, ownerState }) => ({
10
12
  display: "flex",
11
13
  flexDireccion: "row",
12
14
  alignItems: "center",
13
15
  flexWrap: "wrap",
14
- width: "100%",
16
+ width: "fit-content",
17
+ ...getHeightSizeStyles(
18
+ theme.generalSettings.isMobile,
19
+ ownerState.size || "small",
20
+ "base"
21
+ ),
15
22
  gap: theme.size.baseSpacings.sp1,
16
- "& .M4LLabelClassCss-root": {
17
- ...ownerState.disabled === true && {
18
- color: theme.vars.palette.text.disabled + "!important"
19
- }
20
- },
21
- flexDirection: "row",
22
- [`& .${ownerState.label}`]: {
23
- ...ownerState.size === "small" && {
24
- height: "20px",
25
- [theme.breakpoints.up("sm")]: {
26
- height: "20px"
27
- }
28
- },
29
- ...ownerState.size === "medium" && {
30
- height: "24px",
31
- [theme.breakpoints.up("sm")]: {
32
- height: "24px"
33
- }
34
- }
23
+ ...ownerState.disabled && {
24
+ color: theme.vars.palette.text.disabled
35
25
  }
36
26
  }),
37
27
  /**
38
- * Estilos para el slot Typography.
39
- * @author Bruce Escobar - automatic
40
- * @createdAt 2024-10-22 09:34:39 - automatic
41
- * @updatedAt 2025-01-08 10:36:40 - automatic
42
- * @updatedUser Andrés Quintero - automatic
28
+ * Estilos para el slot Typography del Label.
43
29
  */
44
30
  typographyStyled: ({ theme, ownerState }) => ({
45
- "& .MuiTypography-root": {
46
- color: theme.vars.palette.text.secondary,
47
- [theme.breakpoints.up("sm")]: {
48
- fontSize: ownerState.size === "medium" ? "11px" : "10px"
49
- },
50
- [theme.breakpoints.down("sm")]: {
51
- fontSize: ownerState.size === "medium" ? "14px" : "13px"
31
+ "&.MuiTypography-root": {
32
+ "&.M4lclassCssSpecificity": {
33
+ color: theme.vars.palette.text.secondary,
34
+ ...ownerState.disabled === true && {
35
+ color: theme.vars.palette.text.disabled
36
+ },
37
+ ...getTypographyStyles(
38
+ theme.generalSettings.isMobile,
39
+ ownerState.size || "medium",
40
+ "body"
41
+ ),
42
+ ...getTypographyStyles(
43
+ theme.generalSettings.isMobile,
44
+ ownerState.size || "small",
45
+ "body"
46
+ )
52
47
  }
53
- },
54
- "&.mandatoryAsterisk": {
55
- color: theme.vars.palette.text.primary
56
- },
57
- "& span": {}
48
+ }
58
49
  }),
59
50
  /**
60
- * Estilos para el mensaje obligatorio.
61
- * @author Bruce Escobar - automatic
62
- * @createdAt 2024-10-22 09:34:39 - automatic
63
- * @updatedAt 2025-01-08 10:36:40 - automatic
64
- * @updatedUser Andrés Quintero - automatic
51
+ * Estilos para el slot Typography del mensaje obligatorio del Label.
65
52
  */
66
53
  typographyMandatoryMessageStyled: ({ theme, ownerState }) => ({
67
- "& .MuiTypography-root": {
68
- color: theme.vars.palette.text.primary,
69
- [theme.breakpoints.up("sm")]: {
70
- fontSize: ownerState.size === "medium" ? "11px" : "10px"
71
- },
72
- [theme.breakpoints.down("sm")]: {
73
- fontSize: ownerState.size === "medium" ? "14px" : "13px"
54
+ "&.MuiTypography-root": {
55
+ "&.M4lclassCssSpecificity": {
56
+ color: theme.vars.palette.text.primary,
57
+ ...ownerState.disabled && {
58
+ color: theme.vars.palette.text.disabled
59
+ },
60
+ ...getTypographyStyles(
61
+ theme.generalSettings.isMobile,
62
+ ownerState.size || "medium",
63
+ "body"
64
+ ),
65
+ ...getTypographyStyles(
66
+ theme.generalSettings.isMobile,
67
+ ownerState.size || "small",
68
+ "body"
69
+ )
74
70
  }
75
71
  }
76
72
  }),
77
73
  /**
78
- * Estilos para el icono del mensaje de ayuda.
79
- * @author Bruce Escobar - automatic
80
- * @createdAt 2024-10-22 09:34:39 - automatic
81
- * @updatedAt 2025-01-08 10:36:40 - automatic
82
- * @updatedUser Andrés Quintero - automatic
74
+ * Estilos para el slot Icon del Label.
83
75
  */
84
- iconHelperMessageStyled: ({ theme }) => ({
85
- height: "24px",
86
- width: "24px",
76
+ iconHelperMessageStyled: ({ theme, ownerState }) => ({
87
77
  borderRadius: theme.vars.size.borderRadius.r1,
88
78
  '&:hover > [class*="M4LIcon-icon"]': {
89
- backgroundColor: theme.vars.palette.primary.main
79
+ backgroundColor: theme.vars.palette.info.selected
90
80
  },
91
81
  '& > [class*="M4LIcon-icon"]': {
92
- fontsize: "16px",
93
- backgroundColor: theme.vars.palette.text.secondary
94
- }
82
+ backgroundColor: theme.vars.palette.info.enabled
83
+ },
84
+ ...getHeightSizeStyles(
85
+ theme.generalSettings.isMobile,
86
+ ownerState.size || "small",
87
+ "base"
88
+ )
95
89
  }),
96
90
  /**
97
- * Estilos para el componente Skeleton.
98
- * @author Bruce Escobar - automatic
99
- * @createdAt 2024-10-22 09:34:39 - automatic
100
- * @updatedAt 2025-01-08 10:36:40 - automatic
101
- * @updatedUser Andrés Quintero - automatic
91
+ * Estilos para el slot Skeleton del Label.
102
92
  */
103
93
  skeletonStyled: ({ ownerState, theme }) => ({
104
94
  width: "100%",
105
- padding: theme.vars.size.baseSpacings.sp2,
106
95
  borderRadius: theme.vars.size.borderRadius.r1,
107
96
  display: "flex",
108
97
  alignItems: "center",
109
98
  backgroundColor: theme.vars.palette.skeleton.transition,
110
- // Estilos específicos para el tamaño small
111
- ...ownerState.size === "small" && {
112
- ...theme.generalSettings.isMobile ? {
113
- height: theme.vars.size.mobile.small.action,
114
- minHeight: theme.vars.size.mobile.small.action
115
- } : {
116
- height: theme.vars.size.desktop.small.action,
117
- minHeight: theme.vars.size.desktop.small.action
118
- }
99
+ ...getHeightSizeStyles(
100
+ theme.generalSettings.isMobile,
101
+ ownerState.size || "medium",
102
+ "action"
103
+ ),
104
+ ...getHeightSizeStyles(
105
+ theme.generalSettings.isMobile,
106
+ ownerState.size || "small",
107
+ "action"
108
+ ),
109
+ "&.MandatoryLabel": {
110
+ width: theme.vars.size.baseSpacings["sp0-5"],
111
+ padding: theme.vars.size.baseSpacings.sp1,
112
+ height: theme.vars.size.baseSpacings.sp3
119
113
  },
120
- // Estilos específicos para el tamaño medium
121
- ...ownerState.size === "medium" && {
122
- ...theme.generalSettings.isMobile ? {
123
- height: theme.vars.size.mobile.medium.action,
124
- minHeight: theme.vars.size.mobile.medium.action
125
- } : {
126
- height: theme.vars.size.desktop.medium.action,
127
- minHeight: theme.vars.size.desktop.medium.action
128
- }
129
- },
130
- ...ownerState.type === "helperMessage" && {
114
+ "&.SkeletonWidthLabel": {
115
+ width: theme.vars.size.baseSpacings.sp14,
131
116
  borderRadius: theme.vars.size.borderRadius.r1
117
+ },
118
+ "&.HelperIconLabel": {
119
+ width: theme.vars.size.baseSpacings.sp2,
120
+ borderRadius: theme.vars.size.borderRadius.r4,
121
+ height: theme.vars.size.baseSpacings.sp2,
122
+ padding: theme.vars.size.baseSpacings.sp2
132
123
  }
133
124
  })
134
125
  };
@@ -1 +1,3 @@
1
1
  export declare const LABEL_KEY_COMPONENT = "M4LLabel";
2
+ export declare const LAB_SPECIFY = "M4lclassCssSpecificity";
3
+ export declare const classLabelRoot: string;
@@ -1,4 +1,9 @@
1
+ import { a as getComponentSlotRoot } from "../../utils/getComponentSlotRoot.js";
1
2
  const LABEL_KEY_COMPONENT = "M4LLabel";
3
+ const LAB_SPECIFY = "M4lclassCssSpecificity";
4
+ const classLabelRoot = getComponentSlotRoot(LABEL_KEY_COMPONENT);
2
5
  export {
3
- LABEL_KEY_COMPONENT as L
6
+ LABEL_KEY_COMPONENT as L,
7
+ LAB_SPECIFY as a,
8
+ classLabelRoot as c
4
9
  };
@@ -2,12 +2,13 @@ import { LabelSlots } from './slots';
2
2
  import { OverridesStyleRules } from '@mui/material/styles/overrides';
3
3
  import { Theme } from '@mui/material';
4
4
  import { LABEL_KEY_COMPONENT } from './constants';
5
+ import { Sizes } from '@m4l/styles';
5
6
  export type LabelVariants = 'standard';
6
7
  export interface LabelProps {
7
8
  /** Mesanje de ayuda opcional que se visualiza cuando se interactua con el tooltip del Icono de informacion */
8
9
  helperMessage?: string | undefined;
9
10
  /** Es la etiqueta de texto principal del componente.*/
10
- label: string;
11
+ label?: string;
11
12
  /** Es una propiedad que permite visualizar el texto que acompaña a la etiqueta `label` Por defecto es `false`.*/
12
13
  mandatory?: boolean;
13
14
  /** Es una etiqueta de texto que define si el campo es obligatorio, por defecto se visualiza un `*` de lo contrario se va a mostrar el valor que se proporciona .*/
@@ -17,7 +18,7 @@ export interface LabelProps {
17
18
  /** Identificador único para la etiqueta html que envuelve al componente, útil para referencias en CSS o JavaScript.*/
18
19
  id?: string;
19
20
  /** Define el tamaño de la etiqueta. Puede ser 'small' o 'medium'. Por defecto es 'medium'. */
20
- size?: 'small' | 'medium';
21
+ size?: Extract<Sizes, 'small' | 'medium'>;
21
22
  /**
22
23
  * Los elementos secundarios que se renderizarán dentro del componente.
23
24
  */
@@ -30,9 +31,14 @@ export interface LabelProps {
30
31
  error?: boolean;
31
32
  /** Indica si el componente está deshabilitado. */
32
33
  disabled?: boolean;
34
+ helperText?: string;
33
35
  }
34
36
  export type OwnerState = Pick<LabelProps, 'size'>;
35
37
  export interface LabelOwnerState extends LabelProps, OwnerState {
38
+ /** Indica si el componente está deshabilitado. */
39
+ disabled?: boolean;
40
+ /** Define el tamaño del componente */
41
+ size?: Extract<Sizes, 'small' | 'medium'>;
36
42
  }
37
43
  export type LabelSlotsType = keyof typeof LabelSlots;
38
- export type LabelStyles = Partial<OverridesStyleRules<LabelSlots, typeof LABEL_KEY_COMPONENT, Theme> | undefined> | undefined;
44
+ export type LabelStyles = OverridesStyleRules<LabelSlots, typeof LABEL_KEY_COMPONENT, Theme>;
@@ -9,7 +9,7 @@ export type ImageProps<T> = (RHFAutocompleteTypeImageProps<T> & {
9
9
  imageRepeat: boolean;
10
10
  imageScale?: never;
11
11
  });
12
- export interface RHFAutocompleteBaseProps<T> extends Omit<TextFieldProps, 'label' | 'variant'>, Omit<LabelProps, 'label'> {
12
+ export interface RHFAutocompleteBaseProps<T> extends Omit<TextFieldProps, 'label' | 'variant' | 'helperText'>, Omit<LabelProps, 'label'> {
13
13
  name: string;
14
14
  options: Array<T>;
15
15
  getOptionLabel: (option: T) => string;
@@ -13,7 +13,7 @@ export type RHFAutocompleteType = 'text' | 'image';
13
13
  * Supports both single and multiple selection, and two types: `text` and `image`.
14
14
  * @createdAt 2024-11-28 17:06:36 - automatic
15
15
  */
16
- export interface RHFAutocompleteProps<T, Multiple extends boolean | undefined = true, DisableClearable extends boolean | undefined = true, FreeSolo extends boolean | undefined = false> extends Omit<MUIAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>, 'variant' | 'color' | 'size' | 'value' | 'classes' | 'defaultValue' | 'onBlur' | 'onFocus' | 'autoComplete' | 'renderInput'>, Omit<TextFieldProps, 'label' | 'variant' | 'defaultValue' | 'classes' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'ref' | 'onChange'>, Omit<LabelProps, 'label'> {
16
+ export interface RHFAutocompleteProps<T, Multiple extends boolean | undefined = true, DisableClearable extends boolean | undefined = true, FreeSolo extends boolean | undefined = false> extends Omit<MUIAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>, 'variant' | 'color' | 'size' | 'value' | 'classes' | 'defaultValue' | 'onBlur' | 'onFocus' | 'autoComplete' | 'renderInput'>, Omit<TextFieldProps, 'label' | 'variant' | 'defaultValue' | 'classes' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'ref' | 'onChange' | 'helperText'>, Omit<LabelProps, 'label'> {
17
17
  name: string;
18
18
  /**
19
19
  * The label for the autocomplete field.
@@ -6,7 +6,7 @@ import { LabelProps } from '../../Label/types';
6
6
  import { RHFTextFieldSlots } from './slots';
7
7
  import { RHF_TEXT_FIELD_KEY_COMPONENT } from './constant';
8
8
  import { ComponentPalletColor } from '@m4l/styles';
9
- export interface RHFTextFieldProps extends Omit<TextFieldProps, 'size' | 'inputProps' | 'label' | 'theme' | 'color' | 'error'>, Omit<LabelProps, 'label' | 'error'> {
9
+ export interface RHFTextFieldProps extends Omit<TextFieldProps, 'size' | 'inputProps' | 'label' | 'theme' | 'error'>, Omit<LabelProps, 'label' | 'error' | 'helperText'> {
10
10
  /**
11
11
  * Valor de anchura total para la vista de carga provisional.
12
12
  * @deprecated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.1.62",
3
+ "version": "9.1.63",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
@@ -1,5 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
- import { Label } from '../../../Label';
2
+ import { Label } from '../../../src/components/Label/Label';
3
3
  /**
4
4
  * Label es un componente React que renderiza una etiqueta de texto, la cual puede ser utilizada en formularios o en cualquier
5
5
  * lugar donde se necesite una descripción textual.
@@ -11,8 +11,6 @@ declare const meta: Meta<typeof Label>;
11
11
  export default meta;
12
12
  type Story = StoryObj<typeof Label>;
13
13
  /** Label component Props Comunes */
14
- export declare const MandatoryAndHelpmessage: Story;
15
- /** Label component With props `mandatory=true` */
16
- export declare const Mandatory: Story;
17
- /** Label component With props `helperMessage` */
18
- export declare const Base: Story;
14
+ export declare const LabelDefault: Story;
15
+ /** Label component mode Skeleton With props `helperMessage` */
16
+ export declare const LabelDefaultSkeleton: Story;
@@ -1,18 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { Label } from '../../../Label';
3
- /**
4
- * Label es un componente React que renderiza una etiqueta de texto, la cual puede ser utilizada en formularios o en cualquier
5
- * lugar donde se necesite una descripción textual.
6
- * Soporta la visualización de un indicador de campo obligatorio, mensaje de ayuda a través
7
- * de un tooltip, y puede adaptar su tamaño. El componente también puede mostrar un estado de esqueleto, indicando
8
- * que el contenido está cargando.
9
- */
10
- declare const meta: Meta<typeof Label>;
11
- export default meta;
12
- type Story = StoryObj<typeof Label>;
13
- /** Label component mode Skeleton With props `helperMessage` */
14
- export declare const MandatoryAndHelpMessage: Story;
15
- /** Label component With props `mandatory=true` in mode Skeleton */
16
- export declare const Mandatory: Story;
17
- /** Base Label component mode Skeleton */
18
- export declare const BaseSkeleton: Story;