@m4l/components 9.3.19-BE171025-beta.1 → 9.3.19-BE241025-beta.2

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.
Files changed (122) hide show
  1. package/components/DataGrid/DataGrid.js +9 -4
  2. package/components/DataGrid/Datagrid.styles.js +270 -0
  3. package/components/DataGrid/constants.js +2 -2
  4. package/components/DataGrid/contexts/DataGridContext/index.js +322 -112
  5. package/components/DataGrid/contexts/DataGridContext/types.d.ts +63 -4
  6. package/components/DataGrid/dictionary.d.ts +5 -0
  7. package/components/DataGrid/dictionary.js +6 -1
  8. package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.js +2 -2
  9. package/components/DataGrid/hooks/useModalCardDetail.d.ts +6 -0
  10. package/components/DataGrid/hooks/useModalCardDetail.js +74 -0
  11. package/components/DataGrid/hooks/useProcessedColumns.d.ts +50 -0
  12. package/components/DataGrid/hooks/useProcessedColumns.js +44 -0
  13. package/components/DataGrid/icons.d.ts +7 -0
  14. package/components/DataGrid/icons.js +5 -1
  15. package/components/DataGrid/index.d.ts +1 -1
  16. package/components/DataGrid/slots/DataGridEnum.d.ts +22 -1
  17. package/components/DataGrid/slots/DataGridEnum.js +21 -0
  18. package/components/DataGrid/slots/DataGridSlot.d.ts +24 -0
  19. package/components/DataGrid/slots/DataGridSlot.js +123 -21
  20. package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.d.ts +9 -0
  21. package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.js +91 -0
  22. package/components/DataGrid/subcomponents/Cards/index.d.ts +5 -0
  23. package/components/DataGrid/subcomponents/Cards/index.js +40 -0
  24. package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.d.ts +8 -0
  25. package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.js +79 -0
  26. package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.d.ts +7 -0
  27. package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.js +98 -0
  28. package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.d.ts +6 -0
  29. package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.js +71 -0
  30. package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.d.ts +20 -0
  31. package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.js +46 -0
  32. package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.d.ts +17 -0
  33. package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.js +34 -0
  34. package/components/DataGrid/subcomponents/Cards/types.d.ts +118 -0
  35. package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.d.ts +7 -0
  36. package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.js +43 -0
  37. package/components/DataGrid/subcomponents/CheckboxCellAdapter/types.d.ts +7 -0
  38. package/components/DataGrid/subcomponents/ControlNavigate/ControlNavigate.js +1 -1
  39. package/components/DataGrid/subcomponents/HeaderActions/index.js +5 -3
  40. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/RowsCount/index.js +1 -1
  41. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/index.js +11 -2
  42. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfig/index.js +1 -1
  43. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.d.ts +2 -0
  44. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.js +304 -0
  45. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/types.d.ts +31 -0
  46. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.d.ts +4 -0
  47. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.js +125 -0
  48. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettings/index.js +2 -2
  49. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.d.ts +7 -0
  50. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.js +74 -0
  51. package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/types.d.ts +4 -0
  52. package/components/DataGrid/subcomponents/RenderContent/index.d.ts +5 -0
  53. package/components/DataGrid/subcomponents/RenderContent/index.js +11 -0
  54. package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.js +2 -2
  55. package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +1 -1
  56. package/components/DataGrid/subcomponents/Table/index.js +1 -1
  57. package/components/DataGrid/subcomponents/Table/subcomponents/ActionsColumn.js +1 -1
  58. package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.js +1 -1
  59. package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js +1 -1
  60. package/components/DataGrid/subcomponents/editors/TextEditor/index.js +1 -1
  61. package/components/DataGrid/tests/components/CardDetails.test.d.ts +1 -0
  62. package/components/DataGrid/tests/components/CardHeader.test.d.ts +1 -0
  63. package/components/DataGrid/tests/components/CardRow.test.d.ts +1 -0
  64. package/components/DataGrid/tests/components/Cards.test.d.ts +1 -0
  65. package/components/DataGrid/tests/components/CheckboxCellAdapter.test.d.ts +1 -0
  66. package/components/DataGrid/tests/components/ColumnsConfigCards.test.d.ts +1 -0
  67. package/components/DataGrid/tests/components/IntersectCard.test.d.ts +1 -0
  68. package/components/DataGrid/tests/components/ViewMode.test.d.ts +1 -0
  69. package/components/DataGrid/tests/helpers/types.d.ts +1 -0
  70. package/components/DataGrid/tests/helpers/useCardsViewConfig.d.ts +24 -0
  71. package/components/DataGrid/tests/helpers/useCustomCardExample.d.ts +7 -0
  72. package/components/DataGrid/tests/hooks/useCardContent.test.d.ts +1 -0
  73. package/components/DataGrid/tests/hooks/useModalDetail.test.d.ts +1 -0
  74. package/components/DataGrid/tests/hooks/useModalSettingsCards.test.d.ts +1 -0
  75. package/components/DataGrid/tests/hooks/useProcessedColumns.test.d.ts +1 -0
  76. package/components/DataGrid/types.d.ts +87 -5
  77. package/components/DynamicFilter/helpers/formatToInitialFilters.js +3 -3
  78. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +11 -3
  79. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +16 -4
  80. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +11 -8
  81. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +21 -8
  82. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +18 -8
  83. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +5 -3
  84. package/components/EditLabel/hooks/useEditLabel.d.ts +1 -0
  85. package/components/LanguagePopover/LanguagePopover.js +2 -0
  86. package/components/MFIsolationApp/MFIsolationApp.js +3 -6
  87. package/components/MFIsolationApp/subcomponents/AppBarSettings/AppBarSettings.js +1 -1
  88. package/components/MFIsolationAppStorybook/MFIsolationAppStorybook.js +4 -20
  89. package/components/MFIsolationAppStorybook/types.d.ts +0 -4
  90. package/components/MenuActions/MenuActions.js +105 -55
  91. package/components/hook-form/RHFAutocomplete/RHFAutocomplete.d.ts +1 -1
  92. package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +4 -4
  93. package/components/hook-form/RHFAutocomplete/types.d.ts +2 -2
  94. package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js +4 -4
  95. package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteSlotsAsync.d.ts +1 -1
  96. package/components/mui_extended/Autocomplete/Autocomplete.d.ts +4 -8
  97. package/components/mui_extended/Autocomplete/Autocomplete.js +92 -67
  98. package/components/mui_extended/Autocomplete/Autocomplete.styles.js +11 -5
  99. package/components/mui_extended/Autocomplete/RenderAdornment/RenderAdornment.d.ts +6 -0
  100. package/components/mui_extended/Autocomplete/RenderAdornment/RenderAdornment.js +45 -0
  101. package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +2 -1
  102. package/components/mui_extended/Autocomplete/hooks/useStartAdornments.d.ts +4 -12
  103. package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +72 -23
  104. package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.d.ts +0 -2
  105. package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +0 -13
  106. package/components/mui_extended/Autocomplete/renderOptions/index.d.ts +4 -17
  107. package/components/mui_extended/Autocomplete/renderOptions/index.js +42 -5
  108. package/components/mui_extended/Autocomplete/renderOptions/types.d.ts +7 -0
  109. package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +2 -2
  110. package/components/mui_extended/Autocomplete/types.d.ts +10 -3
  111. package/components/mui_extended/MenuItem/MenuItem.styles.js +4 -1
  112. package/contexts/AppearanceComponentContext/AppearanceComponentContext.js +4 -1
  113. package/hooks/useDataGridPersistence/helpers.d.ts +2 -2
  114. package/hooks/useDataGridPersistence/useDataGridPersistence.d.ts +2 -2
  115. package/hooks/useDataGridPersistence/useDataGridPersistence.js +5 -0
  116. package/index.js +8 -8
  117. package/package.json +1 -1
  118. package/components/MFIsolationAppStorybook/icons.js +0 -6
  119. package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/AppBarSettings.d.ts +0 -4
  120. package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/AppBarSettings.js +0 -21
  121. package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/index.d.ts +0 -1
  122. package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/index.js +0 -1
