@m4l/components 9.2.10 → 9.2.11

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.
@@ -1,6 +1,8 @@
1
1
  import { g as getFormatBoolean } from "../../../formatters/BooleanFormatter/BooleanFormatter.js";
2
2
  import { C as ColumnBooleanFormatter } from "./index.js";
3
3
  import { useModuleDictionary, getPropertyByString } from "@m4l/core";
4
+ import { useState, useRef, useEffect, useMemo } from "react";
5
+ import { deepEqual } from "fast-equals";
4
6
  const getCustomBooleanFilter = (props, getLabel) => {
5
7
  return (row, value) => {
6
8
  const valueMaybeString = getPropertyByString(row, props.fieldValue);
@@ -54,11 +56,19 @@ const getCustomBooleanSort = (props, getLabel) => {
54
56
  };
55
57
  const useColumnBoolean = (props) => {
56
58
  const { getLabel } = useModuleDictionary();
57
- return {
58
- formatter: ColumnBooleanFormatter(props),
59
- customFilter: getCustomBooleanFilter(props, getLabel),
60
- customSort: getCustomBooleanSort(props, getLabel)
61
- };
59
+ const [stateProps, setStateProps] = useState(props);
60
+ const refProps = useRef({ ...props });
61
+ useEffect(() => {
62
+ if (!deepEqual(refProps.current, props)) {
63
+ refProps.current = props;
64
+ setStateProps(props);
65
+ }
66
+ }, [props]);
67
+ return useMemo(() => ({
68
+ formatter: ColumnBooleanFormatter(stateProps),
69
+ customFilter: getCustomBooleanFilter(stateProps, getLabel),
70
+ customSort: getCustomBooleanSort(stateProps, getLabel)
71
+ }), [stateProps, getLabel]);
62
72
  };
63
73
  export {
64
74
  useColumnBoolean as u
@@ -1,6 +1,8 @@
1
1
  import { getPropertyByString } from "@m4l/core";
2
2
  import { C as ColumnChipStatusFormatter } from "./ColumnChipStatusFormatter.js";
3
3
  import { g as getColumnKey } from "../../helpers/getColumnKey.js";
4
+ import { deepEqual } from "fast-equals";
5
+ import { useState, useRef, useEffect, useMemo } from "react";
4
6
  const getCustomChipStatusFilter = (props) => {
5
7
  const { uriLabel } = props;
6
8
  return (row, value) => {
@@ -16,11 +18,19 @@ const getCustomChipStatusSort = (props) => {
16
18
  };
17
19
  };
18
20
  const useColumnChipStatus = (props) => {
19
- return {
20
- formatter: ColumnChipStatusFormatter(props),
21
- customFilter: getCustomChipStatusFilter(props),
22
- customSort: getCustomChipStatusSort(props)
23
- };
21
+ const [stateProps, setStateProps] = useState(props);
22
+ const refProps = useRef({ ...props });
23
+ useEffect(() => {
24
+ if (!deepEqual(refProps.current, props)) {
25
+ refProps.current = props;
26
+ setStateProps(props);
27
+ }
28
+ }, [props]);
29
+ return useMemo(() => ({
30
+ formatter: ColumnChipStatusFormatter(stateProps),
31
+ customFilter: getCustomChipStatusFilter(stateProps),
32
+ customSort: getCustomChipStatusSort(stateProps)
33
+ }), [stateProps]);
24
34
  };
25
35
  export {
26
36
  useColumnChipStatus as u
@@ -1,7 +1,9 @@
1
1
  import { getPropertyByString } from "@m4l/core";
2
+ import { deepEqual } from "fast-equals";
2
3
  import { C as ColumnConcatenatedValueFormatter } from "./index.js";
3
4
  import { g as getColumnKey } from "../../helpers/getColumnKey.js";
4
5
  import { g as getFormatConcatenated } from "../../../formatters/ConcatenatedFormatter/ConcatenatedFormatter.js";
6
+ import { useState, useRef, useEffect, useMemo } from "react";
5
7
  const getArrayValuesWithFieldValue = (row, fieldValue) => {
6
8
  const values = fieldValue.map((element) => {
7
9
  const keyWiouthRow = getColumnKey(element);
@@ -38,11 +40,19 @@ const getCustomConcatenatedValueSort = (props) => {
38
40
  };
39
41
  };
40
42
  const useColumnConcatenatedValue = (props) => {
41
- return {
42
- formatter: ColumnConcatenatedValueFormatter(props),
43
- customFilter: getCustomContatenatedValueFilter(props),
44
- customSort: getCustomConcatenatedValueSort(props)
45
- };
43
+ const [stateProps, setStateProps] = useState(props);
44
+ const refProps = useRef({ ...props });
45
+ useEffect(() => {
46
+ if (!deepEqual(refProps.current, props)) {
47
+ refProps.current = props;
48
+ setStateProps(props);
49
+ }
50
+ }, [props]);
51
+ return useMemo(() => ({
52
+ formatter: ColumnConcatenatedValueFormatter(stateProps),
53
+ customFilter: getCustomContatenatedValueFilter(stateProps),
54
+ customSort: getCustomConcatenatedValueSort(stateProps)
55
+ }), [stateProps]);
46
56
  };
47
57
  export {
48
58
  useColumnConcatenatedValue as u
@@ -4,9 +4,11 @@ import { C as ColumnDateFormatter } from "./index.js";
4
4
  import { g as getColumnKey } from "../../helpers/getColumnKey.js";
5
5
  import { useFormatter } from "@m4l/graphics";
6
6
  import { g as getValidDate } from "../../../../utils/getValidDate.js";
7
+ import { useState, useRef, useEffect, useMemo, useCallback } from "react";
8
+ import { deepEqual } from "fast-equals";
7
9
  const useCustomDateFilter = (props) => {
8
10
  const { dateFormatter } = useFormatter();
9
- return (row, value) => {
11
+ const ret = useCallback((row, value) => {
10
12
  const fieldValue = getColumnKey(props.fieldValue);
11
13
  const rawValue = getPropertyByString(row, fieldValue);
12
14
  let dateValue = null;
@@ -20,7 +22,8 @@ const useCustomDateFilter = (props) => {
20
22
  }
21
23
  const formattedDate = getFormatDate(props.presentationType, dateValue, dateFormatter, props.format);
22
24
  return formattedDate.includes(value);
23
- };
25
+ }, [props.presentationType, props.format, dateFormatter]);
26
+ return ret;
24
27
  };
25
28
  const getCustomDateSort = (props) => {
26
29
  return (a, b) => {
@@ -42,12 +45,20 @@ const getCustomDateSort = (props) => {
42
45
  };
43
46
  };
44
47
  const useColumnDate = (props) => {
45
- const customFilter = useCustomDateFilter(props);
46
- return {
47
- formatter: ColumnDateFormatter(props),
48
+ const [stateProps, setStateProps] = useState(props);
49
+ const customFilter = useCustomDateFilter(stateProps);
50
+ const refProps = useRef({ ...props });
51
+ useEffect(() => {
52
+ if (!deepEqual(refProps.current, props)) {
53
+ refProps.current = props;
54
+ setStateProps(props);
55
+ }
56
+ }, [props]);
57
+ return useMemo(() => ({
58
+ formatter: ColumnDateFormatter(stateProps),
48
59
  customFilter,
49
- customSort: getCustomDateSort(props)
50
- };
60
+ customSort: getCustomDateSort(stateProps)
61
+ }), [stateProps, customFilter]);
51
62
  };
52
63
  export {
53
64
  useColumnDate as u
@@ -7,6 +7,6 @@ import { ColumnInteractiveCheckFormatterProps } from './types';
7
7
  */
8
8
  export declare const useColumnInteractiveCheck: <TRow>(props: ColumnInteractiveCheckFormatterProps<TRow>) => {
9
9
  formatter: import("react/jsx-runtime").JSX.Element;
10
- filter: (row: TRow, value: boolean) => boolean;
10
+ customFilter: (row: TRow, value: boolean) => boolean;
11
11
  customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
12
12
  };
@@ -1,3 +1,5 @@
1
+ import { useState, useRef, useEffect, useMemo } from "react";
2
+ import { deepEqual } from "fast-equals";
1
3
  import { C as ColumnInteractiveCheckFormatter } from "./index.js";
2
4
  const getCustomInteractiveCheckFilter = (props) => {
3
5
  return (row, value) => {
@@ -18,11 +20,19 @@ const getCustomInteractiveCheckSort = (props) => {
18
20
  };
19
21
  };
20
22
  const useColumnInteractiveCheck = (props) => {
21
- return {
22
- formatter: ColumnInteractiveCheckFormatter(props),
23
- filter: getCustomInteractiveCheckFilter(props),
24
- customSort: getCustomInteractiveCheckSort(props)
25
- };
23
+ const [stateProps, setStateProps] = useState(props);
24
+ const refProps = useRef({ ...props });
25
+ useEffect(() => {
26
+ if (!deepEqual(refProps.current, props)) {
27
+ refProps.current = props;
28
+ setStateProps(props);
29
+ }
30
+ }, [props]);
31
+ return useMemo(() => ({
32
+ formatter: ColumnInteractiveCheckFormatter(stateProps),
33
+ customFilter: getCustomInteractiveCheckFilter(stateProps),
34
+ customSort: getCustomInteractiveCheckSort(stateProps)
35
+ }), [stateProps]);
26
36
  };
27
37
  export {
28
38
  useColumnInteractiveCheck as u
@@ -1,5 +1,7 @@
1
1
  import { getPropertyByString } from "@m4l/core";
2
2
  import { C as ColumnNestedValueFormatter } from "./index.js";
3
+ import { useState, useRef, useEffect, useMemo } from "react";
4
+ import { deepEqual } from "fast-equals";
3
5
  const getCustomNestedValueFilter = (props) => {
4
6
  return (row, value) => {
5
7
  const property = getPropertyByString(row, props.fieldValue) ?? "";
@@ -26,11 +28,19 @@ const getCustomNestedValueSort = (props) => {
26
28
  };
27
29
  };
28
30
  const useColumnNestedValue = (props) => {
29
- return {
30
- formatter: ColumnNestedValueFormatter(props),
31
- customFilter: getCustomNestedValueFilter(props),
32
- customSort: getCustomNestedValueSort(props)
33
- };
31
+ const [stateProps, setStateProps] = useState(props);
32
+ const refProps = useRef({ ...props });
33
+ useEffect(() => {
34
+ if (!deepEqual(refProps.current, props)) {
35
+ refProps.current = props;
36
+ setStateProps(props);
37
+ }
38
+ }, [props]);
39
+ return useMemo(() => ({
40
+ formatter: ColumnNestedValueFormatter(stateProps),
41
+ customFilter: getCustomNestedValueFilter(stateProps),
42
+ customSort: getCustomNestedValueSort(stateProps)
43
+ }), [stateProps]);
34
44
  };
35
45
  export {
36
46
  useColumnNestedValue as u
@@ -1,3 +1,5 @@
1
+ import { useState, useRef, useEffect, useMemo } from "react";
2
+ import { deepEqual } from "fast-equals";
1
3
  import { C as ColumnPointsFormatter } from "./index.js";
2
4
  import { g as getColumnKey } from "../../helpers/getColumnKey.js";
3
5
  import { g as getFormatPoints } from "../../../formatters/PointsFormatter/PointsFormatter.js";
@@ -24,11 +26,19 @@ const getCustomPointsSort = (props) => {
24
26
  };
25
27
  };
26
28
  const useColumnPoints = (props) => {
27
- return {
28
- formatter: ColumnPointsFormatter(props),
29
- customFilter: getCustomPointsFilter(props),
30
- customSort: getCustomPointsSort(props)
31
- };
29
+ const [stateProps, setStateProps] = useState(props);
30
+ const refProps = useRef({ ...props });
31
+ useEffect(() => {
32
+ if (!deepEqual(refProps.current, props)) {
33
+ refProps.current = props;
34
+ setStateProps(props);
35
+ }
36
+ }, [props]);
37
+ return useMemo(() => ({
38
+ formatter: ColumnPointsFormatter(stateProps),
39
+ customFilter: getCustomPointsFilter(stateProps),
40
+ customSort: getCustomPointsSort(stateProps)
41
+ }), [stateProps]);
32
42
  };
33
43
  export {
34
44
  useColumnPoints as u
@@ -1,8 +1,10 @@
1
+ import { useState, useRef, useEffect, useMemo } from "react";
2
+ import { useFormatter } from "@m4l/graphics";
1
3
  import { getPropertyByString } from "@m4l/core";
2
- import { C as ColumnPriceFormatter } from "./index.js";
3
- import { g as getColumnKey } from "../../helpers/getColumnKey.js";
4
+ import { deepEqual } from "fast-equals";
4
5
  import { g as getFormatPrice } from "../../../formatters/PriceFormatter/PriceFormatter.js";
5
- import { useFormatter } from "@m4l/graphics";
6
+ import { g as getColumnKey } from "../../helpers/getColumnKey.js";
7
+ import { C as ColumnPriceFormatter } from "./index.js";
6
8
  const getCustomPriceFilter = (props) => {
7
9
  const { currencyFormatter } = useFormatter();
8
10
  return (row, value) => {
@@ -37,11 +39,19 @@ const getCustomPriceSort = (props) => {
37
39
  };
38
40
  };
39
41
  const useColumnPrice = (props) => {
40
- return {
41
- formatter: ColumnPriceFormatter(props),
42
- customFilter: getCustomPriceFilter(props),
43
- customSort: getCustomPriceSort(props)
44
- };
42
+ const [stateProps, setStateProps] = useState(props);
43
+ const refProps = useRef({ ...props });
44
+ useEffect(() => {
45
+ if (!deepEqual(refProps.current, props)) {
46
+ refProps.current = props;
47
+ setStateProps(props);
48
+ }
49
+ }, [props]);
50
+ return useMemo(() => ({
51
+ formatter: ColumnPriceFormatter(stateProps),
52
+ customFilter: getCustomPriceFilter(stateProps),
53
+ customSort: getCustomPriceSort(stateProps)
54
+ }), [stateProps]);
45
55
  };
46
56
  export {
47
57
  useColumnPrice as u
@@ -1,5 +1,5 @@
1
- import { ColumnSetCheckFormatterProps } from './types';
2
1
  import { RowKey } from '../../types';
2
+ import { ColumnSetCheckFormatterProps } from './types';
3
3
  /**
4
4
  * Funcion helper que retorna el formatter, customFilter y customSort
5
5
  * de la columna de selección de elementos.
@@ -1,5 +1,7 @@
1
- import { C as ColumnSetCheckFormatter } from "./index.js";
1
+ import { useState, useRef, useEffect, useMemo } from "react";
2
2
  import { getPropertyByString } from "@m4l/core";
3
+ import { deepEqual } from "fast-equals";
4
+ import { C as ColumnSetCheckFormatter } from "./index.js";
3
5
  const getCustomFilter = (props) => {
4
6
  return (row, value) => {
5
7
  const valueCheck = getPropertyByString(row, props.field);
@@ -21,11 +23,19 @@ const getCustomSort = (props) => {
21
23
  };
22
24
  };
23
25
  const useColumnSetCheck = (props) => {
24
- return {
25
- formatter: ColumnSetCheckFormatter(props),
26
- customFilter: getCustomFilter(props),
27
- customSort: getCustomSort(props)
28
- };
26
+ const [stateProps, setStateProps] = useState(props);
27
+ const refProps = useRef({ ...props });
28
+ useEffect(() => {
29
+ if (!deepEqual(refProps.current, props)) {
30
+ refProps.current = props;
31
+ setStateProps(props);
32
+ }
33
+ }, [props]);
34
+ return useMemo(() => ({
35
+ formatter: ColumnSetCheckFormatter(stateProps),
36
+ customFilter: getCustomFilter(stateProps),
37
+ customSort: getCustomSort(stateProps)
38
+ }), [stateProps]);
29
39
  };
30
40
  export {
31
41
  useColumnSetCheck as u
@@ -1,6 +1,8 @@
1
+ import { useState, useRef, useEffect, useMemo } from "react";
2
+ import { deepEqual } from "fast-equals";
1
3
  import { g as getUncertaintyFormat } from "../../../formatters/UncertaintyFormatter/UncertaintyFormatter.js";
2
- import { C as ColumnUncertaintyFormatter } from "./index.js";
3
4
  import { g as getColumnKey } from "../../helpers/getColumnKey.js";
5
+ import { C as ColumnUncertaintyFormatter } from "./index.js";
4
6
  const getCustomUncertaintyFilter = (props) => {
5
7
  return (row, value) => {
6
8
  const fieldValue = getColumnKey(props.fieldValue);
@@ -32,11 +34,19 @@ const getCustomUncertaintySort = (props) => {
32
34
  };
33
35
  };
34
36
  const useColumnCertanity = (props) => {
35
- return {
36
- formatter: ColumnUncertaintyFormatter(props),
37
- customFilter: getCustomUncertaintyFilter(props),
38
- customSort: getCustomUncertaintySort(props)
39
- };
37
+ const [stateProps, setStateProps] = useState(props);
38
+ const refProps = useRef({ ...props });
39
+ useEffect(() => {
40
+ if (!deepEqual(refProps.current, props)) {
41
+ refProps.current = props;
42
+ setStateProps(props);
43
+ }
44
+ }, [props]);
45
+ return useMemo(() => ({
46
+ formatter: ColumnUncertaintyFormatter(stateProps),
47
+ customFilter: getCustomUncertaintyFilter(stateProps),
48
+ customSort: getCustomUncertaintySort(stateProps)
49
+ }), [stateProps]);
40
50
  };
41
51
  export {
42
52
  useColumnCertanity as u
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.2.10",
3
+ "version": "9.2.11",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0 --no-warn-ignored"