@m4l/components 9.3.29-JT19112025.beta.1 → 9.3.29-JT19112025.beta.3
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/hooks/useModalCardDetail.d.ts +1 -1
- package/components/DataGrid/hooks/useModalCardDetail.js +6 -1
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.d.ts +1 -1
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.js +21 -6
- package/components/DataGrid/subcomponents/Cards/index.js +5 -2
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.d.ts +1 -1
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.js +22 -7
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.d.ts +1 -1
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.js +4 -0
- package/components/DataGrid/subcomponents/Cards/types.d.ts +16 -0
- package/components/DataGrid/types.d.ts +12 -0
- package/package.json +1 -1
|
@@ -3,4 +3,4 @@ import { UseModalDetailProps } from '../types';
|
|
|
3
3
|
* Hook que renderiza el modal de detalle para cualquier vista
|
|
4
4
|
* mostrando TODAS las columnas sin excepción
|
|
5
5
|
*/
|
|
6
|
-
export declare const useModalDetail: <TRow>({ columns, viewMode, onRowsChange, }: UseModalDetailProps<TRow>) => (row: TRow) => void;
|
|
6
|
+
export declare const useModalDetail: <TRow>({ columns, viewMode, onRowsChange, rows, }: UseModalDetailProps<TRow>) => (row: TRow) => void;
|
|
@@ -14,7 +14,8 @@ import { A as ActionCancel } from "../../CommonActions/components/ActionCancel/A
|
|
|
14
14
|
const useModalDetail = ({
|
|
15
15
|
columns,
|
|
16
16
|
viewMode,
|
|
17
|
-
onRowsChange
|
|
17
|
+
onRowsChange,
|
|
18
|
+
rows
|
|
18
19
|
}) => {
|
|
19
20
|
const { getConfigColumns, size } = useDataGrid();
|
|
20
21
|
const { openModal, closeModal } = useModal();
|
|
@@ -24,6 +25,7 @@ const useModalDetail = ({
|
|
|
24
25
|
const handleOpenDetail = useCallback(
|
|
25
26
|
(row) => {
|
|
26
27
|
const viewColumnsConfig = getConfigColumns(viewMode);
|
|
28
|
+
const rowIndex = rows.findIndex((r) => r === row);
|
|
27
29
|
openModal({
|
|
28
30
|
initialWidth: 500,
|
|
29
31
|
initialHeight: 680,
|
|
@@ -42,6 +44,8 @@ const useModalDetail = ({
|
|
|
42
44
|
CardDetails,
|
|
43
45
|
{
|
|
44
46
|
row,
|
|
47
|
+
rows,
|
|
48
|
+
rowIndex,
|
|
45
49
|
columns,
|
|
46
50
|
viewColumnsConfig,
|
|
47
51
|
onRowsChange,
|
|
@@ -56,6 +60,7 @@ const useModalDetail = ({
|
|
|
56
60
|
},
|
|
57
61
|
[
|
|
58
62
|
columns,
|
|
63
|
+
rows,
|
|
59
64
|
onRowsChange,
|
|
60
65
|
size,
|
|
61
66
|
getConfigColumns,
|
|
@@ -2,7 +2,7 @@ import { CardContentProps } from '../../../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook que encapsula toda la lógica de renderizado del contenido de una Card
|
|
4
4
|
*/
|
|
5
|
-
export declare function useCardContent<TRow>({ row, columns, onRowsChange, }: CardContentProps<TRow>): {
|
|
5
|
+
export declare function useCardContent<TRow>({ row, rows, rowIndex, columns, onRowsChange, }: CardContentProps<TRow>): {
|
|
6
6
|
cardContent: import("react/jsx-runtime").JSX.Element[];
|
|
7
7
|
columnsCount: number;
|
|
8
8
|
};
|
|
@@ -8,6 +8,8 @@ import { p as pathIcons } from "../../../icons.js";
|
|
|
8
8
|
import { u as useComponentSize } from "../../../../../hooks/useComponentSize/useComponentSize.js";
|
|
9
9
|
function useCardContent({
|
|
10
10
|
row,
|
|
11
|
+
rows,
|
|
12
|
+
rowIndex,
|
|
11
13
|
columns,
|
|
12
14
|
onRowsChange
|
|
13
15
|
}) {
|
|
@@ -41,8 +43,11 @@ function useCardContent({
|
|
|
41
43
|
*/
|
|
42
44
|
onRowChange: (updatedRow) => {
|
|
43
45
|
if (onRowsChange) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
const updatedRows = rows.map(
|
|
47
|
+
(r, i) => i === rowIndex ? updatedRow : r
|
|
48
|
+
);
|
|
49
|
+
onRowsChange(updatedRows, {
|
|
50
|
+
indexes: [rowIndex],
|
|
46
51
|
column
|
|
47
52
|
});
|
|
48
53
|
}
|
|
@@ -62,8 +67,11 @@ function useCardContent({
|
|
|
62
67
|
*/
|
|
63
68
|
onRowChange: (updatedRow) => {
|
|
64
69
|
if (onRowsChange) {
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
const updatedRows = rows.map(
|
|
71
|
+
(r, i) => i === rowIndex ? updatedRow : r
|
|
72
|
+
);
|
|
73
|
+
onRowsChange(updatedRows, {
|
|
74
|
+
indexes: [rowIndex],
|
|
67
75
|
column
|
|
68
76
|
});
|
|
69
77
|
}
|
|
@@ -74,9 +82,16 @@ function useCardContent({
|
|
|
74
82
|
const rawValue = row[column.key];
|
|
75
83
|
const isEmpty = rawValue === null || rawValue === void 0 || rawValue === "";
|
|
76
84
|
const isEditable = !!column.renderEditCell;
|
|
77
|
-
if (
|
|
85
|
+
if (isEditable) {
|
|
78
86
|
return /* @__PURE__ */ jsxs(EditablePlaceholderStyled, { children: [
|
|
79
|
-
/* @__PURE__ */ jsx(
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
ValueColumnStyled,
|
|
89
|
+
{
|
|
90
|
+
variant: "body",
|
|
91
|
+
color: isEmpty ? "text.secondary" : "text.primary",
|
|
92
|
+
children: isEmpty ? getLabel(DICTIONARY.EDIT_PLACEHOLDER) : rawValue
|
|
93
|
+
}
|
|
94
|
+
),
|
|
80
95
|
/* @__PURE__ */ jsx(
|
|
81
96
|
IconButtonEditStyled,
|
|
82
97
|
{
|
|
@@ -28,7 +28,8 @@ function Cards(props) {
|
|
|
28
28
|
const handleOpenDetail = useModalDetail({
|
|
29
29
|
columns: allProcessedColumns,
|
|
30
30
|
viewMode: "cards",
|
|
31
|
-
onRowsChange
|
|
31
|
+
onRowsChange,
|
|
32
|
+
rows
|
|
32
33
|
});
|
|
33
34
|
const cardHeight = useMemo(() => {
|
|
34
35
|
return calculateCardHeight({
|
|
@@ -64,7 +65,7 @@ function Cards(props) {
|
|
|
64
65
|
if (processedColumns.length === 0) {
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
67
|
-
return /* @__PURE__ */ jsx(CardsContainerStyled, { "data-testid": "cards-container", ref: containerRef, children: /* @__PURE__ */ jsx(ContainerFlow, { variant: "grid-layout", minWidth: 280, children: rows.map((row) => {
|
|
68
|
+
return /* @__PURE__ */ jsx(CardsContainerStyled, { "data-testid": "cards-container", ref: containerRef, children: /* @__PURE__ */ jsx(ContainerFlow, { variant: "grid-layout", minWidth: 280, children: rows.map((row, rowIndex) => {
|
|
68
69
|
const rowKey = rowKeyGetter(row);
|
|
69
70
|
const isChecked = checkedRows?.has(rowKey) || false;
|
|
70
71
|
const showCheckbox = checkedRows !== void 0 && onCheckedRowsChange !== void 0;
|
|
@@ -72,6 +73,8 @@ function Cards(props) {
|
|
|
72
73
|
CardRow,
|
|
73
74
|
{
|
|
74
75
|
row,
|
|
76
|
+
rows,
|
|
77
|
+
rowIndex,
|
|
75
78
|
columns: processedColumns,
|
|
76
79
|
originalColumns: allProcessedColumns,
|
|
77
80
|
rowKeyGetter,
|
|
@@ -5,4 +5,4 @@ import { CardDetailsProps } from '../../types';
|
|
|
5
5
|
*
|
|
6
6
|
* A diferencia del componente Cards, este muestra TODAS las columnas
|
|
7
7
|
*/
|
|
8
|
-
export declare function CardDetails<TRow>({ row, columns, viewColumnsConfig, onRowsChange, size, }: CardDetailsProps<TRow>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function CardDetails<TRow>({ row, columns, viewColumnsConfig, onRowsChange, size, rows, rowIndex, }: CardDetailsProps<TRow>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,7 +10,9 @@ function CardDetails({
|
|
|
10
10
|
columns,
|
|
11
11
|
viewColumnsConfig,
|
|
12
12
|
onRowsChange,
|
|
13
|
-
size = "medium"
|
|
13
|
+
size = "medium",
|
|
14
|
+
rows,
|
|
15
|
+
rowIndex
|
|
14
16
|
}) {
|
|
15
17
|
const [editingColumnKey, setEditingColumnKey] = useState(null);
|
|
16
18
|
const [refreshCounter, setRefreshCounter] = useState(0);
|
|
@@ -61,8 +63,11 @@ function CardDetails({
|
|
|
61
63
|
*/
|
|
62
64
|
onRowChange: (updatedRow) => {
|
|
63
65
|
if (onRowsChange) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
const updatedRows = rows.map(
|
|
67
|
+
(r, i) => i === rowIndex ? updatedRow : r
|
|
68
|
+
);
|
|
69
|
+
onRowsChange(updatedRows, {
|
|
70
|
+
indexes: [rowIndex],
|
|
66
71
|
column: originalColumn
|
|
67
72
|
});
|
|
68
73
|
}
|
|
@@ -82,8 +87,11 @@ function CardDetails({
|
|
|
82
87
|
*/
|
|
83
88
|
onRowChange: (updatedRow) => {
|
|
84
89
|
if (onRowsChange) {
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const updatedRows = rows.map(
|
|
91
|
+
(r, i) => i === rowIndex ? updatedRow : r
|
|
92
|
+
);
|
|
93
|
+
onRowsChange(updatedRows, {
|
|
94
|
+
indexes: [rowIndex],
|
|
87
95
|
column: originalColumn
|
|
88
96
|
});
|
|
89
97
|
}
|
|
@@ -94,9 +102,16 @@ function CardDetails({
|
|
|
94
102
|
const rawValue = row[modifiedColumn.key];
|
|
95
103
|
const isEmpty = rawValue === null || rawValue === void 0 || rawValue === "";
|
|
96
104
|
const isEditable = !!modifiedColumn.renderEditCell;
|
|
97
|
-
if (
|
|
105
|
+
if (isEditable) {
|
|
98
106
|
return /* @__PURE__ */ jsxs(EditablePlaceholderStyled, { children: [
|
|
99
|
-
/* @__PURE__ */ jsx(
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
ValueColumnStyled,
|
|
109
|
+
{
|
|
110
|
+
variant: "body",
|
|
111
|
+
color: isEmpty ? "text.secondary" : "text.primary",
|
|
112
|
+
children: isEmpty ? getLabel(DICTIONARY.EDIT_PLACEHOLDER) : rawValue
|
|
113
|
+
}
|
|
114
|
+
),
|
|
100
115
|
/* @__PURE__ */ jsx(
|
|
101
116
|
IconButtonEditStyled,
|
|
102
117
|
{
|
|
@@ -3,7 +3,7 @@ import { CardRowProps } from '../../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Componente que muestra una fila de tarjetas.
|
|
5
5
|
*/
|
|
6
|
-
declare function CardRowComponent<TRow, TKey extends RowKey = RowKey>({ row, columns, originalColumns, rowKeyGetter, selectedRows, onSelectedRowsChange, onRowsChange, customRender, minHeight, isChecked, checkedRows, showCheckbox, onCheckedRowsChange, onOpenDetail, }: CardRowProps<TRow, TKey>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function CardRowComponent<TRow, TKey extends RowKey = RowKey>({ row, rows, rowIndex, columns, originalColumns, rowKeyGetter, selectedRows, onSelectedRowsChange, onRowsChange, customRender, minHeight, isChecked, checkedRows, showCheckbox, onCheckedRowsChange, onOpenDetail, }: CardRowProps<TRow, TKey>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
/**
|
|
8
8
|
* Componente que muestra CardRow
|
|
9
9
|
*/
|
|
@@ -7,6 +7,8 @@ import { C as CardHeader } from "../CardHeader/index.js";
|
|
|
7
7
|
import { deepEqual } from "fast-equals";
|
|
8
8
|
function CardRowComponent({
|
|
9
9
|
row,
|
|
10
|
+
rows,
|
|
11
|
+
rowIndex,
|
|
10
12
|
columns,
|
|
11
13
|
originalColumns,
|
|
12
14
|
rowKeyGetter,
|
|
@@ -24,6 +26,8 @@ function CardRowComponent({
|
|
|
24
26
|
const hasCustomRender = customRender !== void 0;
|
|
25
27
|
const { cardContent } = useCardContent({
|
|
26
28
|
row,
|
|
29
|
+
rows,
|
|
30
|
+
rowIndex,
|
|
27
31
|
columns,
|
|
28
32
|
onRowsChange
|
|
29
33
|
});
|
|
@@ -78,6 +78,14 @@ export interface CardRowProps<TRow, TKey extends RowKey = RowKey> {
|
|
|
78
78
|
* Fila que se mostrará en la tarjeta
|
|
79
79
|
*/
|
|
80
80
|
row: TRow;
|
|
81
|
+
/**
|
|
82
|
+
* Array completo de todas las filas (necesario para reconstruir el array al editar)
|
|
83
|
+
*/
|
|
84
|
+
rows: readonly TRow[];
|
|
85
|
+
/**
|
|
86
|
+
* Índice de la fila actual en el array de filas
|
|
87
|
+
*/
|
|
88
|
+
rowIndex: number;
|
|
81
89
|
/**
|
|
82
90
|
* Columnas que se mostrarán en la tarjeta (procesadas, filtradas por visibilidad)
|
|
83
91
|
*/
|
|
@@ -140,6 +148,14 @@ export interface CardDetailsProps<TRow> {
|
|
|
140
148
|
viewColumnsConfig: IViewConfig<any, any>[];
|
|
141
149
|
onRowsChange?: Maybe<(rows: TRow[], data: RowsChangeData<TRow, any>) => void>;
|
|
142
150
|
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
151
|
+
/**
|
|
152
|
+
* Array completo de todas las filas (necesario para reconstruir el array al editar)
|
|
153
|
+
*/
|
|
154
|
+
rows: readonly TRow[];
|
|
155
|
+
/**
|
|
156
|
+
* Índice de la fila actual en el array de filas
|
|
157
|
+
*/
|
|
158
|
+
rowIndex: number;
|
|
143
159
|
}
|
|
144
160
|
/**
|
|
145
161
|
* Props para el componente CardHeader
|
|
@@ -193,6 +193,10 @@ export interface UseModalDetailProps<TRow> {
|
|
|
193
193
|
columns: readonly Column<TRow, any>[];
|
|
194
194
|
viewMode: ViewMode;
|
|
195
195
|
onRowsChange?: Maybe<(rows: TRow[], data: RowsChangeData<TRow, any>) => void>;
|
|
196
|
+
/**
|
|
197
|
+
* Array completo de todas las filas (necesario para reconstruir el array al editar en el modal)
|
|
198
|
+
*/
|
|
199
|
+
rows: readonly TRow[];
|
|
196
200
|
}
|
|
197
201
|
/**
|
|
198
202
|
* Configuración de una columna específica en vista "cards"
|
|
@@ -252,6 +256,14 @@ export interface CardContentProps<TRow> {
|
|
|
252
256
|
columns: readonly Column<TRow, any>[];
|
|
253
257
|
originalColumns: readonly Column<TRow, any>[];
|
|
254
258
|
onRowsChange?: Maybe<(rows: TRow[], data: RowsChangeData<TRow, any>) => void>;
|
|
259
|
+
/**
|
|
260
|
+
* Array completo de todas las filas (necesario para reconstruir el array al editar)
|
|
261
|
+
*/
|
|
262
|
+
rows: readonly TRow[];
|
|
263
|
+
/**
|
|
264
|
+
* Índice de la fila actual en el array de filas
|
|
265
|
+
*/
|
|
266
|
+
rowIndex: number;
|
|
255
267
|
}
|
|
256
268
|
/**
|
|
257
269
|
* Configuración de densidad para el DataGrid.
|