@m4l/components 9.3.25-beta.0 → 9.3.26
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 +6 -0
- package/@types/types.d.ts +26 -1
- package/components/CommonActions/components/ActionFormCancel/ActionFormCancel.js +8 -2
- package/components/CommonActions/components/ActionFormCancel/types.d.ts +1 -0
- package/components/DataGrid/DataGrid.js +6 -2
- package/components/DataGrid/Datagrid.styles.js +67 -18
- package/components/DataGrid/constants.d.ts +19 -0
- package/components/DataGrid/formatters/ColumnIconFormatter/formatter.d.ts +1 -2
- package/components/DataGrid/formatters/ColumnIconFormatter/formatter.js +3 -6
- package/components/DataGrid/formatters/ColumnIconFormatter/types.d.ts +2 -4
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.js +7 -1
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/types.d.ts +1 -0
- package/components/DataGrid/formatters/ColumnTagsFormatter/formatter.d.ts +8 -0
- package/components/DataGrid/formatters/ColumnTagsFormatter/formatter.js +16 -0
- package/components/DataGrid/formatters/ColumnTagsFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/ColumnTagsFormatter/index.js +1 -0
- package/components/DataGrid/formatters/ColumnTagsFormatter/types.d.ts +4 -0
- package/components/DataGrid/formatters/ColumnTagsFormatter/useColumnTags.d.ts +9 -0
- package/components/DataGrid/formatters/ColumnTagsFormatter/useColumnTags.js +60 -0
- package/components/DataGrid/formatters/index.d.ts +1 -0
- package/components/DataGrid/hooks/useModalCardDetail.d.ts +2 -2
- package/components/DataGrid/hooks/useModalCardDetail.js +49 -48
- package/components/DataGrid/slots/DataGridEnum.d.ts +2 -0
- package/components/DataGrid/slots/DataGridEnum.js +2 -0
- package/components/DataGrid/slots/DataGridSlot.d.ts +3 -1
- package/components/DataGrid/slots/DataGridSlot.js +45 -37
- package/components/DataGrid/subcomponents/Cards/helpers/calculateCardHeight.d.ts +18 -0
- package/components/DataGrid/subcomponents/Cards/helpers/calculateCardHeight.js +10 -0
- package/components/DataGrid/subcomponents/Cards/helpers/scrollToCardElement.d.ts +9 -0
- package/components/DataGrid/subcomponents/Cards/helpers/scrollToCardElement.js +25 -0
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.d.ts +1 -2
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.js +62 -73
- package/components/DataGrid/subcomponents/Cards/index.js +71 -16
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.js +36 -18
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.d.ts +1 -1
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.js +13 -20
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.d.ts +6 -1
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.js +67 -36
- package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.js +9 -2
- package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.js +4 -2
- package/components/DataGrid/subcomponents/Cards/types.d.ts +50 -1
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.js +5 -2
- package/components/DataGrid/subcomponents/ControlNavigate/ControlNavigate.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/index.js +1 -1
- 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/HeaderActions/subcomponents/hooks/useModalSettings/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.js +1 -1
- package/components/DataGrid/subcomponents/Table/index.js +60 -41
- package/components/DataGrid/subcomponents/Table/subcomponents/CheckboxFormatter.js +16 -18
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.js +3 -3
- 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 +3 -0
- package/components/DataGrid/types.d.ts +17 -2
- package/components/ObjectLogs/slots/ObjectLogsSlots.js +3 -5
- package/components/Stepper/Stepper.styles.js +1 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js +1 -1
- package/components/formatters/IconsFormatter/IconsFormatter.d.ts +6 -0
- package/components/formatters/IconsFormatter/IconsFormatter.js +22 -0
- package/components/formatters/IconsFormatter/IconsFormatter.styles.d.ts +2 -0
- package/components/formatters/IconsFormatter/IconsFormatter.styles.js +29 -0
- package/components/formatters/IconsFormatter/constants.d.ts +1 -0
- package/components/formatters/IconsFormatter/constants.js +4 -0
- package/components/{DataGrid/formatters/ColumnIconFormatter → formatters/IconsFormatter}/helpers/renderIcon.d.ts +2 -2
- package/components/formatters/IconsFormatter/helpers/renderIcon.js +24 -0
- package/components/formatters/IconsFormatter/helpers/renderMultipleIcons.d.ts +7 -0
- package/components/formatters/IconsFormatter/helpers/renderMultipleIcons.js +16 -0
- package/components/formatters/IconsFormatter/index.d.ts +3 -0
- package/components/formatters/IconsFormatter/index.js +1 -0
- package/components/formatters/IconsFormatter/slots/IconsFormatterEnum.d.ts +5 -0
- package/components/formatters/IconsFormatter/slots/IconsFormatterEnum.js +9 -0
- package/components/formatters/IconsFormatter/slots/IconsFormatterSlots.d.ts +9 -0
- package/components/formatters/IconsFormatter/slots/IconsFormatterSlots.js +22 -0
- package/components/formatters/IconsFormatter/types.d.ts +57 -0
- package/components/formatters/IconsFormatter/types.js +1 -0
- package/components/formatters/TagsFormatter/TagsFormatter.d.ts +5 -0
- package/components/formatters/TagsFormatter/TagsFormatter.js +28 -0
- package/components/formatters/TagsFormatter/TagsFormatter.styles.d.ts +2 -0
- package/components/formatters/TagsFormatter/TagsFormatter.styles.js +41 -0
- package/components/formatters/TagsFormatter/constants.d.ts +5 -0
- package/components/formatters/TagsFormatter/constants.js +11 -0
- package/components/formatters/TagsFormatter/helpers/renderMultipleTag.d.ts +8 -0
- package/components/formatters/TagsFormatter/helpers/renderMultipleTag.js +19 -0
- package/components/formatters/TagsFormatter/helpers/renderTag.d.ts +7 -0
- package/components/formatters/TagsFormatter/helpers/renderTag.js +9 -0
- package/components/formatters/TagsFormatter/helpers/validateHexColor.d.ts +8 -0
- package/components/formatters/TagsFormatter/helpers/validateHexColor.js +9 -0
- package/components/formatters/TagsFormatter/index.d.ts +2 -0
- package/components/formatters/TagsFormatter/index.js +1 -0
- package/components/formatters/TagsFormatter/slots/TagsFormatterEnum.d.ts +5 -0
- package/components/formatters/TagsFormatter/slots/TagsFormatterEnum.js +9 -0
- package/components/formatters/TagsFormatter/slots/TagsFormatterSlots.d.ts +6 -0
- package/components/formatters/TagsFormatter/slots/TagsFormatterSlots.js +16 -0
- package/components/formatters/TagsFormatter/subcomponents/Tag/Tag.d.ts +5 -0
- package/components/formatters/TagsFormatter/subcomponents/Tag/Tag.js +35 -0
- package/components/formatters/TagsFormatter/subcomponents/Tag/index.d.ts +1 -0
- package/components/formatters/TagsFormatter/subcomponents/Tag/index.js +1 -0
- package/components/formatters/TagsFormatter/types.d.ts +47 -0
- package/components/formatters/index.d.ts +6 -5
- package/components/hook-form/RHFormContext/styles.js +2 -1
- package/contexts/ModalContext/index.js +5 -5
- package/index.js +62 -56
- package/package.json +1 -1
- package/components/DataGrid/formatters/ColumnIconFormatter/constants.js +0 -4
- package/components/DataGrid/formatters/ColumnIconFormatter/helpers/renderIcon.js +0 -58
- package/components/DataGrid/formatters/ColumnIconFormatter/helpers/renderMultipleIcons.d.ts +0 -7
- package/components/DataGrid/formatters/ColumnIconFormatter/helpers/renderMultipleIcons.js +0 -19
|
@@ -36,9 +36,11 @@ var TableSlots = /* @__PURE__ */ ((TableSlots2) => {
|
|
|
36
36
|
TableSlots2["textToggleCardButton"] = "textToggleCardButton";
|
|
37
37
|
TableSlots2["card"] = "card";
|
|
38
38
|
TableSlots2["cardsContainer"] = "cardsContainer";
|
|
39
|
+
TableSlots2["cardContentWrapper"] = "cardContentWrapper";
|
|
39
40
|
TableSlots2["cardHeader"] = "cardHeader";
|
|
40
41
|
TableSlots2["cardHeaderLeft"] = "cardHeaderLeft";
|
|
41
42
|
TableSlots2["cardHeaderRight"] = "cardHeaderRight";
|
|
43
|
+
TableSlots2["cardContent"] = "cardContent";
|
|
42
44
|
TableSlots2["containerLabelValueColumn"] = "containerLabelValueColumn";
|
|
43
45
|
TableSlots2["contentWrapperColumn"] = "contentWrapperColumn";
|
|
44
46
|
TableSlots2["cardDetailContainer"] = "cardDetailContainer";
|
|
@@ -44,7 +44,9 @@ export declare const CardStyled: import('@emotion/styled').StyledComponent<any,
|
|
|
44
44
|
export declare const CardHeaderStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
45
45
|
export declare const CardHeaderLeftStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
46
46
|
export declare const CardHeaderRightStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
47
|
-
export declare const
|
|
47
|
+
export declare const CardContentWrapperStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
48
|
+
export declare const CardContentStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
49
|
+
export declare const CardsContainerStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
48
50
|
export declare const ContainerLabelValueColumnStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
49
51
|
export declare const ContentWrapperColumnStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
50
52
|
export declare const CardDetailContainerStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { styled } from "@mui/material/styles";
|
|
2
2
|
import { MenuList, InputBase } from "@mui/material";
|
|
3
3
|
import { D as DATAGRID_PREFIX_NAME } from "../constants.js";
|
|
4
|
-
import { D as DataGridSlots, T as TextEditorSlots, A as ActionsSlots, C as ControlNavigateSlots,
|
|
4
|
+
import { D as DataGridSlots, T as TextEditorSlots, A as ActionsSlots, C as ControlNavigateSlots, b as TableSlots, R as RowsCountSlots, a as ColumnsConfigSlots, c as ColumnIconFormatterSlots } from "./DataGridEnum.js";
|
|
5
5
|
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
|
-
import { C as ContainerFlow } from "../../ContainerFlow/ContainerFlow.js";
|
|
9
8
|
import { T as Typography } from "../../mui_extended/Typography/Typography.js";
|
|
10
9
|
const DataGridRootStyled = styled("div", {
|
|
11
10
|
name: DATAGRID_PREFIX_NAME,
|
|
@@ -91,7 +90,15 @@ const CardHeaderRightStyled = styled("div", {
|
|
|
91
90
|
name: DATAGRID_PREFIX_NAME,
|
|
92
91
|
slot: TableSlots.cardHeaderRight
|
|
93
92
|
})(dataGridStyles.cardHeaderRight);
|
|
94
|
-
const
|
|
93
|
+
const CardContentWrapperStyled = styled("div", {
|
|
94
|
+
name: DATAGRID_PREFIX_NAME,
|
|
95
|
+
slot: TableSlots.cardContentWrapper
|
|
96
|
+
})(dataGridStyles.cardContentWrapper);
|
|
97
|
+
const CardContentStyled = styled("div", {
|
|
98
|
+
name: DATAGRID_PREFIX_NAME,
|
|
99
|
+
slot: TableSlots.cardContent
|
|
100
|
+
})(dataGridStyles.cardContent);
|
|
101
|
+
const CardsContainerStyled = styled("div", {
|
|
95
102
|
name: DATAGRID_PREFIX_NAME,
|
|
96
103
|
slot: TableSlots.cardsContainer
|
|
97
104
|
})(dataGridStyles.cardsContainer);
|
|
@@ -207,54 +214,55 @@ const ControlNavigateStyled = styled("div", {
|
|
|
207
214
|
name: DATAGRID_PREFIX_NAME,
|
|
208
215
|
slot: ControlNavigateSlots.controlNavigate
|
|
209
216
|
})(dataGridStyles.controlNavigate);
|
|
210
|
-
|
|
217
|
+
styled("div", {
|
|
211
218
|
name: DATAGRID_PREFIX_NAME,
|
|
212
219
|
slot: ColumnIconFormatterSlots.columnIconFormatter
|
|
213
220
|
})(dataGridStyles.columnIconFormatter);
|
|
214
221
|
export {
|
|
215
222
|
ActionsRootStyled as A,
|
|
216
|
-
|
|
223
|
+
NameColumnStyled as B,
|
|
217
224
|
CustomHeaderStyled as C,
|
|
218
225
|
DataGridRootStyled as D,
|
|
219
226
|
EditorCellWrapperStyled as E,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
DraggableHeaderRootStyled as F,
|
|
228
|
+
ButtonHeaderActionsStyled as G,
|
|
229
|
+
DraggableWrapperInputBaseStyled as H,
|
|
223
230
|
IconColumnStyled as I,
|
|
224
|
-
|
|
225
|
-
|
|
231
|
+
IconSearchStyled as J,
|
|
232
|
+
HeaderInputBaseStyled as K,
|
|
226
233
|
LabelHeaderColumnStyled as L,
|
|
227
234
|
MenuListStyled as M,
|
|
228
235
|
NameColumnIconStyled as N,
|
|
229
|
-
|
|
236
|
+
HeaderRenderClickStyled as O,
|
|
237
|
+
InputTextEditorStyled as P,
|
|
230
238
|
RowsCountRootStyled as R,
|
|
231
239
|
TableWrapperDataGridStyled as T,
|
|
232
240
|
ValueColumnStyled as V,
|
|
233
241
|
WrapperSkeletonStyled as W,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
242
|
+
ContentModalSettingStyled as a,
|
|
243
|
+
ContainerLabelValueColumnStyled as b,
|
|
244
|
+
ContentWrapperColumnStyled as c,
|
|
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
|
|
260
268
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CalculateCardHeightProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Calcula la altura estimada de una card basándose en el número de columnas visibles.
|
|
4
|
+
* @param visibleColumnsCount - Número de columnas visibles en la card
|
|
5
|
+
* @param customMinHeight - Altura mínima personalizada (opcional, para customRender)
|
|
6
|
+
* @returns Altura calculada en píxeles
|
|
7
|
+
*
|
|
8
|
+
* Fórmula:
|
|
9
|
+
* - 32px por cada columna visible (altura de label + value)
|
|
10
|
+
* - 40px de padding, márgenes y header
|
|
11
|
+
* - Mínimo de 120px para garantizar una altura base
|
|
12
|
+
*
|
|
13
|
+
* Ejemplos:
|
|
14
|
+
* - 3 columnas: Math.max(120, 3 * 32 + 40) = 136px
|
|
15
|
+
* - 5 columnas: Math.max(120, 5 * 32 + 40) = 200px
|
|
16
|
+
* - 10 columnas: Math.max(120, 10 * 32 + 40) = 360px
|
|
17
|
+
*/
|
|
18
|
+
export declare function calculateCardHeight(props: CalculateCardHeightProps): number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function calculateCardHeight(props) {
|
|
2
|
+
const { visibleColumnsCount, customMinHeight } = props;
|
|
3
|
+
if (customMinHeight !== void 0) {
|
|
4
|
+
return customMinHeight;
|
|
5
|
+
}
|
|
6
|
+
return Math.max(120, visibleColumnsCount * 32 + 40);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
calculateCardHeight as c
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper para hacer scroll a una card por su key.
|
|
3
|
+
* Busca el elemento en el DOM usando querySelector y hace scrollIntoView.
|
|
4
|
+
* @param containerElement - Elemento contenedor que tiene scroll
|
|
5
|
+
* @param rowKey - Key de la fila/card a la que hacer scroll
|
|
6
|
+
* @param selectorType - Tipo de selector: 'class' o 'data-attribute'
|
|
7
|
+
* @param selectorName - Nombre de la clase o atributo base
|
|
8
|
+
*/
|
|
9
|
+
export declare function scrollToCardElement(containerElement: HTMLElement | null, rowKey: string | number, selectorType?: 'class' | 'data-attribute', selectorName?: string): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function scrollToCardElement(containerElement, rowKey, selectorType = "data-attribute", selectorName = "data-row-key") {
|
|
2
|
+
if (!containerElement) {
|
|
3
|
+
console.warn("scrollToCardElement: containerElement is null");
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
const selector = selectorType === "class" ? `.${selectorName}-${rowKey}` : `[${selectorName}="${rowKey}"]`;
|
|
8
|
+
const foundElement = containerElement.querySelector(selector);
|
|
9
|
+
if (!foundElement) {
|
|
10
|
+
console.warn(
|
|
11
|
+
`scrollToCardElement: No se encontró card con selector "${selector}"`
|
|
12
|
+
);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
foundElement.scrollIntoView({
|
|
16
|
+
behavior: "auto",
|
|
17
|
+
block: "center"
|
|
18
|
+
});
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error("scrollToCardElement: Error al hacer scroll", error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
scrollToCardElement as s
|
|
25
|
+
};
|
|
@@ -2,8 +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,
|
|
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
|
-
onOpenDetail: () => void;
|
|
9
8
|
};
|
|
@@ -1,89 +1,78 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState
|
|
3
|
-
import { u as useModalDetail } from "../../../hooks/useModalCardDetail.js";
|
|
2
|
+
import { useState } from "react";
|
|
4
3
|
import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
|
|
5
|
-
import {
|
|
4
|
+
import { b as ContainerLabelValueColumnStyled, c as ContentWrapperColumnStyled, L as LabelHeaderColumnStyled, E as EditorCellWrapperStyled, V as ValueColumnStyled } from "../../../slots/DataGridSlot.js";
|
|
6
5
|
function useCardContent({
|
|
7
6
|
row,
|
|
8
7
|
columns,
|
|
9
|
-
originalColumns,
|
|
10
8
|
onRowsChange
|
|
11
9
|
}) {
|
|
12
10
|
const { getConfigColumns, size } = useDataGrid();
|
|
13
11
|
const [editingColumnKey, setEditingColumnKey] = useState(null);
|
|
14
12
|
const columnsConfig = getConfigColumns("cards");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
onRowChange: (updatedRow) => {
|
|
66
|
-
if (onRowsChange) {
|
|
67
|
-
onRowsChange([updatedRow], {
|
|
68
|
-
indexes: [index],
|
|
69
|
-
column
|
|
70
|
-
});
|
|
71
|
-
}
|
|
13
|
+
const cardContent = columns.map((column, index) => {
|
|
14
|
+
const configColumn = columnsConfig.find(
|
|
15
|
+
(config) => config.key === column.key
|
|
16
|
+
);
|
|
17
|
+
const shouldShowTitle = configColumn?.showTitle !== false;
|
|
18
|
+
return /* @__PURE__ */ jsx(ContainerLabelValueColumnStyled, { children: /* @__PURE__ */ jsxs(
|
|
19
|
+
ContentWrapperColumnStyled,
|
|
20
|
+
{
|
|
21
|
+
onDoubleClick: column.renderEditCell && editingColumnKey !== column.key ? () => {
|
|
22
|
+
setEditingColumnKey(column.key);
|
|
23
|
+
} : void 0,
|
|
24
|
+
children: [
|
|
25
|
+
shouldShowTitle && /* @__PURE__ */ jsx(LabelHeaderColumnStyled, { variant: "body", color: "text.secondary", children: column.name }),
|
|
26
|
+
(() => {
|
|
27
|
+
if (column.renderEditCell && editingColumnKey === column.key) {
|
|
28
|
+
return /* @__PURE__ */ jsx(EditorCellWrapperStyled, { ownerState: { size }, children: column.renderEditCell({
|
|
29
|
+
column,
|
|
30
|
+
row,
|
|
31
|
+
rowIdx: index,
|
|
32
|
+
/**
|
|
33
|
+
* onRowChange es una función que se ejecuta cuando el usuario edita una celda.
|
|
34
|
+
*/
|
|
35
|
+
onRowChange: (updatedRow) => {
|
|
36
|
+
if (onRowsChange) {
|
|
37
|
+
onRowsChange([updatedRow], {
|
|
38
|
+
indexes: [index],
|
|
39
|
+
column
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
onClose: () => setEditingColumnKey(null)
|
|
44
|
+
}) });
|
|
45
|
+
}
|
|
46
|
+
if (column.renderCell) {
|
|
47
|
+
const cellContent = column.renderCell({
|
|
48
|
+
column,
|
|
49
|
+
row,
|
|
50
|
+
rowIdx: index,
|
|
51
|
+
isCellSelected: false,
|
|
52
|
+
tabIndex: -1,
|
|
53
|
+
/**
|
|
54
|
+
* onRowChange es una función que se ejecuta cuando el usuario edita una celda.
|
|
55
|
+
*/
|
|
56
|
+
onRowChange: (updatedRow) => {
|
|
57
|
+
if (onRowsChange) {
|
|
58
|
+
onRowsChange([updatedRow], {
|
|
59
|
+
indexes: [index],
|
|
60
|
+
column
|
|
61
|
+
});
|
|
72
62
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: cellContent });
|
|
66
|
+
}
|
|
67
|
+
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: row[column.key] ?? "-" });
|
|
68
|
+
})()
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
) }, column.key);
|
|
72
|
+
});
|
|
83
73
|
return {
|
|
84
74
|
cardContent,
|
|
85
|
-
columnsCount: columns.length
|
|
86
|
-
onOpenDetail
|
|
75
|
+
columnsCount: columns.length
|
|
87
76
|
};
|
|
88
77
|
}
|
|
89
78
|
export {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useRef, useMemo, useEffect } from "react";
|
|
3
|
+
import { d as CardsContainerStyled } from "../../slots/DataGridSlot.js";
|
|
3
4
|
import { C as CardRow } from "./subcomponents/CardRow/index.js";
|
|
4
5
|
import { u as useProcessedColumns } from "../../hooks/useProcessedColumns.js";
|
|
6
|
+
import { c as calculateCardHeight } from "./helpers/calculateCardHeight.js";
|
|
7
|
+
import { u as useModalDetail } from "../../hooks/useModalCardDetail.js";
|
|
8
|
+
import { s as scrollToCardElement } from "./helpers/scrollToCardElement.js";
|
|
5
9
|
import { C as ContainerFlow } from "../../../ContainerFlow/ContainerFlow.js";
|
|
6
10
|
function Cards(props) {
|
|
7
11
|
const {
|
|
@@ -11,29 +15,80 @@ function Cards(props) {
|
|
|
11
15
|
selectedRows,
|
|
12
16
|
onSelectedRowsChange,
|
|
13
17
|
onRowsChange,
|
|
14
|
-
cardsViewConfig
|
|
18
|
+
cardsViewConfig,
|
|
19
|
+
focusOnRowKey,
|
|
20
|
+
checkedRows,
|
|
21
|
+
onCheckedRowsChange
|
|
15
22
|
} = props;
|
|
23
|
+
const containerRef = useRef(null);
|
|
16
24
|
const processedColumns = useProcessedColumns(columns);
|
|
17
25
|
const allProcessedColumns = useProcessedColumns(columns, {
|
|
18
26
|
applyVisibilityFilter: false
|
|
19
27
|
});
|
|
28
|
+
const handleOpenDetail = useModalDetail({
|
|
29
|
+
columns: allProcessedColumns,
|
|
30
|
+
viewMode: "cards",
|
|
31
|
+
onRowsChange
|
|
32
|
+
});
|
|
33
|
+
const cardHeight = useMemo(() => {
|
|
34
|
+
return calculateCardHeight({
|
|
35
|
+
visibleColumnsCount: processedColumns.length,
|
|
36
|
+
customMinHeight: cardsViewConfig?.customRender?.minHeight
|
|
37
|
+
});
|
|
38
|
+
}, [processedColumns.length, cardsViewConfig]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!focusOnRowKey) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const rowIndex = rows.findIndex(
|
|
44
|
+
(row) => rowKeyGetter(row) === focusOnRowKey
|
|
45
|
+
);
|
|
46
|
+
if (rowIndex === -1) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const timer = setTimeout(() => {
|
|
50
|
+
const container = containerRef.current;
|
|
51
|
+
if (!container) {
|
|
52
|
+
console.warn("container es null, abortando scroll");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
scrollToCardElement(
|
|
56
|
+
container,
|
|
57
|
+
focusOnRowKey,
|
|
58
|
+
"data-attribute",
|
|
59
|
+
"data-row-key"
|
|
60
|
+
);
|
|
61
|
+
}, 300);
|
|
62
|
+
return () => clearTimeout(timer);
|
|
63
|
+
}, [focusOnRowKey, rows, rowKeyGetter, cardHeight]);
|
|
20
64
|
if (processedColumns.length === 0) {
|
|
21
65
|
return null;
|
|
22
66
|
}
|
|
23
|
-
return /* @__PURE__ */ jsx(CardsContainerStyled, { "data-testid": "cards-container", children: /* @__PURE__ */ jsx(ContainerFlow, { variant: "grid-layout", minWidth: 280, children: rows.map((row) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
const rowKey = rowKeyGetter(row);
|
|
69
|
+
const isChecked = checkedRows?.has(rowKey) || false;
|
|
70
|
+
const showCheckbox = checkedRows !== void 0 && onCheckedRowsChange !== void 0;
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
CardRow,
|
|
73
|
+
{
|
|
74
|
+
row,
|
|
75
|
+
columns: processedColumns,
|
|
76
|
+
originalColumns: allProcessedColumns,
|
|
77
|
+
rowKeyGetter,
|
|
78
|
+
selectedRows,
|
|
79
|
+
onSelectedRowsChange,
|
|
80
|
+
onRowsChange,
|
|
81
|
+
customRender: cardsViewConfig?.customRender,
|
|
82
|
+
minHeight: cardHeight,
|
|
83
|
+
isChecked,
|
|
84
|
+
showCheckbox,
|
|
85
|
+
checkedRows,
|
|
86
|
+
onCheckedRowsChange,
|
|
87
|
+
onOpenDetail: handleOpenDetail
|
|
88
|
+
},
|
|
89
|
+
rowKeyGetter(row)
|
|
90
|
+
);
|
|
91
|
+
}) }) });
|
|
37
92
|
}
|
|
38
93
|
export {
|
|
39
94
|
Cards as C
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { e as CardDetailContainerStyled, b as ContainerLabelValueColumnStyled, c as ContentWrapperColumnStyled, L as LabelHeaderColumnStyled, E as EditorCellWrapperStyled, V as ValueColumnStyled } from "../../../../slots/DataGridSlot.js";
|
|
4
4
|
function CardDetails({
|
|
5
5
|
row,
|
|
6
6
|
columns,
|
|
@@ -9,27 +9,45 @@ function CardDetails({
|
|
|
9
9
|
size = "medium"
|
|
10
10
|
}) {
|
|
11
11
|
const [editingColumnKey, setEditingColumnKey] = useState(null);
|
|
12
|
-
|
|
12
|
+
const [refreshCounter, setRefreshCounter] = useState(0);
|
|
13
|
+
const handleForceRefresh = useCallback(() => {
|
|
14
|
+
setRefreshCounter((prev) => prev + 1);
|
|
15
|
+
}, []);
|
|
16
|
+
const columnsWithRefresh = columns.map((column) => {
|
|
17
|
+
if (column.renderCell) {
|
|
18
|
+
return {
|
|
19
|
+
...column,
|
|
20
|
+
// Agregar onAfterChange al objeto de la columna si no existe
|
|
21
|
+
...!column.onAfterChange && {
|
|
22
|
+
onAfterChange: handleForceRefresh
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return column;
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ jsx(CardDetailContainerStyled, { children: columnsWithRefresh.map((modifiedColumn, index) => {
|
|
13
29
|
const configColumn = viewColumnsConfig.find(
|
|
14
|
-
(config) => config.key ===
|
|
30
|
+
(config) => config.key === modifiedColumn.key
|
|
15
31
|
);
|
|
32
|
+
const originalColumn = columns[index];
|
|
33
|
+
const columnKey = `${originalColumn.key}-${refreshCounter}`;
|
|
16
34
|
const shouldShowTitle = configColumn?.showTitle !== false;
|
|
17
35
|
return /* @__PURE__ */ jsx(ContainerLabelValueColumnStyled, { children: /* @__PURE__ */ jsxs(
|
|
18
36
|
ContentWrapperColumnStyled,
|
|
19
37
|
{
|
|
20
|
-
"data-testid": `card-detail-column-${
|
|
21
|
-
onDoubleClick:
|
|
22
|
-
setEditingColumnKey(
|
|
38
|
+
"data-testid": `card-detail-column-${originalColumn.key}`,
|
|
39
|
+
onDoubleClick: modifiedColumn.renderEditCell && editingColumnKey !== modifiedColumn.key ? () => {
|
|
40
|
+
setEditingColumnKey(modifiedColumn.key);
|
|
23
41
|
} : void 0,
|
|
24
42
|
children: [
|
|
25
43
|
shouldShowTitle && /* @__PURE__ */ jsxs(LabelHeaderColumnStyled, { variant: "body", color: "text.secondary", children: [
|
|
26
|
-
|
|
44
|
+
modifiedColumn.name,
|
|
27
45
|
":"
|
|
28
46
|
] }),
|
|
29
47
|
(() => {
|
|
30
|
-
if (
|
|
31
|
-
return /* @__PURE__ */ jsx(EditorCellWrapperStyled, { ownerState: { size }, children:
|
|
32
|
-
column,
|
|
48
|
+
if (modifiedColumn.renderEditCell && editingColumnKey === modifiedColumn.key) {
|
|
49
|
+
return /* @__PURE__ */ jsx(EditorCellWrapperStyled, { ownerState: { size }, children: modifiedColumn.renderEditCell({
|
|
50
|
+
column: originalColumn,
|
|
33
51
|
row,
|
|
34
52
|
rowIdx: index,
|
|
35
53
|
/**
|
|
@@ -39,16 +57,16 @@ function CardDetails({
|
|
|
39
57
|
if (onRowsChange) {
|
|
40
58
|
onRowsChange([updatedRow], {
|
|
41
59
|
indexes: [index],
|
|
42
|
-
column
|
|
60
|
+
column: originalColumn
|
|
43
61
|
});
|
|
44
62
|
}
|
|
45
63
|
},
|
|
46
64
|
onClose: () => setEditingColumnKey(null)
|
|
47
65
|
}) });
|
|
48
66
|
}
|
|
49
|
-
if (
|
|
50
|
-
const cellContent =
|
|
51
|
-
column,
|
|
67
|
+
if (modifiedColumn.renderCell) {
|
|
68
|
+
const cellContent = modifiedColumn.renderCell({
|
|
69
|
+
column: originalColumn,
|
|
52
70
|
row,
|
|
53
71
|
rowIdx: index,
|
|
54
72
|
isCellSelected: false,
|
|
@@ -60,18 +78,18 @@ function CardDetails({
|
|
|
60
78
|
if (onRowsChange) {
|
|
61
79
|
onRowsChange([updatedRow], {
|
|
62
80
|
indexes: [index],
|
|
63
|
-
column
|
|
81
|
+
column: originalColumn
|
|
64
82
|
});
|
|
65
83
|
}
|
|
66
84
|
}
|
|
67
85
|
});
|
|
68
86
|
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: cellContent });
|
|
69
87
|
}
|
|
70
|
-
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: row[
|
|
88
|
+
return /* @__PURE__ */ jsx(ValueColumnStyled, { variant: "body", color: "text.primary", children: row[modifiedColumn.key] ?? "-" });
|
|
71
89
|
})()
|
|
72
90
|
]
|
|
73
91
|
}
|
|
74
|
-
) },
|
|
92
|
+
) }, columnKey);
|
|
75
93
|
}) });
|
|
76
94
|
}
|
|
77
95
|
export {
|
|
@@ -4,4 +4,4 @@ import { CardHeaderProps } from '../../types';
|
|
|
4
4
|
* - Checkbox en el lado izquierdo (solo si existen checkedRows/onCheckedRowsChange)
|
|
5
5
|
* - Botones de acción en el lado derecho (IconButton + MenuActions)
|
|
6
6
|
*/
|
|
7
|
-
export declare function CardHeader<TRow>({ row, onOpenDetail }: CardHeaderProps<TRow>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function CardHeader<TRow>({ row, onOpenDetail, isChecked, showCheckbox, checkedRows, onCheckedRowsChange, }: CardHeaderProps<TRow>): import("react/jsx-runtime").JSX.Element;
|