@m4l/components 9.3.34-JT25112025.beta.2 → 9.3.34-JT26112025.beta.1
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/@types/export.d.ts +3 -0
- package/@types/types.d.ts +11 -0
- package/components/DataGrid/Datagrid.styles.js +40 -111
- package/components/DataGrid/dictionary.d.ts +0 -1
- package/components/DataGrid/dictionary.js +1 -2
- package/components/DataGrid/formatters/ColumnIconFormatter/constants.d.ts +4 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/ImageFormatterCell.d.ts +13 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/ImageFormatterCell.js +33 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/constants.d.ts +6 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/constants.js +6 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/formatter.d.ts +8 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/formatter.js +25 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/index.js +1 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/types.d.ts +44 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/types.js +1 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/useColumnImage.d.ts +9 -0
- package/components/DataGrid/formatters/ColumnImageFormatter/useColumnImage.js +22 -0
- package/components/DataGrid/formatters/index.d.ts +1 -0
- package/components/DataGrid/hooks/useModalCardDetail.d.ts +1 -1
- package/components/DataGrid/hooks/useModalCardDetail.js +1 -6
- package/components/DataGrid/icons.d.ts +0 -1
- package/components/DataGrid/icons.js +1 -2
- package/components/DataGrid/slots/DataGridEnum.d.ts +1 -4
- package/components/DataGrid/slots/DataGridEnum.js +0 -3
- package/components/DataGrid/slots/DataGridSlot.d.ts +0 -3
- package/components/DataGrid/slots/DataGridSlot.js +33 -48
- package/components/DataGrid/subcomponents/Cards/helpers/scrollToCardElement.js +2 -2
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.d.ts +1 -1
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.js +5 -47
- package/components/DataGrid/subcomponents/Cards/index.js +19 -9
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.d.ts +1 -1
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.js +15 -59
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.js +1 -1
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.d.ts +2 -2
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.js +2 -5
- package/components/DataGrid/subcomponents/Cards/types.d.ts +0 -16
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.js +1 -1
- package/components/DataGrid/subcomponents/ControlNavigate/ControlNavigate.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/index.js +2 -2
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/RowsCount/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfig/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.js +1 -1
- package/components/DataGrid/subcomponents/Table/index.js +11 -2
- package/components/DataGrid/subcomponents/Table/subcomponents/CheckboxFormatter.js +0 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/CustomIcons.js +14 -39
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js +1 -1
- package/components/DataGrid/subcomponents/editors/TextEditor/index.js +1 -1
- package/components/DataGrid/tests/helpers/types.d.ts +10 -0
- package/components/DataGrid/types.d.ts +0 -12
- package/components/formatters/ImageFormatter/ImageFormatter.d.ts +10 -0
- package/components/formatters/ImageFormatter/ImageFormatter.js +72 -0
- package/components/formatters/ImageFormatter/ImageFormatter.styles.d.ts +2 -0
- package/components/formatters/ImageFormatter/ImageFormatter.styles.js +42 -0
- package/components/formatters/ImageFormatter/constants.d.ts +5 -0
- package/components/formatters/ImageFormatter/constants.js +10 -0
- package/components/formatters/ImageFormatter/index.d.ts +2 -0
- package/components/formatters/ImageFormatter/index.js +1 -0
- package/components/formatters/ImageFormatter/slots/ImageFormatterEnum.d.ts +5 -0
- package/components/formatters/ImageFormatter/slots/ImageFormatterEnum.js +9 -0
- package/components/formatters/ImageFormatter/slots/ImageFormatterSlots.d.ts +9 -0
- package/components/formatters/ImageFormatter/slots/ImageFormatterSlots.js +23 -0
- package/components/formatters/ImageFormatter/types.d.ts +51 -0
- package/components/formatters/ImageFormatter/types.js +1 -0
- package/components/formatters/index.d.ts +1 -0
- package/index.js +68 -62
- package/package.json +1 -1
- package/components/DataGrid/formatters/ColumnTagsFormatter/tests/ColumnTagsFormatter.test.d.ts +0 -1
- package/components/DataGrid/formatters/ColumnTagsFormatter/tests/useColumnTags.test.d.ts +0 -1
- /package/components/DataGrid/formatters/{ColumnColorFormatter/tests/ColumnColorFormatter.test.d.ts → ColumnImageFormatter/tests/ColumnImageFormatter.test.d.ts} +0 -0
- /package/components/{DataGrid/formatters/ColumnColorFormatter/tests/useColumnColor.test.d.ts → formatters/ImageFormatter/tests/ImageFormatter.test.d.ts} +0 -0
|
@@ -6,7 +6,6 @@ import { d as dataGridStyles } from "../Datagrid.styles.js";
|
|
|
6
6
|
import { I as Icon } from "../../Icon/Icon.js";
|
|
7
7
|
import { C as Card } from "../../Card/Card.js";
|
|
8
8
|
import { T as Typography } from "../../mui_extended/Typography/Typography.js";
|
|
9
|
-
import { I as IconButton } from "../../mui_extended/IconButton/IconButton.js";
|
|
10
9
|
const DataGridRootStyled = styled("div", {
|
|
11
10
|
name: DATAGRID_PREFIX_NAME,
|
|
12
11
|
slot: DataGridSlots.datagridRoot
|
|
@@ -207,18 +206,6 @@ const NameColumnStyled = styled("div", {
|
|
|
207
206
|
name: DATAGRID_PREFIX_NAME,
|
|
208
207
|
slot: TableSlots.nameColumn
|
|
209
208
|
})(dataGridStyles.nameColumn);
|
|
210
|
-
const EditablePlaceholderStyled = styled("div", {
|
|
211
|
-
name: DATAGRID_PREFIX_NAME,
|
|
212
|
-
slot: TableSlots.editablePlaceholder
|
|
213
|
-
})(dataGridStyles.editablePlaceholder);
|
|
214
|
-
styled(Typography, {
|
|
215
|
-
name: DATAGRID_PREFIX_NAME,
|
|
216
|
-
slot: TableSlots.editLabel
|
|
217
|
-
})(dataGridStyles.editLabel);
|
|
218
|
-
const IconButtonEditStyled = styled(IconButton, {
|
|
219
|
-
name: DATAGRID_PREFIX_NAME,
|
|
220
|
-
slot: TableSlots.iconButtonEdit
|
|
221
|
-
})(dataGridStyles.iconButtonEdit);
|
|
222
209
|
const InputTextEditorStyled = styled("input", {
|
|
223
210
|
name: DATAGRID_PREFIX_NAME,
|
|
224
211
|
slot: TextEditorSlots.inputTexEditor
|
|
@@ -233,51 +220,49 @@ styled("div", {
|
|
|
233
220
|
})(dataGridStyles.columnIconFormatter);
|
|
234
221
|
export {
|
|
235
222
|
ActionsRootStyled as A,
|
|
236
|
-
|
|
223
|
+
NameColumnStyled as B,
|
|
237
224
|
CustomHeaderStyled as C,
|
|
238
225
|
DataGridRootStyled as D,
|
|
239
226
|
EditorCellWrapperStyled as E,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
227
|
+
DraggableHeaderRootStyled as F,
|
|
228
|
+
ButtonHeaderActionsStyled as G,
|
|
229
|
+
DraggableWrapperInputBaseStyled as H,
|
|
230
|
+
IconColumnStyled as I,
|
|
231
|
+
IconSearchStyled as J,
|
|
232
|
+
HeaderInputBaseStyled as K,
|
|
246
233
|
LabelHeaderColumnStyled as L,
|
|
247
|
-
|
|
234
|
+
MenuListStyled as M,
|
|
248
235
|
NameColumnIconStyled as N,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
HeaderRenderClickStyled as Q,
|
|
236
|
+
HeaderRenderClickStyled as O,
|
|
237
|
+
InputTextEditorStyled as P,
|
|
252
238
|
RowsCountRootStyled as R,
|
|
253
|
-
InputTextEditorStyled as S,
|
|
254
239
|
TableWrapperDataGridStyled as T,
|
|
255
240
|
ValueColumnStyled as V,
|
|
256
241
|
WrapperSkeletonStyled as W,
|
|
257
242
|
ContentModalSettingStyled as a,
|
|
258
243
|
ContainerLabelValueColumnStyled as b,
|
|
259
244
|
ContentWrapperColumnStyled as c,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
245
|
+
CardsContainerStyled as d,
|
|
246
|
+
CardDetailContainerStyled as e,
|
|
247
|
+
CardHeaderStyled as f,
|
|
248
|
+
CardHeaderLeftStyled as g,
|
|
249
|
+
CardHeaderRightStyled as h,
|
|
250
|
+
CardContentWrapperStyled as i,
|
|
251
|
+
CardContentStyled as j,
|
|
252
|
+
CardStyled as k,
|
|
253
|
+
CheckboxCellWrapperStyled as l,
|
|
254
|
+
ControlNavigateStyled as m,
|
|
255
|
+
ActionsConfigContainerStyled as n,
|
|
256
|
+
ContainerLeftActionsStyled as o,
|
|
257
|
+
ContainerRightActionsStyled as p,
|
|
258
|
+
RowsCountLabelStyled as q,
|
|
259
|
+
RowsCountValueStyled as r,
|
|
260
|
+
ColumnsConfigWrapperStyled as s,
|
|
261
|
+
ColumnsConfigDataGridStyled as t,
|
|
262
|
+
ColumnsConfigSelColumnsStyled as u,
|
|
263
|
+
ColumnsConfigActiosStyled as v,
|
|
264
|
+
ContainerToggleCardsStyled as w,
|
|
265
|
+
CardToggleButtonStyled as x,
|
|
266
|
+
TextToggleCardButtonStyled as y,
|
|
267
|
+
TableContainerStyled as z
|
|
283
268
|
};
|
|
@@ -13,8 +13,8 @@ function scrollToCardElement(containerElement, rowKey, selectorType = "data-attr
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
foundElement.scrollIntoView({
|
|
16
|
-
behavior: "
|
|
17
|
-
block: "
|
|
16
|
+
behavior: "smooth",
|
|
17
|
+
block: "end"
|
|
18
18
|
});
|
|
19
19
|
} catch (error) {
|
|
20
20
|
console.error("scrollToCardElement: Error al hacer scroll", error);
|
|
@@ -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,
|
|
5
|
+
export declare function useCardContent<TRow>({ row, columns, onRowsChange, }: CardContentProps<TRow>): {
|
|
6
6
|
cardContent: import("react/jsx-runtime").JSX.Element[];
|
|
7
7
|
columnsCount: number;
|
|
8
8
|
};
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
|
|
4
|
-
import { b as ContainerLabelValueColumnStyled, c as ContentWrapperColumnStyled, L as LabelHeaderColumnStyled, E as EditorCellWrapperStyled, V as ValueColumnStyled
|
|
5
|
-
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
6
|
-
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
7
|
-
import { p as pathIcons } from "../../../icons.js";
|
|
8
|
-
import { u as useComponentSize } from "../../../../../hooks/useComponentSize/useComponentSize.js";
|
|
4
|
+
import { b as ContainerLabelValueColumnStyled, c as ContentWrapperColumnStyled, L as LabelHeaderColumnStyled, E as EditorCellWrapperStyled, V as ValueColumnStyled } from "../../../slots/DataGridSlot.js";
|
|
9
5
|
function useCardContent({
|
|
10
6
|
row,
|
|
11
|
-
rows,
|
|
12
|
-
rowIndex,
|
|
13
7
|
columns,
|
|
14
8
|
onRowsChange
|
|
15
9
|
}) {
|
|
16
10
|
const { getConfigColumns, size } = useDataGrid();
|
|
17
|
-
const { getLabel } = useModuleDictionary();
|
|
18
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
19
|
-
const { currentSize } = useComponentSize(size);
|
|
20
11
|
const [editingColumnKey, setEditingColumnKey] = useState(null);
|
|
21
12
|
const columnsConfig = getConfigColumns("cards");
|
|
22
13
|
const cardContent = columns.map((column, index) => {
|
|
@@ -43,11 +34,8 @@ function useCardContent({
|
|
|
43
34
|
*/
|
|
44
35
|
onRowChange: (updatedRow) => {
|
|
45
36
|
if (onRowsChange) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
onRowsChange(updatedRows, {
|
|
50
|
-
indexes: [rowIndex],
|
|
37
|
+
onRowsChange([updatedRow], {
|
|
38
|
+
indexes: [index],
|
|
51
39
|
column
|
|
52
40
|
});
|
|
53
41
|
}
|
|
@@ -67,11 +55,8 @@ function useCardContent({
|
|
|
67
55
|
*/
|
|
68
56
|
onRowChange: (updatedRow) => {
|
|
69
57
|
if (onRowsChange) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
73
|
-
onRowsChange(updatedRows, {
|
|
74
|
-
indexes: [rowIndex],
|
|
58
|
+
onRowsChange([updatedRow], {
|
|
59
|
+
indexes: [index],
|
|
75
60
|
column
|
|
76
61
|
});
|
|
77
62
|
}
|
|
@@ -79,33 +64,6 @@ function useCardContent({
|
|
|
79
64
|
});
|
|
80
65
|
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: cellContent });
|
|
81
66
|
}
|
|
82
|
-
const rawValue = row[column.key];
|
|
83
|
-
const isEmpty = rawValue === null || rawValue === void 0 || rawValue === "";
|
|
84
|
-
const isEditable = !!column.renderEditCell;
|
|
85
|
-
if (isEditable) {
|
|
86
|
-
return /* @__PURE__ */ jsxs(EditablePlaceholderStyled, { children: [
|
|
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
|
-
),
|
|
95
|
-
/* @__PURE__ */ jsx(
|
|
96
|
-
IconButtonEditStyled,
|
|
97
|
-
{
|
|
98
|
-
src: `${host_static_assets}/${environment_assets}/${pathIcons.edit}`,
|
|
99
|
-
onClick: () => {
|
|
100
|
-
setEditingColumnKey(column.key);
|
|
101
|
-
},
|
|
102
|
-
size: currentSize,
|
|
103
|
-
role: "button",
|
|
104
|
-
"aria-label": "Editar texto"
|
|
105
|
-
}
|
|
106
|
-
)
|
|
107
|
-
] });
|
|
108
|
-
}
|
|
109
67
|
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: row[column.key] ?? "-" });
|
|
110
68
|
})()
|
|
111
69
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useRef, useMemo, useEffect } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { d as CardsContainerStyled } from "../../slots/DataGridSlot.js";
|
|
4
4
|
import { C as CardRow } from "./subcomponents/CardRow/index.js";
|
|
5
5
|
import { u as useProcessedColumns } from "../../hooks/useProcessedColumns.js";
|
|
6
6
|
import { c as calculateCardHeight } from "./helpers/calculateCardHeight.js";
|
|
@@ -21,6 +21,7 @@ function Cards(props) {
|
|
|
21
21
|
onCheckedRowsChange
|
|
22
22
|
} = props;
|
|
23
23
|
const containerRef = useRef(null);
|
|
24
|
+
const hasScrolledToFocusRow = useRef(false);
|
|
24
25
|
const processedColumns = useProcessedColumns(columns);
|
|
25
26
|
const allProcessedColumns = useProcessedColumns(columns, {
|
|
26
27
|
applyVisibilityFilter: false
|
|
@@ -28,17 +29,24 @@ function Cards(props) {
|
|
|
28
29
|
const handleOpenDetail = useModalDetail({
|
|
29
30
|
columns: allProcessedColumns,
|
|
30
31
|
viewMode: "cards",
|
|
31
|
-
onRowsChange
|
|
32
|
-
rows
|
|
32
|
+
onRowsChange
|
|
33
33
|
});
|
|
34
34
|
const cardHeight = useMemo(() => {
|
|
35
|
+
const imageHeight = processedColumns.reduce((totalHeight, col) => {
|
|
36
|
+
const formatterHeight = col.renderCell?.__imageFormatterHeight;
|
|
37
|
+
return formatterHeight ? totalHeight + formatterHeight : totalHeight;
|
|
38
|
+
}, 0);
|
|
35
39
|
return calculateCardHeight({
|
|
36
40
|
visibleColumnsCount: processedColumns.length,
|
|
37
41
|
customMinHeight: cardsViewConfig?.customRender?.minHeight
|
|
38
|
-
});
|
|
39
|
-
}, [processedColumns
|
|
42
|
+
}) + imageHeight;
|
|
43
|
+
}, [processedColumns, cardsViewConfig]);
|
|
40
44
|
useEffect(() => {
|
|
41
45
|
if (!focusOnRowKey) {
|
|
46
|
+
hasScrolledToFocusRow.current = false;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (hasScrolledToFocusRow.current) {
|
|
42
50
|
return;
|
|
43
51
|
}
|
|
44
52
|
const rowIndex = rows.findIndex(
|
|
@@ -59,13 +67,17 @@ function Cards(props) {
|
|
|
59
67
|
"data-attribute",
|
|
60
68
|
"data-row-key"
|
|
61
69
|
);
|
|
70
|
+
if (onSelectedRowsChange) {
|
|
71
|
+
onSelectedRowsChange(/* @__PURE__ */ new Set([focusOnRowKey]));
|
|
72
|
+
}
|
|
73
|
+
hasScrolledToFocusRow.current = true;
|
|
62
74
|
}, 300);
|
|
63
75
|
return () => clearTimeout(timer);
|
|
64
|
-
}, [focusOnRowKey, rows, rowKeyGetter, cardHeight]);
|
|
76
|
+
}, [focusOnRowKey, rows, rowKeyGetter, cardHeight, onSelectedRowsChange]);
|
|
65
77
|
if (processedColumns.length === 0) {
|
|
66
78
|
return null;
|
|
67
79
|
}
|
|
68
|
-
return /* @__PURE__ */ jsx(CardsContainerStyled, { "data-testid": "cards-container", ref: containerRef, children: /* @__PURE__ */ jsx(ContainerFlow, { variant: "grid-layout", minWidth: 280, children: rows.map((row
|
|
80
|
+
return /* @__PURE__ */ jsx(CardsContainerStyled, { "data-testid": "cards-container", ref: containerRef, children: /* @__PURE__ */ jsx(ContainerFlow, { variant: "grid-layout", minWidth: 280, children: rows.map((row) => {
|
|
69
81
|
const rowKey = rowKeyGetter(row);
|
|
70
82
|
const isChecked = checkedRows?.has(rowKey) || false;
|
|
71
83
|
const showCheckbox = checkedRows !== void 0 && onCheckedRowsChange !== void 0;
|
|
@@ -73,8 +85,6 @@ function Cards(props) {
|
|
|
73
85
|
CardRow,
|
|
74
86
|
{
|
|
75
87
|
row,
|
|
76
|
-
rows,
|
|
77
|
-
rowIndex,
|
|
78
88
|
columns: processedColumns,
|
|
79
89
|
originalColumns: allProcessedColumns,
|
|
80
90
|
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,
|
|
8
|
+
export declare function CardDetails<TRow>({ row, columns, viewColumnsConfig, onRowsChange, size, }: CardDetailsProps<TRow>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { D as DICTIONARY } from "../../../../dictionary.js";
|
|
5
|
-
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
6
|
-
import { p as pathIcons } from "../../../../icons.js";
|
|
7
|
-
import { u as useComponentSize } from "../../../../../../hooks/useComponentSize/useComponentSize.js";
|
|
3
|
+
import { e as CardDetailContainerStyled, b as ContainerLabelValueColumnStyled, c as ContentWrapperColumnStyled, L as LabelHeaderColumnStyled, E as EditorCellWrapperStyled, V as ValueColumnStyled } from "../../../../slots/DataGridSlot.js";
|
|
8
4
|
function CardDetails({
|
|
9
5
|
row,
|
|
10
6
|
columns,
|
|
11
7
|
viewColumnsConfig,
|
|
12
8
|
onRowsChange,
|
|
13
|
-
size = "medium"
|
|
14
|
-
rows,
|
|
15
|
-
rowIndex
|
|
9
|
+
size = "medium"
|
|
16
10
|
}) {
|
|
17
11
|
const [editingColumnKey, setEditingColumnKey] = useState(null);
|
|
18
12
|
const [refreshCounter, setRefreshCounter] = useState(0);
|
|
19
|
-
const { getLabel } = useModuleDictionary();
|
|
20
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
21
|
-
const { currentSize } = useComponentSize(size);
|
|
22
|
-
const currentRow = rows[rowIndex] || row;
|
|
23
13
|
const handleForceRefresh = useCallback(() => {
|
|
24
14
|
setRefreshCounter((prev) => prev + 1);
|
|
25
15
|
}, []);
|
|
@@ -27,8 +17,10 @@ function CardDetails({
|
|
|
27
17
|
if (column.renderCell) {
|
|
28
18
|
return {
|
|
29
19
|
...column,
|
|
30
|
-
// Agregar onAfterChange al objeto de la columna
|
|
31
|
-
onAfterChange
|
|
20
|
+
// Agregar onAfterChange al objeto de la columna si no existe
|
|
21
|
+
...!column.onAfterChange && {
|
|
22
|
+
onAfterChange: handleForceRefresh
|
|
23
|
+
}
|
|
32
24
|
};
|
|
33
25
|
}
|
|
34
26
|
return column;
|
|
@@ -38,8 +30,7 @@ function CardDetails({
|
|
|
38
30
|
(config) => config.key === modifiedColumn.key
|
|
39
31
|
);
|
|
40
32
|
const originalColumn = columns[index];
|
|
41
|
-
const
|
|
42
|
-
const columnKey = hasInteractiveFormatter ? `${originalColumn.key}-${refreshCounter}` : `${originalColumn.key}`;
|
|
33
|
+
const columnKey = `${originalColumn.key}-${refreshCounter}`;
|
|
43
34
|
const shouldShowTitle = configColumn?.showTitle !== false;
|
|
44
35
|
return /* @__PURE__ */ jsx(ContainerLabelValueColumnStyled, { children: /* @__PURE__ */ jsxs(
|
|
45
36
|
ContentWrapperColumnStyled,
|
|
@@ -57,21 +48,17 @@ function CardDetails({
|
|
|
57
48
|
if (modifiedColumn.renderEditCell && editingColumnKey === modifiedColumn.key) {
|
|
58
49
|
return /* @__PURE__ */ jsx(EditorCellWrapperStyled, { ownerState: { size }, children: modifiedColumn.renderEditCell({
|
|
59
50
|
column: originalColumn,
|
|
60
|
-
row
|
|
51
|
+
row,
|
|
61
52
|
rowIdx: index,
|
|
62
53
|
/**
|
|
63
54
|
* onRowChange es una función que se ejecuta cuando el usuario edita una celda.
|
|
64
55
|
*/
|
|
65
56
|
onRowChange: (updatedRow) => {
|
|
66
57
|
if (onRowsChange) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
70
|
-
onRowsChange(updatedRows, {
|
|
71
|
-
indexes: [rowIndex],
|
|
58
|
+
onRowsChange([updatedRow], {
|
|
59
|
+
indexes: [index],
|
|
72
60
|
column: originalColumn
|
|
73
61
|
});
|
|
74
|
-
handleForceRefresh();
|
|
75
62
|
}
|
|
76
63
|
},
|
|
77
64
|
onClose: () => setEditingColumnKey(null)
|
|
@@ -79,8 +66,8 @@ function CardDetails({
|
|
|
79
66
|
}
|
|
80
67
|
if (modifiedColumn.renderCell) {
|
|
81
68
|
const cellContent = modifiedColumn.renderCell({
|
|
82
|
-
column:
|
|
83
|
-
row
|
|
69
|
+
column: originalColumn,
|
|
70
|
+
row,
|
|
84
71
|
rowIdx: index,
|
|
85
72
|
isCellSelected: false,
|
|
86
73
|
tabIndex: -1,
|
|
@@ -89,47 +76,16 @@ function CardDetails({
|
|
|
89
76
|
*/
|
|
90
77
|
onRowChange: (updatedRow) => {
|
|
91
78
|
if (onRowsChange) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
);
|
|
95
|
-
onRowsChange(updatedRows, {
|
|
96
|
-
indexes: [rowIndex],
|
|
79
|
+
onRowsChange([updatedRow], {
|
|
80
|
+
indexes: [index],
|
|
97
81
|
column: originalColumn
|
|
98
82
|
});
|
|
99
|
-
handleForceRefresh();
|
|
100
83
|
}
|
|
101
84
|
}
|
|
102
85
|
});
|
|
103
86
|
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: cellContent });
|
|
104
87
|
}
|
|
105
|
-
|
|
106
|
-
const isEmpty = rawValue === null || rawValue === void 0 || rawValue === "";
|
|
107
|
-
const isEditable = !!modifiedColumn.renderEditCell;
|
|
108
|
-
if (isEditable) {
|
|
109
|
-
return /* @__PURE__ */ jsxs(EditablePlaceholderStyled, { children: [
|
|
110
|
-
/* @__PURE__ */ jsx(
|
|
111
|
-
ValueColumnStyled,
|
|
112
|
-
{
|
|
113
|
-
variant: "body",
|
|
114
|
-
color: isEmpty ? "text.secondary" : "text.primary",
|
|
115
|
-
children: isEmpty ? getLabel(DICTIONARY.EDIT_PLACEHOLDER) : rawValue
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
|
-
/* @__PURE__ */ jsx(
|
|
119
|
-
IconButtonEditStyled,
|
|
120
|
-
{
|
|
121
|
-
src: `${host_static_assets}/${environment_assets}/${pathIcons.edit}`,
|
|
122
|
-
onClick: () => {
|
|
123
|
-
setEditingColumnKey(modifiedColumn.key);
|
|
124
|
-
},
|
|
125
|
-
size: currentSize,
|
|
126
|
-
role: "button",
|
|
127
|
-
"aria-label": "Editar texto"
|
|
128
|
-
}
|
|
129
|
-
)
|
|
130
|
-
] });
|
|
131
|
-
}
|
|
132
|
-
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: rawValue ?? "-" });
|
|
88
|
+
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: row[modifiedColumn.key] ?? "-" });
|
|
133
89
|
})()
|
|
134
90
|
]
|
|
135
91
|
}
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useCallback } from "react";
|
|
3
3
|
import { useEnvironment } from "@m4l/core";
|
|
4
4
|
import { u as useDataGrid } from "../../../../hooks/useDataGrid.js";
|
|
5
|
-
import {
|
|
5
|
+
import { f as CardHeaderStyled, g as CardHeaderLeftStyled, h as CardHeaderRightStyled } from "../../../../slots/DataGridSlot.js";
|
|
6
6
|
import { p as pathIcons } from "../../../../icons.js";
|
|
7
7
|
import { C as CheckboxCellAdapter } from "../../../CheckboxCellAdapter/index.js";
|
|
8
8
|
import { I as IconButton } from "../../../../../mui_extended/IconButton/IconButton.js";
|
|
@@ -3,9 +3,9 @@ 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,
|
|
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;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
*/
|
|
10
10
|
export declare const CardRow: typeof CardRowComponent;
|
|
11
11
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import React, { useMemo } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { i as CardContentWrapperStyled, j as CardContentStyled, k as CardStyled } from "../../../../slots/DataGridSlot.js";
|
|
4
4
|
import { L as LazyLoadCard } from "../LazyLoadCard/index.js";
|
|
5
5
|
import { u as useCardContent } from "../../hooks/useCardContent.js";
|
|
6
6
|
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,
|
|
12
10
|
columns,
|
|
13
11
|
originalColumns,
|
|
14
12
|
rowKeyGetter,
|
|
@@ -26,8 +24,6 @@ function CardRowComponent({
|
|
|
26
24
|
const hasCustomRender = customRender !== void 0;
|
|
27
25
|
const { cardContent } = useCardContent({
|
|
28
26
|
row,
|
|
29
|
-
rows,
|
|
30
|
-
rowIndex,
|
|
31
27
|
columns,
|
|
32
28
|
onRowsChange
|
|
33
29
|
});
|
|
@@ -92,6 +88,7 @@ function CardRowComponent({
|
|
|
92
88
|
},
|
|
93
89
|
onClick: onCardClick,
|
|
94
90
|
"data-testid": "data-grid-card",
|
|
91
|
+
"data-row-key": rowKeyGetter(row),
|
|
95
92
|
children: content
|
|
96
93
|
}
|
|
97
94
|
)
|
|
@@ -78,14 +78,6 @@ 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;
|
|
89
81
|
/**
|
|
90
82
|
* Columnas que se mostrarán en la tarjeta (procesadas, filtradas por visibilidad)
|
|
91
83
|
*/
|
|
@@ -148,14 +140,6 @@ export interface CardDetailsProps<TRow> {
|
|
|
148
140
|
viewColumnsConfig: IViewConfig<any, any>[];
|
|
149
141
|
onRowsChange?: Maybe<(rows: TRow[], data: RowsChangeData<TRow, any>) => void>;
|
|
150
142
|
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;
|
|
159
143
|
}
|
|
160
144
|
/**
|
|
161
145
|
* Props para el componente CardHeader
|
|
@@ -3,7 +3,7 @@ import { forwardRef, useContext } from "react";
|
|
|
3
3
|
import { SelectCellFormatter } from "react-data-grid";
|
|
4
4
|
import { C as CheckboxFormatter } from "../Table/subcomponents/CheckboxFormatter.js";
|
|
5
5
|
import { a as DataGridContext } from "../../contexts/DataGridContext/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { l as CheckboxCellWrapperStyled } from "../../slots/DataGridSlot.js";
|
|
7
7
|
const CheckboxCellAdapter = forwardRef(function CheckboxCellAdapter2(props, ref) {
|
|
8
8
|
const {
|
|
9
9
|
value,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useIsMobile } from "@m4l/graphics";
|
|
3
|
-
import {
|
|
3
|
+
import { m as ControlNavigateStyled } from "../../slots/DataGridSlot.js";
|
|
4
4
|
import { R as RowsCount } from "../HeaderActions/subcomponents/RowsCount/index.js";
|
|
5
5
|
import { u as useComponentSize } from "../../../../hooks/useComponentSize/useComponentSize.js";
|
|
6
6
|
import { P as Pager } from "../../../Pager/Pager.js";
|
|
@@ -6,7 +6,7 @@ import { V as ViewMode } from "./subcomponents/ViewMode/index.js";
|
|
|
6
6
|
import { u as useDataGrid } from "../../hooks/useDataGrid.js";
|
|
7
7
|
import { useIsMobile } from "@m4l/graphics";
|
|
8
8
|
import { M as MobileMenuActions } from "./subcomponents/MobileMenuActions/index.js";
|
|
9
|
-
import { A as ActionsRootStyled,
|
|
9
|
+
import { A as ActionsRootStyled, n as ActionsConfigContainerStyled, o as ContainerLeftActionsStyled, p as ContainerRightActionsStyled } from "../../slots/DataGridSlot.js";
|
|
10
10
|
import { u as useComponentSize } from "../../../../hooks/useComponentSize/useComponentSize.js";
|
|
11
11
|
function HeaderActions(props) {
|
|
12
12
|
const {
|
|
@@ -29,7 +29,7 @@ function HeaderActions(props) {
|
|
|
29
29
|
] }) : /* @__PURE__ */ jsxs(ActionsConfigContainerStyled, { ownerState: { withPager }, children: [
|
|
30
30
|
/* @__PURE__ */ jsxs(ContainerLeftActionsStyled, { children: [
|
|
31
31
|
leftActions,
|
|
32
|
-
typeof rowHeights !== "number" &&
|
|
32
|
+
typeof rowHeights !== "number" && /* @__PURE__ */ jsx(Density, {}),
|
|
33
33
|
withLocalFilters && /* @__PURE__ */ jsx(Filter, {}),
|
|
34
34
|
withSettings && !(viewMode === "cards" && cardsViewConfig?.customRender) && /* @__PURE__ */ jsx(Settings, { ...settingsProps, columns }),
|
|
35
35
|
cardsViewConfig !== void 0 && /* @__PURE__ */ jsx(ViewMode, {})
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
3
3
|
import { Skeleton } from "@mui/material";
|
|
4
4
|
import { u as useDataGrid } from "../../../../hooks/useDataGrid.js";
|
|
5
|
-
import { R as RowsCountRootStyled,
|
|
5
|
+
import { R as RowsCountRootStyled, q as RowsCountLabelStyled, r as RowsCountValueStyled } from "../../../../slots/DataGridSlot.js";
|
|
6
6
|
function RowsCount() {
|
|
7
7
|
const { rowsCount, size } = useDataGrid();
|
|
8
8
|
const { getLabel } = useModuleDictionary();
|
|
@@ -4,7 +4,7 @@ import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
|
4
4
|
import DataGrid from "react-data-grid";
|
|
5
5
|
import { I as IconButton } from "../../../../../../../mui_extended/IconButton/IconButton.js";
|
|
6
6
|
import { p as pathIcons } from "../../../../../../icons.js";
|
|
7
|
-
import {
|
|
7
|
+
import { s as ColumnsConfigWrapperStyled, t as ColumnsConfigDataGridStyled, u as ColumnsConfigSelColumnsStyled, T as TableWrapperDataGridStyled, v as ColumnsConfigActiosStyled } from "../../../../../../slots/DataGridSlot.js";
|
|
8
8
|
import { D as DICTIONARY } from "../../../../../../dictionary.js";
|
|
9
9
|
import { C as ColumnInteractiveCheckFormatter } from "../../../../../../formatters/ColumnInteractiveCheckFormatter/formatter.js";
|
|
10
10
|
function getRowsFromColumnsConfig(columnsConfig, columns) {
|
|
@@ -4,7 +4,7 @@ import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
|
4
4
|
import DataGrid from "react-data-grid";
|
|
5
5
|
import { I as IconButton } from "../../../../../../../mui_extended/IconButton/IconButton.js";
|
|
6
6
|
import { p as pathIcons } from "../../../../../../icons.js";
|
|
7
|
-
import {
|
|
7
|
+
import { s as ColumnsConfigWrapperStyled, t as ColumnsConfigDataGridStyled, u as ColumnsConfigSelColumnsStyled, T as TableWrapperDataGridStyled, v as ColumnsConfigActiosStyled } from "../../../../../../slots/DataGridSlot.js";
|
|
8
8
|
import { D as DICTIONARY } from "../../../../../../dictionary.js";
|
|
9
9
|
import { C as ColumnInteractiveCheckFormatter } from "../../../../../../formatters/ColumnInteractiveCheckFormatter/formatter.js";
|
|
10
10
|
function getRowsFromColumnsConfigCards(columnsConfigCards, columns) {
|
|
@@ -6,7 +6,7 @@ import { I as IconButton } from "../../../../../mui_extended/IconButton/IconButt
|
|
|
6
6
|
import { P as Popover } from "../../../../../mui_extended/Popover/Popover.js";
|
|
7
7
|
import { p as pathIcons } from "../../../../icons.js";
|
|
8
8
|
import { D as DICTIONARY } from "../../../../dictionary.js";
|
|
9
|
-
import {
|
|
9
|
+
import { w as ContainerToggleCardsStyled, x as CardToggleButtonStyled, y as TextToggleCardButtonStyled } from "../../../../slots/DataGridSlot.js";
|
|
10
10
|
import { I as Icon } from "../../../../../Icon/Icon.js";
|
|
11
11
|
function ViewMode() {
|
|
12
12
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
@@ -8,7 +8,7 @@ import { a as filterHeight } from "./subcomponents/SelectColumn.js";
|
|
|
8
8
|
import { u as useSortColumnsRows } from "./hooks/useSortColumnsRows.js";
|
|
9
9
|
import { u as useFilters } from "../../hooks/useFilters.js";
|
|
10
10
|
import { u as useDataGrid } from "../../hooks/useDataGrid.js";
|
|
11
|
-
import {
|
|
11
|
+
import { z as TableContainerStyled, T as TableWrapperDataGridStyled } from "../../slots/DataGridSlot.js";
|
|
12
12
|
import { u as useHeaderMenuActions } from "./hooks/useHeaderMenuActions.js";
|
|
13
13
|
import { H as HeaderRenderClick } from "./subcomponents/HeaderRenderClick/HeaderRenderClick.js";
|
|
14
14
|
function Table(props) {
|
|
@@ -68,6 +68,7 @@ function Table(props) {
|
|
|
68
68
|
anchorEl: null,
|
|
69
69
|
columnKey: null
|
|
70
70
|
});
|
|
71
|
+
const hasScrolledToFocusRow = useRef(false);
|
|
71
72
|
const [allowSortChange, setAllowSortChange] = useState(false);
|
|
72
73
|
const handleSortColumnsChange = (newSortColumns) => {
|
|
73
74
|
if (allowSortChange) {
|
|
@@ -113,6 +114,10 @@ function Table(props) {
|
|
|
113
114
|
}, [finalRows]);
|
|
114
115
|
useEffect(() => {
|
|
115
116
|
if (!focusOnRowKey) {
|
|
117
|
+
hasScrolledToFocusRow.current = false;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (hasScrolledToFocusRow.current) {
|
|
116
121
|
return;
|
|
117
122
|
}
|
|
118
123
|
const rowIndex = finalRows.findIndex(
|
|
@@ -120,8 +125,12 @@ function Table(props) {
|
|
|
120
125
|
);
|
|
121
126
|
if (rowIndex !== -1) {
|
|
122
127
|
ref_data_grid.current?.scrollToCell({ rowIdx: rowIndex });
|
|
128
|
+
if (onSelectedRowsChange) {
|
|
129
|
+
onSelectedRowsChange(/* @__PURE__ */ new Set([focusOnRowKey]));
|
|
130
|
+
}
|
|
131
|
+
hasScrolledToFocusRow.current = true;
|
|
123
132
|
}
|
|
124
|
-
}, [focusOnRowKey, finalRows, rowKeyGetter]);
|
|
133
|
+
}, [focusOnRowKey, finalRows, rowKeyGetter, onSelectedRowsChange]);
|
|
125
134
|
const onColumnResize = (idx, width) => {
|
|
126
135
|
onChangeColumnWidth(finalColumns[idx].key, width);
|
|
127
136
|
};
|