@m4l/components 9.3.21 → 9.3.22-JT22102025.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 +322 -112
- 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 +5 -3
- 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/types.d.ts +1 -0
- package/components/DataGrid/tests/helpers/useCardsViewConfig.d.ts +24 -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 +87 -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
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useState, useImperativeHandle, useMemo, useEffect } from "react";
|
|
3
|
+
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
4
|
+
import DataGrid from "react-data-grid";
|
|
5
|
+
import { I as IconButton } from "../../../../../../../mui_extended/IconButton/IconButton.js";
|
|
6
|
+
import { p as pathIcons } from "../../../../../../icons.js";
|
|
7
|
+
import { r as ColumnsConfigWrapperStyled, s as ColumnsConfigDataGridStyled, t as ColumnsConfigSelColumnsStyled, T as TableWrapperDataGridStyled, u as ColumnsConfigActiosStyled } from "../../../../../../slots/DataGridSlot.js";
|
|
8
|
+
import { D as DICTIONARY } from "../../../../../../dictionary.js";
|
|
9
|
+
import { C as ColumnInteractiveCheckFormatter } from "../../../../../../formatters/ColumnInteractiveCheckFormatter/formatter.js";
|
|
10
|
+
function getRowsFromColumnsConfigCards(columnsConfigCards, columns) {
|
|
11
|
+
return columnsConfigCards.filter((cConfig) => !cConfig.hidden).map(
|
|
12
|
+
(cConfig) => ({
|
|
13
|
+
key: cConfig.key,
|
|
14
|
+
name: columns?.find((c) => c.key === cConfig.key)?.name ?? "",
|
|
15
|
+
visible: cConfig.visible === void 0 ? true : cConfig.visible,
|
|
16
|
+
showTitle: cConfig.showTitle === void 0 ? true : cConfig.showTitle,
|
|
17
|
+
originalIndex: cConfig.originalIndex,
|
|
18
|
+
originalVisible: cConfig.originalVisible,
|
|
19
|
+
originalShowTitle: cConfig.originalShowTitle
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const getAlignClass = (align) => {
|
|
24
|
+
const cellClass = align !== void 0 ? `rdg-cell-align-${align}` : "";
|
|
25
|
+
return {
|
|
26
|
+
cellClass,
|
|
27
|
+
headerCellClass: cellClass
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const ColumnsConfigCards = forwardRef(
|
|
31
|
+
(props, ref) => {
|
|
32
|
+
const refdata_grid = useRef(null);
|
|
33
|
+
const {
|
|
34
|
+
onCloseSettings,
|
|
35
|
+
columnsConfigCards,
|
|
36
|
+
onChangeColumnsConfigCards,
|
|
37
|
+
rowHeight,
|
|
38
|
+
classes,
|
|
39
|
+
size,
|
|
40
|
+
columns
|
|
41
|
+
} = props;
|
|
42
|
+
const { getLabel } = useModuleDictionary();
|
|
43
|
+
const [isInit, setIsInit] = useState(true);
|
|
44
|
+
const [rows, setRows] = useState(
|
|
45
|
+
getRowsFromColumnsConfigCards(columnsConfigCards, columns)
|
|
46
|
+
);
|
|
47
|
+
const [selRows, setSelRows] = useState(
|
|
48
|
+
() => /* @__PURE__ */ new Set()
|
|
49
|
+
);
|
|
50
|
+
const divRef = useRef(null);
|
|
51
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
52
|
+
useImperativeHandle(ref, () => ({
|
|
53
|
+
onClickIntro: handleIntro,
|
|
54
|
+
current: divRef.current
|
|
55
|
+
}));
|
|
56
|
+
const columnsdata_grid = useMemo(
|
|
57
|
+
() => [
|
|
58
|
+
{
|
|
59
|
+
key: "name",
|
|
60
|
+
name: getLabel(DICTIONARY.SETTINGS_COLUMN_NAME),
|
|
61
|
+
width: 220,
|
|
62
|
+
resizable: true,
|
|
63
|
+
type: "string",
|
|
64
|
+
...getAlignClass("left")
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "visible",
|
|
68
|
+
name: getLabel(DICTIONARY.SETTINGS_COLUMN_VISIBLE),
|
|
69
|
+
width: 80,
|
|
70
|
+
type: "boolean",
|
|
71
|
+
renderCell: ColumnInteractiveCheckFormatter,
|
|
72
|
+
...getAlignClass("center")
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
key: "showTitle",
|
|
76
|
+
name: getLabel(DICTIONARY.SETTINGS_COLUMN_SHOW_TITLE),
|
|
77
|
+
width: 100,
|
|
78
|
+
type: "boolean",
|
|
79
|
+
renderCell: ColumnInteractiveCheckFormatter,
|
|
80
|
+
...getAlignClass("center")
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
[getLabel]
|
|
84
|
+
);
|
|
85
|
+
const checkAll = () => {
|
|
86
|
+
setRows(rows.map((row) => ({ ...row, visible: true })));
|
|
87
|
+
};
|
|
88
|
+
const unCheckAll = () => {
|
|
89
|
+
setRows(rows.map((row) => ({ ...row, visible: false })));
|
|
90
|
+
};
|
|
91
|
+
const restoreAll = () => {
|
|
92
|
+
setRows(
|
|
93
|
+
rows.map((row) => ({
|
|
94
|
+
...row,
|
|
95
|
+
visible: row.originalVisible,
|
|
96
|
+
showTitle: row.originalShowTitle,
|
|
97
|
+
index: row.originalIndex
|
|
98
|
+
})).sort((a, b) => a.index - b.index)
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (isInit === false) {
|
|
103
|
+
setRows(getRowsFromColumnsConfigCards(columnsConfigCards, columns));
|
|
104
|
+
}
|
|
105
|
+
setIsInit(false);
|
|
106
|
+
}, [columnsConfigCards]);
|
|
107
|
+
const rowSelectedIndex = useMemo(() => {
|
|
108
|
+
let rowIndex = -1;
|
|
109
|
+
if (selRows.size !== 1) {
|
|
110
|
+
return rowIndex;
|
|
111
|
+
}
|
|
112
|
+
const iterator = selRows.entries();
|
|
113
|
+
const entry = iterator.next().value?.[1];
|
|
114
|
+
rowIndex = rows.findIndex((row) => row.key === entry);
|
|
115
|
+
return rowIndex;
|
|
116
|
+
}, [rows, selRows]);
|
|
117
|
+
const handleMoveFirst = () => {
|
|
118
|
+
if (rowSelectedIndex === -1) {
|
|
119
|
+
return -1;
|
|
120
|
+
}
|
|
121
|
+
const newRows = [...rows];
|
|
122
|
+
newRows.splice(rowSelectedIndex, 1);
|
|
123
|
+
newRows.splice(0, 0, rows[rowSelectedIndex]);
|
|
124
|
+
refdata_grid.current?.selectCell({ idx: 0, rowIdx: 0 });
|
|
125
|
+
setRows(newRows);
|
|
126
|
+
};
|
|
127
|
+
const handleMoveLast = () => {
|
|
128
|
+
if (rowSelectedIndex === -1) {
|
|
129
|
+
return -1;
|
|
130
|
+
}
|
|
131
|
+
const newRows = [...rows];
|
|
132
|
+
newRows.splice(rowSelectedIndex, 1);
|
|
133
|
+
newRows.splice(newRows.length, 0, rows[rowSelectedIndex]);
|
|
134
|
+
refdata_grid.current?.selectCell({ idx: 0, rowIdx: newRows.length - 1 });
|
|
135
|
+
setRows(newRows);
|
|
136
|
+
};
|
|
137
|
+
const handleMoveUpDownd = (position) => {
|
|
138
|
+
if (rowSelectedIndex === -1) {
|
|
139
|
+
return -1;
|
|
140
|
+
}
|
|
141
|
+
const newRows = [...rows];
|
|
142
|
+
const element = newRows[rowSelectedIndex];
|
|
143
|
+
newRows.splice(rowSelectedIndex, 1);
|
|
144
|
+
newRows.splice(rowSelectedIndex + position, 0, element);
|
|
145
|
+
refdata_grid.current?.selectCell({
|
|
146
|
+
idx: 0,
|
|
147
|
+
rowIdx: rowSelectedIndex + position
|
|
148
|
+
});
|
|
149
|
+
setRows(newRows);
|
|
150
|
+
};
|
|
151
|
+
const getColumnConfigByKey = (key) => {
|
|
152
|
+
const rowIndexFinded = rows.findIndex((row) => row.key === key);
|
|
153
|
+
if (rowIndexFinded > -1) {
|
|
154
|
+
return {
|
|
155
|
+
visible: rows[rowIndexFinded].visible,
|
|
156
|
+
showTitle: rows[rowIndexFinded].showTitle
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return void 0;
|
|
160
|
+
};
|
|
161
|
+
const getRowIndex = (column) => {
|
|
162
|
+
const rowIndexFinded = rows.findIndex((row) => row.key === column.key);
|
|
163
|
+
if (rowIndexFinded > -1) {
|
|
164
|
+
return rowIndexFinded;
|
|
165
|
+
}
|
|
166
|
+
return columnsConfigCards.findIndex(
|
|
167
|
+
(columnConfigCards) => columnConfigCards.key === column.key
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
const handleIntro = () => {
|
|
171
|
+
const newColumnsConfig = columnsConfigCards.map((columnConfigCards) => {
|
|
172
|
+
const newColumnConfig = { ...columnConfigCards };
|
|
173
|
+
if (!columnConfigCards.hidden) {
|
|
174
|
+
const columnConfigRow = getColumnConfigByKey(columnConfigCards.key);
|
|
175
|
+
if (columnConfigRow) {
|
|
176
|
+
newColumnConfig.visible = columnConfigRow.visible;
|
|
177
|
+
newColumnConfig.showTitle = columnConfigRow.showTitle;
|
|
178
|
+
}
|
|
179
|
+
const rowIndex = rows.findIndex(
|
|
180
|
+
(row) => row.key === columnConfigCards.key
|
|
181
|
+
);
|
|
182
|
+
if (rowIndex > -1) {
|
|
183
|
+
newColumnConfig.index = rowIndex;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return newColumnConfig;
|
|
187
|
+
}).sort((a, b) => getRowIndex(a) - getRowIndex(b));
|
|
188
|
+
onChangeColumnsConfigCards(newColumnsConfig);
|
|
189
|
+
onCloseSettings();
|
|
190
|
+
};
|
|
191
|
+
const onInternalSelectedRowsChange = () => {
|
|
192
|
+
};
|
|
193
|
+
const onInternalRowsChange = (newRows) => {
|
|
194
|
+
setRows(newRows);
|
|
195
|
+
};
|
|
196
|
+
const onCellClick = ({ row }) => {
|
|
197
|
+
if (selRows.has(row.key)) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const mySet = /* @__PURE__ */ new Set([row.key]);
|
|
201
|
+
setSelRows(mySet);
|
|
202
|
+
};
|
|
203
|
+
return /* @__PURE__ */ jsxs(ColumnsConfigWrapperStyled, { ref: divRef, children: [
|
|
204
|
+
/* @__PURE__ */ jsxs(ColumnsConfigDataGridStyled, { children: [
|
|
205
|
+
/* @__PURE__ */ jsx(ColumnsConfigSelColumnsStyled, { ownerState: { size }, children: getLabel(DICTIONARY.SETTINGS_SEL_COLUMNS) }),
|
|
206
|
+
/* @__PURE__ */ jsx(
|
|
207
|
+
TableWrapperDataGridStyled,
|
|
208
|
+
{
|
|
209
|
+
className: classes?.tableWrapperDataGrid,
|
|
210
|
+
ownerState: { size },
|
|
211
|
+
children: /* @__PURE__ */ jsx(
|
|
212
|
+
DataGrid,
|
|
213
|
+
{
|
|
214
|
+
ref: refdata_grid,
|
|
215
|
+
rowHeight,
|
|
216
|
+
columns: columnsdata_grid,
|
|
217
|
+
rows,
|
|
218
|
+
onRowsChange: onInternalRowsChange,
|
|
219
|
+
selectedRows: selRows,
|
|
220
|
+
onSelectedRowsChange: onInternalSelectedRowsChange,
|
|
221
|
+
onCellClick,
|
|
222
|
+
rowKeyGetter: (row) => row.key,
|
|
223
|
+
defaultColumnOptions: { resizable: true, sortable: true }
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
] }),
|
|
229
|
+
/* @__PURE__ */ jsxs(ColumnsConfigActiosStyled, { children: [
|
|
230
|
+
/* @__PURE__ */ jsx(
|
|
231
|
+
IconButton,
|
|
232
|
+
{
|
|
233
|
+
tooltip: getLabel(DICTIONARY.SETTINGS_MOVE_FIRST),
|
|
234
|
+
onClick: handleMoveFirst,
|
|
235
|
+
"aria-label": "move first place",
|
|
236
|
+
disabled: rowSelectedIndex < 1,
|
|
237
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.moveFirstPlace}`
|
|
238
|
+
}
|
|
239
|
+
),
|
|
240
|
+
/* @__PURE__ */ jsx(
|
|
241
|
+
IconButton,
|
|
242
|
+
{
|
|
243
|
+
tooltip: getLabel(DICTIONARY.SETTINGS_MOVE_UP),
|
|
244
|
+
onClick: () => handleMoveUpDownd(-1),
|
|
245
|
+
"aria-label": "move up place",
|
|
246
|
+
disabled: rowSelectedIndex < 1,
|
|
247
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.moveUpPlace}`
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsx(
|
|
251
|
+
IconButton,
|
|
252
|
+
{
|
|
253
|
+
tooltip: getLabel(DICTIONARY.SETTINGS_MOVE_LAST),
|
|
254
|
+
onClick: handleMoveLast,
|
|
255
|
+
"aria-label": "move last place",
|
|
256
|
+
disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
|
|
257
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.moveLastPlace}`
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ jsx(
|
|
261
|
+
IconButton,
|
|
262
|
+
{
|
|
263
|
+
tooltip: getLabel(DICTIONARY.SETTINGS_MOVE_DOWN),
|
|
264
|
+
onClick: () => handleMoveUpDownd(1),
|
|
265
|
+
"aria-label": "move down place",
|
|
266
|
+
disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
|
|
267
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.moveDownPlace}`
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsx(
|
|
271
|
+
IconButton,
|
|
272
|
+
{
|
|
273
|
+
tooltip: getLabel(DICTIONARY.SETTINGS_VISIBLE_ALL),
|
|
274
|
+
onClick: checkAll,
|
|
275
|
+
"aria-label": "check visible all",
|
|
276
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.checkAll}`
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
/* @__PURE__ */ jsx(
|
|
280
|
+
IconButton,
|
|
281
|
+
{
|
|
282
|
+
tooltip: getLabel(DICTIONARY.SETTINGS_NO_VISIBLE_ALL),
|
|
283
|
+
onClick: unCheckAll,
|
|
284
|
+
"aria-label": "un check all",
|
|
285
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.uncheckAll}`
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
/* @__PURE__ */ jsx(
|
|
289
|
+
IconButton,
|
|
290
|
+
{
|
|
291
|
+
tooltip: getLabel(DICTIONARY.SETTINGS_RESTORE),
|
|
292
|
+
onClick: restoreAll,
|
|
293
|
+
"aria-label": "Restore columns",
|
|
294
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.restoreColumns}`
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
] })
|
|
298
|
+
] });
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
ColumnsConfigCards.displayName = "ColumnsConfigCards";
|
|
302
|
+
export {
|
|
303
|
+
ColumnsConfigCards as C
|
|
304
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DataGridContextProps, IViewConfig } from '../../../../../../contexts/DataGridContext/types';
|
|
2
|
+
import { GridProps } from '../../../../../../types';
|
|
3
|
+
import { Column } from 'react-data-grid';
|
|
4
|
+
export interface Row {
|
|
5
|
+
key: string;
|
|
6
|
+
name: string;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
showTitle: boolean;
|
|
9
|
+
width: number;
|
|
10
|
+
index: number;
|
|
11
|
+
originalIndex: number;
|
|
12
|
+
originalVisible: boolean;
|
|
13
|
+
originalShowTitle: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type ColumnsConfigRef = {
|
|
16
|
+
onClickIntro: () => void;
|
|
17
|
+
current: HTMLDivElement | null;
|
|
18
|
+
};
|
|
19
|
+
export interface ConfigProps {
|
|
20
|
+
onCloseSettings: () => void;
|
|
21
|
+
columns: readonly Column<any, any>[];
|
|
22
|
+
columnsConfigCards: IViewConfig[];
|
|
23
|
+
onChangeColumnsConfigCards: (newColumnsConfigCards: IViewConfig[]) => void;
|
|
24
|
+
rowHeight: number;
|
|
25
|
+
classes: DataGridContextProps<unknown, unknown>['classes'];
|
|
26
|
+
size: GridProps<unknown, unknown>['size'];
|
|
27
|
+
}
|
|
28
|
+
export interface CheckFormatterProps {
|
|
29
|
+
key: string;
|
|
30
|
+
row: any;
|
|
31
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo, useCallback } from "react";
|
|
3
|
+
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
4
|
+
import { u as useDataGrid } from "../../../../hooks/useDataGrid.js";
|
|
5
|
+
import { I as IconButton } from "../../../../../mui_extended/IconButton/IconButton.js";
|
|
6
|
+
import { P as Popover } from "../../../../../mui_extended/Popover/Popover.js";
|
|
7
|
+
import { p as pathIcons } from "../../../../icons.js";
|
|
8
|
+
import { D as DICTIONARY } from "../../../../dictionary.js";
|
|
9
|
+
import { v as ContainerToggleCardsStyled, w as CardToggleButtonStyled, x as TextToggleCardButtonStyled } from "../../../../slots/DataGridSlot.js";
|
|
10
|
+
import { I as Icon } from "../../../../../Icon/Icon.js";
|
|
11
|
+
function ViewMode() {
|
|
12
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
13
|
+
const { viewMode, onViewModeChange } = useDataGrid();
|
|
14
|
+
const { getLabel } = useModuleDictionary();
|
|
15
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
16
|
+
const ownerState = {
|
|
17
|
+
viewMode
|
|
18
|
+
};
|
|
19
|
+
const open = useMemo(() => Boolean(anchorEl), [anchorEl]);
|
|
20
|
+
const handleClick = useCallback(
|
|
21
|
+
(event) => {
|
|
22
|
+
setAnchorEl(event.currentTarget);
|
|
23
|
+
},
|
|
24
|
+
[]
|
|
25
|
+
);
|
|
26
|
+
const handleClose = useCallback(() => {
|
|
27
|
+
setAnchorEl(null);
|
|
28
|
+
}, []);
|
|
29
|
+
const handleViewModeChange = useCallback(
|
|
30
|
+
(newViewMode) => {
|
|
31
|
+
onViewModeChange?.(newViewMode);
|
|
32
|
+
handleClose();
|
|
33
|
+
},
|
|
34
|
+
[onViewModeChange, handleClose]
|
|
35
|
+
);
|
|
36
|
+
const renderIcon = useMemo(() => {
|
|
37
|
+
return viewMode === "table" ? pathIcons.viewTable : pathIcons.viewCards;
|
|
38
|
+
}, [viewMode]);
|
|
39
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
IconButton,
|
|
42
|
+
{
|
|
43
|
+
tooltip: getLabel(DICTIONARY.TOOLTIP_VIEW_MODE),
|
|
44
|
+
onClick: handleClick,
|
|
45
|
+
"aria-label": "view-mode",
|
|
46
|
+
icon: `${host_static_assets}/${environment_assets}/${renderIcon}`,
|
|
47
|
+
"data-testid": "view-mode-button"
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
Popover,
|
|
52
|
+
{
|
|
53
|
+
open,
|
|
54
|
+
anchorEl,
|
|
55
|
+
onClose: handleClose,
|
|
56
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
57
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
58
|
+
slotProps: {
|
|
59
|
+
paper: {
|
|
60
|
+
sx: { mt: 0.6 }
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
children: /* @__PURE__ */ jsxs(ContainerToggleCardsStyled, { children: [
|
|
64
|
+
/* @__PURE__ */ jsxs(
|
|
65
|
+
CardToggleButtonStyled,
|
|
66
|
+
{
|
|
67
|
+
ownerState: { ...ownerState, isActive: viewMode === "table" },
|
|
68
|
+
variant: "outlined",
|
|
69
|
+
role: "button",
|
|
70
|
+
onClick: () => handleViewModeChange("table"),
|
|
71
|
+
"data-testid": "toggle-button-table",
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
Icon,
|
|
75
|
+
{
|
|
76
|
+
src: `${host_static_assets}/${environment_assets}/${pathIcons.viewTable}`,
|
|
77
|
+
color: viewMode === "table" ? "primary.enabled" : "text.disabled"
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
TextToggleCardButtonStyled,
|
|
82
|
+
{
|
|
83
|
+
ownerState: { ...ownerState, isActive: viewMode === "table" },
|
|
84
|
+
variant: "body",
|
|
85
|
+
children: getLabel(DICTIONARY.VIEW_MODE_TABLE)
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ jsxs(
|
|
92
|
+
CardToggleButtonStyled,
|
|
93
|
+
{
|
|
94
|
+
ownerState: { ...ownerState, isActive: viewMode === "cards" },
|
|
95
|
+
variant: "outlined",
|
|
96
|
+
role: "button",
|
|
97
|
+
onClick: () => handleViewModeChange("cards"),
|
|
98
|
+
"data-testid": "toggle-button-cards",
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsx(
|
|
101
|
+
Icon,
|
|
102
|
+
{
|
|
103
|
+
src: `${host_static_assets}/${environment_assets}/${pathIcons.viewCards}`,
|
|
104
|
+
color: viewMode === "cards" ? "primary.enabled" : "text.disabled"
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
TextToggleCardButtonStyled,
|
|
109
|
+
{
|
|
110
|
+
ownerState: { ...ownerState, isActive: viewMode === "cards" },
|
|
111
|
+
variant: "body",
|
|
112
|
+
children: getLabel(DICTIONARY.VIEW_MODE_CARDS)
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
] })
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
] });
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
ViewMode as V
|
|
125
|
+
};
|
|
@@ -5,7 +5,7 @@ import { useRef, useCallback } from "react";
|
|
|
5
5
|
import { u as useDataGrid } from "../../../../../hooks/useDataGrid.js";
|
|
6
6
|
import { u as useModal } from "../../../../../../../hooks/useModal/index.js";
|
|
7
7
|
import { C as ColumnsConfig } from "../../Settings/subcomponents/ColumnsConfig/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { b as ContentModalSettingStyled, D as DataGridRootStyled } from "../../../../../slots/DataGridSlot.js";
|
|
9
9
|
import { p as pathIcons } from "../../../../../icons.js";
|
|
10
10
|
import { A as ActionsContainer } from "../../../../../../CommonActions/components/ActionsContainer/ActionsContainer.js";
|
|
11
11
|
import { W as WindowBase } from "../../../../../../WindowBase/WindowBase.js";
|
|
@@ -27,7 +27,7 @@ const useModalSettings = (size, columns) => {
|
|
|
27
27
|
}
|
|
28
28
|
}, []);
|
|
29
29
|
const handleColumnsSetting = (config) => {
|
|
30
|
-
onChangeColumnsConfig(config);
|
|
30
|
+
onChangeColumnsConfig("table", config);
|
|
31
31
|
};
|
|
32
32
|
const onClickSettings = () => {
|
|
33
33
|
openModal({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GridProps } from '../../../../../types';
|
|
2
|
+
import { Column } from 'react-data-grid';
|
|
3
|
+
/**
|
|
4
|
+
* Hook que renderiza el modal de configuración de las columnas
|
|
5
|
+
* de la tabla
|
|
6
|
+
*/
|
|
7
|
+
export declare const useModalSettingsCards: (size: GridProps<unknown, unknown>["size"], columns: readonly Column<any, any>[]) => () => void;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
3
|
+
import { useIsMobile } from "@m4l/graphics";
|
|
4
|
+
import { useRef, useCallback } from "react";
|
|
5
|
+
import { u as useDataGrid } from "../../../../../hooks/useDataGrid.js";
|
|
6
|
+
import { u as useModal } from "../../../../../../../hooks/useModal/index.js";
|
|
7
|
+
import { b as ContentModalSettingStyled, D as DataGridRootStyled } from "../../../../../slots/DataGridSlot.js";
|
|
8
|
+
import { p as pathIcons } from "../../../../../icons.js";
|
|
9
|
+
import { C as ColumnsConfigCards } from "../../Settings/subcomponents/ColumnsConfigCards/index.js";
|
|
10
|
+
import { A as ActionsContainer } from "../../../../../../CommonActions/components/ActionsContainer/ActionsContainer.js";
|
|
11
|
+
import { W as WindowBase } from "../../../../../../WindowBase/WindowBase.js";
|
|
12
|
+
import { A as ActionCancel } from "../../../../../../CommonActions/components/ActionCancel/ActionCancel.js";
|
|
13
|
+
import { A as ActionIntro } from "../../../../../../CommonActions/components/ActionIntro/ActionIntro.js";
|
|
14
|
+
const useModalSettingsCards = (size, columns) => {
|
|
15
|
+
const { openModal, closeModal } = useModal();
|
|
16
|
+
const { getConfigColumns, onChangeColumnsConfig, currentRowHeight, classes } = useDataGrid();
|
|
17
|
+
const columnsConfigCards = getConfigColumns("cards");
|
|
18
|
+
const { getLabel } = useModuleDictionary();
|
|
19
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
20
|
+
const isMobile = useIsMobile();
|
|
21
|
+
const ref = useRef(null);
|
|
22
|
+
const onCloseSettings = useCallback(() => {
|
|
23
|
+
closeModal();
|
|
24
|
+
}, [closeModal]);
|
|
25
|
+
const onClickIntro = useCallback(() => {
|
|
26
|
+
if (ref.current?.onClickIntro) {
|
|
27
|
+
ref.current.onClickIntro();
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
const handleColumnsSetting = (config) => {
|
|
31
|
+
onChangeColumnsConfig("cards", config);
|
|
32
|
+
};
|
|
33
|
+
const onClickSettings = () => {
|
|
34
|
+
openModal({
|
|
35
|
+
initialWidth: 500,
|
|
36
|
+
initialHeight: 680,
|
|
37
|
+
fullScreen: isMobile,
|
|
38
|
+
window: /* @__PURE__ */ jsx(
|
|
39
|
+
WindowBase,
|
|
40
|
+
{
|
|
41
|
+
title: getLabel("data_grid.settings_title"),
|
|
42
|
+
iconUrl: `${host_static_assets}/${environment_assets}/${pathIcons.configuration}`,
|
|
43
|
+
onClose: closeModal,
|
|
44
|
+
className: "settings-modal",
|
|
45
|
+
variant: "outlined",
|
|
46
|
+
emergeType: "modal",
|
|
47
|
+
children: /* @__PURE__ */ jsxs(ContentModalSettingStyled, { classes: classes?.contentModalSetting, children: [
|
|
48
|
+
/* @__PURE__ */ jsx(DataGridRootStyled, { children: /* @__PURE__ */ jsx(
|
|
49
|
+
ColumnsConfigCards,
|
|
50
|
+
{
|
|
51
|
+
ref,
|
|
52
|
+
rowHeight: currentRowHeight,
|
|
53
|
+
columnsConfigCards,
|
|
54
|
+
onChangeColumnsConfigCards: handleColumnsSetting,
|
|
55
|
+
onCloseSettings,
|
|
56
|
+
classes,
|
|
57
|
+
size,
|
|
58
|
+
columns
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
/* @__PURE__ */ jsxs(ActionsContainer, { children: [
|
|
62
|
+
/* @__PURE__ */ jsx(ActionCancel, { onClick: closeModal }),
|
|
63
|
+
/* @__PURE__ */ jsx(ActionIntro, { onClick: onClickIntro })
|
|
64
|
+
] })
|
|
65
|
+
] })
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return onClickSettings;
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
useModalSettingsCards as u
|
|
74
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GridProps, RowKey } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente que renderiza el contenido del DataGrid en formato de tarjetas o tabla, depende del viewMode.
|
|
4
|
+
*/
|
|
5
|
+
export declare function RenderContent<TRow, TSummaryRow, TKey extends RowKey = RowKey>(props: GridProps<TRow, TSummaryRow, TKey>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { u as useDataGrid } from "../../hooks/useDataGrid.js";
|
|
3
|
+
import { C as Cards } from "../Cards/index.js";
|
|
4
|
+
import { T as Table } from "../Table/index.js";
|
|
5
|
+
function RenderContent(props) {
|
|
6
|
+
const { viewMode } = useDataGrid();
|
|
7
|
+
return /* @__PURE__ */ jsx(Fragment, { children: viewMode === "table" ? /* @__PURE__ */ jsx(Table, { ...props }) : /* @__PURE__ */ jsx(Cards, { ...props }) });
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
RenderContent as R
|
|
11
|
+
};
|
|
@@ -86,7 +86,7 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable, handleSo
|
|
|
86
86
|
const next = columnsConfig.map(
|
|
87
87
|
(c) => c.key === columnKey ? { ...c, frozen: !c.frozen } : c
|
|
88
88
|
);
|
|
89
|
-
onChangeColumnsConfig(next);
|
|
89
|
+
onChangeColumnsConfig("table", next);
|
|
90
90
|
}, [columnKey, columnsConfig, onChangeColumnsConfig]);
|
|
91
91
|
const toggleVisible = useCallback(() => {
|
|
92
92
|
if (!columnKey) {
|
|
@@ -95,7 +95,7 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable, handleSo
|
|
|
95
95
|
const next = columnsConfig.map(
|
|
96
96
|
(c) => c.key === columnKey ? { ...c, visible: !c.visible } : c
|
|
97
97
|
);
|
|
98
|
-
onChangeColumnsConfig(next);
|
|
98
|
+
onChangeColumnsConfig("table", next);
|
|
99
99
|
}, [columnKey, columnsConfig, onChangeColumnsConfig]);
|
|
100
100
|
const addExternalSort = useCallback(
|
|
101
101
|
(direction) => {
|
|
@@ -123,7 +123,7 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
123
123
|
}, [sourceColumns, columnsConfig, rowActionsGetter]);
|
|
124
124
|
const finalColumns = useMemo(() => {
|
|
125
125
|
const DragAndDropHeaderRenderer = getDragHeaderRenderer(
|
|
126
|
-
onChangeColumnsOrder,
|
|
126
|
+
(sourceKey, targetKey) => onChangeColumnsOrder("table", sourceKey, targetKey),
|
|
127
127
|
{
|
|
128
128
|
openPopover: popoverHandlers?.openPopover
|
|
129
129
|
}
|
|
@@ -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 { y 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) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
|
|
3
3
|
import { useTheme } from "@mui/material";
|
|
4
|
-
import {
|
|
4
|
+
import { f as DATAGRID_SEMANTIC_WIDTHS, e as DATAGRID_ACTIONS_COLUMN_KEY } from "../../../constants.js";
|
|
5
5
|
import { M as MenuActions } from "../../../../MenuActions/MenuActions.js";
|
|
6
6
|
function ActionsFormatter(props) {
|
|
7
7
|
const { rowActionsGetter } = useDataGrid();
|
|
@@ -5,7 +5,7 @@ import { useDrag, useDrop } from "react-dnd";
|
|
|
5
5
|
import { renderHeaderCell } from "react-data-grid";
|
|
6
6
|
import { u as useFocusRef } from "../hooks/useFocusRef.js";
|
|
7
7
|
import { u as useFilters } from "../../../hooks/useFilters.js";
|
|
8
|
-
import { N as NameColumnIconStyled,
|
|
8
|
+
import { N as NameColumnIconStyled, z as NameColumnStyled, I as IconColumnStyled, B as DraggableHeaderRootStyled, F as ButtonHeaderActionsStyled, G as DraggableWrapperInputBaseStyled, H as IconSearchStyled, J as HeaderInputBaseStyled } from "../../../slots/DataGridSlot.js";
|
|
9
9
|
import { p as pathIcons } from "../../../icons.js";
|
|
10
10
|
import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
|
|
11
11
|
import { I as Icon } from "../../../../Icon/Icon.js";
|
package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useMemo, useEffect, useCallback } from "react";
|
|
3
3
|
import { useModuleDictionary } from "@m4l/core";
|
|
4
4
|
import { M as MenuItem } from "../../../../../mui_extended/MenuItem/MenuItem.js";
|
|
5
|
-
import { M as MenuListStyled,
|
|
5
|
+
import { M as MenuListStyled, K as HeaderRenderClickStyled } from "../../../../slots/DataGridSlot.js";
|
|
6
6
|
import { M as MenuDivider } from "../../../../../mui_extended/MenuDivider/MenuDivider.js";
|
|
7
7
|
import { P as Popover } from "../../../../../mui_extended/Popover/Popover.js";
|
|
8
8
|
import { D as DICTIONARY } from "../../../../dictionary.js";
|