@m4l/components 9.3.14 → 9.3.15-BE100925-beta.1

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.
@@ -4,9 +4,10 @@ import { useEnvironment, useModuleDictionary } from "@m4l/core";
4
4
  import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
5
5
  import { P as Popover } from "../mui_extended/Popover/Popover.js";
6
6
  import { M as MenuItem } from "../mui_extended/MenuItem/MenuItem.js";
7
- import { I as ICON_PATH, a as ICONS, M as MENU_ACTIONS_ } from "./constants.js";
7
+ import { I as ICON_PATH, a as ICONS, M as MENU_ACTIONS_, b as MENU_ACTIONS_CLASSES } from "./constants.js";
8
8
  import { a as getMenuActionsDictionary, D as DICTIONARY } from "./dictionary.js";
9
9
  import { M as MenuDivider } from "../mui_extended/MenuDivider/MenuDivider.js";
10
+ import clsx from "clsx";
10
11
  import { M as MenuListStyled, a as MenuLoaderStyled, R as RootStyled, I as IconButtonStyled, H as HeaderMenuActionsStyled, F as FooterMenuActionsStyled } from "./slots/MenuActionsSlots.js";
11
12
  import { C as CircularProgress } from "../mui_extended/CircularProgress/CircularProgress.js";
12
13
  function MenuActions(props) {
@@ -128,7 +129,7 @@ function MenuActions(props) {
128
129
  endListElement && endListElement
129
130
  ] });
130
131
  }, [menuActions, header, size, footer, endListElement, objItem, getLabel, actionKey, handleClick]);