@@ -0,0 +1,2 @@
1
+ import { ColumnsConfigRef, ConfigProps } from './types';
2
+ export declare const ColumnsConfigCards: import('react').ForwardRefExoticComponent<ConfigProps & import('react').RefAttributes<ColumnsConfigRef>>;
@@ -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,4 @@
1
+ /**
2
+ * Componente que renderiza el botón de cambio de vista en el DataGrid
3
+ */
4
+ export declare function ViewMode(): import("react/jsx-runtime").JSX.Element;
@@ -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 { l as ContentModalSettingStyled, D as DataGridRootStyled } from "../../../../../slots/DataGridSlot.js";
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,4 @@
1
+ export type ColumnsConfigRef = {
2
+ onClickIntro: () => void;
3
+ current: HTMLDivElement | null;
4
+ };
@@ -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 { m as TableContainerStyled, T as TableWrapperDataGridStyled } from "../../slots/DataGridSlot.js";
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 { e as DATAGRID_SEMANTIC_WIDTHS, f as DATAGRID_ACTIONS_COLUMN_KEY } from "../../../constants.js";
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, n as NameColumnStyled, I as IconColumnStyled, o as DraggableHeaderRootStyled, B as ButtonHeaderActionsStyled, p as DraggableWrapperInputBaseStyled, q as IconSearchStyled, H as HeaderInputBaseStyled } from "../../../slots/DataGridSlot.js";
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";
@@ -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, r as HeaderRenderClickStyled } from "../../../../slots/DataGridSlot.js";
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";