@m4l/components 9.2.60-19062025.beta.1 → 9.2.60-J18062025.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/@types/types.d.ts +0 -8
- package/components/DataGrid/DataGrid.js +17 -3
- package/components/DataGrid/Datagrid.styles.js +67 -24
- package/components/DataGrid/constants.d.ts +2 -0
- package/components/DataGrid/constants.js +7 -3
- package/components/DataGrid/contexts/DataGridContext/index.js +77 -30
- package/components/DataGrid/contexts/DataGridContext/types.d.ts +5 -2
- package/components/DataGrid/dictionary.d.ts +8 -0
- package/components/DataGrid/dictionary.js +26 -17
- package/components/DataGrid/icons.d.ts +6 -0
- package/components/DataGrid/icons.js +7 -1
- package/components/DataGrid/slots/DataGridEnum.d.ts +5 -1
- package/components/DataGrid/slots/DataGridEnum.js +4 -0
- package/components/DataGrid/slots/DataGridSlot.d.ts +4 -0
- package/components/DataGrid/slots/DataGridSlot.js +22 -2
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Filter/index.js +9 -1
- package/components/DataGrid/subcomponents/Table/hooks/getDragHeaderRenderer.d.ts +3 -1
- package/components/DataGrid/subcomponents/Table/hooks/getDragHeaderRenderer.js +9 -2
- package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.d.ts +6 -0
- package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.js +259 -0
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.d.ts +6 -4
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +35 -18
- package/components/DataGrid/subcomponents/Table/index.js +97 -34
- package/components/DataGrid/subcomponents/Table/subcomponents/ActionsColumn.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.d.ts +1 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.js +42 -3
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.d.ts +5 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js +136 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/index.d.ts +1 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/types.d.ts +131 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/SelectColumn.js +1 -1
- package/components/DataGrid/subcomponents/editors/TextEditor/index.js +1 -1
- package/components/DataGrid/tests/HeaderRenderClick.test.d.ts +1 -0
- package/components/DataGrid/tests/useHeaderMenuActions.test.d.ts +1 -0
- package/components/DataGrid/types.d.ts +53 -0
- package/components/DynamicFilter/DynamicFilter.styles.js +90 -99
- package/components/DynamicFilter/slots/SlotsEnum.d.ts +3 -0
- package/components/DynamicFilter/slots/SlotsEnum.js +3 -0
- package/components/DynamicFilter/slots/dynamicFilterSlots.d.ts +9 -0
- package/components/DynamicFilter/slots/dynamicFilterSlots.js +19 -3
- package/components/DynamicFilter/store/DynamicFilterContext.js +67 -26
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.js +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index.js +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index.js +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/index.js +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index.js +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index.js +2 -2
- package/components/DynamicFilter/subcomponents/FilterActions/FilterActions.js +1 -1
- package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.d.ts +0 -1
- package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.js +1 -2
- package/components/DynamicFilter/subcomponents/InputFilter/InputFilter.js +0 -2
- package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +18 -23
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.js +1 -4
- package/components/DynamicFilter/types.d.ts +3 -0
- package/components/DynamicSort/DynamicSort.js +10 -6
- package/components/DynamicSort/DynamicSort.styles.js +88 -90
- package/components/DynamicSort/slots/DynamicSortSlots.d.ts +9 -0
- package/components/DynamicSort/slots/DynamicSortSlots.js +21 -5
- package/components/DynamicSort/slots/SlotsEnum.d.ts +4 -1
- package/components/DynamicSort/slots/SlotsEnum.js +4 -1
- package/components/DynamicSort/store/DynamicSortContext.js +96 -67
- package/components/DynamicSort/store/DynamicSortStore.js +53 -4
- package/components/DynamicSort/store/types.d.ts +11 -0
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/index.js +2 -2
- package/components/DynamicSort/subcomponents/InputSort/InputSort.js +0 -2
- package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.js +17 -21
- package/components/DynamicSort/subcomponents/SortActions/SortActions.js +2 -2
- package/components/DynamicSort/subcomponents/SortActions/useSortActions.d.ts +0 -2
- package/components/DynamicSort/subcomponents/SortActions/useSortActions.js +1 -2
- package/components/DynamicSort/types.d.ts +4 -0
- package/components/LanguagePopover/LanguagePopover.js +6 -8
- package/components/LanguagePopover/LanguagePopover.styles.js +4 -25
- package/components/LanguagePopover/slots/LanguagePopoverSlots.d.ts +3 -9
- package/components/LanguagePopover/slots/LanguagePopoverSlots.js +3 -1
- package/components/LanguagePopover/types.d.ts +1 -6
- package/components/PaperForm/styles.js +1 -2
- package/components/PropertyValue/PropertyValue.js +1 -2
- package/components/PropertyValue/PropertyValue.styles.js +4 -7
- package/components/PropertyValue/types.d.ts +0 -4
- package/components/SideBar/SideBar.js +2 -4
- package/components/SideBar/constants.d.ts +2 -26
- package/components/SideBar/constants.js +7 -19
- package/components/SideBar/context/sideBarContext/index.js +5 -19
- package/components/SideBar/context/sideBarContext/types.d.ts +1 -22
- package/components/SideBar/helpers/getMenuDataWithState/index.js +8 -25
- package/components/SideBar/slots/SideBarEnum.d.ts +5 -5
- package/components/SideBar/slots/SideBarEnum.js +11 -9
- package/components/SideBar/slots/SideBarSlots.d.ts +3 -9
- package/components/SideBar/slots/SideBarSlots.js +28 -36
- package/components/SideBar/styles.js +4 -2
- package/components/SideBar/subcomponents/ContentComponent/index.js +19 -39
- package/components/SideBar/subcomponents/ContentComponent/style.js +22 -171
- package/components/SideBar/subcomponents/ContentGroups/index.d.ts +5 -0
- package/components/SideBar/subcomponents/{TreeGroupItems → ContentGroups}/index.js +18 -16
- package/components/SideBar/subcomponents/{TreeGroupItems → ContentGroups}/styles.js +7 -5
- package/components/SideBar/subcomponents/{TreeGroupItems/subcomponents/NodeMenuItem → ContentGroups/subcomponents/ContainerMenuItemsMain}/index.d.ts +3 -3
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/index.js +63 -0
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/styles.d.ts +2 -0
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/styles.js +47 -0
- package/components/SideBar/subcomponents/{TreeGroupItems → ContentGroups/subcomponents/ContainerMenuItemsMain}/subcomponents/ArrowIcon/index.js +7 -10
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/types.d.ts +7 -0
- package/components/SideBar/subcomponents/ContentGroups/types.d.ts +4 -0
- package/components/SideBar/subcomponents/{Promotion → FooterSidebar}/index.d.ts +2 -2
- package/components/SideBar/subcomponents/{Promotion → FooterSidebar}/index.js +15 -8
- package/components/SideBar/subcomponents/{Promotion → FooterSidebar}/styles.js +2 -2
- package/components/SideBar/subcomponents/FooterSidebar/types.d.ts +5 -0
- package/components/SideBar/subcomponents/HeaderSidebar/index.js +25 -0
- package/components/SideBar/subcomponents/SideBarDesktop/index.js +1 -1
- package/components/SideBar/subcomponents/SideBarDesktop/styles.js +14 -10
- package/components/SideBar/subcomponents/SideBarMobile/index.js +1 -1
- package/components/SideBar/types.d.ts +3 -7
- package/components/WindowBase/WindowBase.js +1 -4
- package/components/WindowBase/WindowBase.styles.js +13 -48
- package/components/WindowBase/constants.d.ts +0 -1
- package/components/WindowBase/constants.js +1 -5
- package/components/WindowBase/slots/WindowBaseEnum.d.ts +1 -2
- package/components/WindowBase/slots/WindowBaseEnum.js +0 -1
- package/components/WindowBase/slots/WindowBaseSlots.d.ts +0 -3
- package/components/WindowBase/slots/WindowBaseSlots.js +1 -6
- package/components/WindowBase/subcomponents/Header/HeaderWindowBase.js +4 -8
- package/components/WindowBase/subcomponents/Header/useButtonActions.js +2 -4
- package/components/WindowBase/subcomponents/MemoizedIconButton/MemoizedIconButton.d.ts +1 -1
- package/components/WindowBase/subcomponents/MemoizedIconButton/MemoizedIconButton.js +1 -1
- package/components/WindowBase/subcomponents/MemoizedIconButton/types.d.ts +0 -5
- package/components/WindowBase/types.d.ts +0 -11
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js +0 -13
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useRightActions.js +20 -21
- package/components/extended/React-Resizable/helpers.js +1 -1
- package/components/extended/React-resizable-panels/SplitLayout.js +3 -6
- package/components/extended/React-resizable-panels/SplitLayout.styles.js +36 -78
- package/components/extended/React-resizable-panels/constants.d.ts +0 -6
- package/components/extended/React-resizable-panels/constants.js +1 -5
- package/components/extended/React-resizable-panels/slots/SplitLayoutEnum.d.ts +1 -2
- package/components/extended/React-resizable-panels/slots/SplitLayoutEnum.js +0 -1
- package/components/extended/React-resizable-panels/slots/SplitLayoutSlots.d.ts +0 -3
- package/components/extended/React-resizable-panels/slots/SplitLayoutSlots.js +1 -7
- package/components/hook-form/RHFAutocomplete/RFHAutocompleteStyles.js +1 -1
- package/components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.styles.js +1 -1
- package/components/mui_extended/Accordion/styles.js +2 -10
- package/components/mui_extended/Tab/Tab.styles.js +1 -2
- package/components/mui_extended/TabContent/TabContent.styles.js +8 -2
- package/components/mui_extended/TextField/TextField.js +1 -1
- package/components/mui_extended/TextField/TextField.styles.js +10 -12
- package/components/mui_extended/index.d.ts +0 -1
- package/hooks/useDynamicFilterAndSort/styles.js +1 -1
- package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.d.ts +7 -0
- package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js +300 -88
- package/index.d.ts +0 -1
- package/index.js +20 -23
- package/package.json +5 -6
- package/storybook/components/DataGrid/DataGrid.stories.d.ts +22 -0
- package/storybook/components/DataGrid/MswHandles.d.ts +1 -0
- package/storybook/components/DataGrid/helpers/filterFieldsSeedData.d.ts +5 -0
- package/storybook/components/DataGrid/helpers/getRows.d.ts +4 -0
- package/storybook/components/DataGrid/helpers/getRowsWithBackendSimulation.d.ts +9 -0
- package/storybook/components/DataGrid/helpers/sortsSeedData.d.ts +5 -0
- package/storybook/components/DataGrid/helpers/types.d.ts +1 -0
- package/storybook/components/DataGrid/helpers/useSeed.d.ts +3 -0
- package/storybook/components/DataGrid/subcomponents/DataGridRenderWithExternalFiltersAndSorts.d.ts +16 -0
- package/storybook/components/DynamicFilter/DynamicFilter.stories.d.ts +11 -27
- package/storybook/components/DynamicSort/DynamicSort.stories.d.ts +10 -26
- package/storybook/components/extended/mui/IconButton/IconButton.stories.d.ts +0 -1
- package/storybook/components/extended/mui/TextField/TextFieldText.stories.d.ts +0 -1
- package/utils/index.d.ts +0 -1
- package/components/SideBar/hooks/useCollapse/index.d.ts +0 -1
- package/components/SideBar/hooks/useCollapse/useCollapse.d.ts +0 -11
- package/components/SideBar/hooks/useCollapse/useCollapse.js +0 -23
- package/components/SideBar/subcomponents/Promotion/types.d.ts +0 -5
- package/components/SideBar/subcomponents/TreeGroupItems/index.d.ts +0 -5
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItem/index.js +0 -69
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItem/types.d.ts +0 -9
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItemMain/NodeMenuItemMain.d.ts +0 -5
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItemMain/NodeMenuItemMain.js +0 -56
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItemMain/index.d.ts +0 -1
- package/components/SideBar/subcomponents/TreeGroupItems/types.d.ts +0 -4
- package/components/mui_extended/Divider/index.d.ts +0 -1
- package/components/mui_extended/Divider/index.js +0 -1
- package/storybook/components/SideBar/subcomponents/FooterPromotion/FooterPromotion.d.ts +0 -4
- package/storybook/components/SideBar/subcomponents/FooterPromotion/constants.d.ts +0 -3
- package/storybook/components/SideBar/subcomponents/FooterPromotion/index.d.ts +0 -1
- /package/components/{SideBar/hooks/useCollapse → DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick}/index.js +0 -0
- /package/components/SideBar/subcomponents/{TreeGroupItems → ContentGroups}/styles.d.ts +0 -0
- /package/components/SideBar/subcomponents/{TreeGroupItems → ContentGroups/subcomponents/ContainerMenuItemsMain}/subcomponents/ArrowIcon/index.d.ts +0 -0
- /package/components/SideBar/subcomponents/{TreeGroupItems → ContentGroups/subcomponents/ContainerMenuItemsMain}/subcomponents/ArrowIcon/types.d.ts +0 -0
- /package/components/SideBar/subcomponents/{Promotion → FooterSidebar}/styles.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styled } from "@mui/material/styles";
|
|
2
|
-
import { InputBase } from "@mui/material";
|
|
2
|
+
import { MenuList, InputBase } from "@mui/material";
|
|
3
3
|
import { D as DATAGRID_PREFIX_NAME } from "../constants.js";
|
|
4
4
|
import { D as DataGridSlots, T as TextEditorSlots, A as ActionsSlots, b as TableSlots, C as ControlNavigateSlots, R as RowsCountSlots, a as ColumnsConfigSlots } from "./DataGridEnum.js";
|
|
5
5
|
import { d as dataGridStyles } from "../Datagrid.styles.js";
|
|
@@ -88,6 +88,22 @@ const ContentModalSettingStyled = styled("div", {
|
|
|
88
88
|
name: DATAGRID_PREFIX_NAME,
|
|
89
89
|
slot: TableSlots.contentModalSetting
|
|
90
90
|
})(dataGridStyles.contentModalSetting);
|
|
91
|
+
const HeaderRenderClickStyled = styled("div", {
|
|
92
|
+
name: DATAGRID_PREFIX_NAME,
|
|
93
|
+
slot: TableSlots.headerRenderClick
|
|
94
|
+
})(dataGridStyles.headerRenderClick);
|
|
95
|
+
const MenuListStyled = styled(MenuList, {
|
|
96
|
+
name: DATAGRID_PREFIX_NAME,
|
|
97
|
+
slot: TableSlots.menuList
|
|
98
|
+
})(dataGridStyles.menuList);
|
|
99
|
+
const ButtonHeaderActionsStyled = styled("div", {
|
|
100
|
+
name: DATAGRID_PREFIX_NAME,
|
|
101
|
+
slot: TableSlots.buttonHeaderActions
|
|
102
|
+
})(dataGridStyles.buttonHeaderActions);
|
|
103
|
+
const NameColumnIconStyled = styled("div", {
|
|
104
|
+
name: DATAGRID_PREFIX_NAME,
|
|
105
|
+
slot: TableSlots.nameColumnIcon
|
|
106
|
+
})(dataGridStyles.nameColumnIcon);
|
|
91
107
|
const InputTextEditorStyled = styled("input", {
|
|
92
108
|
name: DATAGRID_PREFIX_NAME,
|
|
93
109
|
slot: TextEditorSlots.inputTexEditor
|
|
@@ -98,10 +114,13 @@ const ControlNavigateStyled = styled("div", {
|
|
|
98
114
|
})(dataGridStyles.controlNavigate);
|
|
99
115
|
export {
|
|
100
116
|
ActionsRootStyled as A,
|
|
117
|
+
ButtonHeaderActionsStyled as B,
|
|
101
118
|
CustomHeaderStyled as C,
|
|
102
119
|
DataGridRootStyled as D,
|
|
103
120
|
HeaderInputBaseStyled as H,
|
|
104
121
|
IconSearchStyled as I,
|
|
122
|
+
MenuListStyled as M,
|
|
123
|
+
NameColumnIconStyled as N,
|
|
105
124
|
RowsCountRootStyled as R,
|
|
106
125
|
TableWrapperDataGridStyled as T,
|
|
107
126
|
WrapperSkeletonStyled as W,
|
|
@@ -119,5 +138,6 @@ export {
|
|
|
119
138
|
TableContainerStyled as l,
|
|
120
139
|
DraggableHeaderRootStyled as m,
|
|
121
140
|
DraggableWrapperInputBaseStyled as n,
|
|
122
|
-
|
|
141
|
+
HeaderRenderClickStyled as o,
|
|
142
|
+
InputTextEditorStyled as p
|
|
123
143
|
};
|
|
@@ -4,12 +4,20 @@ import { u as useFilters } from "../../../../hooks/useFilters.js";
|
|
|
4
4
|
import { I as IconButton } from "../../../../../mui_extended/IconButton/IconButton.js";
|
|
5
5
|
import { p as pathIcons } from "../../../../icons.js";
|
|
6
6
|
import { D as DICTIONARY } from "../../../../dictionary.js";
|
|
7
|
+
import { u as useDataGrid } from "../../../../hooks/useDataGrid.js";
|
|
7
8
|
function Filter() {
|
|
8
9
|
const { activeFilters, setActiveFilters } = useFilters();
|
|
9
10
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
10
11
|
const { getLabel } = useModuleDictionary();
|
|
12
|
+
const { externalFilterSettings } = useDataGrid();
|
|
11
13
|
const toggleIcon = () => {
|
|
12
|
-
|
|
14
|
+
if (externalFilterSettings) {
|
|
15
|
+
externalFilterSettings.onChange?.({
|
|
16
|
+
action: "openPopoverMenuFields"
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
setActiveFilters(!activeFilters);
|
|
20
|
+
}
|
|
13
21
|
};
|
|
14
22
|
return /* @__PURE__ */ jsx(
|
|
15
23
|
IconButton,
|
|
@@ -4,4 +4,6 @@ import { HeaderRendererProps } from 'react-data-grid';
|
|
|
4
4
|
* Función encargada de retornar el componente de renderizado de cabecera con la capacidad de arrastrar columnas
|
|
5
5
|
* @param handleColumnsReorder - Función que se ejecuta al reordenar columnas
|
|
6
6
|
*/
|
|
7
|
-
export declare const getDragHeaderRenderer: <TRow, TSummaryRow>(handleColumnsReorder: (sourceKey: string, targetKey: string) => void
|
|
7
|
+
export declare const getDragHeaderRenderer: <TRow, TSummaryRow>(handleColumnsReorder: (sourceKey: string, targetKey: string) => void, options?: {
|
|
8
|
+
openPopover?: (anchorEl: HTMLElement, columnKey: string) => void;
|
|
9
|
+
}) => FunctionComponent<HeaderRendererProps<TRow, TSummaryRow>>;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { D as DraggableHeaderRenderer } from "../subcomponents/DraggableHeaderRenderer.js";
|
|
3
|
-
const getDragHeaderRenderer = (handleColumnsReorder) => {
|
|
3
|
+
const getDragHeaderRenderer = (handleColumnsReorder, options) => {
|
|
4
4
|
function HeaderRenderer(props) {
|
|
5
|
-
return /* @__PURE__ */ jsx(
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
DraggableHeaderRenderer,
|
|
7
|
+
{
|
|
8
|
+
...props,
|
|
9
|
+
onColumnsReorder: handleColumnsReorder,
|
|
10
|
+
openPopover: options?.openPopover
|
|
11
|
+
}
|
|
12
|
+
);
|
|
6
13
|
}
|
|
7
14
|
return HeaderRenderer;
|
|
8
15
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Column } from 'react-data-grid';
|
|
2
|
+
import { MenuAction } from '../subcomponents/HeaderRenderClick/types';
|
|
3
|
+
/**
|
|
4
|
+
* Función que retorna las acciones del menu del header de la columna
|
|
5
|
+
*/
|
|
6
|
+
export declare function useHeaderMenuActions<Trow, TSummaryRow>(columnKey: string | null, finalColumns: readonly Column<Trow, TSummaryRow>[], defaultSortable: boolean): MenuAction[];
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { useMemo, useCallback } from "react";
|
|
2
|
+
import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
|
|
3
|
+
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
4
|
+
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
5
|
+
import { p as pathIcons } from "../../../icons.js";
|
|
6
|
+
function useHeaderMenuActions(columnKey, finalColumns, defaultSortable) {
|
|
7
|
+
const {
|
|
8
|
+
columnsConfig,
|
|
9
|
+
onChangeColumnsConfig,
|
|
10
|
+
setSortColumns,
|
|
11
|
+
sortColumns,
|
|
12
|
+
externalSortSettings,
|
|
13
|
+
externalFilterSettings
|
|
14
|
+
} = useDataGrid();
|
|
15
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
16
|
+
const { getLabel } = useModuleDictionary();
|
|
17
|
+
const column = useMemo(() => {
|
|
18
|
+
return finalColumns.find((c) => c.key === columnKey);
|
|
19
|
+
}, [columnKey, finalColumns]);
|
|
20
|
+
const canSort = useMemo(() => {
|
|
21
|
+
if (!columnKey) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return column?.sortable !== false ? defaultSortable : false;
|
|
25
|
+
}, [columnKey, column, defaultSortable]);
|
|
26
|
+
const canSortExternally = useMemo(() => {
|
|
27
|
+
if (!columnKey || !externalSortSettings) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return externalSortSettings.sortsColumns.includes(columnKey);
|
|
31
|
+
}, [columnKey, externalSortSettings]);
|
|
32
|
+
const currentSort = useMemo(() => {
|
|
33
|
+
if (!columnKey || !externalSortSettings?.sortsApplied) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
return externalSortSettings.sortsApplied.find(
|
|
37
|
+
(s) => s.columnKey === columnKey
|
|
38
|
+
);
|
|
39
|
+
}, [columnKey, externalSortSettings?.sortsApplied]);
|
|
40
|
+
const hasExternalSortAsc = useMemo(() => {
|
|
41
|
+
return currentSort?.direction === "asc";
|
|
42
|
+
}, [currentSort]);
|
|
43
|
+
const hasExternalSortDesc = useMemo(() => {
|
|
44
|
+
return currentSort?.direction === "desc";
|
|
45
|
+
}, [currentSort]);
|
|
46
|
+
const isAsc = useMemo(
|
|
47
|
+
() => Boolean(
|
|
48
|
+
columnKey && sortColumns.some(
|
|
49
|
+
(s) => s.columnKey === columnKey && s.direction === "ASC"
|
|
50
|
+
)
|
|
51
|
+
),
|
|
52
|
+
[columnKey, sortColumns]
|
|
53
|
+
);
|
|
54
|
+
const isDesc = useMemo(
|
|
55
|
+
() => Boolean(
|
|
56
|
+
columnKey && sortColumns.some(
|
|
57
|
+
(s) => s.columnKey === columnKey && s.direction === "DESC"
|
|
58
|
+
)
|
|
59
|
+
),
|
|
60
|
+
[columnKey, sortColumns]
|
|
61
|
+
);
|
|
62
|
+
const clearLocalSort = useCallback(() => {
|
|
63
|
+
if (!columnKey) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
setSortColumns((prev) => prev.filter((s) => s.columnKey !== columnKey));
|
|
67
|
+
}, [columnKey, setSortColumns]);
|
|
68
|
+
const hasAnySortApplied = useMemo(() => {
|
|
69
|
+
return Boolean(currentSort);
|
|
70
|
+
}, [currentSort]);
|
|
71
|
+
const toggleFrozen = useCallback(() => {
|
|
72
|
+
if (!columnKey) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const next = columnsConfig.map(
|
|
76
|
+
(c) => c.key === columnKey ? { ...c, frozen: !c.frozen } : c
|
|
77
|
+
);
|
|
78
|
+
onChangeColumnsConfig(next);
|
|
79
|
+
}, [columnKey, columnsConfig, onChangeColumnsConfig]);
|
|
80
|
+
const toggleVisible = useCallback(() => {
|
|
81
|
+
if (!columnKey) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const next = columnsConfig.map(
|
|
85
|
+
(c) => c.key === columnKey ? { ...c, visible: !c.visible } : c
|
|
86
|
+
);
|
|
87
|
+
onChangeColumnsConfig(next);
|
|
88
|
+
}, [columnKey, columnsConfig, onChangeColumnsConfig]);
|
|
89
|
+
const addExternalSort = useCallback(
|
|
90
|
+
(direction) => {
|
|
91
|
+
if (!columnKey || !column || column?.type === "custom") {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
externalSortSettings?.onChange({
|
|
95
|
+
action: "add",
|
|
96
|
+
columnKey,
|
|
97
|
+
direction
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
[columnKey, column, externalSortSettings]
|
|
101
|
+
);
|
|
102
|
+
const isRemovable = useMemo(() => {
|
|
103
|
+
return currentSort?.removable;
|
|
104
|
+
}, [currentSort]);
|
|
105
|
+
const addExternalFilter = useCallback(() => {
|
|
106
|
+
if (!columnKey || !column) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
externalFilterSettings?.onChange({
|
|
110
|
+
action: "add",
|
|
111
|
+
columnKey
|
|
112
|
+
});
|
|
113
|
+
}, [columnKey, column, externalFilterSettings]);
|
|
114
|
+
const isAddFilterDisabled = useMemo(() => {
|
|
115
|
+
if (!columnKey || !column) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (column.type === "custom") {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
const isInFilterColumns = externalFilterSettings?.filterColumns.some(
|
|
122
|
+
(filter) => filter.name === columnKey
|
|
123
|
+
);
|
|
124
|
+
if (!isInFilterColumns) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
const isFilterApplied = externalFilterSettings?.filtersApplied.some(
|
|
128
|
+
(filter) => filter.columnKey === columnKey && filter.isValid
|
|
129
|
+
);
|
|
130
|
+
const isFilterMultiple = externalFilterSettings?.filterColumns.find(
|
|
131
|
+
(filter) => filter.name === columnKey
|
|
132
|
+
)?.multiple;
|
|
133
|
+
return isFilterApplied && !isFilterMultiple;
|
|
134
|
+
}, [columnKey, column, externalFilterSettings]);
|
|
135
|
+
return useMemo(() => {
|
|
136
|
+
if (!columnKey) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
const sortActions = [
|
|
140
|
+
{
|
|
141
|
+
type: "menuItem",
|
|
142
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.sortAsc}`,
|
|
143
|
+
label: getLabel(DICTIONARY.ORDER_ASC_COLUMN),
|
|
144
|
+
dataTestId: "sort-ascending",
|
|
145
|
+
/**
|
|
146
|
+
* Función que agrega un sort externo en modo ascendente
|
|
147
|
+
*/
|
|
148
|
+
onClick: () => {
|
|
149
|
+
if (externalSortSettings) {
|
|
150
|
+
addExternalSort("asc");
|
|
151
|
+
} else {
|
|
152
|
+
setSortColumns([
|
|
153
|
+
{
|
|
154
|
+
columnKey,
|
|
155
|
+
direction: "ASC"
|
|
156
|
+
}
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
disabled: !canSort || (externalSortSettings ? !canSortExternally || hasExternalSortAsc : isAsc)
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: "menuItem",
|
|
164
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.sortDesc}`,
|
|
165
|
+
label: getLabel(DICTIONARY.ORDER_DESC_COLUMN),
|
|
166
|
+
dataTestId: "sort-descending",
|
|
167
|
+
/**
|
|
168
|
+
* Función que agrega un sort externo en modo descendente
|
|
169
|
+
*/
|
|
170
|
+
onClick: () => {
|
|
171
|
+
if (externalSortSettings) {
|
|
172
|
+
addExternalSort("desc");
|
|
173
|
+
} else {
|
|
174
|
+
setSortColumns([
|
|
175
|
+
{
|
|
176
|
+
columnKey,
|
|
177
|
+
direction: "DESC"
|
|
178
|
+
}
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
disabled: !canSort || (externalSortSettings ? !canSortExternally || hasExternalSortDesc : isDesc)
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
type: "menuItem",
|
|
186
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.removeSort}`,
|
|
187
|
+
label: getLabel(DICTIONARY.REMOVE_ORDER_COLUMN),
|
|
188
|
+
dataTestId: "sort-remove",
|
|
189
|
+
/**
|
|
190
|
+
* Función que elimina el sort externo
|
|
191
|
+
*/
|
|
192
|
+
onClick: () => {
|
|
193
|
+
if (columnKey) {
|
|
194
|
+
if (externalSortSettings && isRemovable) {
|
|
195
|
+
externalSortSettings.onChange({
|
|
196
|
+
action: "remove",
|
|
197
|
+
columnKey
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
} else {
|
|
201
|
+
clearLocalSort();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
disabled: externalSortSettings ? !hasAnySortApplied || !isRemovable : !(isAsc || isDesc)
|
|
206
|
+
}
|
|
207
|
+
];
|
|
208
|
+
const filterAction = externalFilterSettings ? [
|
|
209
|
+
{
|
|
210
|
+
type: "menuItem",
|
|
211
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.filter}`,
|
|
212
|
+
label: getLabel(DICTIONARY.ADD_FILTER_COLUMN),
|
|
213
|
+
dataTestId: "filter-add",
|
|
214
|
+
onClick: () => {
|
|
215
|
+
addExternalFilter();
|
|
216
|
+
},
|
|
217
|
+
disabled: isAddFilterDisabled
|
|
218
|
+
}
|
|
219
|
+
] : [];
|
|
220
|
+
const baseActions = [
|
|
221
|
+
{
|
|
222
|
+
type: "menuItem",
|
|
223
|
+
startIcon: columnsConfig.find((c) => c.key === columnKey)?.frozen ? `${host_static_assets}/${environment_assets}/${pathIcons.unfreezeColumn}` : `${host_static_assets}/${environment_assets}/${pathIcons.freezeColumn}`,
|
|
224
|
+
label: columnsConfig.find((c) => c.key === columnKey)?.frozen ? getLabel(DICTIONARY.UNFREEZE_COLUMN) : getLabel(DICTIONARY.FREEZE_COLUMN),
|
|
225
|
+
onClick: toggleFrozen,
|
|
226
|
+
disabled: !columnsConfig.find((c) => c.key === columnKey)?.visible,
|
|
227
|
+
dataTestId: "toggle-freeze"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
type: "menuItem",
|
|
231
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.hideColumn}`,
|
|
232
|
+
label: getLabel(DICTIONARY.HIDE_COLUMN),
|
|
233
|
+
onClick: toggleVisible,
|
|
234
|
+
dataTestId: "hide-column"
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
return [...sortActions, ...filterAction, ...baseActions];
|
|
238
|
+
}, [
|
|
239
|
+
columnKey,
|
|
240
|
+
canSort,
|
|
241
|
+
canSortExternally,
|
|
242
|
+
hasExternalSortAsc,
|
|
243
|
+
hasExternalSortDesc,
|
|
244
|
+
hasAnySortApplied,
|
|
245
|
+
addExternalSort,
|
|
246
|
+
toggleFrozen,
|
|
247
|
+
toggleVisible,
|
|
248
|
+
columnsConfig,
|
|
249
|
+
externalSortSettings,
|
|
250
|
+
externalFilterSettings,
|
|
251
|
+
host_static_assets,
|
|
252
|
+
environment_assets,
|
|
253
|
+
getLabel,
|
|
254
|
+
isAddFilterDisabled
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
export {
|
|
258
|
+
useHeaderMenuActions as u
|
|
259
|
+
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Column
|
|
1
|
+
import { Column } from 'react-data-grid';
|
|
2
2
|
/**
|
|
3
3
|
* Hook encargado de ordenar datos de las columnas y las filas.
|
|
4
4
|
* Se utiliza para ordenar las columnas y las filas de un DataGrid.
|
|
5
5
|
*/
|
|
6
|
-
export declare const useSortColumnsRows: <TRow, TSummaryRow>(sourceColumns: readonly Column<TRow, TSummaryRow>[], sourceRows: readonly TRow[]
|
|
6
|
+
export declare const useSortColumnsRows: <TRow, TSummaryRow>(sourceColumns: readonly Column<TRow, TSummaryRow>[], sourceRows: readonly TRow[], popoverHandlers?: {
|
|
7
|
+
openPopover?: (anchorEl: HTMLElement, columnKey: string) => void;
|
|
8
|
+
}) => {
|
|
7
9
|
finalColumns: readonly Column<TRow, TSummaryRow>[];
|
|
8
|
-
sortColumns:
|
|
9
|
-
setSortColumns: import('react').Dispatch<import('react').SetStateAction<
|
|
10
|
+
sortColumns: import('react-data-grid').SortColumn[];
|
|
11
|
+
setSortColumns: import('react').Dispatch<import('react').SetStateAction<import('react-data-grid').SortColumn[]>>;
|
|
10
12
|
finalRows: readonly TRow[];
|
|
11
13
|
};
|
|
@@ -6,7 +6,7 @@ import { useModuleSkeleton, getPropertyByString } from "@m4l/core";
|
|
|
6
6
|
import { u as useFilters } from "../../../hooks/useFilters.js";
|
|
7
7
|
import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
|
|
8
8
|
import { S as SkeletonFormatter } from "../subcomponents/SkeletonFormatter/index.js";
|
|
9
|
-
import {
|
|
9
|
+
import { d as DATAGRID_SELECT_COLUMN_KEY } from "../../../constants.js";
|
|
10
10
|
function getComparator(columns, sortColumn) {
|
|
11
11
|
const column = columns.find((d) => d.key === sortColumn);
|
|
12
12
|
let typeOrder = "string";
|
|
@@ -43,15 +43,13 @@ const getInOrderColumns = (columns, hasCheckedRows, columnsConfig, columnsWidths
|
|
|
43
43
|
const columnConfigIndex = getColumIndex(column.key, columnsConfig);
|
|
44
44
|
const visible = columnConfigIndex > -1 ? columnsConfig[columnConfigIndex].visible : true;
|
|
45
45
|
return !column.hidden && visible;
|
|
46
|
-
}).sort(
|
|
47
|
-
(a,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
).map((columnSorted) => {
|
|
46
|
+
}).sort((a, b) => {
|
|
47
|
+
let indexA = getColumIndex(a.key, columnsConfig);
|
|
48
|
+
indexA = indexA === -1 ? columnsConfig.length : indexA;
|
|
49
|
+
let indexB = getColumIndex(b.key, columnsConfig);
|
|
50
|
+
indexB = indexB === -1 ? columnsConfig.length : indexB;
|
|
51
|
+
return indexA - indexB;
|
|
52
|
+
}).map((columnSorted) => {
|
|
55
53
|
const columnConfigIndex = getColumIndex(columnSorted.key, columnsConfig);
|
|
56
54
|
return {
|
|
57
55
|
...columnSorted,
|
|
@@ -83,21 +81,26 @@ const getAligByType = (columnType) => {
|
|
|
83
81
|
}
|
|
84
82
|
return "left";
|
|
85
83
|
};
|
|
86
|
-
const useSortColumnsRows = (sourceColumns, sourceRows) => {
|
|
84
|
+
const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
|
|
87
85
|
const {
|
|
88
86
|
columnsConfig,
|
|
89
87
|
columnsWidths,
|
|
90
88
|
onChangeColumnsOrder,
|
|
91
89
|
rowActionsGetter,
|
|
92
90
|
checkedRows,
|
|
93
|
-
onCheckedRowsChange
|
|
91
|
+
onCheckedRowsChange,
|
|
92
|
+
sortColumns,
|
|
93
|
+
setSortColumns
|
|
94
94
|
} = useDataGrid();
|
|
95
|
-
const [columns, setColumns] = useState(
|
|
96
|
-
|
|
95
|
+
const [columns, setColumns] = useState(
|
|
96
|
+
() => []
|
|
97
|
+
);
|
|
97
98
|
const isSkeleton = useModuleSkeleton();
|
|
98
99
|
const { activeFilters, filters } = useFilters();
|
|
99
100
|
const findKeyInColumns = (key, cols) => {
|
|
100
|
-
const index = cols.findIndex(
|
|
101
|
+
const index = cols.findIndex(
|
|
102
|
+
(column) => key === column.key && column.hidden === false
|
|
103
|
+
);
|
|
101
104
|
return index !== -1;
|
|
102
105
|
};
|
|
103
106
|
useEffect(() => {
|
|
@@ -119,7 +122,12 @@ const useSortColumnsRows = (sourceColumns, sourceRows) => {
|
|
|
119
122
|
}
|
|
120
123
|
}, [sourceColumns, columnsConfig, rowActionsGetter]);
|
|
121
124
|
const finalColumns = useMemo(() => {
|
|
122
|
-
const DragAndDropHeaderRenderer = getDragHeaderRenderer(
|
|
125
|
+
const DragAndDropHeaderRenderer = getDragHeaderRenderer(
|
|
126
|
+
onChangeColumnsOrder,
|
|
127
|
+
{
|
|
128
|
+
openPopover: popoverHandlers?.openPopover
|
|
129
|
+
}
|
|
130
|
+
);
|
|
123
131
|
return columns.map((c) => {
|
|
124
132
|
const cellClass = c.align !== void 0 ? `rdg-cell-align-${c.align}` : `rdg-cell-align-${getAligByType(c.type)}`;
|
|
125
133
|
const newColumn = {
|
|
@@ -143,7 +151,13 @@ const useSortColumnsRows = (sourceColumns, sourceRows) => {
|
|
|
143
151
|
newColumn.headerRenderer = DragAndDropHeaderRenderer;
|
|
144
152
|
return newColumn;
|
|
145
153
|
});
|
|
146
|
-
}, [
|
|
154
|
+
}, [
|
|
155
|
+
isSkeleton,
|
|
156
|
+
columns,
|
|
157
|
+
activeFilters,
|
|
158
|
+
onChangeColumnsOrder,
|
|
159
|
+
popoverHandlers
|
|
160
|
+
]);
|
|
147
161
|
const finalRows = useMemo(() => {
|
|
148
162
|
const nextRows = sourceRows.filter((r) => {
|
|
149
163
|
if (!filters || filters.size === 0) {
|
|
@@ -154,7 +168,10 @@ const useSortColumnsRows = (sourceColumns, sourceRows) => {
|
|
|
154
168
|
for (let i = 0; i < filters.size; i++) {
|
|
155
169
|
const entry = iterator.next().value;
|
|
156
170
|
const columnKey = entry?.[0] ?? "";
|
|
157
|
-
const columnFilter = entry?.[1] ?? {
|
|
171
|
+
const columnFilter = entry?.[1] ?? {
|
|
172
|
+
value: "",
|
|
173
|
+
customFilter: void 0
|
|
174
|
+
};
|
|
158
175
|
let valCell;
|
|
159
176
|
const valueMaybeString = getPropertyByString(r, columnKey);
|
|
160
177
|
let fixedValue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useEffect } from "react";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState, useRef, useEffect } from "react";
|
|
3
3
|
import DataGrid from "react-data-grid";
|
|
4
4
|
import { DndProvider } from "react-dnd";
|
|
5
5
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
@@ -9,15 +9,52 @@ 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
11
|
import { l as TableContainerStyled, T as TableWrapperDataGridStyled } from "../../slots/DataGridSlot.js";
|
|
12
|
+
import { u as useHeaderMenuActions } from "./hooks/useHeaderMenuActions.js";
|
|
13
|
+
import { H as HeaderRenderClick } from "./subcomponents/HeaderRenderClick/HeaderRenderClick.js";
|
|
12
14
|
function Table(props) {
|
|
13
|
-
const {
|
|
14
|
-
const { finalColumns, sortColumns, setSortColumns, finalRows } = useSortColumnsRows(
|
|
15
|
+
const {
|
|
15
16
|
columns,
|
|
16
|
-
rows
|
|
17
|
+
rows,
|
|
18
|
+
onRowsChange,
|
|
19
|
+
rowKeyGetter,
|
|
20
|
+
selectedRows,
|
|
21
|
+
onSelectedRowsChange
|
|
22
|
+
} = props;
|
|
23
|
+
const { finalColumns, finalRows } = useSortColumnsRows(
|
|
24
|
+
columns,
|
|
25
|
+
rows,
|
|
26
|
+
useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
/**
|
|
29
|
+
* Función que abre el menú de acciones para una columna
|
|
30
|
+
*/
|
|
31
|
+
openPopover: (anchorEl, columnKey) => {
|
|
32
|
+
if (anchorEl instanceof HTMLDivElement) {
|
|
33
|
+
setPopoverState({
|
|
34
|
+
anchorEl,
|
|
35
|
+
columnKey
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
[]
|
|
41
|
+
)
|
|
17
42
|
);
|
|
18
43
|
const { activeFilters } = useFilters();
|
|
19
|
-
const {
|
|
44
|
+
const {
|
|
45
|
+
onChangeColumnWidth,
|
|
46
|
+
setRowsCount,
|
|
47
|
+
currentRowHeight,
|
|
48
|
+
currentRowHeaderHeight,
|
|
49
|
+
size,
|
|
50
|
+
sortColumns,
|
|
51
|
+
setSortColumns
|
|
52
|
+
} = useDataGrid();
|
|
20
53
|
const ref_data_grid = useRef(null);
|
|
54
|
+
const [popoverState, setPopoverState] = useState({
|
|
55
|
+
anchorEl: null,
|
|
56
|
+
columnKey: null
|
|
57
|
+
});
|
|
21
58
|
const onRowClick = (row) => {
|
|
22
59
|
if (selectedRows && onSelectedRowsChange) {
|
|
23
60
|
if (selectedRows.entries().next().value) {
|
|
@@ -32,11 +69,17 @@ function Table(props) {
|
|
|
32
69
|
useEffect(() => {
|
|
33
70
|
let columnIndice = 0;
|
|
34
71
|
for (const column of finalColumns) {
|
|
35
|
-
const index = sortColumns.findIndex(
|
|
72
|
+
const index = sortColumns.findIndex(
|
|
73
|
+
(sortColumn) => column.key === sortColumn.columnKey
|
|
74
|
+
);
|
|
36
75
|
if (index !== -1) {
|
|
37
|
-
ref_data_grid.current?.element?.querySelector(
|
|
76
|
+
ref_data_grid.current?.element?.querySelector(
|
|
77
|
+
`[role="columnheader"][aria-colindex="${columnIndice + 1}"]`
|
|
78
|
+
)?.setAttribute("aria-columnsort", `${sortColumns[index].direction}`);
|
|
38
79
|
} else {
|
|
39
|
-
ref_data_grid.current?.element?.querySelector(
|
|
80
|
+
ref_data_grid.current?.element?.querySelector(
|
|
81
|
+
`[role="columnheader"][aria-colindex="${columnIndice + 1}"]`
|
|
82
|
+
)?.removeAttribute("aria-columnsort");
|
|
40
83
|
}
|
|
41
84
|
columnIndice++;
|
|
42
85
|
}
|
|
@@ -47,31 +90,51 @@ function Table(props) {
|
|
|
47
90
|
const onColumnResize = (idx, width) => {
|
|
48
91
|
onChangeColumnWidth(finalColumns[idx].key, width);
|
|
49
92
|
};
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
const defaultColumnOptions = { resizable: true, sortable: true };
|
|
94
|
+
const menuActions = useHeaderMenuActions(
|
|
95
|
+
popoverState.columnKey,
|
|
96
|
+
finalColumns,
|
|
97
|
+
defaultColumnOptions.sortable
|
|
98
|
+
);
|
|
99
|
+
return /* @__PURE__ */ jsx(TableContainerStyled, { id: "WrapperTable", children: /* @__PURE__ */ jsxs(TableWrapperDataGridStyled, { ownerState: { size }, children: [
|
|
100
|
+
/* @__PURE__ */ jsx(DndProvider, { backend: HTML5Backend, context: window, children: /* @__PURE__ */ jsx(
|
|
101
|
+
DataGrid,
|
|
102
|
+
{
|
|
103
|
+
className: "rdg-light",
|
|
104
|
+
ref: ref_data_grid,
|
|
105
|
+
headerRowHeight: activeFilters ? currentRowHeaderHeight + filterHeight : currentRowHeaderHeight,
|
|
106
|
+
columns: finalColumns,
|
|
107
|
+
sortColumns,
|
|
108
|
+
onSortColumnsChange: setSortColumns,
|
|
109
|
+
onColumnResize,
|
|
110
|
+
rows: finalRows,
|
|
111
|
+
onRowsChange,
|
|
112
|
+
selectedRows,
|
|
113
|
+
onSelectedRowsChange,
|
|
114
|
+
onRowClick,
|
|
115
|
+
rowHeight: currentRowHeight,
|
|
116
|
+
rowKeyGetter,
|
|
117
|
+
cellNavigationMode: "LOOP_OVER_ROW",
|
|
118
|
+
components: { checkboxFormatter: CheckboxFormatter },
|
|
119
|
+
defaultColumnOptions
|
|
120
|
+
}
|
|
121
|
+
) }),
|
|
122
|
+
popoverState.columnKey && popoverState.anchorEl instanceof HTMLDivElement && /* @__PURE__ */ jsx(
|
|
123
|
+
HeaderRenderClick,
|
|
124
|
+
{
|
|
125
|
+
externalOpen: popoverState.anchorEl,
|
|
126
|
+
onOpen: (open) => {
|
|
127
|
+
if (!open) {
|
|
128
|
+
setPopoverState({
|
|
129
|
+
anchorEl: null,
|
|
130
|
+
columnKey: null
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
menuActions
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] }) });
|
|
75
138
|
}
|
|
76
139
|
export {
|
|
77
140
|
Table as T
|
|
@@ -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 { e as DATAGRID_SEMANTIC_WIDTHS, f 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();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HeaderRendererProps } from 'react-data-grid';
|
|
2
2
|
interface DraggableHeaderRendererProps<TRow> extends HeaderRendererProps<TRow> {
|
|
3
3
|
onColumnsReorder: (sourceKey: string, targetKey: string) => void;
|
|
4
|
+
openPopover?: (anchorEl: HTMLElement, columnKey: string) => void;
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
6
7
|
* TODO: Documentar
|