131
- return /* @__PURE__ */ jsxs(RootStyled, { className, ownerState: { ownerState }, children: [
132
+ return /* @__PURE__ */ jsxs(RootStyled, { className: clsx(className, MENU_ACTIONS_CLASSES.root, ownerState.selected && MENU_ACTIONS_CLASSES.selected), ownerState: { ownerState }, children: [
132
133
  /* @__PURE__ */ jsx(
133
134
  IconButtonStyled,
134
135
  {
@@ -38,7 +38,7 @@ const menuActionsStyles = {
38
38
  "& active": {
39
39
  backgroundColor: theme.vars.palette[ownerState?.paletteColor ?? "default"].selectedOpacity
40
40
  },
41
- '& [class*="M4LIcon-icon"]': {
41
+ "& .M4LIcon-icon": {
42
42
  backgroundColor: ownerState?.selected ? theme.vars.palette[ownerState?.paletteColor ?? "default"].selected : void 0
43
43
  }
44
44
  }),
@@ -20,3 +20,4 @@ export declare const MENU_ACTIONS_EMPTY = "menu_action_empty";
20
20
  * Prefijo de la clave que se utiliza cuando un ítem del menú está cargando en React.
21
21
  */
22
22
  export declare const MENU_ACTIONS_ = "menu_action_";
23
+ export declare const MENU_ACTIONS_CLASSES: Record<string, string>;
@@ -1,12 +1,23 @@
1
+ import { g as getComponentClasses } from "../../utils/getComponentSlotRoot.js";
2
+ import { M as MenuActionsSlots } from "./slots/MenuActionsEnum.js";
1
3
  const ICON_PATH = "frontend/components/menu_actions/assets/icons";
2
4
  const ICONS = {
3
5
  MENU: "menu.svg"
4
6
  };
5
7
  const MENU_ACTIONS_KEY_COMPONENT = "M4LMenuActions";
6
8
  const MENU_ACTIONS_ = "menu_action_";
9
+ const MenuActionsComplementaryClasses = {
10
+ selected: "selected"
11
+ };
12
+ const MENU_ACTIONS_COMBINATE_CLASSES = {
13
+ ...MenuActionsSlots,
14
+ ...MenuActionsComplementaryClasses
15
+ };
16
+ const MENU_ACTIONS_CLASSES = getComponentClasses(MENU_ACTIONS_KEY_COMPONENT, MENU_ACTIONS_COMBINATE_CLASSES);
7
17
  export {
8
18
  ICON_PATH as I,
9
19
  MENU_ACTIONS_ as M,
10
20
  ICONS as a,
11
- MENU_ACTIONS_KEY_COMPONENT as b
21
+ MENU_ACTIONS_CLASSES as b,
22
+ MENU_ACTIONS_KEY_COMPONENT as c
12
23
  };
@@ -1,6 +1,6 @@
1
1
  import { MenuList } from "@mui/material";
2
2
  import { styled } from "@mui/material/styles";
3
- import { b as MENU_ACTIONS_KEY_COMPONENT } from "../constants.js";
3
+ import { c as MENU_ACTIONS_KEY_COMPONENT } from "../constants.js";
4
4
  import { m as menuActionsStyles } from "../MenuActions.styles.js";
5
5
  import { M as MenuActionsSlots } from "./MenuActionsEnum.js";
6
6
  import { I as IconButton } from "../../mui_extended/IconButton/IconButton.js";
@@ -291,7 +291,7 @@ const windowBaseStyles = {
291
291
  }
292
292
  }
293
293
  },
294
- "&.MuiButtonBase-root:not(:hover, :active, :focus) .M4LIcon-root .M4LIcon-icon": {
294
+ "&.MuiButtonBase-root:not(:hover, :active, :focus, .M4LIconButton-selected) .M4LIcon-root .M4LIcon-icon": {
295
295
  backgroundColor: `${theme.vars.palette.text.disabled} !important`
296
296
  }
297
297
  },
@@ -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
- size: !isDesktop ? "medium" : size,
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
- currentVariant === "error" ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
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, PaletteColor, PopperProps } from '@mui/material';
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.
@@ -8,30 +8,72 @@ import { M4LOverridesStyleRules } from '../../../@types/augmentations';
8
8
  export type GetOptionString<T> = (option: T | null) => string;
9
9
  export type AutocompleteVariants = 'outlined' | 'text';
10
10
  export interface BaseAutocompleteProps {
11
+ /**
12
+ * The size of the autocomplete input field.
13
+ */
11
14
  size?: Extract<Sizes, 'small' | 'medium'>;
15
+ /**
16
+ * The variant of the autocomplete (e.g., outlined, contained, text).
17
+ */
12
18
  variant?: AutocompleteVariants;
19
+ /**
20
+ * Custom data-testid for testing purposes.
21
+ */
13
22
  dataTestid?: string;
14
23
  }
15
24
  /**
16
25
  * Props for the unified Autocomplete component.
17
26
  * Supports both single and multiple selection, and two types: `text` and `image`.
18
27
  */
19
- export interface AutocompleteProps<T, Multiple extends boolean | undefined> extends Pick<MUIAutocompleteProps<T, Multiple, undefined, false>, 'options' | 'onOpen' | 'onClose' | 'loading' | 'disabled'>, Pick<TextFieldProps, 'error'>, BaseAutocompleteProps {
28
+ export interface AutocompleteProps<T, Multiple extends boolean | undefined> extends Pick<MUIAutocompleteProps<T, Multiple, undefined, false>, 'options' | 'onOpen' | 'onClose' | 'loading' | 'disabled' | 'open'>, Pick<TextFieldProps, 'error' | 'focused'>, BaseAutocompleteProps {
29
+ /**
30
+ * Indica si el campo de texto está en modo de solo lectura.
31
+ * readOnly={true}
32
+ */
33
+ readOnly?: boolean;
34
+ /**
35
+ * The placeholder of the autocomplete.
36
+ * placeholder={}
37
+ */
38
+ placeholder?: string;
39
+ /**
40
+ * Whether multiple selections are allowed.
41
+ * multiple={true}
42
+ */
20
43
  multiple?: boolean;
21
44
  /**
22
45
  * The value of the autocomplete, supports single or multiple selection.
23
46
  * Extended to include `null` for controlled components.
24
47
  */
25
- value: T | T[] | null | null | undefined;
48
+ value: T | T[] | null | undefined;
49
+ /**
50
+ * Function to get the label for a given option.
51
+ */
26
52
  getOptionLabel: (option: T | AutocompleteFreeSoloValueMapping<false>) => string;
53
+ /**
54
+ * Function to compare if an option matches the selected value.
55
+ */
27
56
  isOptionEqualToValue: (option: T, value: T) => boolean;
28
57
  /**
29
58
  * Function to refresh the options.
30
59
  */
31
60
  refresh?: () => void;
61
+ /**
62
+ * Callback for filtering options based on user input.
63
+ */
32
64
  onChangeFilterParmsLocal?: (newValue: string, reason: AutocompleteInputChangeReason) => void;
65
+ /**
66
+ * Function to get the image URL for a given option (only for `type: 'image'`).
67
+ */
33
68
  getOptionUrlImage?: (option: T) => string;
69
+ /**
70
+ * se cambia el nativo de Autocomplete por este, debido a que el value esta disponible para procesar
71
+ * Handler for when the selected value changes.
72
+ */
34
73
  onChange: (event: ChangeEvent<{}> | undefined, value: T | T[] | null, reason: AutocompleteChangeReason) => void;
74
+ /**
75
+ * "htmlFor" attribute for the autocomplete field.
76
+ */
35
77
  htmlFor?: string;
36
78
  }
37
79
  /**
@@ -41,6 +83,7 @@ export interface AutocompleteOwnerState extends Pick<BaseAutocompleteProps, 'siz
41
83
  error?: boolean;
42
84
  disabled?: boolean;
43
85
  multiple?: boolean;
86
+ readOnly?: boolean;
44
87
  }
45
88
  /**
46
89
  * Defines the types of Slots available for the Autocomplete.
@@ -24,11 +24,13 @@ const badgeStyles = {
24
24
  ...theme.generalSettings.isMobile ? {
25
25
  height: theme.vars.size.baseSpacings.sp5,
26
26
  width: ownerState?.displayBadgeContent ? "26px" : theme.vars.size.baseSpacings.sp5,
27
- right: ownerState?.displayBadgeContent ? 4 : 0
27
+ right: ownerState?.displayBadgeContent ? 0 : 2,
28
+ top: ownerState?.displayBadgeContent ? 0 : 2
28
29
  } : {
29
30
  height: theme.vars.size.baseSpacings["sp3-5"],
30
31
  width: ownerState?.displayBadgeContent ? "23px" : theme.vars.size.baseSpacings["sp3-5"],
31
- right: ownerState?.displayBadgeContent ? 4 : 0
32
+ right: ownerState?.displayBadgeContent ? 0 : 2,
33
+ top: ownerState?.displayBadgeContent ? 0 : 2
32
34
  },
33
35
  // Estilos para variantes
34
36
  ...ownerState?.BadgeVariant === "dot" && {
@@ -88,7 +88,12 @@ const IconButton = forwardRef((props, ref) => {
88
88
  color,
89
89
  role: "button",
90
90
  ...other,
91
- className: clsx(ICON_BUTTON_CLASSES[variant], ICON_BUTTON_CLASSES.styledMUIIconButton, className),
91
+ className: clsx(
92
+ ICON_BUTTON_CLASSES[variant],
93
+ ICON_BUTTON_CLASSES.styledMUIIconButton,
94
+ selected && ICON_BUTTON_CLASSES.selected,
95
+ className
96
+ ),
92
97
  children: renderIcon(icon || src)
93
98
  }
94
99
  )
@@ -104,7 +109,12 @@ const IconButton = forwardRef((props, ref) => {
104
109
  "data-testid": "IconButtonRoot",
105
110
  color,
106
111
  ...other,
107
- className: clsx(ICON_BUTTON_CLASSES[variant], ICON_BUTTON_CLASSES.styledMUIIconButton, className),
112
+ className: clsx(
113
+ ICON_BUTTON_CLASSES[variant],
114
+ ICON_BUTTON_CLASSES.styledMUIIconButton,
115
+ selected && ICON_BUTTON_CLASSES.selected,
116
+ className
117
+ ),
108
118
  children: renderIcon(icon || src)
109
119
  }
110
120
  );
@@ -13,7 +13,7 @@ const iconButtonStyles = {
13
13
  overflow: "hidden",
14
14
  cursor: ownerState?.disabled ? "not-allowed" : "pointer",
15
15
  color: theme.vars.palette.text.primary,
16
- borderRadius: theme.size.borderRadius.r1,
16
+ borderRadius: theme.size.borderRadius["r1-5"],
17
17
  pointerEvents: ownerState?.disabled ? "none" : "auto",
18
18
  display: ownerState?.isSkeleton ? "none" : "flex",
19
19
  justifyContent: "center",
@@ -47,24 +47,24 @@ const iconButtonStyles = {
47
47
  // Estilos para la variante contained
48
48
  ...ownerState?.variant === "contained" && {
49
49
  // 🎯 Color de fondo según variante y color del componente
50
- backgroundColor: ownerState?.variant === "contained" ? ownerState?.color === "error" ? paletteColor.active : ownerState?.color === "default" ? theme.vars.palette.primary.selected : paletteColor.selected : ownerState?.color === "error" ? paletteColor.activeOpacity : paletteColor.selectedOpacity,
50
+ backgroundColor: ownerState?.variant === "contained" ? ownerState?.color === "error" ? paletteColor.active : ownerState?.color === "default" ? theme.vars.palette.primary.selected : ownerState?.color === "success" ? theme.vars.palette.success.selected : paletteColor.selected : ownerState?.color === "error" ? paletteColor.activeOpacity : paletteColor.selectedOpacity,
51
51
  "&&& .M4LIcon-icon": {
52
52
  backgroundColor: ownerState?.variant === "contained" ? theme.vars.palette.primary.contrastText : paletteColor.semanticText
53
53
  }
54
54
  },
55
55
  // Estilos para la variante text
56
56
  ...ownerState.variant === "outline" && {
57
- backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.activeOpacity : paletteColor.activeOpacity,
57
+ backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.selectedOpacity : paletteColor.selectedOpacity,
58
58
  border: theme.vars.size.borderStroke.actionInput,
59
59
  borderColor: ownerState.color === "default" ? theme.vars.palette.primary.active : paletteColor.active,
60
60
  "&&& .M4LIcon-icon": {
61
- backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.semanticText : paletteColor.selected
61
+ backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.semanticText : ownerState.color === "warning" ? paletteColor.active : paletteColor.selected
62
62
  }
63
63
  },
64
64
  ...ownerState.variant === "text" && {
65
- backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.activeOpacity : paletteColor.activeOpacity,
65
+ backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.selectedOpacity : paletteColor.selectedOpacity,
66
66
  "&&& .M4LIcon-icon": {
67
- backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.semanticText : paletteColor.selected
67
+ backgroundColor: ownerState.color === "default" ? theme.vars.palette.primary.semanticText : ownerState.color === "warning" ? paletteColor.active : paletteColor.selected
68
68
  }
69
69
  }
70
70
  } : {
@@ -128,7 +128,7 @@ const iconButtonStyles = {
128
128
  backgroundColor: paletteColor.enabled,
129
129
  // 🖼️ Color del icono
130
130
  "&&& .M4LIcon-icon": {
131
- backgroundColor: paletteColor.semanticText
131
+ backgroundColor: ownerState?.color === "default" ? paletteColor.semanticText : paletteColor.contrastText
132
132
  },
133
133
  // 🖱️ Estado Hover
134
134
  "&:hover": {
@@ -1,7 +1,14 @@
1
1
  import { g as getComponentClasses } from "../../../utils/getComponentSlotRoot.js";
2
2
  import { I as IconButtonSlots } from "./slots/IconButtonEnum.js";
3
3
  const ICON_BUTTON_KEY_COMPONENT = "M4LIconButton";
4
- const ICON_BUTTON_CLASSES = getComponentClasses(ICON_BUTTON_KEY_COMPONENT, IconButtonSlots);
4
+ const IconButtonComplementaryClasses = {
5
+ selected: "selected"
6
+ };
7
+ const IconButtonCombineClasses = {
8
+ ...IconButtonSlots,
9
+ ...IconButtonComplementaryClasses
10
+ };
11
+ const ICON_BUTTON_CLASSES = getComponentClasses(ICON_BUTTON_KEY_COMPONENT, IconButtonCombineClasses);
5
12
  export {
6
13
  ICON_BUTTON_CLASSES as I,
7
14
  ICON_BUTTON_KEY_COMPONENT as a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.3.14",
3
+ "version": "9.3.15-BE100925-beta.1",
4
4
  "license": "UNLICENSED",
5
5
  "description": "M4L Components",
6
6
  "lint-staged": {