@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.
- package/components/Chip/Chip.js +3 -0
- package/components/Chip/types.d.ts +4 -0
- package/components/DataGrid/formatters/ColumnPriceFormatter/useColumnPrice.js +8 -6
- package/components/MenuActions/MenuActions.js +0 -1
- package/components/Pager/subcomponents/PagerActions/PagerActions.js +0 -4
- package/components/formatters/ChipStatusFormatter/ChipStatusFormatter.js +1 -1
- package/components/mui_extended/IconButton/types.d.ts +4 -1
- package/package.json +1 -1
package/components/Chip/Chip.js
CHANGED
|
@@ -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
|
|
8
|
+
const useCustomPriceFilter = (props) => {
|
|
9
9
|
const { currencyFormatter } = useFormatter();
|
|
10
|
-
|
|
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
|
|
54
|
+
customFilter,
|
|
53
55
|
customSort: getCustomPriceSort(stateProps)
|
|
54
|
-
}), [stateProps]);
|
|
56
|
+
}), [stateProps, customFilter]);
|
|
55
57
|
};
|
|
56
58
|
export {
|
|
57
59
|
useColumnPrice as u
|
|
@@ -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",
|
|
@@ -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
|
-
/**
|
|
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;
|