@m4l/components 9.3.29-JT19112025.beta.1 → 9.3.29-JT19112025.beta.2

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.
@@ -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
- onRowsChange([updatedRow], {
45
- indexes: [index],
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
- onRowsChange([updatedRow], {
66
- indexes: [index],
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
  }
@@ -64,7 +64,7 @@ function Cards(props) {
64
64
  if (processedColumns.length === 0) {
65
65
  return null;
66
66
  }
67
- return /* @__PURE__ */ jsx(CardsContainerStyled, { "data-testid": "cards-container", ref: containerRef, children: /* @__PURE__ */ jsx(ContainerFlow, { variant: "grid-layout", minWidth: 280, children: rows.map((row) => {
67
+ 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
68
  const rowKey = rowKeyGetter(row);
69
69
  const isChecked = checkedRows?.has(rowKey) || false;
70
70
  const showCheckbox = checkedRows !== void 0 && onCheckedRowsChange !== void 0;
@@ -72,6 +72,8 @@ function Cards(props) {
72
72
  CardRow,
73
73
  {
74
74
  row,
75
+ rows,
76
+ rowIndex,
75
77
  columns: processedColumns,
76
78
  originalColumns: allProcessedColumns,
77
79
  rowKeyGetter,
@@ -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
  */
@@ -252,6 +252,14 @@ export interface CardContentProps<TRow> {
252
252
  columns: readonly Column<TRow, any>[];
253
253
  originalColumns: readonly Column<TRow, any>[];
254
254
  onRowsChange?: Maybe<(rows: TRow[], data: RowsChangeData<TRow, any>) => void>;
255
+ /**
256
+ * Array completo de todas las filas (necesario para reconstruir el array al editar)
257
+ */
258
+ rows: readonly TRow[];
259
+ /**
260
+ * Índice de la fila actual en el array de filas
261
+ */
262
+ rowIndex: number;
255
263
  }
256
264
  /**
257
265
  * Configuración de densidad para el DataGrid.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.3.29-JT19112025.beta.1",
3
+ "version": "9.3.29-JT19112025.beta.2",
4
4
  "license": "UNLICENSED",
5
5
  "description": "M4L Components",
6
6
  "lint-staged": {