@m4l/components 9.4.13 → 9.4.15
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/AccountPopover/slots/AccountPopoverSlots.d.ts +6 -6
- package/components/ActionsGroup/slots/ActionsGroupSlots.d.ts +2 -2
- package/components/AppBar/slots/AppBarSlots.d.ts +1 -1
- package/components/Card/constants.d.ts +1 -1
- package/components/CheckableList/slots/styled.d.ts +9 -9
- package/components/Chip/slots/ChipSlots.d.ts +2 -2
- package/components/CommonActions/components/ActionCancel/slots/ActionsCancelSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionFormCancel/slots/ActionFormCancelSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionFormSubmitProgrammatic/slots/ActionFormSubmitProgrammaticSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionIntro/slots/ActionsIntroSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionsContainer/slots/ActionsContainerSlots.d.ts +1 -1
- package/components/DynamicFilter/slots/dynamicFilterSlots.d.ts +2 -2
- package/components/DynamicSort/slots/DynamicSortSlots.d.ts +2 -2
- package/components/EditLabel/slots/EditLabelSlots.d.ts +4 -4
- package/components/GridLayout/classes/index.d.ts +1 -1
- package/components/HelperError/slots/HelperErrorSlots.d.ts +1 -1
- package/components/ImageText/constants.d.ts +1 -1
- package/components/ImageText/slots/ImageTextSlots.d.ts +2 -2
- package/components/Label/slots/LabelSlots.d.ts +3 -3
- package/components/LanguagePopover/slots/LanguagePopoverSlots.d.ts +1 -1
- package/components/LoadingError/slots/LoadingErrorSlots.d.ts +1 -1
- package/components/MFIsolationApp/slots/MFIsolationAppSlots.d.ts +2 -2
- package/components/MenuActions/constants.d.ts +1 -1
- package/components/MenuActions/slots/MenuActionsSlots.d.ts +2 -2
- package/components/ModalDialog/slots/ModalDialogSlots.d.ts +2 -2
- package/components/NumberInput/hooks/useNumberInput/useNumberInput.js +0 -2
- package/components/NumberInput/slots/NumberInputSlots.d.ts +2 -2
- package/components/ObjectLogs/slots/ObjectLogsSlots.d.ts +2 -2
- package/components/Pager/slots/PagerSlots.d.ts +3 -3
- package/components/PaperForm/slots/PaperFormSlots.d.ts +1 -1
- package/components/SettingsLayout/slots/SettingsLayoutSlots.d.ts +3 -3
- package/components/SideBar/slots/SideBarSlots.d.ts +1 -1
- package/components/Stepper/slots/StepperSlot.d.ts +4 -4
- package/components/TabsNavigator/slots/TabsNavigatorSlots.d.ts +2 -2
- package/components/ToastContainer/slots/toastContainerSlots.d.ts +4 -4
- package/components/WindowBase/slots/WindowBaseSlots.d.ts +2 -2
- package/components/areas/components/AreasAdmin/slots/AreasAdminSlots.d.ts +3 -3
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow.d.ts +1 -1
- package/components/datagrids/Datagrid.styles.js +24 -0
- package/components/datagrids/components/BaseDataGrid/BaseDataGrid.d.ts +12 -0
- package/components/datagrids/components/BaseDataGrid/BaseDataGrid.js +131 -0
- package/components/datagrids/components/BaseDataGrid/index.d.ts +1 -0
- package/components/datagrids/components/BaseDataGrid/index.js +1 -0
- package/components/datagrids/components/DataGridMain/DataGridMain.js +22 -134
- package/components/datagrids/components/TreeDataGrid/TreeDataGrid.d.ts +22 -0
- package/components/datagrids/components/TreeDataGrid/TreeDataGrid.js +50 -0
- package/components/datagrids/components/TreeDataGrid/TreeDataGrid.test.d.ts +1 -0
- package/components/datagrids/components/TreeDataGrid/index.d.ts +1 -0
- package/components/datagrids/components/TreeDataGrid/index.js +1 -0
- package/components/datagrids/constants.js +3 -5
- package/components/datagrids/contexts/DataGridContext/DataGridContext.js +8 -4
- package/components/datagrids/contexts/DataGridContext/types.d.ts +19 -3
- package/components/datagrids/dictionary.d.ts +3 -0
- package/components/datagrids/dictionary.js +4 -0
- package/components/datagrids/formatters/ColumnBooleanFormatter/ColumnBooleanGroupFormatter.d.ts +15 -0
- package/components/datagrids/formatters/ColumnBooleanFormatter/ColumnBooleanGroupFormatter.js +32 -0
- package/components/datagrids/formatters/ColumnBooleanFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnBooleanFormatter/useColumnBoolean.d.ts +1 -0
- package/components/datagrids/formatters/ColumnBooleanFormatter/useColumnBoolean.js +2 -0
- package/components/datagrids/formatters/ColumnChipStatusFormatter/ColumnChipStatusGroupFormatter.d.ts +16 -0
- package/components/datagrids/formatters/ColumnChipStatusFormatter/ColumnChipStatusGroupFormatter.js +37 -0
- package/components/datagrids/formatters/ColumnChipStatusFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnChipStatusFormatter/useColumnChipStatus.d.ts +1 -0
- package/components/datagrids/formatters/ColumnChipStatusFormatter/useColumnChipStatus.js +2 -0
- package/components/datagrids/formatters/ColumnColorFormatter/ColumnColorGroupFormatter.d.ts +14 -0
- package/components/datagrids/formatters/ColumnColorFormatter/ColumnColorGroupFormatter.js +24 -0
- package/components/datagrids/formatters/ColumnColorFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnColorFormatter/useColumnColor.d.ts +1 -0
- package/components/datagrids/formatters/ColumnColorFormatter/useColumnColor.js +3 -1
- package/components/datagrids/formatters/ColumnConcatenatedValuesFormatter/ColumnConcatenatedValuesGroupFormatter.d.ts +15 -0
- package/components/datagrids/formatters/ColumnConcatenatedValuesFormatter/ColumnConcatenatedValuesGroupFormatter.js +35 -0
- package/components/datagrids/formatters/ColumnConcatenatedValuesFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnConcatenatedValuesFormatter/useColumnConcatenatedValues.d.ts +1 -0
- package/components/datagrids/formatters/ColumnConcatenatedValuesFormatter/useColumnConcatenatedValues.js +2 -0
- package/components/datagrids/formatters/ColumnDateFormatter/ColumnDateGroupFormatter.d.ts +9 -0
- package/components/datagrids/formatters/ColumnDateFormatter/ColumnDateGroupFormatter.js +35 -0
- package/components/datagrids/formatters/ColumnDateFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnDateFormatter/useColumnDate.d.ts +1 -0
- package/components/datagrids/formatters/ColumnDateFormatter/useColumnDate.js +2 -0
- package/components/datagrids/formatters/ColumnIconFormatter/ColumnIconGroupFormatter.d.ts +13 -0
- package/components/datagrids/formatters/ColumnIconFormatter/ColumnIconGroupFormatter.js +17 -0
- package/components/datagrids/formatters/ColumnIconFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnIconFormatter/useColumnIcon.d.ts +1 -0
- package/components/datagrids/formatters/ColumnIconFormatter/useColumnIcon.js +3 -1
- package/components/datagrids/formatters/ColumnImageFormatter/ColumnImageGroupFormatter.d.ts +15 -0
- package/components/datagrids/formatters/ColumnImageFormatter/ColumnImageGroupFormatter.js +33 -0
- package/components/datagrids/formatters/ColumnImageFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnImageFormatter/useColumnImage.d.ts +1 -0
- package/components/datagrids/formatters/ColumnImageFormatter/useColumnImage.js +3 -1
- package/components/datagrids/formatters/ColumnInteractiveCheckFormatter/formatter.d.ts +12 -1
- package/components/datagrids/formatters/ColumnInteractiveCheckFormatter/formatter.js +6 -0
- package/components/datagrids/formatters/ColumnNestedValueFormatter/ColumnNestedValueGroupFormatter.d.ts +14 -0
- package/components/datagrids/formatters/ColumnNestedValueFormatter/ColumnNestedValueGroupFormatter.js +22 -0
- package/components/datagrids/formatters/ColumnNestedValueFormatter/formatter.d.ts +33 -1
- package/components/datagrids/formatters/ColumnNestedValueFormatter/formatter.js +3 -2
- package/components/datagrids/formatters/ColumnNestedValueFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnNestedValueFormatter/types.d.ts +19 -1
- package/components/datagrids/formatters/ColumnNestedValueFormatter/useColumnNestedValue.d.ts +35 -2
- package/components/datagrids/formatters/ColumnNestedValueFormatter/useColumnNestedValue.js +24 -8
- package/components/datagrids/formatters/ColumnPointsFormatter/ColumnPointsGroupFormatter.d.ts +15 -0
- package/components/datagrids/formatters/ColumnPointsFormatter/ColumnPointsGroupFormatter.js +28 -0
- package/components/datagrids/formatters/ColumnPointsFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnPointsFormatter/useColumnPoints.d.ts +1 -0
- package/components/datagrids/formatters/ColumnPointsFormatter/useColumnPoints.js +2 -0
- package/components/datagrids/formatters/ColumnPriceFormatter/ColumnPriceGroupFormatter.d.ts +14 -0
- package/components/datagrids/formatters/ColumnPriceFormatter/ColumnPriceGroupFormatter.js +26 -0
- package/components/datagrids/formatters/ColumnPriceFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnPriceFormatter/useColumnPrice.d.ts +1 -0
- package/components/datagrids/formatters/ColumnPriceFormatter/useColumnPrice.js +2 -0
- package/components/datagrids/formatters/ColumnTagsFormatter/ColumnTagsGroupFormatter.d.ts +13 -0
- package/components/datagrids/formatters/ColumnTagsFormatter/ColumnTagsGroupFormatter.js +21 -0
- package/components/datagrids/formatters/ColumnTagsFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnTagsFormatter/useColumnTags.d.ts +1 -0
- package/components/datagrids/formatters/ColumnTagsFormatter/useColumnTags.js +2 -0
- package/components/datagrids/formatters/ColumnUncertaintyFormatter/ColumnUncertaintyGroupFormatter.d.ts +15 -0
- package/components/datagrids/formatters/ColumnUncertaintyFormatter/ColumnUncertaintyGroupFormatter.js +27 -0
- package/components/datagrids/formatters/ColumnUncertaintyFormatter/index.d.ts +1 -0
- package/components/datagrids/formatters/ColumnUncertaintyFormatter/useColumnUncertainty.d.ts +1 -0
- package/components/datagrids/formatters/ColumnUncertaintyFormatter/useColumnUncertainty.js +2 -0
- package/components/datagrids/helpers/shared/getInitialColumnsConfig/getInitialColumnsConfig.js +8 -0
- package/components/datagrids/helpers/shared/getViewSpecificConfig/getViewSpecificConfig.js +10 -3
- package/components/datagrids/hooks/useChangeColumnsOrder/useChangeColumnsOrder.d.ts +1 -0
- package/components/datagrids/hooks/useChangeColumnsOrder/useChangeColumnsOrder.js +12 -4
- package/components/datagrids/icons.d.ts +5 -0
- package/components/datagrids/icons.js +5 -1
- package/components/datagrids/index.d.ts +2 -1
- package/components/datagrids/slots/DataGridEnum.d.ts +3 -1
- package/components/datagrids/slots/DataGridEnum.js +2 -0
- package/components/datagrids/slots/DataGridSlot.d.ts +2 -0
- package/components/datagrids/slots/DataGridSlot.js +12 -2
- package/components/datagrids/tests/helpers/types.d.ts +10 -0
- package/components/datagrids/types.d.ts +52 -0
- package/components/datagrids/views/CardsView/hooks/useProcessedColumns/useProcessedColumns.d.ts +2 -0
- package/components/datagrids/views/CardsView/hooks/useProcessedColumns/useProcessedColumns.js +3 -2
- package/components/datagrids/views/TableView/TableView.d.ts +4 -4
- package/components/datagrids/views/TableView/TableView.js +41 -3
- package/components/datagrids/views/TableView/helpers/defaultRowGrouper/defaultRowGrouper.d.ts +28 -0
- package/components/datagrids/views/TableView/helpers/defaultRowGrouper/defaultRowGrouper.js +15 -0
- package/components/datagrids/views/TableView/helpers/defaultRowGrouper/defaultRowGrouper.test.d.ts +1 -0
- package/components/datagrids/views/TableView/helpers/defaultRowGrouper/index.d.ts +1 -0
- package/components/datagrids/views/TableView/helpers/defaultRowGrouper/index.js +1 -0
- package/components/datagrids/views/TableView/helpers/getGroupBy/getGroupBy.d.ts +20 -0
- package/components/datagrids/views/TableView/helpers/getGroupBy/getGroupBy.js +13 -0
- package/components/datagrids/views/TableView/helpers/getGroupBy/getGroupBy.test.d.ts +1 -0
- package/components/datagrids/views/TableView/helpers/getGroupBy/index.d.ts +1 -0
- package/components/datagrids/views/TableView/helpers/getGroupBy/index.js +1 -0
- package/components/datagrids/views/TableView/helpers/index.d.ts +2 -0
- package/components/datagrids/views/TableView/hooks/useHeaderMenuActions/useHeaderMenuActions.js +62 -1
- package/components/datagrids/views/TableView/hooks/useSortColumnsRows/useSortColumnsRows.js +39 -13
- package/components/datagrids/views/TableView/subcomponents/ActionsColumn/ActionsColumn.js +1 -1
- package/components/datagrids/views/TableView/subcomponents/HeaderRenderClick/HeaderRenderClick.js +1 -1
- package/components/datagrids/views/TableView/subcomponents/RadioSelectColumn/RadioSelectColumn.js +2 -2
- package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/RenderGroupCell.d.ts +10 -0
- package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/RenderGroupCell.js +35 -0
- package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/RenderGroupCell.test.d.ts +1 -0
- package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/index.d.ts +2 -0
- package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/index.js +1 -0
- package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/types.d.ts +12 -0
- package/components/datagrids/views/TableView/subcomponents/SelectColumn/SelectColumn.js +46 -14
- package/components/datagrids/views/TableView/subcomponents/Settings/hooks/useModalSettings/useModalSettings.js +13 -2
- package/components/datagrids/views/TableView/subcomponents/Settings/subcomponents/ColumnsConfig/ColumnsConfig.js +47 -13
- package/components/datagrids/views/TableView/subcomponents/Settings/subcomponents/ColumnsConfig/types.d.ts +22 -0
- package/components/datagrids/views/adapters/CheckboxCellAdapter/CheckboxCellAdapter.js +1 -1
- package/components/extended/React-Resizable/Resizable/slots/ResizableSlots.d.ts +1 -1
- package/components/extended/React-Resizable/ResizableBox/slots/ResizableBoxSlots.d.ts +1 -1
- package/components/extended/React-resizable-panels/slots/SplitLayoutSlots.d.ts +6 -6
- package/components/formatters/BooleanFormatter/slots/BooleanFormatterSlots.d.ts +1 -1
- package/components/formatters/ConcatenatedFormatter/slots/ConcatenatedFormatterSlots.d.ts +1 -1
- package/components/formatters/DateFormatter/slots/DateFormatterSlots.d.ts +1 -1
- package/components/formatters/DistanceToNowFormatter/slots/DistanceToNowFormatterSlots.d.ts +1 -1
- package/components/formatters/ImageFormatter/slots/ImageFormatterSlots.d.ts +1 -1
- package/components/formatters/PeriodFormatter/slots/PeriodFormatterSlots.d.ts +1 -1
- package/components/formatters/PointsFormatter/slots/ointsFormatterSlots.d.ts +1 -1
- package/components/formatters/PriceFormatter/slots/PriceFormatterSlots.d.ts +1 -1
- package/components/formatters/UncertaintyFormatter/slots/UncertaintyFormatterSlots.d.ts +1 -1
- package/components/hook-form/RHFAutocompleteAsync/reducer/RHFAutocompleteReducer.js +0 -5
- package/components/hook-form/RHFCheckbox/slots/RHFCheckBoxSlots.d.ts +1 -1
- package/components/hook-form/RHFColorPicker/slots/RHFColorPickerSlots.d.ts +1 -1
- package/components/hook-form/RHFDatePicker/slots/RHFDatePickerSlots.d.ts +3 -3
- package/components/hook-form/RHFPeriod/slots/RHFPeriodSlots.d.ts +1 -1
- package/components/hook-form/RHFSelect/constants.d.ts +1 -1
- package/components/hook-form/RHFSelect/slots/RHFSlots.d.ts +1 -1
- package/components/hook-form/RHFTextField/slots/RHFTextFieldSlots.d.ts +1 -1
- package/components/hook-form/RHFTextFieldPassword/slots/RHFTextFieldPasswordSlots.d.ts +2 -2
- package/components/hook-form/RHFUpload/RHFUploadImage/slots/RHFUploadImageSlots.d.ts +3 -3
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/constants.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.d.ts +7 -7
- package/components/hook-form/RHFormProvider/classes/index.d.ts +1 -1
- package/components/mui_extended/Accordion/slots/AccordionSlots.d.ts +3 -3
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +6 -6
- package/components/mui_extended/Avatar/slots/AvatarSlots.d.ts +1 -1
- package/components/mui_extended/Badge/slots/BadgeSlots.d.ts +1 -1
- package/components/mui_extended/Button/slots/ButtonSlots.d.ts +2 -2
- package/components/mui_extended/CheckBox/slots/CheckBoxSlots.d.ts +2 -2
- package/components/mui_extended/DatePicker/constants.d.ts +1 -1
- package/components/mui_extended/DatePicker/slots/DatePickerSlots.d.ts +3 -3
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerSlots.d.ts +4 -4
- package/components/mui_extended/Divider/slots/DividerSlots.d.ts +1 -1
- package/components/mui_extended/IconButton/constants.d.ts +1 -1
- package/components/mui_extended/IconButton/slots/IconButtonSlots.d.ts +1 -1
- package/components/mui_extended/LoadingButton/slots/LoadingButtonSlots.d.ts +1 -1
- package/components/mui_extended/MenuDivider/slots/MenuDividerSlots.d.ts +1 -1
- package/components/mui_extended/MenuItem/slots/MenuItemSlots.d.ts +2 -2
- package/components/mui_extended/NavLink/slots/NavLinkSlots.d.ts +1 -1
- package/components/mui_extended/Popper/slots/PopperStlots.d.ts +1 -1
- package/components/mui_extended/Radio/slots/styled.d.ts +2 -2
- package/components/mui_extended/Select/constants.d.ts +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.d.ts +5 -5
- package/components/mui_extended/Skeleton/Slots/skeletonSlots.d.ts +1 -1
- package/components/mui_extended/Stack/slots/StackSlot.d.ts +1 -1
- package/components/mui_extended/Tab/Slots/TabSlots.d.ts +2 -2
- package/components/mui_extended/Tabs/slots/TabsSlots.d.ts +1 -1
- package/components/mui_extended/TextField/constants.d.ts +1 -1
- package/components/mui_extended/TextField/slots/TextFieldSlots.d.ts +4 -4
- package/components/mui_extended/TimePicker/slots/TimePickerSlots.d.ts +3 -3
- package/components/mui_extended/ToggleButton/slots/ToggleButtonSlots.d.ts +1 -1
- package/components/mui_extended/ToggleIconButton/slots/ToggleIconButtonSlots.d.ts +1 -1
- package/components/mui_extended/Typography/slots/typographySlots.d.ts +1 -1
- package/hooks/useDynamicFilterAndSort/slots/DynamicFilterAndSortSlots.d.ts +4 -4
- package/index.js +108 -82
- package/not_recognized/index.js +25 -100
- package/package.json +1 -1
- package/test/mocks.d.ts +2 -2
package/components/datagrids/views/TableView/hooks/useHeaderMenuActions/useHeaderMenuActions.js
CHANGED
|
@@ -123,6 +123,24 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable, handleSo
|
|
|
123
123
|
columnKey
|
|
124
124
|
});
|
|
125
125
|
}, [columnKey, column, externalFilterSettings]);
|
|
126
|
+
const canGroup = useMemo(() => {
|
|
127
|
+
if (!columnKey || !column) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return column.groupable === true;
|
|
131
|
+
}, [columnKey, column]);
|
|
132
|
+
const isGrouped = useMemo(() => {
|
|
133
|
+
if (!columnKey) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const colConfig = columnsConfig.find((c) => c.key === columnKey);
|
|
137
|
+
return colConfig?.grouped === true;
|
|
138
|
+
}, [columnKey, columnsConfig]);
|
|
139
|
+
const hasGroupableColumns = useMemo(() => {
|
|
140
|
+
return finalColumns.some(
|
|
141
|
+
(col) => col.groupable === true || col.grouped === true
|
|
142
|
+
);
|
|
143
|
+
}, [finalColumns]);
|
|
126
144
|
const isAddFilterDisabled = useMemo(() => {
|
|
127
145
|
if (!columnKey || !column) {
|
|
128
146
|
return true;
|
|
@@ -229,6 +247,44 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable, handleSo
|
|
|
229
247
|
disabled: isAddFilterDisabled
|
|
230
248
|
}
|
|
231
249
|
] : [];
|
|
250
|
+
const toggleGrouped = (grouped) => {
|
|
251
|
+
if (!columnKey) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const currentGroupedColumns = columnsConfig.filter((c) => c.grouped);
|
|
255
|
+
const newGroupOrder = grouped ? currentGroupedColumns.length : 0;
|
|
256
|
+
const next = columnsConfig.map(
|
|
257
|
+
(c) => c.key === columnKey ? {
|
|
258
|
+
...c,
|
|
259
|
+
grouped,
|
|
260
|
+
groupOrder: grouped ? newGroupOrder : c.groupOrder
|
|
261
|
+
} : c
|
|
262
|
+
);
|
|
263
|
+
onChangeColumnsConfig("table", next);
|
|
264
|
+
};
|
|
265
|
+
const groupActions = hasGroupableColumns ? [
|
|
266
|
+
{
|
|
267
|
+
type: "menuItem",
|
|
268
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.group}`,
|
|
269
|
+
label: getLabel(DICTIONARY.GROUP_BY_COLUMN),
|
|
270
|
+
dataTestId: "group-add",
|
|
271
|
+
onClick: () => {
|
|
272
|
+
toggleGrouped(true);
|
|
273
|
+
},
|
|
274
|
+
disabled: !canGroup || isGrouped
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
type: "menuItem",
|
|
278
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.removeGroup}`,
|
|
279
|
+
label: getLabel(DICTIONARY.REMOVE_GROUP_COLUMN),
|
|
280
|
+
dataTestId: "group-remove",
|
|
281
|
+
onClick: () => {
|
|
282
|
+
toggleGrouped(false);
|
|
283
|
+
},
|
|
284
|
+
// Solo deshabilitado si no está agrupada O si es una agrupación estática (groupable=false)
|
|
285
|
+
disabled: !isGrouped || !canGroup
|
|
286
|
+
}
|
|
287
|
+
] : [];
|
|
232
288
|
const baseActions = [
|
|
233
289
|
{
|
|
234
290
|
type: "menuItem",
|
|
@@ -246,9 +302,10 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable, handleSo
|
|
|
246
302
|
dataTestId: "hide-column"
|
|
247
303
|
}
|
|
248
304
|
];
|
|
249
|
-
return [...sortActions, ...filterAction, ...baseActions];
|
|
305
|
+
return [...sortActions, ...filterAction, ...groupActions, ...baseActions];
|
|
250
306
|
}, [
|
|
251
307
|
columnKey,
|
|
308
|
+
column,
|
|
252
309
|
canSort,
|
|
253
310
|
canSortExternally,
|
|
254
311
|
hasExternalSortAsc,
|
|
@@ -258,8 +315,12 @@ function useHeaderMenuActions(columnKey, finalColumns, defaultSortable, handleSo
|
|
|
258
315
|
toggleFrozen,
|
|
259
316
|
toggleVisible,
|
|
260
317
|
columnsConfig,
|
|
318
|
+
onChangeColumnsConfig,
|
|
261
319
|
externalSortSettings,
|
|
262
320
|
externalFilterSettings,
|
|
321
|
+
hasGroupableColumns,
|
|
322
|
+
canGroup,
|
|
323
|
+
isGrouped,
|
|
263
324
|
host_static_assets,
|
|
264
325
|
environment_assets,
|
|
265
326
|
getLabel,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { useState, useEffect, useMemo } from "react";
|
|
2
3
|
import { useModuleSkeleton, getPropertyByString } from "@m4l/core";
|
|
3
|
-
import {
|
|
4
|
+
import { SELECT_COLUMN_KEY } from "react-data-grid";
|
|
4
5
|
import { g as getDragHeaderRenderer } from "../../helpers/getDragHeaderRenderer/getDragHeaderRenderer.js";
|
|
5
6
|
import { S as SkeletonFormatter } from "../../subcomponents/SkeletonFormatter/SkeletonFormatter.js";
|
|
6
7
|
import { a as filterColumnClassName, S as SelectColumn } from "../../subcomponents/SelectColumn/SelectColumn.js";
|
|
8
|
+
import { R as RenderGroupCell } from "../../subcomponents/RenderGroupCell/RenderGroupCell.js";
|
|
7
9
|
import { A as ActionsColumn } from "../../subcomponents/ActionsColumn/ActionsColumn.js";
|
|
8
10
|
import { R as RadioSelectColumn } from "../../subcomponents/RadioSelectColumn/RadioSelectColumn.js";
|
|
9
11
|
import { u as useDataGrid } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
|
|
@@ -18,7 +20,6 @@ function getComparator(columns, sortColumn) {
|
|
|
18
20
|
return column.customSort;
|
|
19
21
|
}
|
|
20
22
|
switch (typeOrder) {
|
|
21
|
-
//Si el tipo de dato de la columna es un numerico, retorna una función de ordenamiento numérica
|
|
22
23
|
case "number":
|
|
23
24
|
return (a, b) => {
|
|
24
25
|
try {
|
|
@@ -27,7 +28,6 @@ function getComparator(columns, sortColumn) {
|
|
|
27
28
|
return -1;
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
|
-
//Por defecto retorna una función de ordenamiento de string
|
|
31
31
|
default:
|
|
32
32
|
return (a, b) => {
|
|
33
33
|
try {
|
|
@@ -39,6 +39,12 @@ function getComparator(columns, sortColumn) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
const getColumIndex = (key, columnsConfig) => columnsConfig.findIndex((columnConfig) => columnConfig.key === key);
|
|
42
|
+
const findKeyInColumns = (key, columns) => {
|
|
43
|
+
const index = columns.findIndex(
|
|
44
|
+
(column) => key === column.key && column.hidden === false
|
|
45
|
+
);
|
|
46
|
+
return index !== -1;
|
|
47
|
+
};
|
|
42
48
|
const getInOrderColumns = (columns, hasCheckedRows, checkedRowsMultiple, columnsConfig, columnsWidths, rowActionsGetter) => {
|
|
43
49
|
let filteredSortedColumns = columns.filter((column) => {
|
|
44
50
|
const columnConfigIndex = getColumIndex(column.key, columnsConfig);
|
|
@@ -100,12 +106,6 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
100
106
|
);
|
|
101
107
|
const isSkeleton = useModuleSkeleton();
|
|
102
108
|
const { activeFilters, filters } = useFilters();
|
|
103
|
-
const findKeyInColumns = (key, cols) => {
|
|
104
|
-
const index = cols.findIndex(
|
|
105
|
-
(column) => key === column.key && column.hidden === false
|
|
106
|
-
);
|
|
107
|
-
return index !== -1;
|
|
108
|
-
};
|
|
109
109
|
useEffect(() => {
|
|
110
110
|
setColumns(
|
|
111
111
|
getInOrderColumns(
|
|
@@ -124,7 +124,17 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
124
124
|
if (JSON.stringify(finalSortedColumns) !== JSON.stringify(sortColumns)) {
|
|
125
125
|
setSortColumns(finalSortedColumns);
|
|
126
126
|
}
|
|
127
|
-
}, [
|
|
127
|
+
}, [
|
|
128
|
+
sourceColumns,
|
|
129
|
+
columnsConfig,
|
|
130
|
+
rowActionsGetter,
|
|
131
|
+
checkedRows,
|
|
132
|
+
onCheckedRowsChange,
|
|
133
|
+
checkedRowsMultiple,
|
|
134
|
+
columnsWidths,
|
|
135
|
+
sortColumns,
|
|
136
|
+
setSortColumns
|
|
137
|
+
]);
|
|
128
138
|
const finalColumns = useMemo(() => {
|
|
129
139
|
const DragAndDropHeaderRenderer = getDragHeaderRenderer(
|
|
130
140
|
(sourceKey, targetKey) => onChangeColumnsOrder("table", sourceKey, targetKey),
|
|
@@ -139,7 +149,7 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
139
149
|
cellClass,
|
|
140
150
|
headerCellClass: cellClass
|
|
141
151
|
};
|
|
142
|
-
if (newColumn.key ===
|
|
152
|
+
if (newColumn.key === SELECT_COLUMN_KEY || newColumn.isDraggable !== void 0 && newColumn.isDraggable === false) {
|
|
143
153
|
return newColumn;
|
|
144
154
|
}
|
|
145
155
|
if (isSkeleton) {
|
|
@@ -161,6 +171,20 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
161
171
|
newColumn.headerCellClass = `${newColumn.headerCellClass} ${filterColumnClassName}`.trim();
|
|
162
172
|
}
|
|
163
173
|
newColumn.renderHeaderCell = DragAndDropHeaderRenderer;
|
|
174
|
+
const columnConfig = columnsConfig.find((cfg) => cfg.key === c.key);
|
|
175
|
+
const isGroupedInConfig = columnConfig?.grouped === true;
|
|
176
|
+
const originalColumn = sourceColumns.find((col) => col.key === c.key);
|
|
177
|
+
const hasCustomGroupCell = originalColumn?.renderGroupCell !== void 0;
|
|
178
|
+
if (isGroupedInConfig) {
|
|
179
|
+
const customGroupCell = hasCustomGroupCell ? originalColumn?.renderGroupCell : void 0;
|
|
180
|
+
newColumn.renderGroupCell = (cellProps) => /* @__PURE__ */ jsx(
|
|
181
|
+
RenderGroupCell,
|
|
182
|
+
{
|
|
183
|
+
...cellProps,
|
|
184
|
+
customRenderGroupCell: customGroupCell
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
}
|
|
164
188
|
return newColumn;
|
|
165
189
|
});
|
|
166
190
|
}, [
|
|
@@ -168,7 +192,9 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
168
192
|
columns,
|
|
169
193
|
activeFilters,
|
|
170
194
|
onChangeColumnsOrder,
|
|
171
|
-
popoverHandlers
|
|
195
|
+
popoverHandlers,
|
|
196
|
+
columnsConfig,
|
|
197
|
+
sourceColumns
|
|
172
198
|
]);
|
|
173
199
|
const finalRows = useMemo(() => {
|
|
174
200
|
const nextRows = sourceRows.filter((r) => {
|
|
@@ -226,7 +252,7 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
|
226
252
|
return 0;
|
|
227
253
|
});
|
|
228
254
|
return nextRows;
|
|
229
|
-
}, [sourceRows, sortColumns, filters]);
|
|
255
|
+
}, [sourceRows, sortColumns, filters, columns]);
|
|
230
256
|
return { finalColumns, sortColumns, setSortColumns, finalRows };
|
|
231
257
|
};
|
|
232
258
|
export {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { e as DATAGRID_SEMANTIC_WIDTHS, d as DATAGRID_ACTIONS_COLUMN_KEY } from "../../../../constants.js";
|
|
3
3
|
import { u as useDataGrid } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
|
|
4
4
|
import { M as MenuActions } from "../../../../../MenuActions/MenuActions.js";
|
|
5
5
|
function ActionsFormatter(props) {
|
package/components/datagrids/views/TableView/subcomponents/HeaderRenderClick/HeaderRenderClick.js
CHANGED
|
@@ -6,7 +6,7 @@ import { P as MenuListStyled, Q as HeaderRenderClickStyled } from "../../../../s
|
|
|
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";
|
|
9
|
-
import {
|
|
9
|
+
import { f as DATAGRID_HEADER_RENDER_CLICK_KEY } from "../../../../constants.js";
|
|
10
10
|
import { u as useFilters } from "../../../../hooks/shared/useFilters/useFilters.js";
|
|
11
11
|
function HeaderRenderClick(props) {
|
|
12
12
|
const {
|
package/components/datagrids/views/TableView/subcomponents/RadioSelectColumn/RadioSelectColumn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { SELECT_COLUMN_KEY } from "react-data-grid";
|
|
3
3
|
import { u as useDataGrid } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
|
|
4
4
|
import { R as RadioFormatter } from "./subcomponents/RadioFormatter/RadioFormatter.js";
|
|
5
5
|
function RadioSelectGroupFormatter(_props) {
|
|
@@ -28,7 +28,7 @@ function RadioSelectColumnHeaderRenderer(_props) {
|
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
30
|
const RadioSelectColumn = {
|
|
31
|
-
key:
|
|
31
|
+
key: SELECT_COLUMN_KEY,
|
|
32
32
|
name: "",
|
|
33
33
|
width: 32,
|
|
34
34
|
minWidth: 32,
|
package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/RenderGroupCell.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RenderGroupCellComponentProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente para renderizar las celdas de grupo en TreeDataGrid.
|
|
4
|
+
* Siempre muestra un icono de expansión/colapso al inicio.
|
|
5
|
+
* Si se proporciona customRenderGroupCell, renderiza ese contenido después del icono.
|
|
6
|
+
* De lo contrario, muestra el texto del grupo (groupKey).
|
|
7
|
+
* Respeta la alineación de la columna (align: left | center | right).
|
|
8
|
+
* @param props - Props de react-data-grid para grupo + customRenderGroupCell opcional
|
|
9
|
+
*/
|
|
10
|
+
export declare function RenderGroupCell<TRow>(props: RenderGroupCellComponentProps<TRow>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEnvironment } from "@m4l/core";
|
|
3
|
+
import { p as pathIcons } from "../../../../icons.js";
|
|
4
|
+
import { I as Icon } from "../../../../../Icon/Icon.js";
|
|
5
|
+
import { S as DefaultRenderGroupCellRootStyled, U as DefaultRenderGroupCellTextStyled } from "../../../../slots/DataGridSlot.js";
|
|
6
|
+
import { u as useDataGrid } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
|
|
7
|
+
function RenderGroupCell(props) {
|
|
8
|
+
const { groupKey, isExpanded, toggleGroup, column, customRenderGroupCell, ...restProps } = props;
|
|
9
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
10
|
+
const { size, currentRowHeightVariant } = useDataGrid();
|
|
11
|
+
const iconPath = isExpanded ? pathIcons.groupDown : pathIcons.groupUp;
|
|
12
|
+
const fullIconPath = `${host_static_assets}/${environment_assets}/${iconPath}`;
|
|
13
|
+
const align = column.align;
|
|
14
|
+
const originalProps = {
|
|
15
|
+
groupKey,
|
|
16
|
+
isExpanded,
|
|
17
|
+
toggleGroup,
|
|
18
|
+
column,
|
|
19
|
+
...restProps
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ jsxs(DefaultRenderGroupCellRootStyled, { ownerState: { align }, onClick: toggleGroup, children: [
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
Icon,
|
|
24
|
+
{
|
|
25
|
+
src: fullIconPath,
|
|
26
|
+
size,
|
|
27
|
+
ariaLabel: isExpanded ? "Colapsar grupo" : "Expandir grupo"
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
customRenderGroupCell ? customRenderGroupCell(originalProps) : /* @__PURE__ */ jsx(DefaultRenderGroupCellTextStyled, { ownerState: { currentRowHeightVariant }, children: String(groupKey) })
|
|
31
|
+
] });
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
RenderGroupCell as R
|
|
35
|
+
};
|
package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/RenderGroupCell.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RenderGroupCellProps } from 'react-data-grid';
|
|
3
|
+
/**
|
|
4
|
+
* Props para RenderGroupCell que permiten contenido personalizado.
|
|
5
|
+
*/
|
|
6
|
+
export interface RenderGroupCellComponentProps<TRow> extends RenderGroupCellProps<TRow> {
|
|
7
|
+
/**
|
|
8
|
+
* Función opcional para renderizar contenido personalizado después del icono.
|
|
9
|
+
* Si se proporciona, se renderiza en lugar del texto por defecto (groupKey).
|
|
10
|
+
*/
|
|
11
|
+
customRenderGroupCell?: (props: RenderGroupCellProps<TRow>) => ReactNode;
|
|
12
|
+
}
|
|
@@ -1,21 +1,49 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { d as DATAGRID_SELECT_COLUMN_KEY } from "../../../../constants.js";
|
|
2
|
+
import { SELECT_COLUMN_KEY, SelectCellFormatter } from "react-data-grid";
|
|
4
3
|
import { u as useDataGrid } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
|
|
5
4
|
const filterColumnClassName = "filter-cell";
|
|
6
5
|
const filterHeight = 35;
|
|
6
|
+
function getAllChildRowIds(childRows, rowKeyGetter) {
|
|
7
|
+
const ids = [];
|
|
8
|
+
for (const row of childRows) {
|
|
9
|
+
if ("childRows" in row && Array.isArray(row.childRows)) {
|
|
10
|
+
ids.push(...getAllChildRowIds(row.childRows, rowKeyGetter));
|
|
11
|
+
} else {
|
|
12
|
+
ids.push(rowKeyGetter(row));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return ids;
|
|
16
|
+
}
|
|
7
17
|
function SelectGroupFormatter(props) {
|
|
8
|
-
const {
|
|
18
|
+
const { checkedRows, onCheckedRowsChange, rowKeyGetter } = useDataGrid();
|
|
19
|
+
const { childRows } = props;
|
|
20
|
+
const childRowIds = getAllChildRowIds(childRows, rowKeyGetter);
|
|
21
|
+
const selectedCount = childRowIds.filter((id) => checkedRows?.has(id)).length;
|
|
22
|
+
const totalCount = childRowIds.length;
|
|
23
|
+
const allChildrenChecked = totalCount > 0 && selectedCount === totalCount;
|
|
24
|
+
const someChildrenChecked = selectedCount > 0 && selectedCount < totalCount;
|
|
9
25
|
const onChange = (checked) => {
|
|
10
|
-
|
|
26
|
+
if (!onCheckedRowsChange) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const newCheckedRows = new Set(checkedRows);
|
|
30
|
+
if (checked) {
|
|
31
|
+
childRowIds.forEach((id) => newCheckedRows.add(id));
|
|
32
|
+
} else {
|
|
33
|
+
childRowIds.forEach((id) => newCheckedRows.delete(id));
|
|
34
|
+
}
|
|
35
|
+
onCheckedRowsChange(newCheckedRows);
|
|
11
36
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
SelectCellFormatter,
|
|
39
|
+
{
|
|
40
|
+
value: allChildrenChecked,
|
|
41
|
+
indeterminate: someChildrenChecked,
|
|
42
|
+
tabIndex: props.tabIndex,
|
|
43
|
+
onChange,
|
|
44
|
+
"aria-label": "Select Group"
|
|
45
|
+
}
|
|
46
|
+
);
|
|
19
47
|
}
|
|
20
48
|
function SelectFormatter(props) {
|
|
21
49
|
const { checkedRows, onCheckedRowsChange, rowKeyGetter } = useDataGrid();
|
|
@@ -40,26 +68,30 @@ function SelectFormatter(props) {
|
|
|
40
68
|
}
|
|
41
69
|
const SelectColumnHeaderRenderer = (props) => {
|
|
42
70
|
const { rows, rowKeyGetter, onCheckedRowsChange, checkedRows } = useDataGrid();
|
|
71
|
+
const selectedCount = checkedRows?.size ?? 0;
|
|
72
|
+
const totalCount = rows.length;
|
|
73
|
+
const allRowsChecked = totalCount > 0 && selectedCount === totalCount;
|
|
74
|
+
const someRowsChecked = selectedCount > 0 && selectedCount < totalCount;
|
|
43
75
|
const onAllRowsCheckedChange = (checked) => {
|
|
44
76
|
if (!onCheckedRowsChange) {
|
|
45
77
|
return;
|
|
46
78
|
}
|
|
47
79
|
if (checked) {
|
|
48
|
-
onCheckedRowsChange(new Set(rows.map((
|
|
80
|
+
onCheckedRowsChange(new Set(rows.map((row) => rowKeyGetter(row))));
|
|
49
81
|
} else {
|
|
50
82
|
onCheckedRowsChange(/* @__PURE__ */ new Set());
|
|
51
83
|
}
|
|
52
84
|
};
|
|
53
|
-
const allRowsChecked = rows.length === checkedRows?.size;
|
|
54
85
|
return SelectCellFormatter({
|
|
55
86
|
"aria-label": "Select All",
|
|
56
87
|
tabIndex: props.tabIndex,
|
|
57
88
|
value: allRowsChecked,
|
|
89
|
+
indeterminate: someRowsChecked,
|
|
58
90
|
onChange: onAllRowsCheckedChange
|
|
59
91
|
});
|
|
60
92
|
};
|
|
61
93
|
const SelectColumn = {
|
|
62
|
-
key:
|
|
94
|
+
key: SELECT_COLUMN_KEY,
|
|
63
95
|
name: "",
|
|
64
96
|
width: 32,
|
|
65
97
|
minWidth: 32,
|
|
@@ -11,13 +11,24 @@ import { u as useDataGrid } from "../../../../../../hooks/shared/useDataGrid/use
|
|
|
11
11
|
import { W as WindowBase } from "../../../../../../../WindowBase/WindowBase.js";
|
|
12
12
|
import { A as ActionCancel } from "../../../../../../../CommonActions/components/ActionCancel/ActionCancel.js";
|
|
13
13
|
import { A as ActionIntro } from "../../../../../../../CommonActions/components/ActionIntro/ActionIntro.js";
|
|
14
|
+
const BASE_MODAL_WIDTH = 520;
|
|
15
|
+
const GROUP_COLUMN_WIDTH = 80;
|
|
14
16
|
const useModalSettings = (size, columns) => {
|
|
15
17
|
const { openModal, closeModal } = useModal();
|
|
16
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
columnsConfig,
|
|
20
|
+
onChangeColumnsConfig,
|
|
21
|
+
currentRowHeight,
|
|
22
|
+
classes
|
|
23
|
+
} = useDataGrid();
|
|
17
24
|
const { getLabel } = useModuleDictionary();
|
|
18
25
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
19
26
|
const isMobile = useIsMobile();
|
|
20
27
|
const ref = useRef(null);
|
|
28
|
+
const hasGroupableColumns = columns.some(
|
|
29
|
+
(col) => col.groupable === true || col.grouped === true
|
|
30
|
+
);
|
|
31
|
+
const modalWidth = hasGroupableColumns ? BASE_MODAL_WIDTH + GROUP_COLUMN_WIDTH : BASE_MODAL_WIDTH;
|
|
21
32
|
const onCloseSettings = useCallback(() => {
|
|
22
33
|
closeModal();
|
|
23
34
|
}, [closeModal]);
|
|
@@ -31,7 +42,7 @@ const useModalSettings = (size, columns) => {
|
|
|
31
42
|
};
|
|
32
43
|
const onClickSettings = () => {
|
|
33
44
|
openModal({
|
|
34
|
-
initialWidth:
|
|
45
|
+
initialWidth: modalWidth,
|
|
35
46
|
initialHeight: 680,
|
|
36
47
|
fullScreen: isMobile,
|
|
37
48
|
window: /* @__PURE__ */ jsx(
|
|
@@ -8,17 +8,24 @@ import { v as ColumnsConfigWrapperStyled, w as ColumnsConfigDataGridStyled, x as
|
|
|
8
8
|
import { D as DICTIONARY } from "../../../../../../dictionary.js";
|
|
9
9
|
import { C as ColumnInteractiveCheckFormatter } from "../../../../../../formatters/ColumnInteractiveCheckFormatter/formatter.js";
|
|
10
10
|
function getRowsFromColumnsConfig(columnsConfig, columns) {
|
|
11
|
-
return columnsConfig.filter((cConfig) => !cConfig.hidden).map(
|
|
12
|
-
(
|
|
11
|
+
return columnsConfig.filter((cConfig) => !cConfig.hidden).map((cConfig) => {
|
|
12
|
+
const originalColumn = columns.find((c) => c.key === cConfig.key);
|
|
13
|
+
const isGroupable = originalColumn?.groupable === true;
|
|
14
|
+
const isGroupedNow = cConfig.grouped === true;
|
|
15
|
+
return {
|
|
13
16
|
key: cConfig.key,
|
|
14
17
|
name: columns?.find((c) => c.key === cConfig.key)?.name ?? "",
|
|
15
18
|
visible: cConfig.visible === void 0 ? true : cConfig.visible,
|
|
16
19
|
frozen: cConfig.frozen === void 0 ? false : cConfig.frozen,
|
|
20
|
+
grouped: isGroupedNow,
|
|
21
|
+
// Checkbox habilitado solo si groupable=true
|
|
22
|
+
groupable: isGroupable,
|
|
17
23
|
originalIndex: cConfig.originalIndex,
|
|
18
24
|
originalFrozen: cConfig.originalFrozen,
|
|
19
|
-
originalVisible: cConfig.originalVisible
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
originalVisible: cConfig.originalVisible,
|
|
26
|
+
originalGrouped: cConfig.originalGrouped ?? false
|
|
27
|
+
};
|
|
28
|
+
});
|
|
22
29
|
}
|
|
23
30
|
const getAlignClass = (align) => {
|
|
24
31
|
const cellClass = align !== void 0 ? `rdg-cell-align-${align}` : "";
|
|
@@ -51,8 +58,8 @@ const ColumnsConfig = forwardRef(
|
|
|
51
58
|
onClickIntro: handleIntro,
|
|
52
59
|
current: divRef.current
|
|
53
60
|
}));
|
|
54
|
-
const columnsdata_grid = useMemo(
|
|
55
|
-
|
|
61
|
+
const columnsdata_grid = useMemo(() => {
|
|
62
|
+
const baseColumns = [
|
|
56
63
|
{
|
|
57
64
|
key: "name",
|
|
58
65
|
name: getLabel(DICTIONARY.SETTINGS_COLUMN_NAME),
|
|
@@ -64,7 +71,7 @@ const ColumnsConfig = forwardRef(
|
|
|
64
71
|
{
|
|
65
72
|
key: "originalIndex",
|
|
66
73
|
name: getLabel(DICTIONARY.SETTINGS_COLUMN_POSITION),
|
|
67
|
-
width:
|
|
74
|
+
width: 70,
|
|
68
75
|
type: "number",
|
|
69
76
|
...getAlignClass("center")
|
|
70
77
|
},
|
|
@@ -84,9 +91,24 @@ const ColumnsConfig = forwardRef(
|
|
|
84
91
|
renderCell: ColumnInteractiveCheckFormatter,
|
|
85
92
|
...getAlignClass("center")
|
|
86
93
|
}
|
|
87
|
-
]
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
];
|
|
95
|
+
const hasGroupableColumns = columns.some(
|
|
96
|
+
(col) => col.groupable === true || col.grouped === true
|
|
97
|
+
);
|
|
98
|
+
if (hasGroupableColumns) {
|
|
99
|
+
baseColumns.push({
|
|
100
|
+
key: "grouped",
|
|
101
|
+
name: getLabel(DICTIONARY.SETTINGS_COLUMN_GROUP),
|
|
102
|
+
width: 80,
|
|
103
|
+
type: "boolean",
|
|
104
|
+
renderCell: ColumnInteractiveCheckFormatter,
|
|
105
|
+
// disabledKey hace que el checkbox esté deshabilitado cuando groupable=false
|
|
106
|
+
disabledKey: "groupable",
|
|
107
|
+
...getAlignClass("center")
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return baseColumns;
|
|
111
|
+
}, [getLabel, columns]);
|
|
90
112
|
const checkAll = () => {
|
|
91
113
|
setRows(rows.map((row) => ({ ...row, visible: true })));
|
|
92
114
|
};
|
|
@@ -99,13 +121,16 @@ const ColumnsConfig = forwardRef(
|
|
|
99
121
|
...row,
|
|
100
122
|
visible: row.originalVisible,
|
|
101
123
|
frozen: row.originalFrozen,
|
|
124
|
+
grouped: row.originalGrouped,
|
|
102
125
|
index: row.originalIndex
|
|
103
126
|
})).sort((a, b) => a.index - b.index)
|
|
104
127
|
);
|
|
105
128
|
};
|
|
106
129
|
useEffect(() => {
|
|
107
130
|
if (isInit === false) {
|
|
108
|
-
setRows(
|
|
131
|
+
setRows(
|
|
132
|
+
getRowsFromColumnsConfig(columnsConfig, columns)
|
|
133
|
+
);
|
|
109
134
|
}
|
|
110
135
|
setIsInit(false);
|
|
111
136
|
}, [columnsConfig]);
|
|
@@ -173,6 +198,7 @@ const ColumnsConfig = forwardRef(
|
|
|
173
198
|
);
|
|
174
199
|
};
|
|
175
200
|
const handleIntro = () => {
|
|
201
|
+
const groupedRows = rows.filter((row) => row.grouped);
|
|
176
202
|
const newColumnsConfig = columnsConfig.map((columnConfig) => {
|
|
177
203
|
const newColumnConfig = { ...columnConfig };
|
|
178
204
|
if (!columnConfig.hidden) {
|
|
@@ -182,11 +208,19 @@ const ColumnsConfig = forwardRef(
|
|
|
182
208
|
newColumnConfig.frozen = columnConfigRow.frozen;
|
|
183
209
|
}
|
|
184
210
|
const rowIndex = rows.findIndex(
|
|
185
|
-
(
|
|
211
|
+
(currentRow) => currentRow.key === columnConfig.key
|
|
186
212
|
);
|
|
187
213
|
if (rowIndex > -1) {
|
|
188
214
|
newColumnConfig.index = rowIndex;
|
|
189
215
|
}
|
|
216
|
+
const rowWithGroupConfig = rows.find((currentRow) => currentRow.key === columnConfig.key);
|
|
217
|
+
if (rowWithGroupConfig) {
|
|
218
|
+
newColumnConfig.grouped = rowWithGroupConfig.grouped;
|
|
219
|
+
const groupOrderIndex = groupedRows.findIndex(
|
|
220
|
+
(groupedRow) => groupedRow.key === columnConfig.key
|
|
221
|
+
);
|
|
222
|
+
newColumnConfig.groupOrder = groupOrderIndex > -1 ? groupOrderIndex : rowIndex;
|
|
223
|
+
}
|
|
190
224
|
}
|
|
191
225
|
return newColumnConfig;
|
|
192
226
|
}).sort((a, b) => getRowIndex(a) - getRowIndex(b));
|
|
@@ -2,27 +2,49 @@ import { DataGridContextProps, IConfigColumn } from '../../../../../../contexts/
|
|
|
2
2
|
import { GridProps } from '../../../../../../types';
|
|
3
3
|
import { Column } from 'react-data-grid';
|
|
4
4
|
export interface Row {
|
|
5
|
+
/** Key única de la columna */
|
|
5
6
|
key: string;
|
|
7
|
+
/** Nombre visible de la columna */
|
|
6
8
|
name: string;
|
|
9
|
+
/** Si la columna está visible */
|
|
7
10
|
visible: boolean;
|
|
11
|
+
/** Si la columna está congelada */
|
|
8
12
|
frozen: boolean;
|
|
13
|
+
/** Si la columna está agrupada actualmente */
|
|
14
|
+
grouped: boolean;
|
|
15
|
+
/** Si la columna PUEDE ser agrupada (está en groupColumns) */
|
|
16
|
+
groupable: boolean;
|
|
17
|
+
/** Ancho de la columna */
|
|
9
18
|
width: number;
|
|
19
|
+
/** Índice actual de la columna */
|
|
10
20
|
index: number;
|
|
21
|
+
/** Índice original de la columna */
|
|
11
22
|
originalIndex: number;
|
|
23
|
+
/** Visibilidad original de la columna */
|
|
12
24
|
originalVisible: boolean;
|
|
25
|
+
/** Estado congelado original de la columna */
|
|
13
26
|
originalFrozen: boolean;
|
|
27
|
+
/** Estado agrupado original de la columna */
|
|
28
|
+
originalGrouped: boolean;
|
|
14
29
|
}
|
|
15
30
|
export type ColumnsConfigRef = {
|
|
16
31
|
onClickIntro: () => void;
|
|
17
32
|
current: HTMLDivElement | null;
|
|
18
33
|
};
|
|
19
34
|
export interface ConfigProps {
|
|
35
|
+
/** Función para cerrar el modal de configuración */
|
|
20
36
|
onCloseSettings: () => void;
|
|
37
|
+
/** Columnas del DataGrid */
|
|
21
38
|
columns: readonly Column<any, any>[];
|
|
39
|
+
/** Configuración actual de las columnas */
|
|
22
40
|
columnsConfig: IConfigColumn[];
|
|
41
|
+
/** Callback para cambiar la configuración de columnas */
|
|
23
42
|
onChangeColumnsConfig: (newColumnsConfig: IConfigColumn[]) => void;
|
|
43
|
+
/** Altura de las filas en el grid interno del modal */
|
|
24
44
|
rowHeight: number;
|
|
45
|
+
/** Clases CSS personalizadas */
|
|
25
46
|
classes: DataGridContextProps<unknown, unknown>['classes'];
|
|
47
|
+
/** Tamaño del componente */
|
|
26
48
|
size: GridProps<unknown, unknown>['size'];
|
|
27
49
|
}
|
|
28
50
|
export interface CheckFormatterProps {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useContext } from "react";
|
|
3
3
|
import { SelectCellFormatter } from "react-data-grid";
|
|
4
|
-
import {
|
|
4
|
+
import { X as CheckboxCellWrapperStyled } from "../../../slots/DataGridSlot.js";
|
|
5
5
|
import { a as DataGridContext } from "../../../contexts/DataGridContext/DataGridContext.js";
|
|
6
6
|
import { R as RadioFormatter } from "../../TableView/subcomponents/RadioSelectColumn/subcomponents/RadioFormatter/RadioFormatter.js";
|
|
7
7
|
import { C as CheckboxFormatter } from "../../TableView/subcomponents/CheckboxFormatter/CheckboxFormatter.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Resizable } from 'react-resizable';
|
|
2
|
-
export declare const RootStyled: import('@emotion/styled').StyledComponent<Pick<import('react-resizable').ResizableProps, "
|
|
2
|
+
export declare const RootStyled: import('@emotion/styled').StyledComponent<Pick<import('react-resizable').ResizableProps, "children" | "resizeHandles" | "height" | "width" | "className" | "onResize" | "handle" | "handleSize" | "lockAspectRatio" | "minConstraints" | "maxConstraints" | "onResizeStop" | "onResizeStart" | "draggableOpts" | "transformScale" | "axis"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {
|
|
3
3
|
ref?: import('react').Ref<Resizable> | undefined;
|
|
4
4
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ResizableBox } from 'react-resizable';
|
|
2
|
-
export declare const RootStyled: import('@emotion/styled').StyledComponent<Pick<import('react-resizable').ResizableBoxProps, "
|
|
2
|
+
export declare const RootStyled: import('@emotion/styled').StyledComponent<Pick<import('react-resizable').ResizableBoxProps, "children" | "resizeHandles" | "height" | "width" | "className" | "style" | "onResize" | "handle" | "handleSize" | "lockAspectRatio" | "minConstraints" | "maxConstraints" | "onResizeStop" | "onResizeStart" | "draggableOpts" | "transformScale" | "axis"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {
|
|
3
3
|
ref?: import('react').Ref<ResizableBox> | undefined;
|
|
4
4
|
}>;
|