@m4l/components 9.3.18 → 9.3.19-BE093025-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.
@@ -23,7 +23,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
23
23
  error = false,
24
24
  htmlFor,
25
25
  readOnly = false,
26
- placeholder
26
+ placeholder,
27
+ startAdornment
27
28
  } = props;
28
29
  const { getLabel } = useModuleDictionary();
29
30
  const isSkeleton = useModuleSkeleton();
@@ -50,8 +51,9 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
50
51
  disabled,
51
52
  multiple: Boolean(multiple),
52
53
  error,
53
- readOnly
54
- }), [adjustedSize, disabled, error, multiple, variant, readOnly]);
54
+ readOnly,
55
+ startAdornment: !!startAdornment
56
+ }), [adjustedSize, disabled, error, multiple, variant, readOnly, startAdornment]);
55
57
  const startAdornments = useStartAdornments({
56
58
  selectedValue,
57
59
  multiple,
@@ -59,7 +61,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
59
61
  getOptionLabelLocal,
60
62
  ownerState,
61
63
  handleDelete,
62
- disabled
64
+ disabled,
65
+ startAdornment
63
66
  });
64
67
  const endAdornments = useEndAdornments({
65
68
  loading,
@@ -70,17 +70,22 @@ const autocompleteSyles = {
70
70
  /**
71
71
  * Styles for the text field component.
72
72
  */
73
- textField: ({ theme }) => {
73
+ textField: ({ theme, ownerState }) => {
74
+ const sp1 = theme?.vars?.size?.baseSpacings?.sp1 || "4px";
75
+ const sp5 = theme?.vars?.size?.baseSpacings?.sp5 || "16px";
76
+ const sp7 = theme?.vars?.size?.baseSpacings?.sp7 || "24px";
74
77
  return {
75
78
  height: "auto !important",
76
79
  position: "relative",
77
- "& .MuiInputBase-root": {
78
- padding: `${theme.vars.size.baseSpacings.sp1} ${theme.vars.size.baseSpacings.sp12} ${theme.vars.size.baseSpacings.sp1} 0!important`,
79
- gap: theme.vars.size.baseSpacings.sp1,
80
+ "&& .MuiInputBase-root": {
81
+ ...ownerState?.startAdornment ? {
82
+ padding: `${sp1} ${sp7} ${sp1} ${sp5}!important`
83
+ } : {
84
+ padding: `${sp1} ${sp7} ${sp1} 0px!important`
85
+ },
86
+ gap: sp1,
80
87
  flexWrap: "wrap",
81
- paddingLeft: `${theme.vars.size.baseSpacings.sp1} !important`,
82
- // borderColor: `${ ownerState?.error ? theme.vars.palette.border.error : theme.vars.palette.border.secondary} !important`,
83
- "& > input": {
88
+ "&& > input": {
84
89
  width: "100%",
85
90
  textOverflow: "ellipsis",
86
91
  whiteSpace: "nowrap",
@@ -149,7 +154,25 @@ const autocompleteSyles = {
149
154
  display: "flex",
150
155
  flexWrap: "wrap",
151
156
  gap: theme.vars.size.baseSpacings.sp1
152
- })
157
+ }),
158
+ /**
159
+ * Styles for the wrapper start adornment component.
160
+ */
161
+ wrapperStartAdornment: ({ theme }) => {
162
+ const sp1 = theme?.vars?.size?.baseSpacings?.sp1 || "4px";
163
+ return {
164
+ width: "fit-content",
165
+ position: "absolute",
166
+ top: 0,
167
+ bottom: 0,
168
+ left: 0,
169
+ display: "flex",
170
+ flexDirection: "column",
171
+ justifyContent: "center",
172
+ alignItems: "center",
173
+ padding: `0px ${sp1}`
174
+ };
175
+ }
153
176
  };
154
177
  export {
155
178
  autocompleteSyles as a
@@ -1,4 +1,5 @@
1
- import { AutocompleteOwnerState } from '../types';
1
+ import { default as React } from 'react';
2
+ import { AutocompleteOwnerState, AutocompleteProps } from '../types';
2
3
  export type UseAdornmentsProps<T> = {
3
4
  selectedValue: T | T[] | null;
4
5
  multiple?: boolean;
@@ -14,6 +15,7 @@ export type UseAdornmentsProps<T> = {
14
15
  handleRefresh: () => void;
15
16
  disabled?: boolean;
16
17
  onOpenLocal: (event: React.MouseEvent<HTMLButtonElement>) => void;
18
+ startAdornment: AutocompleteProps<unknown, true>['startAdornment'];
17
19
  };
18
20
  /**
19
21
  * Hook para el componente Autocomplete local
@@ -1,5 +1,6 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { b as ContainerMultipleValuesStyled, c as ContainerWrapperStyled, d as ChipStyled } from "../slots/AutocompleteSlots.js";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import React, { useMemo } from "react";
3
+ import { b as ContainerMultipleValuesStyled, c as ContainerWrapperStyled, d as ChipStyled, W as WrapperStartAdornmentStyled } from "../slots/AutocompleteSlots.js";
3
4
  function useStartAdornments(props) {
4
5
  const {
5
6
  selectedValue,
@@ -8,23 +9,44 @@ function useStartAdornments(props) {
8
9
  getOptionLabelLocal,
9
10
  ownerState,
10
11
  handleDelete,
11
- disabled
12
+ disabled,
13
+ startAdornment
12
14
  } = props;
13
- if (!(Array.isArray(selectedValue) && multiple)) {
14
- return null;
15
+ const startAdornmentClone = startAdornment ? React.cloneElement(startAdornment, {
16
+ size: adjustedSize
17
+ }) : null;
18
+ const internalAdornments = useMemo(() => {
19
+ if (!(Array.isArray(selectedValue) && multiple)) {
20
+ return null;
21
+ }
22
+ return /* @__PURE__ */ jsx(ContainerMultipleValuesStyled, { children: /* @__PURE__ */ jsx(ContainerWrapperStyled, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
23
+ ChipStyled,
24
+ {
25
+ size: adjustedSize,
26
+ label: getOptionLabelLocal(option),
27
+ opacity: true,
28
+ onDeleted: () => handleDelete(option),
29
+ disabledDeleteButton: disabled,
30
+ ownerState: { ...ownerState }
31
+ },
32
+ `${option}-${index}`
33
+ )) }) });
34
+ }, [
35
+ selectedValue,
36
+ multiple,
37
+ adjustedSize,
38
+ getOptionLabelLocal,
39
+ handleDelete,
40
+ disabled,
41
+ ownerState
42
+ ]);
43
+ if (startAdornmentClone && internalAdornments) {
44
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
45
+ /* @__PURE__ */ jsx(WrapperStartAdornmentStyled, { children: startAdornmentClone }),
46
+ internalAdornments
47
+ ] });
15
48
  }
