@m4l/components 9.3.21-JAEBeta.2 → 9.3.21-JT15102025.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/components/DataGrid/DataGrid.js +9 -4
- package/components/DataGrid/Datagrid.styles.js +270 -0
- package/components/DataGrid/constants.js +2 -2
- package/components/DataGrid/contexts/DataGridContext/index.js +254 -111
- package/components/DataGrid/contexts/DataGridContext/types.d.ts +63 -4
- package/components/DataGrid/dictionary.d.ts +5 -0
- package/components/DataGrid/dictionary.js +6 -1
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.js +2 -2
- package/components/DataGrid/hooks/useModalCardDetail.d.ts +6 -0
- package/components/DataGrid/hooks/useModalCardDetail.js +74 -0
- package/components/DataGrid/hooks/useProcessedColumns.d.ts +50 -0
- package/components/DataGrid/hooks/useProcessedColumns.js +44 -0
- package/components/DataGrid/icons.d.ts +7 -0
- package/components/DataGrid/icons.js +5 -1
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/slots/DataGridEnum.d.ts +22 -1
- package/components/DataGrid/slots/DataGridEnum.js +21 -0
- package/components/DataGrid/slots/DataGridSlot.d.ts +24 -0
- package/components/DataGrid/slots/DataGridSlot.js +123 -21
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.d.ts +9 -0
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.js +91 -0
- package/components/DataGrid/subcomponents/Cards/index.d.ts +5 -0
- package/components/DataGrid/subcomponents/Cards/index.js +40 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.d.ts +8 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.js +79 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.js +98 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.d.ts +6 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.js +71 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.d.ts +20 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.js +46 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.d.ts +17 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.js +34 -0
- package/components/DataGrid/subcomponents/Cards/types.d.ts +118 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.js +43 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/types.d.ts +7 -0
- package/components/DataGrid/subcomponents/ControlNavigate/ControlNavigate.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/index.js +7 -4
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/RowsCount/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/index.js +11 -2
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfig/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.d.ts +2 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.js +304 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/types.d.ts +31 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.d.ts +4 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.js +125 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettings/index.js +2 -2
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.js +74 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/types.d.ts +4 -0
- package/components/DataGrid/subcomponents/RenderContent/index.d.ts +5 -0
- package/components/DataGrid/subcomponents/RenderContent/index.js +11 -0
- package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.js +2 -2
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +1 -1
- package/components/DataGrid/subcomponents/Table/index.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/ActionsColumn.js +1 -1
- 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/components/CardDetails.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CardHeader.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CardRow.test.d.ts +1 -0
- package/components/DataGrid/tests/components/Cards.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CheckboxCellAdapter.test.d.ts +1 -0
- package/components/DataGrid/tests/components/ColumnsConfigCards.test.d.ts +1 -0
- package/components/DataGrid/tests/components/IntersectCard.test.d.ts +1 -0
- package/components/DataGrid/tests/components/ViewMode.test.d.ts +1 -0
- package/components/DataGrid/tests/helpers/useCustomCardExample.d.ts +7 -0
- package/components/DataGrid/tests/hooks/useCardContent.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useModalDetail.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useModalSettingsCards.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useProcessedColumns.test.d.ts +1 -0
- package/components/DataGrid/types.d.ts +54 -5
- package/components/MFIsolationAppStorybook/MFIsolationAppStorybook.d.ts +5 -0
- package/components/MFIsolationAppStorybook/constants.d.ts +1 -0
- package/components/MFIsolationAppStorybook/icons.d.ts +3 -0
- package/components/MFIsolationAppStorybook/index.d.ts +1 -0
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/AppBarSettings.d.ts +4 -0
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/index.d.ts +1 -0
- package/components/MFIsolationAppStorybook/subcomponents/MFAuthAppStorybook/MFAuthAppStorybook.d.ts +5 -0
- package/components/MFIsolationAppStorybook/subcomponents/MFAuthAppStorybook/index.d.ts +1 -0
- package/components/MFIsolationAppStorybook/subcomponents/MFAuthAppStorybook/types.d.ts +4 -0
- package/components/MFIsolationAppStorybook/types.d.ts +31 -0
- package/components/MenuActions/MenuActions.js +105 -55
- package/components/areas/contexts/AreasContext/store.js +2 -2
- package/components/hook-form/RHFormContext/index.d.ts +1 -1
- package/hooks/useDataGridPersistence/helpers.d.ts +2 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.d.ts +2 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.js +5 -0
- package/index.js +8 -8
- package/package.json +1 -1
|
@@ -1,51 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect, useMemo,
|
|
2
|
+
import { useState, useCallback, useEffect, useMemo, createContext } from "react";
|
|
3
3
|
import { c as castMapColumnsWidthToRecord } from "../../helpers/castMapColumnsWidthToRecord.js";
|
|
4
|
-
import { useFirstRender } from "@m4l/graphics";
|
|
4
|
+
import { useFirstRender, useIsMobile } from "@m4l/graphics";
|
|
5
5
|
import { g as getComponentClasses } from "../../../../utils/getComponentSlotRoot.js";
|
|
6
6
|
import { a as DATAGRID_ROW_HEIGHTS, b as DATAGRID_ROW_HEADER_HEIGHTS, D as DATAGRID_PREFIX_NAME } from "../../constants.js";
|
|
7
7
|
import { C as ControlNavigateSlots, a as ColumnsConfigSlots, T as TextEditorSlots, b as TableSlots, R as RowsCountSlots, A as ActionsSlots, D as DataGridSlots } from "../../slots/DataGridEnum.js";
|
|
8
8
|
import { deepEqual } from "fast-equals";
|
|
9
9
|
const DataGridContext = createContext(null);
|
|
10
|
-
const getColumnConfigByKey = (key, storeColumnsConfig) => {
|
|
11
|
-
let indexFind = -1;
|
|
12
|
-
return [
|
|
13
|
-
storeColumnsConfig.find((column, index) => {
|
|
14
|
-
if (column.key === key) {
|
|
15
|
-
indexFind = index;
|
|
16
|
-
}
|
|
17
|
-
return column.key === key;
|
|
18
|
-
}),
|
|
19
|
-
indexFind
|
|
20
|
-
];
|
|
21
|
-
};
|
|
22
|
-
function getColumnsConfig(id, columns, defaultUserColumns = void 0) {
|
|
23
|
-
let columnsConfig;
|
|
24
|
-
if (defaultUserColumns) {
|
|
25
|
-
columnsConfig = defaultUserColumns.columnsConfig;
|
|
26
|
-
} else {
|
|
27
|
-
try {
|
|
28
|
-
const item = window.localStorage.getItem(`${id}_columns_config`);
|
|
29
|
-
columnsConfig = item !== null ? JSON.parse(item) : [];
|
|
30
|
-
} catch (_e) {
|
|
31
|
-
columnsConfig = [];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return columns.map((column, index) => {
|
|
35
|
-
const [columnConfig = { ...column }, columnConfigIndex] = getColumnConfigByKey(column.key, columnsConfig);
|
|
36
|
-
return {
|
|
37
|
-
key: column.key,
|
|
38
|
-
name: typeof column.name === "string" ? column.name : String(column.name),
|
|
39
|
-
hidden: column.hidden === void 0 ? false : column.hidden,
|
|
40
|
-
index: columnConfigIndex > -1 ? columnConfigIndex : index,
|
|
41
|
-
visible: columnConfig.visible === void 0 ? true : columnConfig.visible,
|
|
42
|
-
frozen: columnConfig.frozen ?? false,
|
|
43
|
-
originalIndex: index,
|
|
44
|
-
originalVisible: column.visible === void 0 ? true : column.visible,
|
|
45
|
-
originalFrozen: column.frozen ?? false
|
|
46
|
-
};
|
|
47
|
-
}).sort((a, b) => a.index - b.index);
|
|
48
|
-
}
|
|
49
10
|
function getColumnsWidth(id, columns, defaultUserColumns) {
|
|
50
11
|
const newMap = /* @__PURE__ */ new Map();
|
|
51
12
|
let storeColumnsWidth;
|
|
@@ -89,12 +50,87 @@ function saveColumnsWidth(id, storeColumnsWidth, onChangeUserColumns) {
|
|
|
89
50
|
JSON.stringify([...storeColumnsWidth])
|
|
90
51
|
);
|
|
91
52
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
53
|
+
const getAllViewModes = () => {
|
|
54
|
+
return ["table", "cards"];
|
|
55
|
+
};
|
|
56
|
+
const getViewSpecificConfig = (viewMode) => {
|
|
57
|
+
const configs = {
|
|
58
|
+
table: {
|
|
59
|
+
defaults: { frozen: false },
|
|
60
|
+
originalDefaults: { originalFrozen: false },
|
|
61
|
+
dynamicOriginalProperty: (item) => ({
|
|
62
|
+
originalFrozen: item?.frozen ?? false
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
cards: {
|
|
66
|
+
defaults: { showTitle: true },
|
|
67
|
+
originalDefaults: { originalShowTitle: true },
|
|
68
|
+
dynamicOriginalProperty: (item) => ({
|
|
69
|
+
originalShowTitle: item?.showTitle ?? true
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return configs[viewMode] || configs.table;
|
|
74
|
+
};
|
|
75
|
+
const getViewSuffix = (viewMode) => {
|
|
76
|
+
if (viewMode === "table") {
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
return `_${viewMode}`;
|
|
80
|
+
};
|
|
81
|
+
function getInitialColumnsConfig(id, columns, viewMode, defaultUserConfig, viewSpecificDefaults, originalViewSpecificDefaults) {
|
|
82
|
+
let columnsConfig;
|
|
83
|
+
if (defaultUserConfig) {
|
|
84
|
+
columnsConfig = defaultUserConfig;
|
|
85
|
+
} else {
|
|
86
|
+
columnsConfig = loadViewConfig(
|
|
87
|
+
id,
|
|
88
|
+
getViewSuffix(viewMode)
|
|
89
|
+
) || [];
|
|
90
|
+
}
|
|
91
|
+
return columns.map((column, index) => {
|
|
92
|
+
const existingConfig = columnsConfig.find((c) => c.key === column.key);
|
|
93
|
+
const columnConfigIndex = existingConfig ? columnsConfig.indexOf(existingConfig) : -1;
|
|
94
|
+
const baseConfig = {
|
|
95
|
+
key: column.key,
|
|
96
|
+
name: typeof column.name === "string" ? column.name : String(column.name),
|
|
97
|
+
hidden: column.hidden === void 0 ? false : column.hidden,
|
|
98
|
+
index: columnConfigIndex > -1 ? columnConfigIndex : index,
|
|
99
|
+
visible: existingConfig?.visible === void 0 ? true : existingConfig.visible,
|
|
100
|
+
originalIndex: index,
|
|
101
|
+
originalVisible: column.visible === void 0 ? true : column.visible
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
...baseConfig,
|
|
105
|
+
...viewSpecificDefaults,
|
|
106
|
+
...originalViewSpecificDefaults,
|
|
107
|
+
...existingConfig || {}
|
|
108
|
+
};
|
|
109
|
+
}).sort((a, b) => a.index - b.index);
|
|
110
|
+
}
|
|
111
|
+
function saveViewConfig(id, viewSuffix, config, onChangeCallback) {
|
|
112
|
+
if (onChangeCallback) {
|
|
113
|
+
const reason = viewSuffix === "" ? "columnsConfig" : `columnsConfig${viewSuffix.replace("_", "")}`;
|
|
114
|
+
onChangeCallback({
|
|
115
|
+
reason,
|
|
116
|
+
userConfig: config
|
|
117
|
+
});
|
|
95
118
|
return;
|
|
96
119
|
}
|
|
97
|
-
|
|
120
|
+
const storageKey = viewSuffix === "" ? `${id}_columns_config` : `${id}_columns_config${viewSuffix}`;
|
|
121
|
+
localStorage.setItem(storageKey, JSON.stringify(config));
|
|
122
|
+
}
|
|
123
|
+
function loadViewConfig(id, viewSuffix) {
|
|
124
|
+
try {
|
|
125
|
+
const storageKey = viewSuffix === "" ? `${id}_columns_config` : `${id}_columns_config${viewSuffix}`;
|
|
126
|
+
const stored = localStorage.getItem(storageKey);
|
|
127
|
+
return stored ? JSON.parse(stored) : null;
|
|
128
|
+
} catch (_e) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function saveViewMode(id, viewMode) {
|
|
133
|
+
localStorage.setItem(`${id}_view_mode`, viewMode);
|
|
98
134
|
}
|
|
99
135
|
function getIndexRowHeightVariant(variant) {
|
|
100
136
|
if (variant === "compact") {
|
|
@@ -123,9 +159,14 @@ function DataGridProvider(props) {
|
|
|
123
159
|
onChangeUserColumns,
|
|
124
160
|
externalSortSettings: sortSettings,
|
|
125
161
|
externalFilterSettings: filterSettings,
|
|
126
|
-
size
|
|
162
|
+
size,
|
|
163
|
+
viewMode,
|
|
164
|
+
onViewModeChange,
|
|
165
|
+
cardSettings,
|
|
166
|
+
defaultViewMode
|
|
127
167
|
} = props;
|
|
128
168
|
const isFirstRender = useFirstRender([columns, id]);
|
|
169
|
+
const isMobile = useIsMobile();
|
|
129
170
|
const classes = getComponentClasses(DATAGRID_PREFIX_NAME, {
|
|
130
171
|
...DataGridSlots,
|
|
131
172
|
...ActionsSlots,
|
|
@@ -136,11 +177,56 @@ function DataGridProvider(props) {
|
|
|
136
177
|
...ControlNavigateSlots
|
|
137
178
|
});
|
|
138
179
|
const [columnsWidths, setColumnsWidths] = useState(/* @__PURE__ */ new Map());
|
|
139
|
-
const [
|
|
140
|
-
|
|
180
|
+
const [viewConfig, setViewConfig] = useState(() => ({
|
|
181
|
+
table: [],
|
|
182
|
+
cards: []
|
|
183
|
+
}));
|
|
184
|
+
const getConfigColumns = useCallback(
|
|
185
|
+
(viewModeParam) => {
|
|
186
|
+
return viewConfig[viewModeParam];
|
|
187
|
+
},
|
|
188
|
+
[viewConfig]
|
|
189
|
+
);
|
|
190
|
+
const updateConfigColumns = useCallback(
|
|
191
|
+
(viewModeParam, config) => {
|
|
192
|
+
setViewConfig((prev) => ({
|
|
193
|
+
...prev,
|
|
194
|
+
[viewModeParam]: config
|
|
195
|
+
}));
|
|
196
|
+
},
|
|
197
|
+
[]
|
|
141
198
|
);
|
|
142
199
|
const [rowsFilterCount, setRowFilterCount] = useState(rowsCount);
|
|
143
200
|
const [sortColumns, setSortColumns] = useState([]);
|
|
201
|
+
const [viewModeState, setViewModeState] = useState(() => {
|
|
202
|
+
if (viewMode) {
|
|
203
|
+
return viewMode;
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
const savedViewMode = localStorage.getItem(`${id}_view_mode`);
|
|
207
|
+
if (savedViewMode === "cards" || savedViewMode === "table") {
|
|
208
|
+
return savedViewMode;
|
|
209
|
+
}
|
|
210
|
+
} catch (_e) {
|
|
211
|
+
}
|
|
212
|
+
if (defaultViewMode) {
|
|
213
|
+
return defaultViewMode;
|
|
214
|
+
}
|
|
215
|
+
return isMobile ? "cards" : "table";
|
|
216
|
+
});
|
|
217
|
+
const handleViewModeChange = useCallback(
|
|
218
|
+
(newViewMode) => {
|
|
219
|
+
setViewModeState(newViewMode);
|
|
220
|
+
saveViewMode(id, newViewMode);
|
|
221
|
+
onViewModeChange?.(newViewMode);
|
|
222
|
+
},
|
|
223
|
+
[onViewModeChange, id]
|
|
224
|
+
);
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (viewMode !== void 0) {
|
|
227
|
+
setViewModeState(viewMode);
|
|
228
|
+
}
|
|
229
|
+
}, [viewMode]);
|
|
144
230
|
const [currentRowHeightVariant, setCurrentRowHeightVariant] = useState(() => {
|
|
145
231
|
if (typeof rowHeights !== typeof rowHeaderHeights) {
|
|
146
232
|
throw new Error("Must be same type rowheights and rowHeaderTypes");
|
|
@@ -190,93 +276,146 @@ function DataGridProvider(props) {
|
|
|
190
276
|
useEffect(() => {
|
|
191
277
|
if (isFirstRender) {
|
|
192
278
|
setColumnsWidths(getColumnsWidth(id, columns, defaultUserColumns));
|
|
193
|
-
|
|
194
|
-
|
|
279
|
+
updateConfigColumns(
|
|
280
|
+
"table",
|
|
281
|
+
getInitialColumnsConfig(
|
|
282
|
+
id,
|
|
283
|
+
columns,
|
|
284
|
+
"table",
|
|
285
|
+
defaultUserColumns?.columnsConfig,
|
|
286
|
+
{ frozen: false },
|
|
287
|
+
{ originalFrozen: false }
|
|
288
|
+
)
|
|
289
|
+
);
|
|
290
|
+
updateConfigColumns(
|
|
291
|
+
"cards",
|
|
292
|
+
getInitialColumnsConfig(
|
|
293
|
+
id,
|
|
294
|
+
columns,
|
|
295
|
+
"cards",
|
|
296
|
+
defaultUserColumns?.columnsConfigCards,
|
|
297
|
+
{ showTitle: true },
|
|
298
|
+
{ originalShowTitle: true }
|
|
299
|
+
)
|
|
195
300
|
);
|
|
196
301
|
}
|
|
197
302
|
}, [defaultUserColumns]);
|
|
198
303
|
useEffect(() => {
|
|
199
304
|
if (!isFirstRender) {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
305
|
+
const updatedConfigs = {
|
|
306
|
+
table: [],
|
|
307
|
+
cards: []
|
|
308
|
+
};
|
|
309
|
+
getAllViewModes().forEach((viewModeParam) => {
|
|
310
|
+
const currentConfig = getConfigColumns(viewModeParam);
|
|
311
|
+
const finalConfig = [];
|
|
312
|
+
for (let i = 0; i < currentConfig.length; i++) {
|
|
313
|
+
const columnIndex = columns.findIndex(
|
|
314
|
+
(c) => c.key === currentConfig[i]?.key
|
|
315
|
+
);
|
|
316
|
+
if (columnIndex !== -1) {
|
|
317
|
+
const column = columns[columnIndex];
|
|
318
|
+
finalConfig.push({
|
|
319
|
+
...currentConfig[i],
|
|
320
|
+
originalIndex: columnIndex,
|
|
321
|
+
// Propiedades específicas por vista dinámicamente
|
|
322
|
+
...getViewSpecificConfig(viewModeParam).dynamicOriginalProperty(
|
|
323
|
+
currentConfig[i] || column
|
|
324
|
+
),
|
|
325
|
+
originalVisible: column.visible ?? true
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
updatedConfigs[viewModeParam] = finalConfig;
|
|
330
|
+
});
|
|
331
|
+
getAllViewModes().forEach((viewModeParam) => {
|
|
332
|
+
const currentConfig = updatedConfigs[viewModeParam];
|
|
333
|
+
const newColumnsForView = columns.filter(
|
|
334
|
+
(column, index) => column.key !== getConfigColumns(viewModeParam)[index]?.key
|
|
204
335
|
);
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
336
|
+
if (newColumnsForView.length > 0) {
|
|
337
|
+
const colLength = currentConfig.length;
|
|
338
|
+
const viewSpecific = getViewSpecificConfig(viewModeParam);
|
|
339
|
+
const viewSpecificDefaults = viewSpecific.defaults;
|
|
340
|
+
const originalViewSpecificDefaults = viewSpecific.originalDefaults;
|
|
341
|
+
const newColConfig = getInitialColumnsConfig(
|
|
342
|
+
id,
|
|
343
|
+
newColumnsForView,
|
|
344
|
+
viewModeParam,
|
|
345
|
+
void 0,
|
|
346
|
+
viewSpecificDefaults,
|
|
347
|
+
originalViewSpecificDefaults
|
|
348
|
+
).map((columnConfig, index) => {
|
|
349
|
+
const columnIndex = columns.findIndex(
|
|
350
|
+
(c) => c.key === newColumnsForView[index].key
|
|
351
|
+
);
|
|
352
|
+
const column = newColumnsForView[index];
|
|
353
|
+
return {
|
|
354
|
+
...columnConfig,
|
|
355
|
+
index: index + colLength,
|
|
356
|
+
name: column.name,
|
|
357
|
+
originalIndex: columnIndex,
|
|
358
|
+
originalVisible: column.visible ?? true,
|
|
359
|
+
// Propiedades específicas por vista dinámicamente
|
|
360
|
+
...getViewSpecificConfig(viewModeParam).dynamicOriginalProperty(
|
|
361
|
+
column
|
|
362
|
+
)
|
|
363
|
+
};
|
|
213
364
|
});
|
|
365
|
+
updatedConfigs[viewModeParam].push(...newColConfig);
|
|
214
366
|
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
(c) => c.key === newColumns[index].key
|
|
227
|
-
);
|
|
228
|
-
const column = newColumns[index];
|
|
229
|
-
const indexNewCol = index + colLength;
|
|
230
|
-
return {
|
|
231
|
-
...columnConfig,
|
|
232
|
-
index: indexNewCol,
|
|
233
|
-
name: column.name,
|
|
234
|
-
originalIndex: columnIndex,
|
|
235
|
-
originalFrozen: column.frozen ?? false,
|
|
236
|
-
originalVisible: column.visible ?? true
|
|
237
|
-
};
|
|
238
|
-
});
|
|
239
|
-
finalColumnsConfig.push(...newColConfig);
|
|
240
|
-
}
|
|
241
|
-
if (deepEqual(columnsConfig, finalColumnsConfig)) {
|
|
367
|
+
});
|
|
368
|
+
let hasChanges = false;
|
|
369
|
+
getAllViewModes().forEach((viewModeParam) => {
|
|
370
|
+
if (!deepEqual(
|
|
371
|
+
getConfigColumns(viewModeParam),
|
|
372
|
+
updatedConfigs[viewModeParam]
|
|
373
|
+
)) {
|
|
374
|
+
hasChanges = true;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
if (!hasChanges) {
|
|
242
378
|
return;
|
|
243
379
|
}
|
|
244
|
-
console.log(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
);
|
|
249
|
-
setColumnsConfigOptions(finalColumnsConfig);
|
|
380
|
+
console.log("useEffect viewConfigs changed", updatedConfigs);
|
|
381
|
+
getAllViewModes().forEach((viewModeParam) => {
|
|
382
|
+
updateConfigColumns(viewModeParam, updatedConfigs[viewModeParam]);
|
|
383
|
+
});
|
|
250
384
|
}
|
|
251
385
|
}, [columns, id]);
|
|
252
386
|
const onChangeColumnsConfig = useCallback(
|
|
253
|
-
(
|
|
254
|
-
|
|
255
|
-
|
|
387
|
+
(viewModeParam, newConfig) => {
|
|
388
|
+
saveViewConfig(
|
|
389
|
+
id,
|
|
390
|
+
getViewSuffix(viewModeParam),
|
|
391
|
+
newConfig,
|
|
392
|
+
onChangeUserColumns
|
|
393
|
+
);
|
|
394
|
+
updateConfigColumns(viewModeParam, newConfig);
|
|
256
395
|
},
|
|
257
|
-
|
|
258
|
-
[setColumnsConfigOptions, id]
|
|
396
|
+
[id, onChangeUserColumns, updateConfigColumns]
|
|
259
397
|
);
|
|
260
398
|
const onChangeColumnsOrder = useCallback(
|
|
261
|
-
(sourceKey, targetKey) => {
|
|
399
|
+
(viewModeParam, sourceKey, targetKey) => {
|
|
262
400
|
if (sourceKey === targetKey) {
|
|
263
401
|
return;
|
|
264
402
|
}
|
|
265
|
-
const
|
|
403
|
+
const currentConfig = getConfigColumns(viewModeParam);
|
|
404
|
+
const sourceColumnIndex = currentConfig.findIndex(
|
|
266
405
|
(c) => c.key === sourceKey
|
|
267
406
|
);
|
|
268
|
-
const targetColumnIndex =
|
|
407
|
+
const targetColumnIndex = currentConfig.findIndex(
|
|
269
408
|
(c) => c.key === targetKey
|
|
270
409
|
);
|
|
271
|
-
const
|
|
272
|
-
|
|
410
|
+
const reorderedConfig = [...currentConfig];
|
|
411
|
+
reorderedConfig.splice(
|
|
273
412
|
targetColumnIndex,
|
|
274
413
|
0,
|
|
275
|
-
|
|
414
|
+
reorderedConfig.splice(sourceColumnIndex, 1)[0]
|
|
276
415
|
);
|
|
277
|
-
onChangeColumnsConfig(
|
|
416
|
+
onChangeColumnsConfig(viewModeParam, reorderedConfig);
|
|
278
417
|
},
|
|
279
|
-
[
|
|
418
|
+
[getConfigColumns, onChangeColumnsConfig]
|
|
280
419
|
);
|
|
281
420
|
const onChangeColumnWidth = (columnKey, width) => {
|
|
282
421
|
columnsWidths.set(columnKey, Math.round(width));
|
|
@@ -307,7 +446,9 @@ function DataGridProvider(props) {
|
|
|
307
446
|
DataGridContext.Provider,
|
|
308
447
|
{
|
|
309
448
|
value: {
|
|
310
|
-
|
|
449
|
+
getConfigColumns,
|
|
450
|
+
onChangeColumnsConfig,
|
|
451
|
+
columnsConfig: getConfigColumns("table"),
|
|
311
452
|
columnsWidths,
|
|
312
453
|
rowsCount: rowsFilterCount,
|
|
313
454
|
currentRowHeightVariant: currentRowHeightVariant.rowHVariant,
|
|
@@ -316,7 +457,6 @@ function DataGridProvider(props) {
|
|
|
316
457
|
rows,
|
|
317
458
|
rowHeights: finalRowHeights,
|
|
318
459
|
checkedRows,
|
|
319
|
-
onChangeColumnsConfig,
|
|
320
460
|
onChangeColumnsOrder,
|
|
321
461
|
onChangeColumnWidth,
|
|
322
462
|
setRowsCount: setRowFilterCountInternal,
|
|
@@ -330,7 +470,10 @@ function DataGridProvider(props) {
|
|
|
330
470
|
externalSortSettings: sortSettings,
|
|
331
471
|
externalFilterSettings: filterSettings,
|
|
332
472
|
classes,
|
|
333
|
-
size
|
|
473
|
+
size,
|
|
474
|
+
viewMode: viewModeState,
|
|
475
|
+
onViewModeChange: handleViewModeChange,
|
|
476
|
+
cardSettings
|
|
334
477
|
},
|
|
335
478
|
children
|
|
336
479
|
}
|
|
@@ -3,6 +3,29 @@ import { RowKey, RowHeightVariants, GridProps } from '../../types';
|
|
|
3
3
|
import { Maybe } from '@m4l/core';
|
|
4
4
|
import { ActionsSlots, ColumnsConfigSlots, ControlNavigateSlots, DataGridSlots, RowsCountSlots, TableSlots, TextEditorSlots } from '../../slots/DataGridEnum';
|
|
5
5
|
import { SortColumn } from 'react-data-grid';
|
|
6
|
+
/**
|
|
7
|
+
* Configuración base genérica que puede extenderse con propiedades específicas de cualquier vista
|
|
8
|
+
* USO INTERNO: El sistema usa esto para manejar genéricamente las configuraciones
|
|
9
|
+
*/
|
|
10
|
+
export type BaseViewConfig<TViewSpecific = {}> = TViewSpecific & {
|
|
11
|
+
key: string;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
index: number;
|
|
14
|
+
name?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Configuración extendida genérica con propiedades originales
|
|
18
|
+
* USO INTERNO: El contexto usa esto para el estado interno con propiedades de tracking
|
|
19
|
+
*/
|
|
20
|
+
export type IViewConfig<TViewSpecific = {}, TOriginalViewSpecific = {}> = BaseViewConfig<TViewSpecific> & {
|
|
21
|
+
hidden: boolean;
|
|
22
|
+
originalIndex: number;
|
|
23
|
+
originalVisible: boolean;
|
|
24
|
+
} & TOriginalViewSpecific;
|
|
25
|
+
/**
|
|
26
|
+
* Configuración base para columnas de tabla
|
|
27
|
+
* USO: Los desarrolladores pasan esto en defaultUserColumns.columnsConfig
|
|
28
|
+
*/
|
|
6
29
|
export interface BaseConfigColumn {
|
|
7
30
|
key: string;
|
|
8
31
|
visible: boolean;
|
|
@@ -13,28 +36,66 @@ export interface BaseConfigColumn {
|
|
|
13
36
|
*/
|
|
14
37
|
name?: string;
|
|
15
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Configuración base para vista cards - omite frozen y agrega showTitle
|
|
41
|
+
* USO: Los desarrolladores pasan esto en defaultUserColumns.columnsConfigCards
|
|
42
|
+
*/
|
|
43
|
+
export interface BaseConfigColumnCards extends Omit<BaseConfigColumn, 'frozen'> {
|
|
44
|
+
showTitle: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Configuración extendida para columnas de tabla (estado interno)
|
|
48
|
+
* USO INTERNO: El contexto agrega estas propiedades para tracking y gestión de estado
|
|
49
|
+
*/
|
|
16
50
|
export interface IConfigColumn extends BaseConfigColumn {
|
|
17
51
|
hidden: boolean;
|
|
18
52
|
originalIndex: number;
|
|
19
53
|
originalVisible: boolean;
|
|
20
54
|
originalFrozen: boolean;
|
|
21
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Configuración extendida para cards (estado interno)
|
|
58
|
+
* USO INTERNO: El contexto agrega estas propiedades para tracking y gestión de estado
|
|
59
|
+
*/
|
|
60
|
+
export interface IConfigColumnCards extends Omit<IConfigColumn, 'frozen' | 'originalFrozen'> {
|
|
61
|
+
showTitle: boolean;
|
|
62
|
+
originalShowTitle: boolean;
|
|
63
|
+
}
|
|
64
|
+
export type ViewMode = 'table' | 'cards';
|
|
65
|
+
/**
|
|
66
|
+
* Configuración base del Grid (API pública original)
|
|
67
|
+
* USO: Tipo base para defaultUserColumns - mantiene retrocompatibilidad
|
|
68
|
+
* IMPORTANTE: No modificar para mantener retrocompatibilidad con código existente
|
|
69
|
+
*/
|
|
22
70
|
export interface IGridConfig {
|
|
23
71
|
columnsConfig: BaseConfigColumn[];
|
|
24
72
|
columnsWidths: Record<RowKey, number>;
|
|
25
73
|
}
|
|
26
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Configuración extendida del Grid para soportar múltiples vistas
|
|
76
|
+
* USO: Para nuevas implementaciones que soporten cards y futuras vistas
|
|
77
|
+
* EXTENSIBILIDAD: Agregar aquí nuevas propiedades para nuevas vistas (ej: columnsConfigList)
|
|
78
|
+
*/
|
|
79
|
+
export interface IGridConfigExtended extends IGridConfig {
|
|
80
|
+
columnsConfigCards?: BaseConfigColumnCards[];
|
|
81
|
+
}
|
|
82
|
+
export interface DataGridProviderProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Pick<GridProps<TRow, TSummaryRow, TKey>, 'rows' | 'columns' | 'rowActionsGetter' | 'rowHeaderHeights' | 'rowHeights' | 'initialRowHeightVariant' | 'checkedRows' | 'onCheckedRowsChange' | 'rowKeyGetter' | 'onChangeUserColumns' | 'defaultUserColumns' | 'externalSortSettings' | 'externalFilterSettings' | 'cardSettings' | 'defaultViewMode'> {
|
|
27
83
|
id: number | string;
|
|
28
84
|
children: ReactNode;
|
|
29
85
|
rowsCount: number;
|
|
30
86
|
size: GridProps<any, any, any>['size'];
|
|
87
|
+
viewMode?: ViewMode;
|
|
88
|
+
onViewModeChange?: (viewMode: ViewMode) => void;
|
|
31
89
|
}
|
|
32
90
|
export type RowHeightState = {
|
|
33
91
|
rowHVariant: RowHeightVariants;
|
|
34
92
|
rowHeight: number;
|
|
35
93
|
rowHeaderHeight: number;
|
|
36
94
|
};
|
|
37
|
-
export interface DataGridContextProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Pick<DataGridProviderProps<TRow, TSummaryRow, TKey>, 'rows' | 'checkedRows' | 'onCheckedRowsChange' | 'rowHeights' | 'rowsCount' | 'rowActionsGetter' | 'rowKeyGetter' | 'onChangeUserColumns' | 'externalSortSettings' | 'externalFilterSettings'> {
|
|
95
|
+
export interface DataGridContextProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Pick<DataGridProviderProps<TRow, TSummaryRow, TKey>, 'rows' | 'checkedRows' | 'onCheckedRowsChange' | 'rowHeights' | 'rowsCount' | 'rowActionsGetter' | 'rowKeyGetter' | 'onChangeUserColumns' | 'externalSortSettings' | 'externalFilterSettings' | 'viewMode' | 'onViewModeChange' | 'cardSettings' | 'defaultViewMode'> {
|
|
96
|
+
getConfigColumns: (viewMode: ViewMode) => IViewConfig[];
|
|
97
|
+
onChangeColumnsConfig: (viewMode: ViewMode, config: IViewConfig[]) => void;
|
|
98
|
+
onChangeColumnsOrder: (viewMode: ViewMode, sourceKey: string, targetKey: string) => void;
|
|
38
99
|
columnsConfig: IConfigColumn[];
|
|
39
100
|
columnsWidths: Map<string, Maybe<string | number>>;
|
|
40
101
|
setRowsCount: (newRowsCount: number) => void;
|
|
@@ -42,8 +103,6 @@ export interface DataGridContextProps<TRow, TSummaryRow, TKey extends RowKey = R
|
|
|
42
103
|
currentRowHeight: number;
|
|
43
104
|
currentRowHeightVariant: RowHeightVariants;
|
|
44
105
|
setRowHeightVariant: (neVariant: RowHeightVariants) => void;
|
|
45
|
-
onChangeColumnsConfig: (newColumnsConfig: IConfigColumn[]) => void;
|
|
46
|
-
onChangeColumnsOrder: (sourceKey: string, targetKey: string) => void;
|
|
47
106
|
onChangeColumnWidth: (columnKey: string, width: number) => void;
|
|
48
107
|
classes?: Record<DataGridSlots | ActionsSlots | RowsCountSlots | TableSlots | TextEditorSlots | ColumnsConfigSlots | ControlNavigateSlots, string>;
|
|
49
108
|
size: GridProps<any, any, any>['size'];
|
|
@@ -16,6 +16,7 @@ export declare const DICTIONARY: {
|
|
|
16
16
|
SETTINGS_COLUMN_NAME: string;
|
|
17
17
|
SETTINGS_COLUMN_POSITION: string;
|
|
18
18
|
SETTINGS_COLUMN_VISIBLE: string;
|
|
19
|
+
SETTINGS_COLUMN_SHOW_TITLE: string;
|
|
19
20
|
SETTINGS_COLUMNS_FROZEN: string;
|
|
20
21
|
SETTINGS_SEL_COLUMNS: string;
|
|
21
22
|
SETTINGS_MOVE_FIRST: string;
|
|
@@ -33,4 +34,8 @@ export declare const DICTIONARY: {
|
|
|
33
34
|
UNFREEZE_COLUMN: string;
|
|
34
35
|
HIDE_COLUMN: string;
|
|
35
36
|
ADD_FILTER_COLUMN: string;
|
|
37
|
+
VIEW_MODE_TABLE: string;
|
|
38
|
+
VIEW_MODE_CARDS: string;
|
|
39
|
+
TOOLTIP_VIEW_MODE: string;
|
|
40
|
+
DETAILS: string;
|
|
36
41
|
};
|
|
@@ -16,6 +16,7 @@ const DICTIONARY = {
|
|
|
16
16
|
SETTINGS_COLUMN_NAME: `${DATAGRID_ID_DICTIONARY}.settings_column_name`,
|
|
17
17
|
SETTINGS_COLUMN_POSITION: `${DATAGRID_ID_DICTIONARY}.settings_column_position`,
|
|
18
18
|
SETTINGS_COLUMN_VISIBLE: `${DATAGRID_ID_DICTIONARY}.settings_column_visible`,
|
|
19
|
+
SETTINGS_COLUMN_SHOW_TITLE: `${DATAGRID_ID_DICTIONARY}.settings_column_show_title`,
|
|
19
20
|
SETTINGS_COLUMNS_FROZEN: `${DATAGRID_ID_DICTIONARY}.settings_column_frozen`,
|
|
20
21
|
SETTINGS_SEL_COLUMNS: `${DATAGRID_ID_DICTIONARY}.settings_sel_columns`,
|
|
21
22
|
SETTINGS_MOVE_FIRST: `${DATAGRID_ID_DICTIONARY}.settings_move_first`,
|
|
@@ -32,7 +33,11 @@ const DICTIONARY = {
|
|
|
32
33
|
FREEZE_COLUMN: `${DATAGRID_ID_DICTIONARY}.freeze_column`,
|
|
33
34
|
UNFREEZE_COLUMN: `${DATAGRID_ID_DICTIONARY}.unfreeze_column`,
|
|
34
35
|
HIDE_COLUMN: `${DATAGRID_ID_DICTIONARY}.hide_column`,
|
|
35
|
-
ADD_FILTER_COLUMN: `${DATAGRID_ID_DICTIONARY}.add_filter
|
|
36
|
+
ADD_FILTER_COLUMN: `${DATAGRID_ID_DICTIONARY}.add_filter`,
|
|
37
|
+
VIEW_MODE_TABLE: `${DATAGRID_ID_DICTIONARY}.view_mode_table`,
|
|
38
|
+
VIEW_MODE_CARDS: `${DATAGRID_ID_DICTIONARY}.view_mode_cards`,
|
|
39
|
+
TOOLTIP_VIEW_MODE: `${DATAGRID_ID_DICTIONARY}.tooltip_view_mode`,
|
|
40
|
+
DETAILS: `${DATAGRID_ID_DICTIONARY}.details`
|
|
36
41
|
};
|
|
37
42
|
export {
|
|
38
43
|
DICTIONARY as D,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { C as CheckboxCellAdapter } from "../../subcomponents/CheckboxCellAdapter/index.js";
|
|
3
3
|
function ColumnSetCheckFormatter(parameters) {
|
|
4
4
|
const { field, disabledGetter, rowKeyGetter, useHook } = parameters;
|
|
5
5
|
const formatter = (props) => {
|
|
@@ -19,7 +19,7 @@ function ColumnSetCheckFormatter(parameters) {
|
|
|
19
19
|
disabled = disabledGetter(row);
|
|
20
20
|
}
|
|
21
21
|
return /* @__PURE__ */ jsx(
|
|
22
|
-
|
|
22
|
+
CheckboxCellAdapter,
|
|
23
23
|
{
|
|
24
24
|
value: checkedRows.has(rowKeyGetter(row)) || false,
|
|
25
25
|
disabled,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UseModalDetailProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook genérico que renderiza el modal de detalle para cualquier vista
|
|
4
|
+
* mostrando TODAS las columnas sin excepción
|
|
5
|
+
*/
|
|
6
|
+
export declare const useModalDetail: <TRow>({ row, columns, viewMode, onRowsChange, }: UseModalDetailProps<TRow>) => () => void;
|