@m4l/components 9.2.65 → 9.3.0
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/DataGrid/Datagrid.styles.js +112 -9
- package/components/DataGrid/formatters/ColumnBooleanFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnBooleanFormatter/formatter.js +2 -3
- package/components/DataGrid/formatters/ColumnBooleanFormatter/useColumnBoolean.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnChipStatusFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnChipStatusFormatter/formatter.js +5 -4
- package/components/DataGrid/formatters/ColumnChipStatusFormatter/useColumnChipStatus.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnConcatenatedValuesFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnConcatenatedValuesFormatter/formatter.js +11 -4
- package/components/DataGrid/formatters/ColumnConcatenatedValuesFormatter/useColumnConcatenatedValues.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnDateFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnDateFormatter/formatter.js +13 -4
- package/components/DataGrid/formatters/ColumnDateFormatter/useColumnDate.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnIconFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnIconFormatter/formatter.js +2 -2
- package/components/DataGrid/formatters/ColumnIconFormatter/useColumnIcon.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/types.d.ts +2 -2
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/formatter.js +4 -3
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/useColumnNestedValue.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnPointsFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnPointsFormatter/formatter.js +13 -5
- package/components/DataGrid/formatters/ColumnPointsFormatter/useColumnPoints.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnPriceFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnPriceFormatter/formatter.js +11 -4
- package/components/DataGrid/formatters/ColumnPriceFormatter/useColumnPrice.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.d.ts +2 -2
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.js +1 -1
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/useColumnSetCheck.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/formatter.d.ts +2 -1
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/formatter.js +15 -6
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/useColumnUncertainty.d.ts +1 -1
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfig/index.js +4 -5
- package/components/DataGrid/subcomponents/Table/hooks/getDragHeaderRenderer.d.ts +2 -2
- package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.d.ts +2 -2
- package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.js +15 -6
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +13 -7
- package/components/DataGrid/subcomponents/Table/index.d.ts +3 -1
- package/components/DataGrid/subcomponents/Table/index.js +38 -9
- package/components/DataGrid/subcomponents/Table/subcomponents/ActionsColumn.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/CheckboxFormatter.d.ts +2 -2
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.d.ts +2 -2
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.js +10 -8
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/SelectColumn.js +7 -7
- package/components/DataGrid/subcomponents/editors/TextEditor/index.d.ts +15 -5
- package/components/DataGrid/types.d.ts +9 -4
- package/components/NumberInput/hooks/useNumberInput/useNumberInput.js +0 -2
- package/components/areas/contexts/AreasContext/store.js +2 -2
- package/components/formatters/BooleanFormatter/BooleanFormatter.styles.js +1 -1
- package/components/hook-form/RHFAutocompleteAsync/reducer/RHFAutocompleteReducer.js +0 -5
- package/components/mui_extended/MenuItem/MenuItem.js +2 -1
- package/components/mui_extended/MenuItem/types.d.ts +4 -0
- package/package.json +2 -2
- package/storybook/components/DataGrid/DataGrid.stories.d.ts +4 -0
- package/storybook/components/DataGrid/helpers/types.d.ts +3 -2
- package/helpers/getFieldValueWithRow.js +0 -10
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { g as getFieldValueWithRow } from "../../../../helpers/getFieldValueWithRow.js";
|
|
4
3
|
import { U as UncertaintyFormatter } from "../../../formatters/UncertaintyFormatter/UncertaintyFormatter.js";
|
|
5
4
|
function ColumnUncertaintyFormatter(props) {
|
|
6
5
|
const { Component = React.Fragment } = props;
|
|
7
|
-
const fieldValue =
|
|
8
|
-
const fieldSymbol =
|
|
9
|
-
const fieldUnit =
|
|
10
|
-
return (
|
|
11
|
-
return /* @__PURE__ */ jsx(
|
|
6
|
+
const fieldValue = props.fieldValue;
|
|
7
|
+
const fieldSymbol = props.fieldSymbol;
|
|
8
|
+
const fieldUnit = props.fieldUnit;
|
|
9
|
+
return (formatterProps) => {
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
UncertaintyFormatter,
|
|
12
|
+
{
|
|
13
|
+
obProps: formatterProps.row,
|
|
14
|
+
...props,
|
|
15
|
+
fieldValue,
|
|
16
|
+
fieldSymbol,
|
|
17
|
+
fieldUnit,
|
|
18
|
+
Component
|
|
19
|
+
}
|
|
20
|
+
);
|
|
12
21
|
};
|
|
13
22
|
}
|
|
14
23
|
export {
|
|
@@ -4,7 +4,7 @@ import { ColumnUncertaintyFormatterProps } from './types';
|
|
|
4
4
|
* the filter and the customSort of the uncertainty column.
|
|
5
5
|
*/
|
|
6
6
|
export declare const useColumnUncertanity: <TRow>(props: ColumnUncertaintyFormatterProps<TRow>) => {
|
|
7
|
-
formatter: (
|
|
7
|
+
formatter: (formatterProps: import('react-data-grid').RenderCellProps<TRow, unknown>) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
customFilter: (row: TRow, value: string) => boolean;
|
|
9
9
|
customSort: (a: TRow, b: TRow) => 0 | 1 | -1;
|
|
10
10
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DataGrid } from './DataGrid';
|
|
2
2
|
export * from './formatters';
|
|
3
|
-
export type { Column,
|
|
3
|
+
export type { Column, RenderEditCellProps, RenderCellProps } from 'react-data-grid';
|
|
4
4
|
export type { RowKey, ChangeUserColumn } from './types';
|
|
5
5
|
export { getDataGridComponentsDictionary } from './dictionary';
|
|
6
6
|
export { TextEditor, NumberEditor } from './subcomponents/editors/TextEditor';
|
|
@@ -62,7 +62,7 @@ const ColumnsConfig = forwardRef((props, ref) => {
|
|
|
62
62
|
name: getLabel(DICTIONARY.SETTINGS_COLUMN_VISIBLE),
|
|
63
63
|
width: 80,
|
|
64
64
|
type: "boolean",
|
|
65
|
-
|
|
65
|
+
renderCell: ColumnInteractiveCheckFormatter,
|
|
66
66
|
...getAlignClass("center")
|
|
67
67
|
},
|
|
68
68
|
{
|
|
@@ -70,7 +70,7 @@ const ColumnsConfig = forwardRef((props, ref) => {
|
|
|
70
70
|
name: getLabel(DICTIONARY.SETTINGS_COLUMNS_FROZEN),
|
|
71
71
|
width: 80,
|
|
72
72
|
type: "boolean",
|
|
73
|
-
|
|
73
|
+
renderCell: ColumnInteractiveCheckFormatter,
|
|
74
74
|
...getAlignClass("center")
|
|
75
75
|
}
|
|
76
76
|
],
|
|
@@ -176,7 +176,7 @@ const ColumnsConfig = forwardRef((props, ref) => {
|
|
|
176
176
|
const onInternalRowsChange = (newRows) => {
|
|
177
177
|
setRows(newRows);
|
|
178
178
|
};
|
|
179
|
-
const
|
|
179
|
+
const onCellClick = ({ row }) => {
|
|
180
180
|
if (selRows.has(row.key)) {
|
|
181
181
|
return;
|
|
182
182
|
}
|
|
@@ -196,9 +196,8 @@ const ColumnsConfig = forwardRef((props, ref) => {
|
|
|
196
196
|
onRowsChange: onInternalRowsChange,
|
|
197
197
|
selectedRows: selRows,
|
|
198
198
|
onSelectedRowsChange: onInternalSelectedRowsChange,
|
|
199
|
-
|
|
199
|
+
onCellClick,
|
|
200
200
|
rowKeyGetter: (row) => row.key,
|
|
201
|
-
cellNavigationMode: "CHANGE_ROW",
|
|
202
201
|
defaultColumnOptions: { resizable: true, sortable: true }
|
|
203
202
|
}
|
|
204
203
|
) })
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { RenderHeaderCellProps } from 'react-data-grid';
|
|
3
3
|
/**
|
|
4
4
|
* Función encargada de retornar el componente de renderizado de cabecera con la capacidad de arrastrar columnas
|
|
5
5
|
* @param handleColumnsReorder - Función que se ejecuta al reordenar columnas
|
|
6
6
|
*/
|
|
7
7
|
export declare const getDragHeaderRenderer: <TRow, TSummaryRow>(handleColumnsReorder: (sourceKey: string, targetKey: string) => void, options?: {
|
|
8
8
|
openPopover?: (anchorEl: HTMLElement, columnKey: string) => void;
|
|
9
|
-
}) => FunctionComponent<
|
|
9
|
+
}) => FunctionComponent<RenderHeaderCellProps<TRow, TSummaryRow>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Column } from 'react-data-grid';
|
|
1
|
+
import { Column, SortColumn } from 'react-data-grid';
|
|
2
2
|
import { MenuAction } from '../subcomponents/HeaderRenderClick/types';
|
|
3
3
|
/**
|
|
4
4
|
* Función que retorna las acciones del menu del header de la columna
|
|
5
5
|
*/
|
|
6
|
-
export declare function useHeaderMenuActions<Trow, TSummaryRow>(columnKey: string | null, finalColumns: readonly Column<Trow, TSummaryRow>[], defaultSortable: boolean): MenuAction[];
|
|
6
|
+
export declare function useHeaderMenuActions<Trow, TSummaryRow>(columnKey: string | null, finalColumns: readonly Column<Trow, TSummaryRow>[], defaultSortable: boolean, handleSortFromPopover?: (newSortColumns: SortColumn[]) => void): MenuAction[];
|
|
@@ -3,7 +3,7 @@ import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
|
|
|
3
3
|
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
4
4
|
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
5
5
|
import { p as pathIcons } from "../../../icons.js";
|
|
6
|
-
function useHeaderMenuActions(columnKey, finalColumns, defaultSortable) {
|
|
6
|
+
function useHeaderMenuActions(columnKey, finalColumns, defaultSortable, handleSortFromPopover) {
|
|
7
7
|
const {
|
|
8
8
|
columnsConfig,
|
|
9
9
|
onChangeColumnsConfig,
|
|
@@ -14,6 +14,13 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable) {
|
|
|
14
14
|
} = useDataGrid();
|
|
15
15
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
16
16
|
const { getLabel } = useModuleDictionary();
|
|
17
|
+
const executeSortChange = (newSortColumns) => {
|
|
18
|
+
if (handleSortFromPopover) {
|
|
19
|
+
handleSortFromPopover(newSortColumns);
|
|
20
|
+
} else {
|
|
21
|
+
setSortColumns(newSortColumns);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
17
24
|
const column = useMemo(() => {
|
|
18
25
|
return finalColumns.find((c) => c.key === columnKey);
|
|
19
26
|
}, [columnKey, finalColumns]);
|
|
@@ -66,8 +73,9 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable) {
|
|
|
66
73
|
if (!columnKey) {
|
|
67
74
|
return;
|
|
68
75
|
}
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
const newSortColumns = sortColumns.filter((s) => s.columnKey !== columnKey);
|
|
77
|
+
executeSortChange(newSortColumns);
|
|
78
|
+
}, [columnKey, sortColumns, executeSortChange]);
|
|
71
79
|
const hasAnySortApplied = useMemo(() => {
|
|
72
80
|
return Boolean(currentSort);
|
|
73
81
|
}, [currentSort]);
|
|
@@ -153,7 +161,7 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable) {
|
|
|
153
161
|
if (externalSortSettings) {
|
|
154
162
|
addExternalSort("asc");
|
|
155
163
|
} else {
|
|
156
|
-
|
|
164
|
+
executeSortChange([
|
|
157
165
|
{
|
|
158
166
|
columnKey,
|
|
159
167
|
direction: "ASC"
|
|
@@ -175,7 +183,7 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable) {
|
|
|
175
183
|
if (externalSortSettings) {
|
|
176
184
|
addExternalSort("desc");
|
|
177
185
|
} else {
|
|
178
|
-
|
|
186
|
+
executeSortChange([
|
|
179
187
|
{
|
|
180
188
|
columnKey,
|
|
181
189
|
direction: "DESC"
|
|
@@ -255,7 +263,8 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable) {
|
|
|
255
263
|
host_static_assets,
|
|
256
264
|
environment_assets,
|
|
257
265
|
getLabel,
|
|
258
|
-
isAddFilterDisabled
|
|
266
|
+
isAddFilterDisabled,
|
|
267
|
+
executeSortChange
|
|
259
268
|
]);
|
|
260
269
|
}
|
|
261
270
|
export {
|
|
@@ -17,7 +17,6 @@ function getComparator(columns, sortColumn) {
|
|
|
17
17
|
return column.customSort;
|
|
18
18
|
}
|
|
19
19
|
switch (typeOrder) {
|
|
20
|
-
//Si el tipo de dato de la columna es un numerico, retorna una función de ordenamiento numérica
|
|
21
20
|
case "number":
|
|
22
21
|
return (a, b) => {
|
|
23
22
|
try {
|
|
@@ -26,7 +25,6 @@ function getComparator(columns, sortColumn) {
|
|
|
26
25
|
return -1;
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
|
-
//Por defecto retorna una función de ordenamiento de string
|
|
30
28
|
default:
|
|
31
29
|
return (a, b) => {
|
|
32
30
|
try {
|
|
@@ -139,16 +137,24 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
139
137
|
return newColumn;
|
|
140
138
|
}
|
|
141
139
|
if (isSkeleton) {
|
|
142
|
-
newColumn.
|
|
143
|
-
newColumn.
|
|
140
|
+
newColumn.renderHeaderCell = SkeletonFormatter;
|
|
141
|
+
newColumn.renderCell = SkeletonFormatter;
|
|
142
|
+
newColumn.renderEditCell = SkeletonFormatter;
|
|
143
|
+
} else {
|
|
144
|
+
if (newColumn.formatter && !newColumn.renderCell) {
|
|
145
|
+
newColumn.renderCell = newColumn.formatter;
|
|
146
|
+
}
|
|
147
|
+
if (newColumn.editor && !newColumn.renderEditCell) {
|
|
148
|
+
newColumn.renderEditCell = newColumn.editor;
|
|
149
|
+
}
|
|
144
150
|
}
|
|
145
|
-
if (newColumn.
|
|
146
|
-
newColumn.withinHeaderRenderer = newColumn.
|
|
151
|
+
if (newColumn.renderHeaderCell) {
|
|
152
|
+
newColumn.withinHeaderRenderer = newColumn.renderHeaderCell;
|
|
147
153
|
}
|
|
148
154
|
if ((newColumn?.withFilter === void 0 || newColumn.withFilter === true) && activeFilters) {
|
|
149
155
|
newColumn.headerCellClass = `${newColumn.headerCellClass} ${filterColumnClassName}`.trim();
|
|
150
156
|
}
|
|
151
|
-
newColumn.
|
|
157
|
+
newColumn.renderHeaderCell = DragAndDropHeaderRenderer;
|
|
152
158
|
return newColumn;
|
|
153
159
|
});
|
|
154
160
|
}, [
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { DataGridProps } from 'react-data-grid';
|
|
1
2
|
import { GridProps, RowKey } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* Componente que renderiza la tabla con las filas y columnas
|
|
5
|
+
* Acepta todos los props de DataGrid y prioriza las configuraciones personalizadas
|
|
4
6
|
*/
|
|
5
|
-
export declare function Table<TRow, TSummaryRow, TKey extends RowKey = RowKey>(props: GridProps<TRow, TSummaryRow, TKey>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function Table<TRow, TSummaryRow, TKey extends RowKey = RowKey>(props: GridProps<TRow, TSummaryRow, TKey> & Omit<DataGridProps<TRow, TSummaryRow>, keyof GridProps<TRow, TSummaryRow, TKey>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,8 +18,19 @@ function Table(props) {
|
|
|
18
18
|
onRowsChange,
|
|
19
19
|
rowKeyGetter,
|
|
20
20
|
selectedRows,
|
|
21
|
-
onSelectedRowsChange
|
|
21
|
+
onSelectedRowsChange,
|
|
22
|
+
defaultColumnOptions: defaultColumnOptionsProp,
|
|
23
|
+
...restProps
|
|
22
24
|
} = props;
|
|
25
|
+
const renderCheckbox = (formatterProps) => {
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
CheckboxFormatter,
|
|
28
|
+
{
|
|
29
|
+
...formatterProps,
|
|
30
|
+
tabIndex: formatterProps.tabIndex
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
};
|
|
23
34
|
const { finalColumns, finalRows } = useSortColumnsRows(
|
|
24
35
|
columns,
|
|
25
36
|
rows,
|
|
@@ -55,7 +66,18 @@ function Table(props) {
|
|
|
55
66
|
anchorEl: null,
|
|
56
67
|
columnKey: null
|
|
57
68
|
});
|
|
58
|
-
const
|
|
69
|
+
const [allowSortChange, setAllowSortChange] = useState(false);
|
|
70
|
+
const handleSortColumnsChange = (newSortColumns) => {
|
|
71
|
+
if (allowSortChange) {
|
|
72
|
+
setSortColumns(newSortColumns);
|
|
73
|
+
setAllowSortChange(false);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handleSortFromPopover = (newSortColumns) => {
|
|
77
|
+
setAllowSortChange(true);
|
|
78
|
+
setSortColumns(newSortColumns);
|
|
79
|
+
};
|
|
80
|
+
const onCellClick = ({ row }) => {
|
|
59
81
|
if (selectedRows && onSelectedRowsChange) {
|
|
60
82
|
if (selectedRows.entries().next().value) {
|
|
61
83
|
if (selectedRows.entries().next().value?.[1] === rowKeyGetter(row)) {
|
|
@@ -90,11 +112,16 @@ function Table(props) {
|
|
|
90
112
|
const onColumnResize = (idx, width) => {
|
|
91
113
|
onChangeColumnWidth(finalColumns[idx].key, width);
|
|
92
114
|
};
|
|
93
|
-
const defaultColumnOptions = {
|
|
115
|
+
const defaultColumnOptions = {
|
|
116
|
+
resizable: true,
|
|
117
|
+
sortable: true,
|
|
118
|
+
...defaultColumnOptionsProp || {}
|
|
119
|
+
};
|
|
94
120
|
const menuActions = useHeaderMenuActions(
|
|
95
121
|
popoverState.columnKey,
|
|
96
122
|
finalColumns,
|
|
97
|
-
defaultColumnOptions.sortable
|
|
123
|
+
Boolean(defaultColumnOptions.sortable),
|
|
124
|
+
handleSortFromPopover
|
|
98
125
|
);
|
|
99
126
|
return /* @__PURE__ */ jsx(TableContainerStyled, { id: "WrapperTable", children: /* @__PURE__ */ jsxs(TableWrapperDataGridStyled, { ownerState: { size }, children: [
|
|
100
127
|
/* @__PURE__ */ jsx(DndProvider, { backend: HTML5Backend, context: window, children: /* @__PURE__ */ jsx(
|
|
@@ -105,18 +132,20 @@ function Table(props) {
|
|
|
105
132
|
headerRowHeight: activeFilters ? currentRowHeaderHeight + filterHeight : currentRowHeaderHeight,
|
|
106
133
|
columns: finalColumns,
|
|
107
134
|
sortColumns,
|
|
108
|
-
onSortColumnsChange:
|
|
135
|
+
onSortColumnsChange: handleSortColumnsChange,
|
|
109
136
|
onColumnResize,
|
|
110
137
|
rows: finalRows,
|
|
111
138
|
onRowsChange,
|
|
112
139
|
selectedRows,
|
|
113
140
|
onSelectedRowsChange,
|
|
114
|
-
|
|
141
|
+
onCellClick,
|
|
115
142
|
rowHeight: currentRowHeight,
|
|
116
143
|
rowKeyGetter,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
144
|
+
renderers: {
|
|
145
|
+
renderCheckbox
|
|
146
|
+
},
|
|
147
|
+
defaultColumnOptions,
|
|
148
|
+
...restProps
|
|
120
149
|
}
|
|
121
150
|
) }),
|
|
122
151
|
popoverState.columnKey && popoverState.anchorEl instanceof HTMLDivElement && /* @__PURE__ */ jsx(
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const CheckboxFormatter: import('react').ForwardRefExoticComponent<
|
|
1
|
+
import { RenderCheckboxProps } from 'react-data-grid';
|
|
2
|
+
export declare const CheckboxFormatter: import('react').ForwardRefExoticComponent<RenderCheckboxProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface DraggableHeaderRendererProps<TRow> extends
|
|
1
|
+
import { RenderHeaderCellProps } from 'react-data-grid';
|
|
2
|
+
interface DraggableHeaderRendererProps<TRow> extends RenderHeaderCellProps<TRow> {
|
|
3
3
|
onColumnsReorder: (sourceKey: string, targetKey: string) => void;
|
|
4
4
|
openPopover?: (anchorEl: HTMLElement, columnKey: string) => void;
|
|
5
5
|
}
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
3
|
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
4
4
|
import { useDrag, useDrop } from "react-dnd";
|
|
5
|
-
import {
|
|
5
|
+
import { renderHeaderCell } from "react-data-grid";
|
|
6
6
|
import { u as useFocusRef } from "../hooks/useFocusRef.js";
|
|
7
7
|
import { u as useFilters } from "../../../hooks/useFilters.js";
|
|
8
8
|
import { N as NameColumnIconStyled, n as NameColumnStyled, I as IconColumnStyled, o as DraggableHeaderRootStyled, B as ButtonHeaderActionsStyled, p as DraggableWrapperInputBaseStyled, q as IconSearchStyled, H as HeaderInputBaseStyled } from "../../../slots/DataGridSlot.js";
|
|
@@ -13,12 +13,13 @@ function DraggableHeaderRenderer(props) {
|
|
|
13
13
|
const {
|
|
14
14
|
onColumnsReorder,
|
|
15
15
|
column,
|
|
16
|
-
|
|
16
|
+
tabIndex: headerTabIndex,
|
|
17
17
|
openPopover,
|
|
18
|
-
onSort,
|
|
19
18
|
...others
|
|
20
19
|
} = props;
|
|
21
|
-
const { ref, tabIndex } = useFocusRef(
|
|
20
|
+
const { ref, tabIndex } = useFocusRef(
|
|
21
|
+
headerTabIndex !== void 0 && headerTabIndex >= 0
|
|
22
|
+
);
|
|
22
23
|
const { getLabel } = useModuleDictionary();
|
|
23
24
|
const { size, classes, externalSortSettings, externalFilterSettings } = useDataGrid();
|
|
24
25
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
@@ -133,6 +134,9 @@ function DraggableHeaderRenderer(props) {
|
|
|
133
134
|
opacity: isDragging ? 0.5 : 1,
|
|
134
135
|
backgroundColor: isOver ? "#ececec" : void 0
|
|
135
136
|
},
|
|
137
|
+
onClick: (e) => {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
},
|
|
136
140
|
children: [
|
|
137
141
|
/* @__PURE__ */ jsx(
|
|
138
142
|
ButtonHeaderActionsStyled,
|
|
@@ -143,12 +147,10 @@ function DraggableHeaderRenderer(props) {
|
|
|
143
147
|
openPopover?.(e.currentTarget, column.key);
|
|
144
148
|
},
|
|
145
149
|
children: /* @__PURE__ */ jsx(
|
|
146
|
-
|
|
150
|
+
renderHeaderCell,
|
|
147
151
|
{
|
|
148
152
|
column: newColumn,
|
|
149
|
-
|
|
150
|
-
onSort: () => {
|
|
151
|
-
},
|
|
153
|
+
tabIndex: headerTabIndex,
|
|
152
154
|
...others
|
|
153
155
|
}
|
|
154
156
|
)
|
|
@@ -5,13 +5,13 @@ import { d as DATAGRID_SELECT_COLUMN_KEY } from "../../../constants.js";
|
|
|
5
5
|
const filterColumnClassName = "filter-cell";
|
|
6
6
|
const filterHeight = 35;
|
|
7
7
|
function SelectGroupFormatter(props) {
|
|
8
|
-
const
|
|
8
|
+
const { isRowSelected, onRowSelectionChange } = useRowSelection();
|
|
9
9
|
const onChange = (checked) => {
|
|
10
10
|
onRowSelectionChange({ row: props.row, checked, isShiftClick: false });
|
|
11
11
|
};
|
|
12
12
|
const cellFormater = SelectCellFormatter({
|
|
13
13
|
value: isRowSelected,
|
|
14
|
-
|
|
14
|
+
tabIndex: props.tabIndex,
|
|
15
15
|
onChange,
|
|
16
16
|
"aria-label": "Select Group"
|
|
17
17
|
});
|
|
@@ -32,7 +32,7 @@ function SelectFormatter(props) {
|
|
|
32
32
|
SelectCellFormatter,
|
|
33
33
|
{
|
|
34
34
|
value: checkedRows?.has(rowKeyGetter(props.row)) || false,
|
|
35
|
-
|
|
35
|
+
tabIndex: props.tabIndex,
|
|
36
36
|
onChange,
|
|
37
37
|
"aria-label": "Select"
|
|
38
38
|
}
|
|
@@ -53,7 +53,7 @@ const SelectColumnHeaderRenderer = (props) => {
|
|
|
53
53
|
const allRowsChecked = rows.length === checkedRows?.size;
|
|
54
54
|
return SelectCellFormatter({
|
|
55
55
|
"aria-label": "Select All",
|
|
56
|
-
|
|
56
|
+
tabIndex: props.tabIndex,
|
|
57
57
|
value: allRowsChecked,
|
|
58
58
|
onChange: onAllRowsCheckedChange
|
|
59
59
|
});
|
|
@@ -68,9 +68,9 @@ const SelectColumn = {
|
|
|
68
68
|
sortable: false,
|
|
69
69
|
frozen: true,
|
|
70
70
|
type: "boolean",
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
renderHeaderCell: SelectColumnHeaderRenderer,
|
|
72
|
+
renderCell: SelectFormatter,
|
|
73
|
+
renderGroupCell: SelectGroupFormatter
|
|
74
74
|
};
|
|
75
75
|
export {
|
|
76
76
|
SelectColumn as S,
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RenderEditCellProps } from 'react-data-grid';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Editor para campos de texto en el DataGrid.
|
|
4
|
+
* Permite editar valores de texto con navegación por teclado.
|
|
5
|
+
* @param row - Fila actual del DataGrid
|
|
6
|
+
* @param column - Columna actual del DataGrid
|
|
7
|
+
* @param onRowChange - Función para actualizar la fila
|
|
8
|
+
* @param onClose - Función para cerrar el editor
|
|
4
9
|
*/
|
|
5
|
-
export declare function TextEditor<TRow, TSummaryRow>({ row, column, onRowChange, onClose, }:
|
|
10
|
+
export declare function TextEditor<TRow, TSummaryRow>({ row, column, onRowChange, onClose, }: RenderEditCellProps<TRow, TSummaryRow>): import("react/jsx-runtime").JSX.Element;
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
12
|
+
* Editor para campos numéricos en el DataGrid.
|
|
13
|
+
* Permite editar valores numéricos con validación y navegación por teclado.
|
|
14
|
+
* @param row - Fila actual del DataGrid
|
|
15
|
+
* @param column - Columna actual del DataGrid
|
|
16
|
+
* @param onRowChange - Función para actualizar la fila
|
|
17
|
+
* @param onClose - Función para cerrar el editor
|
|
8
18
|
*/
|
|
9
|
-
export declare function NumberEditor<TRow, TSummaryRow>({ row, column, onRowChange, onClose, }:
|
|
19
|
+
export declare function NumberEditor<TRow, TSummaryRow>({ row, column, onRowChange, onClose, }: RenderEditCellProps<TRow, TSummaryRow>): import("react/jsx-runtime").JSX.Element;
|
|
10
20
|
export default TextEditor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Maybe } from '@m4l/core';
|
|
2
2
|
import { Theme } from '@mui/material/styles';
|
|
3
|
-
import { Column, RowsChangeData,
|
|
3
|
+
import { Column, RowsChangeData, RenderCellProps, DataGridProps as NativeDataGridProps } from 'react-data-grid';
|
|
4
4
|
import { MenuAction } from '../MenuActions/types';
|
|
5
5
|
import { ActionsSlots, ColumnIconFormatterSlots, ColumnsConfigSlots, ControlNavigateSlots, DataGridSlots, RowsCountSlots, TableSlots, TextEditorSlots } from './slots/DataGridEnum';
|
|
6
6
|
import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
@@ -9,7 +9,8 @@ import { IGridConfig } from './contexts/DataGridContext/types';
|
|
|
9
9
|
import { Sizes } from '@m4l/styles';
|
|
10
10
|
import { PagerProps } from '../Pager';
|
|
11
11
|
import { SettingsProps } from './subcomponents/HeaderActions/subcomponents/Settings/types';
|
|
12
|
-
|
|
12
|
+
import { ReactNode } from 'react';
|
|
13
|
+
export type GridFormatterPropss<T, SR> = RenderCellProps<T, SR>;
|
|
13
14
|
export type { ColumnUncertaintyFormatter, ColumnPointsFormatter, ColumnNestedValueFormatter, } from './formatters';
|
|
14
15
|
export declare type ColumnType = 'string' | 'date' | 'number' | 'boolean' | 'custom';
|
|
15
16
|
export declare type ColumnAlign = 'left' | 'center' | 'right';
|
|
@@ -31,9 +32,13 @@ declare module 'react-data-grid' {
|
|
|
31
32
|
align?: ColumnAlign;
|
|
32
33
|
isDraggable?: boolean;
|
|
33
34
|
withFilter?: boolean;
|
|
34
|
-
withinHeaderRenderer?: React.FunctionComponent<
|
|
35
|
+
withinHeaderRenderer?: React.FunctionComponent<RenderHeaderCellProps<TRow, TSummaryRow>>;
|
|
35
36
|
customFilter?: (row: TRow, value: string) => boolean;
|
|
36
37
|
customSort?: (a: TRow, b: TRow) => number;
|
|
38
|
+
/** @deprecated Usa renderCell en lugar de formatter. Este atributo será removido en una futura versión. */
|
|
39
|
+
formatter?: (props: any) => JSX.Element;
|
|
40
|
+
/** @deprecated Usa renderEditCell en lugar de editor. Este atributo será removido en una futura versión. */
|
|
41
|
+
editor?: Maybe<(props: RenderEditCellProps<TRow, TSummaryRow>) => ReactNode>;
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
export declare type RowKey = string | number;
|
|
@@ -107,7 +112,7 @@ export interface FilterSettings {
|
|
|
107
112
|
onChange: (event: FilterChangeEvent) => void;
|
|
108
113
|
}
|
|
109
114
|
/**--------------------Termina tipado de filtros-------------------------------------------- */
|
|
110
|
-
export interface GridProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> {
|
|
115
|
+
export interface GridProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Omit<NativeDataGridProps<TRow, TSummaryRow>, 'rowKeyGetter' | 'rows' | 'columns' | 'onRowsChange' | 'selectedRows' | 'onSelectedRowsChange' | 'renderers'> {
|
|
111
116
|
id: string;
|
|
112
117
|
withActions?: boolean;
|
|
113
118
|
columns: readonly Column<TRow, TSummaryRow>[];
|
|
@@ -56,11 +56,9 @@ const useNumberInput = (parameters) => {
|
|
|
56
56
|
(event, field, fieldValue, reason) => {
|
|
57
57
|
if (field === "value" && typeof fieldValue !== "string") {
|
|
58
58
|
switch (reason) {
|
|
59
|
-
// only a blur event will dispatch `numberInput:clamp`
|
|
60
59
|
case "numberInput:inputChange":
|
|
61
60
|
onChange?.(event, fieldValue);
|
|
62
61
|
break;
|
|
63
|
-
// only a blur event will dispatch `numberInput:clamp`
|
|
64
62
|
case "numberInput:clamp":
|
|
65
63
|
onChange?.(event, fieldValue);
|
|
66
64
|
break;
|
|
@@ -441,8 +441,8 @@ const createAreasStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
441
441
|
bounds: {
|
|
442
442
|
left: MARGIN_GRIDLAYOUT,
|
|
443
443
|
top: MARGIN_GRIDLAYOUT,
|
|
444
|
-
right: -
|
|
445
|
-
bottom: -
|
|
444
|
+
right: -10,
|
|
445
|
+
bottom: -10
|
|
446
446
|
}
|
|
447
447
|
});
|
|
448
448
|
}
|
|
@@ -65,11 +65,6 @@ const RHFAutocompleteAsyncReducer = (onChangeFilterParms) => (state, action) =>
|
|
|
65
65
|
...state,
|
|
66
66
|
isOpen: false
|
|
67
67
|
};
|
|
68
|
-
// case actionsType.SET_SELECTED_OPTIONS_TO_AUTOCOMPLETE:
|
|
69
|
-
// return {
|
|
70
|
-
// ...state,
|
|
71
|
-
// selectedOptions: action.payload,
|
|
72
|
-
// };
|
|
73
68
|
default:
|
|
74
69
|
return state;
|
|
75
70
|
}
|
|
@@ -20,6 +20,7 @@ const MenuItem = (props) => {
|
|
|
20
20
|
checked = false,
|
|
21
21
|
checkable = false,
|
|
22
22
|
className,
|
|
23
|
+
dataTestId,
|
|
23
24
|
...other
|
|
24
25
|
} = props;
|
|
25
26
|
const { currentSize } = useComponentSize(size);
|
|
@@ -83,7 +84,7 @@ const MenuItem = (props) => {
|
|
|
83
84
|
disableRipple: true,
|
|
84
85
|
size: adjustedSize,
|
|
85
86
|
className: clsx(className, MENUITEM_CLASSES.root),
|
|
86
|
-
"data-testid": "MenuItemRoot",
|
|
87
|
+
"data-testid": dataTestId || "MenuItemRoot",
|
|
87
88
|
children: [
|
|
88
89
|
checkable && /* @__PURE__ */ jsx(
|
|
89
90
|
MenuItemIconCheckedStyled,
|
|
@@ -53,6 +53,10 @@ export interface MenuItemProps extends Omit<MUIMenuItemProps, 'size' | 'color'>
|
|
|
53
53
|
* indica si debe aparecer el icono de check
|
|
54
54
|
*/
|
|
55
55
|
checkable?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* ID para pruebas que se pasará como data-testid
|
|
58
|
+
*/
|
|
59
|
+
dataTestId?: string;
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
62
|
* Estado del propietario del `MenuItem` utilizado para definir propiedades internas de estilo y comportamiento.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/components",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "M4L Components",
|
|
6
6
|
"lint-staged": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react": "18.3.1",
|
|
35
35
|
"react-chartjs-2": "^5.2.0",
|
|
36
36
|
"react-color": "^2.19.3",
|
|
37
|
-
"react-data-grid": "7.0.0-beta.
|
|
37
|
+
"react-data-grid": "7.0.0-beta.47",
|
|
38
38
|
"react-dnd": "^16.0.1",
|
|
39
39
|
"react-dnd-html5-backend": "^16.0.1",
|
|
40
40
|
"react-dom": "18.3.1",
|
|
@@ -19,6 +19,10 @@ export declare const DataGridWithEventChangeUserColumn: Story;
|
|
|
19
19
|
* DataGrid con columns formatters
|
|
20
20
|
*/
|
|
21
21
|
export declare const DatagridWithFormatters: Story;
|
|
22
|
+
/**
|
|
23
|
+
* DataGrid con columns editors
|
|
24
|
+
*/
|
|
25
|
+
export declare const DatagridWithEditors: Story;
|
|
22
26
|
/**
|
|
23
27
|
* DataGrid con columns with actions
|
|
24
28
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RenderHeaderCellProps } from 'react-data-grid';
|
|
2
2
|
import { ChipStatusFormatterProps } from '../../../../src/components/formatters/ChipStatusFormatter/types';
|
|
3
3
|
import { DeepKeyOf } from '../../../../src/utils/types';
|
|
4
4
|
import { ColumnAlign } from '../../../../src/components/DataGrid/types';
|
|
@@ -21,6 +21,7 @@ export interface SeedProps {
|
|
|
21
21
|
withActionsUser?: boolean;
|
|
22
22
|
withBooleanStatus?: boolean;
|
|
23
23
|
withUserType?: boolean;
|
|
24
|
+
withEditors?: boolean;
|
|
24
25
|
aligns?: Record<string, ColumnAlign>;
|
|
25
26
|
names?: Record<string, string>;
|
|
26
27
|
}
|
|
@@ -74,7 +75,7 @@ export interface Column<TRow, TSummaryRow> {
|
|
|
74
75
|
type: ColumnType;
|
|
75
76
|
formatter?: (props: any) => JSX.Element;
|
|
76
77
|
width?: number;
|
|
77
|
-
withinHeaderRenderer?: React.FunctionComponent<
|
|
78
|
+
withinHeaderRenderer?: React.FunctionComponent<RenderHeaderCellProps<TRow, TSummaryRow>>;
|
|
78
79
|
customFilter?: (row: TRow, value: string) => boolean;
|
|
79
80
|
customSort?: (a: TRow, b: TRow) => number;
|
|
80
81
|
}
|