16
- return /* @__PURE__ */ jsx(ContainerMultipleValuesStyled, { children: /* @__PURE__ */ jsx(ContainerWrapperStyled, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
17
- ChipStyled,
18
- {
19
- size: adjustedSize,
20
- label: getOptionLabelLocal(option),
21
- opacity: true,
22
- onDeleted: () => handleDelete(option),
23
- disabledDeleteButton: disabled,
24
- ownerState: { ...ownerState }
25
- },
26
- `${option}-${index}`
27
- )) }) });
49
+ return startAdornment ? /* @__PURE__ */ jsx(WrapperStartAdornmentStyled, { children: startAdornmentClone }) : internalAdornments;
28
50
  }
29
51
  export {
30
52
  useStartAdornments as u
@@ -27,9 +27,12 @@ function useValuesAndHandlers(props) {
27
27
  return;
28
28
  }
29
29
  const newValue = value || (multiple ? [] : null);
30
+ if (deepEqual(selectedValue, newValue)) {
31
+ return;
32
+ }
30
33
  refValue.current = newValue;
31
34
  setSelectedValue(newValue);
32
- }, [multiple, value]);
35
+ }, [multiple, value, selectedValue]);
33
36
  const isOptionEqualToValueLocal = useCallback(
34
37
  (option, val) => {
35
38
  if (val === null || val === void 0) {
@@ -122,11 +125,15 @@ function useValuesAndHandlers(props) {
122
125
  useEffect(() => {
123
126
  if (readOnly && value !== null && value !== void 0 && !multiple) {
124
127
  const displayValue = getOptionLabelLocal(value);
125
- setInputValue(displayValue);
128
+ if (inputValue !== displayValue) {
129
+ setInputValue(displayValue);
130
+ }
126
131
  } else if (readOnly && multiple) {
127
- setInputValue("");
132
+ if (inputValue !== "") {
133
+ setInputValue("");
134
+ }
128
135
  }
129
- }, [readOnly, value, getOptionLabelLocal, multiple]);
136
+ }, [readOnly, value, getOptionLabelLocal, multiple, inputValue]);
130
137
  useEffect(() => {
131
138
  if (open === false && value === null && inputValue !== "") {
132
139
  setInputValue("");
@@ -13,5 +13,6 @@ export declare enum AutocompleteSlots {
13
13
  image = "image",
14
14
  renderInputText = "renderInputText",
15
15
  containerMultipleValues = "containerMultipleValues",
16
- containerWrapper = "containerWrapper"
16
+ containerWrapper = "containerWrapper",
17
+ wrapperStartAdornment = "wrapperStartAdornment"
17
18
  }
@@ -14,6 +14,7 @@ var AutocompleteSlots = /* @__PURE__ */ ((AutocompleteSlots2) => {
14
14
  AutocompleteSlots2["renderInputText"] = "renderInputText";
15
15
  AutocompleteSlots2["containerMultipleValues"] = "containerMultipleValues";
16
16
  AutocompleteSlots2["containerWrapper"] = "containerWrapper";
17
+ AutocompleteSlots2["wrapperStartAdornment"] = "wrapperStartAdornment";
17
18
  return AutocompleteSlots2;
18
19
  })(AutocompleteSlots || {});
19
20
  export {
@@ -39,6 +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 WrapperStartAdornmentStyled: 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>>, {}>;
42
45
  export declare const ContainerMultipleValuesStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
43
46
  ownerState?: (Partial<import('../types').AutocompleteOwnerState> & Record<string, unknown>) | undefined;
44
47
  }, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
@@ -64,6 +64,10 @@ const AdormentsStyled = styled("div", {
64
64
  name: AUTOCOMPLETE_KEY_COMPONENT,
65
65
  slot: AutocompleteSlots.adorments
66
66
  })(autocompleteSyles?.adorments);
67
+ const WrapperStartAdornmentStyled = styled("div", {
68
+ name: AUTOCOMPLETE_KEY_COMPONENT,
69
+ slot: AutocompleteSlots.wrapperStartAdornment
70
+ })(autocompleteSyles?.wrapperStartAdornment);
67
71
  const ContainerMultipleValuesStyled = styled("div", {
68
72
  name: AUTOCOMPLETE_KEY_COMPONENT,
69
73
  slot: AutocompleteSlots.containerMultipleValues
@@ -79,6 +83,7 @@ export {
79
83
  PopperComponentStyled as P,
80
84
  RenderInputStyled as R,
81
85
  SkeletonAutocompleteStyled as S,
86
+ WrapperStartAdornmentStyled as W,
82
87
  AdormentsStyled as a,
83
88
  ContainerMultipleValuesStyled as b,
84
89
  ContainerWrapperStyled as c,
@@ -1,6 +1,6 @@
1
1
  import { AutocompleteChangeReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme } from '@mui/material';
2
2
  import { Sizes } from '@m4l/styles';
3
- import { ChangeEvent } from 'react';
3
+ import { ChangeEvent, ReactElement } from 'react';
4
4
  import { TextFieldProps } from '../TextField/types';
5
5
  import { AUTOCOMPLETE_KEY_COMPONENT } from './constants';
6
6
  import { AutocompleteSlots } from './slots';
@@ -75,6 +75,10 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined> exte
75
75
  * "htmlFor" attribute for the autocomplete field.
76
76
  */
77
77
  htmlFor?: string;
78
+ /**
79
+ * Icono o adorno que se muestra al inicio del autocomplete.
80
+ */
81
+ startAdornment?: ReactElement;
78
82
  }
79
83
  /**
80
84
  * Represents the owner state of the Autocomplete component for styling purposes.
@@ -84,6 +88,7 @@ export interface AutocompleteOwnerState extends Pick<BaseAutocompleteProps, 'siz
84
88
  disabled?: boolean;
85
89
  multiple?: boolean;
86
90
  readOnly?: boolean;
91
+ startAdornment?: boolean;
87
92
  }
88
93
  /**
89
94
  * Defines the types of Slots available for the Autocomplete.
@@ -64,6 +64,7 @@ const CheckBox = forwardRef((props, ref) => {
64
64
  ownerState: { ...ownerState },
65
65
  size: adjustedSize,
66
66
  disabled,
67
+ ellipsis: true,
67
68
  children: inlineText
68
69
  }
69
70
  )
@@ -14,7 +14,7 @@ const checkBoxStyles = {
14
14
  overflow: "visible",
15
15
  boxSizing: "border-box",
16
16
  gap: theme.vars.size.baseSpacings.sp1,
17
- width: "fit-content"
17
+ width: "100%"
18
18
  };
19
19
  },
20
20
  /**
@@ -8,6 +8,7 @@ const tooltipStyles = {
8
8
  * Estilos del texto del componente Tooltip
9
9
  */
10
10
  text: ({ theme, ownerState }) => ({
11
+ color: theme.vars.palette.text.contrastText,
11
12
  ...getTypographyStyles(
12
13
  theme.generalSettings.isMobile,
13
14
  ownerState?.size || "medium",
@@ -18,14 +19,18 @@ const tooltipStyles = {
18
19
  * Estilos del componente Tooltip
19
20
  */
20
21
  tooltip: ({ theme }) => ({
21
- background: theme.vars.palette.background.default,
22
+ background: theme.vars.palette.background.contrastDefault,
22
23
  padding: theme.vars.size.baseSpacings.sp2,
23
24
  borderRadius: theme.vars.size.borderRadius.r1,
24
25
  boxShadow: theme.vars.customShadows.z3,
25
26
  ".MuiTooltip-arrow": {
26
27
  "&::before": {
27
- backgroundColor: theme.vars.palette.background.default,
28
- borderRadius: theme.vars.size.borderRadius["r0-5"]
28
+ backgroundColor: theme.vars.palette.background.contrastDefault,
29
+ borderRadius: theme.vars.size.borderRadius["r1"],
30
+ width: theme.vars.size.baseSpacings.sp3,
31
+ height: theme.vars.size.baseSpacings.sp3,
32
+ border: "unset",
33
+ margin: "unset"
29
34
  }
30
35
  }
31
36
  })
@@ -3,6 +3,7 @@ import { Sizes, TypographyVariants } from '@m4l/styles';
3
3
  import { TypographySlots } from './slots/typographyEnum';
4
4
  import { TYPOGRAPHY_KEY_COMPONENT } from './constants';
5
5
  import { M4LOverridesStyleRules } from '../../../@types/augmentations';
6
+ import { DeepKeyOf } from 'src/utils/types';
6
7
  /**
7
8
  * Define los colores de tipografía disponibles para el componente.
8
9
  */
@@ -23,7 +24,7 @@ export interface TypographyProps extends Omit<MUITypographyProps, 'color' | 'var
23
24
  /**
24
25
  * Opción de color usada para pintar el componente.
25
26
  */
26
- color?: TypographyColors;
27
+ color?: DeepKeyOf<Theme['vars']['palette']> | string;
27
28
  /**
28
29
  * Opciones de tamaño del componente.
29
30
  */
@@ -1,3 +1,4 @@
1
+ import { getPropertyByString } from "@m4l/core";
1
2
  import { g as getSizeStyles } from "../../../utils/getSizeStyles/getSizeStyles.js";
2
3
  import { g as getTypographyStyles } from "../../../utils/getTypographyStyles.js";
3
4
  const typographyStyles = {
@@ -8,7 +9,9 @@ const typographyStyles = {
8
9
  root: ({ ownerState, theme }) => ({
9
10
  margin: 0,
10
11
  cursor: "default",
11
- fontFamily: ownerState?.fontFamily || "Inter",
12
+ ...ownerState?.fontFamily && ownerState?.fontFamily !== "Inter" && {
13
+ fontFamily: ownerState?.fontFamily
14
+ },
12
15
  "&.M4lclassCssSpecificity": {
13
16
  // Estilos generales 🌐
14
17
  // skeleton spacing when multiple rows 🦴
@@ -17,17 +20,11 @@ const typographyStyles = {
17
20
  flexDirection: "column"
18
21
  },
19
22
  // Override de estilos generales de MUI 🚫
20
- // color text.primary 🎨
21
- ...ownerState?.color === "text.primary" && {
22
- color: theme.vars.palette.text.primary
23
- },
24
- // color text.secondary 🎨
25
- ...ownerState?.color === "text.secondary" && {
26
- color: theme.vars.palette.text.secondary
27
- },
28
23
  // color text.disabled 🎨
29
- ...(ownerState?.disabled || ownerState?.color === "text.disabled") && {
24
+ ...ownerState?.disabled || ownerState?.color === "text.disabled" ? {
30
25
  color: theme.vars.palette.text.disabled
26
+ } : {
27
+ color: getPropertyByString(theme.vars.palette, ownerState?.color || "text.primary", "text.primary")
31
28
  },
32
29
  ...getTypographyStyles(
33
30
  theme.generalSettings.isMobile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.3.18",
3
+ "version": "9.3.19-BE093025-beta.1",
4
4
  "license": "UNLICENSED",
5
5
  "description": "M4L Components",
6
6
  "lint-staged": {
@@ -11,8 +11,8 @@
11
11
  "@googlemaps/js-api-loader": "^1.16.6",
12
12
  "@hookform/resolvers": "2.9.11",
13
13
  "@m4l/core": "^2.0.0",
14
- "@m4l/graphics": "^7.0.0",
15
- "@m4l/styles": "^7.0.0",
14
+ "@m4l/graphics": "7.1.5-BE093025-beta.1",
15
+ "@m4l/styles": "7.1.34-BE093025-beta.1",
16
16
  "@mui/lab": "5.0.0-alpha.173",
17
17
  "@mui/material": "5.16.7",
18
18
  "@mui/x-date-pickers": "6.20.2",