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

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.
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useModuleDictionary, useEnvironment } from "@m4l/core";
3
3
  import { useIsMobile } from "@m4l/graphics";
4
- import { useCallback } from "react";
4
+ import { useRef, useEffect, useCallback } from "react";
5
5
  import { u as useModal } from "../../../hooks/useModal/index.js";
6
6
  import { a as ContentModalSettingStyled, D as DataGridRootStyled } from "../slots/DataGridSlot.js";
7
7
  import { p as pathIcons } from "../icons.js";
@@ -14,16 +14,22 @@ 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();
21
22
  const { getLabel } = useModuleDictionary();
22
23
  const { host_static_assets, environment_assets } = useEnvironment();
23
24
  const isMobile = useIsMobile();
25
+ const rowsRef = useRef(rows);
26
+ useEffect(() => {
27
+ rowsRef.current = rows;
28
+ }, [rows]);
24
29
  const handleOpenDetail = useCallback(
25
30
  (row) => {
26
31
  const viewColumnsConfig = getConfigColumns(viewMode);
32
+ const rowIndex = rowsRef.current.findIndex((r) => r === row);
27
33
  openModal({
28
34
  initialWidth: 500,
29
35
  initialHeight: 680,
@@ -42,6 +48,8 @@ const useModalDetail = ({
42
48
  CardDetails,
43
49
  {
44
50
  row,
51
+ rows: rowsRef.current,
52
+ rowIndex,
45
53
  columns,
46
54
  viewColumnsConfig,
47
55
  onRowsChange,
@@ -82,9 +82,16 @@ function useCardContent({
82
82
  const rawValue = row[column.key];
83
83
  const isEmpty = rawValue === null || rawValue === void 0 || rawValue === "";
84
84
  const isEditable = !!column.renderEditCell;
85
- if (isEmpty && isEditable) {
85
+ if (isEditable) {
86
86
  return /* @__PURE__ */ jsxs(EditablePlaceholderStyled, { children: [
87
- /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.secondary", children: getLabel(DICTIONARY.EDIT_PLACEHOLDER) }),
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
+ ),
88
95
  /* @__PURE__ */ jsx(
89
96
  IconButtonEditStyled,
90
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({
@@ -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
- onRowsChange([updatedRow], {
65
- indexes: [index],
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
- onRowsChange([updatedRow], {
86
- indexes: [index],
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 (isEmpty && isEditable) {
105
+ if (isEditable) {
98
106
  return /* @__PURE__ */ jsxs(EditablePlaceholderStyled, { children: [
99
- /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.secondary", children: getLabel(DICTIONARY.EDIT_PLACEHOLDER) }),
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
  {
@@ -148,6 +148,14 @@ export interface CardDetailsProps<TRow> {
148
148
  viewColumnsConfig: IViewConfig<any, any>[];
149
149
  onRowsChange?: Maybe<(rows: TRow[], data: RowsChangeData<TRow, any>) => void>;
150
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;
151
159
  }
152
160
  /**
153
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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.3.29-JT19112025.beta.2",
3
+ "version": "9.3.29-JT19112025.beta.4",
4
4
  "license": "UNLICENSED",
5
5
  "description": "M4L Components",
6
6
  "lint-staged": {