@m4l/components 9.2.38 → 9.2.39

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.
@@ -3,6 +3,7 @@ import { useModuleSkeleton, useEnvironment } from "@m4l/core";
3
3
  import clsx from "clsx";
4
4
  import { forwardRef, useMemo } from "react";
5
5
  import { C as CHIP_CLASSES } from "./constants.js";
6
+ import { T as TEST_PROP_ID } from "../../test/constants_no_mock.js";
6
7
  import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
7
8
  import { I as IconStyled, S as SkeletonChipStyled, C as ChipRootStyled, T as TextChipStyled, a as IconButtonStyled } from "./slots/ChipSlots.js";
8
9
  const Chip = forwardRef((props, ref) => {
@@ -20,6 +21,7 @@ const Chip = forwardRef((props, ref) => {
20
21
  onDeleted,
21
22
  iconButtonProps,
22
23
  className,
24
+ dataTestId,
23
25
  ...others
24
26
  } = props;
25
27
  const { currentSize } = useComponentSize(size);
@@ -77,6 +79,7 @@ const Chip = forwardRef((props, ref) => {
77
79
  ownerState: { ...ownerState },
78
80
  className: clsx(className, CHIP_CLASSES.root),
79
81
  ref,
82
+ ...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: dataTestId } : {},
80
83
  ...onClick ? { tabIndex: 0 } : {},
81
84
  ...others,
82
85
  children: [
@@ -69,6 +69,10 @@ export interface ChipProps {
69
69
  * If the `Chip` is focusable.
70
70
  */
71
71
  focusable?: boolean;
72
+ /**
73
+ * Test id for the `Chip`.
74
+ */
75
+ dataTestId?: string;
72
76
  }
73
77
  /**
74
78
  * Owner state of the `Chip` used to define internal style and behavior properties.
@@ -1,16 +1,17 @@
1
- import { useState, useRef, useEffect, useMemo } from "react";
1
+ import { useState, useRef, useEffect, useMemo, useCallback } from "react";
2
2
  import { useFormatter } from "@m4l/graphics";
3
3
  import { getPropertyByString } from "@m4l/core";
4
4
  import { deepEqual } from "fast-equals";
5
5
  import { g as getFormatPrice } from "../../../formatters/PriceFormatter/PriceFormatter.js";
6
6
  import { g as getColumnKey } from "../../helpers/getColumnKey.js";
7
7
  import { C as ColumnPriceFormatter } from "./formatter.js";
8
- const getCustomPriceFilter = (props) => {
8
+ const useCustomPriceFilter = (props) => {
9
9
  const { currencyFormatter } = useFormatter();
10
- return (row, value) => {
10
+ const customFilter = useCallback((row, value) => {
11
11
  const fieldValue = getColumnKey(props.fieldValue);
12
12
  return getFormatPrice(row, fieldValue, currencyFormatter.code, currencyFormatter.decimalDigits).includes(value);
13
- };
13
+ }, [props.fieldValue, currencyFormatter]);
14
+ return customFilter;
14
15
  };
15
16
  const getCustomPriceSort = (props) => {
16
17
  return (a, b) => {
@@ -41,6 +42,7 @@ const getCustomPriceSort = (props) => {
41
42
  const useColumnPrice = (props) => {
42
43
  const [stateProps, setStateProps] = useState(props);
43
44
  const refProps = useRef({ ...props });
45
+ const customFilter = useCustomPriceFilter(stateProps);
44
46
  useEffect(() => {
45
47
  if (!deepEqual(refProps.current, props)) {
46
48
  refProps.current = props;
@@ -49,9 +51,9 @@ const useColumnPrice = (props) => {
49
51
  }, [props]);
50
52
  return useMemo(() => ({
51
53
  formatter: ColumnPriceFormatter(stateProps),
52
- customFilter: getCustomPriceFilter(stateProps),
54
+ customFilter,
53
55
  customSort: getCustomPriceSort(stateProps)
54
- }), [stateProps]);
56
+ }), [stateProps, customFilter]);
55
57
  };
56
58
  export {
57
59
  useColumnPrice as u
@@ -139,7 +139,6 @@ function MenuActions(props) {
139
139
  className: iconButtonClassName,
140
140
  selected: open,
141
141
  disabled,
142
- componentPaletteColor: "default",
143
142
  badgeContent,
144
143
  "aria-label": "menu-actions"
145
144
  }
@@ -29,7 +29,6 @@ function PagerActions(props) {
29
29
  IconButton,
30
30
  {
31
31
  size,
32
- dictionaryTooltipId: "pager.first",
33
32
  onClick: handleFirstPageButtonClick,
34
33
  disabled: page === 0,
35
34
  "aria-label": "first page",
@@ -40,7 +39,6 @@ function PagerActions(props) {
40
39
  IconButton,
41
40
  {
42
41
  size,
43
- dictionaryTooltipId: "pager.previous",
44
42
  onClick: handleBackButtonClick,
45
43
  disabled: page === 0,
46
44
  "aria-label": "first page",
@@ -51,7 +49,6 @@ function PagerActions(props) {
51
49
  IconButton,
52
50
  {
53
51
  size,
54
- dictionaryTooltipId: "pager.next",
55
52
  onClick: handleNextButtonClick,
56
53
  disabled: page >= Math.ceil(count / rowsPerPage) - 1,
57
54
  "aria-label": "next page",
@@ -62,7 +59,6 @@ function PagerActions(props) {
62
59
  IconButton,
63
60
  {
64
61
  size,
65
- dictionaryTooltipId: "pager.last",
66
62
  onClick: handleLastPageButtonClick,
67
63
  disabled: page >= Math.ceil(count / rowsPerPage) - 1,
68
64
  "aria-label": "last page",
@@ -28,7 +28,7 @@ const ChipStatusFormatter = (props) => {
28
28
  color,
29
29
  opacity,
30
30
  size: adjustedSize,
31
- dataTestid
31
+ dataTestId: dataTestid
32
32
  }
33
33
  ) });
34
34
  };
@@ -15,7 +15,10 @@ export type IconButtonSize = 'small' | 'medium';
15
15
  export interface IconButtonProps extends Omit<IconProps, 'size' | 'color' | 'src' | 'selected' | 'enabledSelected'>, Omit<MUIIconButtonProps, 'size' | 'color' | 'disabled' | 'src'>, Pick<BadgeProps, 'badgeContent'>, Pick<TooltipProps, 'placement'> {
16
16
  /** Define el uso de tooltip en IconButton */
17
17
  tooltip?: string;
18
- /** Representa la identificación del tooltip en el diccionario para que designe internamente el getLabel */
18
+ /**
19
+ * @deprecated
20
+ * Representa la identificación del tooltip en el diccionario para que designe internamente el getLabel
21
+ */
19
22
  dictionaryTooltipId?: string;
20
23
  /** Variante del componente, modifica la apariencia gráfica */
21
24
  variant?: IconButtonVariants;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.2.38",
3
+ "version": "9.2.39",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0 --no-warn-ignored"