@m4l/components 9.1.129 → 9.1.131
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/types.d.ts +2 -2
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index.js +2 -1
- package/components/DataGrid/formatters/ColumnBooleanFormatter/useColumnBoolean.d.ts +10 -0
- package/components/DataGrid/formatters/ColumnBooleanFormatter/useColumnBoolean.js +65 -0
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index.js +2 -1
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/types.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/useColumnConcatenatedValue.d.ts +9 -0
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/useColumnConcatenatedValue.js +49 -0
- package/components/DataGrid/formatters/ColumnDateFormatter/index.js +2 -1
- package/components/DataGrid/formatters/ColumnDateFormatter/useColumnDate.d.ts +14 -0
- package/components/DataGrid/formatters/ColumnDateFormatter/useColumnDate.js +50 -0
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/useColumnInteractiveCheck.d.ts +12 -0
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/useColumnInteractiveCheck.js +29 -0
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index.js +1 -1
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/useColumnNestedValue.d.ts +10 -0
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/useColumnNestedValue.js +37 -0
- package/components/DataGrid/formatters/ColumnPointsFormatter/index.js +3 -1
- package/components/DataGrid/formatters/ColumnPointsFormatter/useColumnPoints.d.ts +10 -0
- package/components/DataGrid/formatters/ColumnPointsFormatter/useColumnPoints.js +35 -0
- package/components/DataGrid/formatters/ColumnPriceFormatter/index.js +3 -1
- package/components/DataGrid/formatters/ColumnPriceFormatter/useColumnPrice.d.ts +10 -0
- package/components/DataGrid/formatters/ColumnPriceFormatter/useColumnPrice.js +48 -0
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/useColumnSetCheck.d.ts +11 -0
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/useColumnSetCheck.js +32 -0
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index.js +3 -1
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/useColumnUncertainty.d.ts +11 -0
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/useColumnUncertainty.js +43 -0
- package/components/DataGrid/formatters/index.d.ts +9 -0
- package/components/DataGrid/helpers/getColumnKey.d.ts +13 -0
- package/components/DataGrid/helpers/getColumnKey.js +11 -0
- package/components/DataGrid/styles.js +2 -1
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +3 -0
- package/components/DataGrid/tests/ColumnsFormatters.test.d.ts +1 -0
- package/components/DataGrid/types.d.ts +1 -0
- package/components/DynamicSort/DynamicSort.d.ts +4 -1
- package/components/DynamicSort/DynamicSort.styles.js +91 -126
- package/components/DynamicSort/constants.d.ts +0 -1
- package/components/DynamicSort/constants.js +0 -1
- package/components/DynamicSort/icons.d.ts +2 -0
- package/components/DynamicSort/icons.js +6 -0
- package/components/DynamicSort/slots/DynamicSortSlots.d.ts +23 -43
- package/components/DynamicSort/slots/DynamicSortSlots.js +30 -57
- package/components/DynamicSort/slots/SlotsEnum.d.ts +2 -9
- package/components/DynamicSort/slots/SlotsEnum.js +1 -8
- package/components/DynamicSort/store/DynamicSortContext.d.ts +3 -3
- package/components/DynamicSort/store/DynamicSortContext.js +10 -4
- package/components/DynamicSort/store/DynamicSortStore.d.ts +1 -177
- package/components/DynamicSort/store/DynamicSortStore.js +10 -1
- package/components/DynamicSort/store/type.d.ts +186 -0
- package/components/DynamicSort/store/useDynamicSortStore.d.ts +2 -2
- package/components/DynamicSort/subcomponents/AppliedSortChip/AppliedSortChip.d.ts +1 -1
- package/components/DynamicSort/subcomponents/AppliedSortChip/AppliedSortChip.js +18 -20
- package/components/DynamicSort/subcomponents/AppliedSortChip/useAppliedSortChip.d.ts +2 -2
- package/components/DynamicSort/subcomponents/AppliedSortChip/useAppliedSortChip.js +4 -4
- package/components/DynamicSort/subcomponents/AppliedSorts/AppliedSorts.d.ts +1 -1
- package/components/DynamicSort/subcomponents/AppliedSorts/AppliedSorts.js +14 -2
- package/components/DynamicSort/subcomponents/AppliedSorts/useAppliedSorts.d.ts +1 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.d.ts +1 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +4 -3
- package/components/DynamicSort/subcomponents/DynamicSortBase/useDynamicSortBase.d.ts +2 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/useDynamicSortBase.js +2 -1
- package/components/DynamicSort/subcomponents/FieldTypes/DataTypeComponent.d.ts +1 -1
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.d.ts +8 -8
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.js +11 -14
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/index.js +16 -12
- package/components/DynamicSort/subcomponents/FieldTypes/fieldFactory.d.ts +1 -1
- package/components/DynamicSort/subcomponents/InputSort/InputSort.d.ts +1 -1
- package/components/DynamicSort/subcomponents/InputSort/InputSort.js +8 -10
- package/components/DynamicSort/subcomponents/PopoverMenuFields/PopoverMenuFields.js +9 -8
- package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.js +8 -6
- package/components/DynamicSort/subcomponents/SortActions/SortActions.js +8 -9
- package/components/DynamicSort/tests/DynamicSort.test.d.ts +1 -0
- package/components/DynamicSort/types.d.ts +9 -2
- package/components/areas/hooks/index.d.ts +1 -0
- package/components/formatters/BooleanFormatter/BooleanFormatter.d.ts +5 -1
- package/components/formatters/BooleanFormatter/BooleanFormatter.js +23 -17
- package/components/formatters/DateFormatter/DateFormatter.d.ts +2 -1
- package/components/formatters/DateFormatter/DateFormatter.js +4 -4
- package/components/formatters/PriceFormatter/PriceFormatter.js +9 -9
- package/components/formatters/index.d.ts +1 -1
- package/index.js +92 -72
- package/package.json +1 -1
- package/vendor.js +3 -3
- package/components/DynamicSort/DynamicSort.stories.d.ts +0 -21
- package/components/DynamicSort/subcomponents/InputSort/InputSortSkeleton.d.ts +0 -5
- package/components/DynamicSort/subcomponents/InputSort/InputSortSkeleton.js +0 -19
- package/components/DynamicSort/subcomponents/SortActions/SortActionsSkeleton.d.ts +0 -5
- package/components/DynamicSort/subcomponents/SortActions/SortActionsSkeleton.js +0 -12
|
@@ -29,7 +29,7 @@ export interface ChipProps {
|
|
|
29
29
|
/**
|
|
30
30
|
* Defines the variant of the `Chip` (default 'contained').
|
|
31
31
|
*/
|
|
32
|
-
variant?: ChipVariants;
|
|
32
|
+
variant?: ChipVariants | string;
|
|
33
33
|
/**
|
|
34
34
|
* Defines the color of the `Chip`.
|
|
35
35
|
*/
|
|
@@ -49,7 +49,7 @@ export interface ChipProps {
|
|
|
49
49
|
/**
|
|
50
50
|
* Function to be executed when the `Chip` is clicked.
|
|
51
51
|
*/
|
|
52
|
-
onClick?: () => void;
|
|
52
|
+
onClick?: (() => void) | ((event: any) => void);
|
|
53
53
|
/**
|
|
54
54
|
* Props for the close icon button.
|
|
55
55
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPropertyByString } from "@m4l/core";
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { B as BooleanFormatter } from "../../../formatters/BooleanFormatter/BooleanFormatter.js";
|
|
4
5
|
function ColumnBooleanFormatter(props) {
|
|
5
|
-
const { fieldValue, presentationType, Component } = props;
|
|
6
|
+
const { fieldValue, presentationType, Component = React.Fragment } = props;
|
|
6
7
|
return (obProps) => {
|
|
7
8
|
const valueMaybeString = getPropertyByString(obProps, fieldValue);
|
|
8
9
|
let fixedValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnBooleanFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Función helper que retorna
|
|
4
|
+
* el formatter de la columna, el filtro y el customSort
|
|
5
|
+
*/
|
|
6
|
+
export declare const useColumnBoolean: <TRow>(props: ColumnBooleanFormatterProps) => {
|
|
7
|
+
formatter: (obProps: any) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
customFilter: (row: TRow, value: string) => boolean;
|
|
9
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
10
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { g as getFormatBoolean } from "../../../formatters/BooleanFormatter/BooleanFormatter.js";
|
|
2
|
+
import { C as ColumnBooleanFormatter } from "./index.js";
|
|
3
|
+
import { useModuleDictionary, getPropertyByString } from "@m4l/core";
|
|
4
|
+
const getCustomBooleanFilter = (props, getLabel) => {
|
|
5
|
+
return (row, value) => {
|
|
6
|
+
const valueMaybeString = getPropertyByString(row, props.fieldValue);
|
|
7
|
+
let fixedValue;
|
|
8
|
+
if (typeof valueMaybeString === "boolean") {
|
|
9
|
+
fixedValue = valueMaybeString;
|
|
10
|
+
} else {
|
|
11
|
+
fixedValue = void 0;
|
|
12
|
+
}
|
|
13
|
+
return getFormatBoolean(
|
|
14
|
+
props.presentationType,
|
|
15
|
+
fixedValue,
|
|
16
|
+
getLabel
|
|
17
|
+
).includes(value);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const getCustomBooleanSort = (props, getLabel) => {
|
|
21
|
+
return (a, b) => {
|
|
22
|
+
const valueMaybeStringA = getPropertyByString(a, props.fieldValue);
|
|
23
|
+
const valueMaybeStringB = getPropertyByString(b, props.fieldValue);
|
|
24
|
+
let fixedValueA;
|
|
25
|
+
let fixedValueB;
|
|
26
|
+
if (typeof valueMaybeStringA === "boolean") {
|
|
27
|
+
fixedValueA = valueMaybeStringA;
|
|
28
|
+
} else {
|
|
29
|
+
fixedValueA = void 0;
|
|
30
|
+
}
|
|
31
|
+
if (typeof valueMaybeStringB === "boolean") {
|
|
32
|
+
fixedValueB = valueMaybeStringB;
|
|
33
|
+
} else {
|
|
34
|
+
fixedValueB = void 0;
|
|
35
|
+
}
|
|
36
|
+
const valueA = getFormatBoolean(
|
|
37
|
+
props.presentationType,
|
|
38
|
+
fixedValueA,
|
|
39
|
+
getLabel
|
|
40
|
+
);
|
|
41
|
+
const valueB = getFormatBoolean(
|
|
42
|
+
props.presentationType,
|
|
43
|
+
fixedValueB,
|
|
44
|
+
getLabel
|
|
45
|
+
);
|
|
46
|
+
if (valueA > valueB) {
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
if (valueA < valueB) {
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const useColumnBoolean = (props) => {
|
|
56
|
+
const { getLabel } = useModuleDictionary();
|
|
57
|
+
return {
|
|
58
|
+
formatter: ColumnBooleanFormatter(props),
|
|
59
|
+
customFilter: getCustomBooleanFilter(props, getLabel),
|
|
60
|
+
customSort: getCustomBooleanSort(props, getLabel)
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
useColumnBoolean as u
|
|
65
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPropertyByString } from "@m4l/core";
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { C as ConcatenatedFormatter } from "../../../formatters/ConcatenatedFormatter/ConcatenatedFormatter.js";
|
|
4
5
|
function ColumnConcatenatedValueFormatter(props) {
|
|
5
|
-
const { fieldValue, fieldSeparator, Component } = props;
|
|
6
|
+
const { fieldValue, fieldSeparator, Component = React.Fragment } = props;
|
|
6
7
|
return (obProps) => {
|
|
7
8
|
const values = fieldValue.map((element) => {
|
|
8
9
|
const valueMaybeString = getPropertyByString(obProps, element);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnConcatenatedValuesFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Funcion helper que retorna el formatter, filter y customSort de la columna concatenada.
|
|
4
|
+
*/
|
|
5
|
+
export declare const useColumnConcatenatedValue: <TRow>(props: ColumnConcatenatedValuesFormatterProps) => {
|
|
6
|
+
formatter: (obProps: any) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
customFilter: (row: TRow, value: string) => boolean;
|
|
8
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
9
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getPropertyByString } from "@m4l/core";
|
|
2
|
+
import { C as ColumnConcatenatedValueFormatter } from "./index.js";
|
|
3
|
+
import { g as getColumnKey } from "../../helpers/getColumnKey.js";
|
|
4
|
+
import { g as getFormatConcatenated } from "../../../formatters/ConcatenatedFormatter/ConcatenatedFormatter.js";
|
|
5
|
+
const getArrayValuesWithFieldValue = (row, fieldValue) => {
|
|
6
|
+
const values = fieldValue.map((element) => {
|
|
7
|
+
const keyWiouthRow = getColumnKey(element);
|
|
8
|
+
const valueMaybeString = getPropertyByString(row, keyWiouthRow);
|
|
9
|
+
let fixedValue;
|
|
10
|
+
if (typeof valueMaybeString === "string" || typeof valueMaybeString === "number") {
|
|
11
|
+
fixedValue = valueMaybeString.toString();
|
|
12
|
+
} else {
|
|
13
|
+
fixedValue = "";
|
|
14
|
+
}
|
|
15
|
+
return fixedValue;
|
|
16
|
+
});
|
|
17
|
+
return values;
|
|
18
|
+
};
|
|
19
|
+
const getCustomContatenatedValueFilter = (props) => {
|
|
20
|
+
return (row, value) => {
|
|
21
|
+
const values = getArrayValuesWithFieldValue(row, props.fieldValue);
|
|
22
|
+
return getFormatConcatenated(values, props.fieldSeparator).includes(value);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const getCustomConcatenatedValueSort = (props) => {
|
|
26
|
+
return (a, b) => {
|
|
27
|
+
const arrayA = getArrayValuesWithFieldValue(a, props.fieldValue);
|
|
28
|
+
const arrayB = getArrayValuesWithFieldValue(b, props.fieldValue);
|
|
29
|
+
const valueA = getFormatConcatenated(arrayA, props.fieldSeparator);
|
|
30
|
+
const valueB = getFormatConcatenated(arrayB, props.fieldSeparator);
|
|
31
|
+
if (valueA > valueB) {
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
if (valueA < valueB) {
|
|
35
|
+
return -1;
|
|
36
|
+
}
|
|
37
|
+
return 0;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const useColumnConcatenatedValue = (props) => {
|
|
41
|
+
return {
|
|
42
|
+
formatter: ColumnConcatenatedValueFormatter(props),
|
|
43
|
+
customFilter: getCustomContatenatedValueFilter(props),
|
|
44
|
+
customSort: getCustomConcatenatedValueSort(props)
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
useColumnConcatenatedValue as u
|
|
49
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPropertyByString } from "@m4l/core";
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { D as DateFormatter } from "../../../formatters/DateFormatter/DateFormatter.js";
|
|
4
5
|
function ColumnDateFormatter(props) {
|
|
5
|
-
const { fieldValue, presentationType, Component } = props;
|
|
6
|
+
const { fieldValue, presentationType, Component = React.Fragment } = props;
|
|
6
7
|
return (obProps) => {
|
|
7
8
|
const valueMaybeDateStringNumber = getPropertyByString(obProps, fieldValue);
|
|
8
9
|
let fixedValue;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColumnDateFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* funcion para filtrar por fecha en una columna
|
|
4
|
+
*/
|
|
5
|
+
export declare const useCustomDateFilter: <TRow>(props: ColumnDateFormatterProps) => (row: TRow, value: string) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Funcion helper que retorna el formatter,
|
|
8
|
+
* customFilter y customSort de una columna de fecha
|
|
9
|
+
*/
|
|
10
|
+
export declare const useColumnDate: <TRow>(props: ColumnDateFormatterProps) => {
|
|
11
|
+
formatter: (obProps: any) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
customFilter: (row: TRow, value: string) => boolean;
|
|
13
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
14
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getPropertyByString } from "@m4l/core";
|
|
2
|
+
import { g as getFormatDate } from "../../../formatters/DateFormatter/DateFormatter.js";
|
|
3
|
+
import { C as ColumnDateFormatter } from "./index.js";
|
|
4
|
+
import { g as getColumnKey } from "../../helpers/getColumnKey.js";
|
|
5
|
+
import { useFormatter } from "@m4l/graphics";
|
|
6
|
+
const useCustomDateFilter = (props) => {
|
|
7
|
+
const { dateFormatter } = useFormatter();
|
|
8
|
+
return (row, value) => {
|
|
9
|
+
const fieldValue = getColumnKey(props.fieldValue);
|
|
10
|
+
const rawValue = getPropertyByString(row, fieldValue);
|
|
11
|
+
let dateValue = null;
|
|
12
|
+
if (typeof rawValue === "string") {
|
|
13
|
+
dateValue = new Date(rawValue);
|
|
14
|
+
} else if (rawValue instanceof Date) {
|
|
15
|
+
dateValue = rawValue;
|
|
16
|
+
}
|
|
17
|
+
if (!dateValue || isNaN(dateValue.getTime())) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const formattedDate = getFormatDate(props.presentationType, dateValue, dateFormatter, props.format);
|
|
21
|
+
return formattedDate.includes(value);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const getCustomDateSort = (props) => {
|
|
25
|
+
return (a, b) => {
|
|
26
|
+
const key = getColumnKey(props.fieldValue);
|
|
27
|
+
const valueMaybeDateStringNumberA = getPropertyByString(a, key);
|
|
28
|
+
const valueMaybeDateStringNumberB = getPropertyByString(b, key);
|
|
29
|
+
const fixedValueA = new Date(valueMaybeDateStringNumberA);
|
|
30
|
+
const fixedValueB = new Date(valueMaybeDateStringNumberB);
|
|
31
|
+
if (fixedValueA.getTime() > fixedValueB.getTime()) {
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
if (fixedValueA.getTime() < fixedValueB.getTime()) {
|
|
35
|
+
return -1;
|
|
36
|
+
}
|
|
37
|
+
return 0;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const useColumnDate = (props) => {
|
|
41
|
+
const customFilter = useCustomDateFilter(props);
|
|
42
|
+
return {
|
|
43
|
+
formatter: ColumnDateFormatter(props),
|
|
44
|
+
customFilter,
|
|
45
|
+
customSort: getCustomDateSort(props)
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
useColumnDate as u
|
|
50
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ColumnInteractiveCheckFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Función que retorna para una columna "check":
|
|
4
|
+
* - formatter: ColumnInteractiveCheckFormatter
|
|
5
|
+
* - filter: getCustomInteractiveCheckFilter
|
|
6
|
+
* - customSort: getCustomInteractiveCheckSort
|
|
7
|
+
*/
|
|
8
|
+
export declare const useColumnInteractiveCheck: <TRow>(props: ColumnInteractiveCheckFormatterProps<TRow>) => {
|
|
9
|
+
formatter: import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
filter: (row: TRow, value: boolean) => boolean;
|
|
11
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
12
|
+
};
|
package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/useColumnInteractiveCheck.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as ColumnInteractiveCheckFormatter } from "./index.js";
|
|
2
|
+
const getCustomInteractiveCheckFilter = (props) => {
|
|
3
|
+
return (row, value) => {
|
|
4
|
+
return row[props.column.key] === value;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
const getCustomInteractiveCheckSort = (props) => {
|
|
8
|
+
return (a, b) => {
|
|
9
|
+
const valueA = a[props.column.key];
|
|
10
|
+
const valueB = b[props.column.key];
|
|
11
|
+
if (valueA > valueB) {
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
if (valueA < valueB) {
|
|
15
|
+
return -1;
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const useColumnInteractiveCheck = (props) => {
|
|
21
|
+
return {
|
|
22
|
+
formatter: ColumnInteractiveCheckFormatter(props),
|
|
23
|
+
filter: getCustomInteractiveCheckFilter(props),
|
|
24
|
+
customSort: getCustomInteractiveCheckSort(props)
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
useColumnInteractiveCheck as u
|
|
29
|
+
};
|
|
@@ -5,7 +5,7 @@ function ColumnNestedValueFormatter(props) {
|
|
|
5
5
|
const { fieldValue, Component = WrapperComponent } = props;
|
|
6
6
|
return (obProps) => {
|
|
7
7
|
const property = getPropertyByString(obProps, fieldValue);
|
|
8
|
-
const value = typeof property === "object" ?
|
|
8
|
+
const value = typeof property === "object" ? JSON.stringify(property) : property;
|
|
9
9
|
return /* @__PURE__ */ jsx(Component, { children: value });
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnNestedValueFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Funcion que retorna el formatter, customFilter y customSort
|
|
4
|
+
* de la columna para ColumnNestedValueFormatter.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useColumnNestedValue: <TRow>(props: ColumnNestedValueFormatterProps) => {
|
|
7
|
+
formatter: (obProps: any) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
customFilter: (row: TRow, value: string) => boolean;
|
|
9
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
10
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getPropertyByString } from "@m4l/core";
|
|
2
|
+
import { C as ColumnNestedValueFormatter } from "./index.js";
|
|
3
|
+
const getCustomNestedValueFilter = (props) => {
|
|
4
|
+
return (row, value) => {
|
|
5
|
+
const property = getPropertyByString(row, props.fieldValue) ?? "";
|
|
6
|
+
if (typeof property === "object") {
|
|
7
|
+
return Object.values(property).includes(value);
|
|
8
|
+
}
|
|
9
|
+
return property.toString().includes(value);
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const getCustomNestedValueSort = (props) => {
|
|
13
|
+
return (a, b) => {
|
|
14
|
+
const valueA = getPropertyByString(a, props.fieldValue);
|
|
15
|
+
const valueB = getPropertyByString(b, props.fieldValue);
|
|
16
|
+
if (typeof valueA === "object" || typeof valueB === "object" || valueA === void 0 || valueB === void 0) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
if (valueA > valueB) {
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
if (valueA < valueB) {
|
|
23
|
+
return -1;
|
|
24
|
+
}
|
|
25
|
+
return 0;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const useColumnNestedValue = (props) => {
|
|
29
|
+
return {
|
|
30
|
+
formatter: ColumnNestedValueFormatter(props),
|
|
31
|
+
customFilter: getCustomNestedValueFilter(props),
|
|
32
|
+
customSort: getCustomNestedValueSort(props)
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
useColumnNestedValue as u
|
|
37
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { P as PointsFormatter } from "../../../formatters/PointsFormatter/PointsFormatter.js";
|
|
3
4
|
function ColumnPointsFormatter(props) {
|
|
5
|
+
const { Component = React.Fragment } = props;
|
|
4
6
|
return (obProps) => {
|
|
5
|
-
return /* @__PURE__ */ jsx(PointsFormatter, { obProps, ...props });
|
|
7
|
+
return /* @__PURE__ */ jsx(PointsFormatter, { obProps, ...props, Component });
|
|
6
8
|
};
|
|
7
9
|
}
|
|
8
10
|
export {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnPointsFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Funcion helper que retorna el formatter,
|
|
4
|
+
* customFilter y customSort de la columna de puntos de calibración.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useColumnPoints: <TRow>(props: ColumnPointsFormatterProps) => {
|
|
7
|
+
formatter: (obProps: any) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
customFilter: (row: TRow, value: string) => boolean;
|
|
9
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
10
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { C as ColumnPointsFormatter } from "./index.js";
|
|
2
|
+
import { g as getColumnKey } from "../../helpers/getColumnKey.js";
|
|
3
|
+
import { g as getFormatPoints } from "../../../formatters/PointsFormatter/PointsFormatter.js";
|
|
4
|
+
const getCustomPointsFilter = (props) => {
|
|
5
|
+
return (row, value) => {
|
|
6
|
+
const fieldValue = getColumnKey(props.fieldValue);
|
|
7
|
+
const unitValue = getColumnKey(props.fieldUnit);
|
|
8
|
+
return getFormatPoints(row, fieldValue, unitValue).toLocaleLowerCase().includes(value.toLocaleLowerCase());
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const getCustomPointsSort = (props) => {
|
|
12
|
+
return (a, b) => {
|
|
13
|
+
const fieldValue = getColumnKey(props.fieldValue);
|
|
14
|
+
const unitValue = getColumnKey(props.fieldUnit);
|
|
15
|
+
const valueA = getFormatPoints(a, fieldValue, unitValue);
|
|
16
|
+
const valueB = getFormatPoints(b, fieldValue, unitValue);
|
|
17
|
+
if (valueA > valueB) {
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
if (valueA < valueB) {
|
|
21
|
+
return -1;
|
|
22
|
+
}
|
|
23
|
+
return 0;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const useColumnPoints = (props) => {
|
|
27
|
+
return {
|
|
28
|
+
formatter: ColumnPointsFormatter(props),
|
|
29
|
+
customFilter: getCustomPointsFilter(props),
|
|
30
|
+
customSort: getCustomPointsSort(props)
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
useColumnPoints as u
|
|
35
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { P as PriceFormatter } from "../../../formatters/PriceFormatter/PriceFormatter.js";
|
|
3
4
|
function ColumnPriceFormatter(props) {
|
|
5
|
+
const { Component = React.Fragment } = props;
|
|
4
6
|
return (obProps) => {
|
|
5
|
-
return /* @__PURE__ */ jsx(PriceFormatter, { obProps, ...props });
|
|
7
|
+
return /* @__PURE__ */ jsx(PriceFormatter, { obProps, ...props, Component });
|
|
6
8
|
};
|
|
7
9
|
}
|
|
8
10
|
export {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnPriceFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Función helper que retorna el formatter,
|
|
4
|
+
* customFilter y customSort de la columna de precios.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useColumnPrice: <TRow>(props: ColumnPriceFormatterProps) => {
|
|
7
|
+
formatter: (obProps: any) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
customFilter: (row: TRow, value: string) => boolean;
|
|
9
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
10
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getPropertyByString } from "@m4l/core";
|
|
2
|
+
import { C as ColumnPriceFormatter } from "./index.js";
|
|
3
|
+
import { g as getColumnKey } from "../../helpers/getColumnKey.js";
|
|
4
|
+
import { g as getFormatPrice } from "../../../formatters/PriceFormatter/PriceFormatter.js";
|
|
5
|
+
import { useFormatter } from "@m4l/graphics";
|
|
6
|
+
const getCustomPriceFilter = (props) => {
|
|
7
|
+
const { currencyFormatter } = useFormatter();
|
|
8
|
+
return (row, value) => {
|
|
9
|
+
const fieldValue = getColumnKey(props.fieldValue);
|
|
10
|
+
return getFormatPrice(row, fieldValue, currencyFormatter.code, currencyFormatter.decimalDigits).includes(value);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const getCustomPriceSort = (props) => {
|
|
14
|
+
return (a, b) => {
|
|
15
|
+
const fieldValue = getColumnKey(props.fieldValue);
|
|
16
|
+
const valueMaybeStringA = getPropertyByString(a, fieldValue);
|
|
17
|
+
const valueMaybeStringB = getPropertyByString(b, fieldValue);
|
|
18
|
+
let fixedValueA;
|
|
19
|
+
let fixedValueB;
|
|
20
|
+
if (typeof valueMaybeStringA === "number") {
|
|
21
|
+
fixedValueA = valueMaybeStringA;
|
|
22
|
+
} else {
|
|
23
|
+
fixedValueA = 0;
|
|
24
|
+
}
|
|
25
|
+
if (typeof valueMaybeStringB === "number") {
|
|
26
|
+
fixedValueB = valueMaybeStringB;
|
|
27
|
+
} else {
|
|
28
|
+
fixedValueB = 0;
|
|
29
|
+
}
|
|
30
|
+
if (fixedValueA > fixedValueB) {
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
if (fixedValueA < fixedValueB) {
|
|
34
|
+
return -1;
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const useColumnPrice = (props) => {
|
|
40
|
+
return {
|
|
41
|
+
formatter: ColumnPriceFormatter(props),
|
|
42
|
+
customFilter: getCustomPriceFilter(props),
|
|
43
|
+
customSort: getCustomPriceSort(props)
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
useColumnPrice as u
|
|
48
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColumnSetCheckFormatterProps } from './types';
|
|
2
|
+
import { RowKey } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Funcion helper que retorna el formatter, customFilter y customSort
|
|
5
|
+
* de la columna de selección de elementos.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useColumnSetCheck: <TRow, TKey extends RowKey = RowKey>(props: ColumnSetCheckFormatterProps<TRow, TKey>) => {
|
|
8
|
+
formatter: (props: import('react-data-grid').FormatterProps<TRow, unknown>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
customFilter: (row: TRow, value: TKey) => boolean;
|
|
10
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
11
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { C as ColumnSetCheckFormatter } from "./index.js";
|
|
2
|
+
import { getPropertyByString } from "@m4l/core";
|
|
3
|
+
const getCustomFilter = (props) => {
|
|
4
|
+
return (row, value) => {
|
|
5
|
+
const valueCheck = getPropertyByString(row, props.field);
|
|
6
|
+
return valueCheck === value;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const getCustomSort = (props) => {
|
|
10
|
+
return (a, b) => {
|
|
11
|
+
const { useHook, field, rowKeyGetter } = props;
|
|
12
|
+
const [checkedRows] = useHook(field);
|
|
13
|
+
const indexA = checkedRows.has(rowKeyGetter(a));
|
|
14
|
+
const indexB = checkedRows.has(rowKeyGetter(b));
|
|
15
|
+
if (indexA && !indexB) {
|
|
16
|
+
return 1;
|
|
17
|
+
} else if (!indexA && indexB) {
|
|
18
|
+
return -1;
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const useColumnSetCheck = (props) => {
|
|
24
|
+
return {
|
|
25
|
+
formatter: ColumnSetCheckFormatter(props),
|
|
26
|
+
customFilter: getCustomFilter(props),
|
|
27
|
+
customSort: getCustomSort(props)
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
useColumnSetCheck as u
|
|
32
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { U as UncertaintyFormatter } from "../../../formatters/UncertaintyFormatter/UncertaintyFormatter.js";
|
|
3
4
|
function ColumnUncertaintyFormatter(props) {
|
|
5
|
+
const { Component = React.Fragment } = props;
|
|
4
6
|
return (obProps) => {
|
|
5
|
-
return /* @__PURE__ */ jsx(UncertaintyFormatter, { obProps, ...props });
|
|
7
|
+
return /* @__PURE__ */ jsx(UncertaintyFormatter, { obProps, ...props, Component });
|
|
6
8
|
};
|
|
7
9
|
}
|
|
8
10
|
export {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColumnUncertaintyFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Función helper que retorna el formatter,
|
|
4
|
+
* el filtro y el customSort de la columna
|
|
5
|
+
* de incertidumbre.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useColumnCertanity: <TRow>(props: ColumnUncertaintyFormatterProps) => {
|
|
8
|
+
formatter: (obProps: any) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
customFilter: (row: TRow, value: string) => boolean;
|
|
10
|
+
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
11
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { g as getUncertaintyFormat } from "../../../formatters/UncertaintyFormatter/UncertaintyFormatter.js";
|
|
2
|
+
import { C as ColumnUncertaintyFormatter } from "./index.js";
|
|
3
|
+
import { g as getColumnKey } from "../../helpers/getColumnKey.js";
|
|
4
|
+
const getCustomUncertaintyFilter = (props) => {
|
|
5
|
+
return (row, value) => {
|
|
6
|
+
const fieldValue = getColumnKey(props.fieldValue);
|
|
7
|
+
const fieldSymbol = getColumnKey(props.fieldSymbol);
|
|
8
|
+
const fieldUnit = getColumnKey(props.fieldUnit);
|
|
9
|
+
const format = getUncertaintyFormat(
|
|
10
|
+
row,
|
|
11
|
+
fieldValue,
|
|
12
|
+
fieldSymbol,
|
|
13
|
+
fieldUnit
|
|
14
|
+
);
|
|
15
|
+
return format.includes(value);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const getCustomUncertaintySort = (props) => {
|
|
19
|
+
return (a, b) => {
|
|
20
|
+
const fieldValue = getColumnKey(props.fieldValue);
|
|
21
|
+
const fieldSymbol = getColumnKey(props.fieldSymbol);
|
|
22
|
+
const fieldUnit = getColumnKey(props.fieldUnit);
|
|
23
|
+
const valueA = getUncertaintyFormat(a, fieldValue, fieldSymbol, fieldUnit);
|
|
24
|
+
const valueB = getUncertaintyFormat(b, fieldValue, fieldSymbol, fieldUnit);
|
|
25
|
+
if (valueA > valueB) {
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
if (valueA < valueB) {
|
|
29
|
+
return -1;
|
|
30
|
+
}
|
|
31
|
+
return 0;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const useColumnCertanity = (props) => {
|
|
35
|
+
return {
|
|
36
|
+
formatter: ColumnUncertaintyFormatter(props),
|
|
37
|
+
customFilter: getCustomUncertaintyFilter(props),
|
|
38
|
+
customSort: getCustomUncertaintySort(props)
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
useColumnCertanity as u
|
|
43
|
+
};
|
|
@@ -9,3 +9,12 @@ export { ColumnInteractiveCheckFormatter } from './ColumnInteractiveCheckFormatt
|
|
|
9
9
|
export { ColumnSetCheckFormatter } from './ColumnSetCheckFormatter';
|
|
10
10
|
export type { ColumnUncertaintyFormatterProps } from './ColumnUncertaintyFormatter/types';
|
|
11
11
|
export { ColumnIconFormatter } from './ColumnIconFormatter';
|
|
12
|
+
export { useColumnBoolean } from './ColumnBooleanFormatter/useColumnBoolean';
|
|
13
|
+
export { useColumnConcatenatedValue } from './ColumnConcatenatedValueFormatter/useColumnConcatenatedValue';
|
|
14
|
+
export { useColumnDate } from './ColumnDateFormatter/useColumnDate';
|
|
15
|
+
export { useColumnNestedValue } from './ColumnNestedValueFormatter/useColumnNestedValue';
|
|
16
|
+
export { useColumnPrice } from './ColumnPriceFormatter/useColumnPrice';
|
|
17
|
+
export { useColumnCertanity } from './ColumnUncertaintyFormatter/useColumnUncertainty';
|
|
18
|
+
export { useColumnPoints } from './ColumnPointsFormatter/useColumnPoints';
|
|
19
|
+
export { useColumnInteractiveCheck } from './ColumnInteractiveCheckFormatter/useColumnInteractiveCheck';
|
|
20
|
+
export { useColumnSetCheck } from './ColumnSetCheckFormatter/useColumnSetCheck';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Función utilizada para remover la parabra 'row' en la posicion cero de las keys de
|
|
3
|
+
* las columnas concatenadas. Esto se utiliza para obtener la key directa
|
|
4
|
+
* asignada en una columna.
|
|
5
|
+
* @param key - key de la columna
|
|
6
|
+
* @returns key sin la palabra 'row'
|
|
7
|
+
* @example
|
|
8
|
+
* - row.concatenated -> concatenated
|
|
9
|
+
* - row.user.name -> user.name
|
|
10
|
+
* @example
|
|
11
|
+
* getColumnKey('row.concatenated') // 'concatenated'
|
|
12
|
+
*/
|
|
13
|
+
export declare const getColumnKey: (key: string) => string;
|