@m4l/components 9.2.60 → 9.2.62
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 +8 -0
- package/components/Chip/Chip.js +9 -10
- package/components/Chip/ChipStyles.js +13 -2
- package/components/Chip/constants.d.ts +9 -0
- package/components/Chip/constants.js +6 -2
- package/components/Chip/slots/ChipEnum.d.ts +3 -0
- package/components/Chip/slots/ChipEnum.js +6 -1
- package/components/Chip/slots/ChipSlots.js +1 -1
- package/components/DataGrid/DataGrid.js +17 -3
- package/components/DataGrid/Datagrid.styles.js +80 -33
- 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 +7 -0
- package/components/DataGrid/icons.js +8 -1
- package/components/DataGrid/slots/DataGridEnum.d.ts +7 -1
- package/components/DataGrid/slots/DataGridEnum.js +6 -0
- package/components/DataGrid/slots/DataGridSlot.d.ts +6 -0
- package/components/DataGrid/slots/DataGridSlot.js +35 -5
- 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 +262 -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 +79 -4
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.d.ts +5 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js +146 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/index.d.ts +1 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/index.js +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 +99 -90
- package/components/DynamicFilter/slots/SlotsEnum.d.ts +0 -3
- package/components/DynamicFilter/slots/SlotsEnum.js +0 -3
- package/components/DynamicFilter/slots/dynamicFilterSlots.d.ts +0 -9
- package/components/DynamicFilter/slots/dynamicFilterSlots.js +3 -19
- package/components/DynamicFilter/store/DynamicFilterContext.js +67 -28
- 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 +1 -0
- package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.js +2 -1
- package/components/DynamicFilter/subcomponents/InputFilter/InputFilter.js +2 -0
- package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +24 -18
- package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.d.ts +3 -3
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.js +4 -1
- package/components/DynamicFilter/types.d.ts +3 -0
- package/components/DynamicSort/DynamicSort.js +10 -6
- package/components/DynamicSort/DynamicSort.styles.js +92 -90
- package/components/DynamicSort/slots/DynamicSortSlots.d.ts +0 -9
- package/components/DynamicSort/slots/DynamicSortSlots.js +7 -23
- package/components/DynamicSort/slots/SlotsEnum.d.ts +1 -4
- package/components/DynamicSort/slots/SlotsEnum.js +1 -4
- 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 +2 -0
- package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.js +22 -17
- package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.d.ts +3 -3
- package/components/DynamicSort/subcomponents/SortActions/SortActions.js +2 -2
- package/components/DynamicSort/subcomponents/SortActions/useSortActions.d.ts +2 -0
- package/components/DynamicSort/subcomponents/SortActions/useSortActions.js +2 -1
- package/components/DynamicSort/types.d.ts +4 -0
- package/components/LanguagePopover/LanguagePopover.js +7 -5
- package/components/LanguagePopover/LanguagePopover.styles.js +32 -4
- package/components/LanguagePopover/slots/LanguagePopoverSlots.d.ts +9 -3
- package/components/LanguagePopover/slots/LanguagePopoverSlots.js +1 -3
- package/components/LanguagePopover/types.d.ts +6 -1
- package/components/PaperForm/styles.js +2 -1
- package/components/PropertyValue/PropertyValue.js +2 -1
- package/components/PropertyValue/PropertyValue.styles.js +7 -4
- package/components/PropertyValue/types.d.ts +4 -0
- package/components/SideBar/SideBar.js +4 -2
- package/components/SideBar/constants.d.ts +26 -2
- package/components/SideBar/constants.js +19 -7
- package/components/SideBar/context/sideBarContext/index.js +19 -5
- package/components/SideBar/context/sideBarContext/types.d.ts +22 -1
- package/components/SideBar/helpers/getMenuDataWithState/index.js +25 -8
- package/components/SideBar/hooks/useCollapse/index.d.ts +1 -0
- package/components/SideBar/hooks/useCollapse/index.js +1 -0
- package/components/SideBar/hooks/useCollapse/useCollapse.d.ts +11 -0
- package/components/SideBar/hooks/useCollapse/useCollapse.js +23 -0
- package/components/SideBar/slots/SideBarEnum.d.ts +5 -5
- package/components/SideBar/slots/SideBarEnum.js +9 -11
- package/components/SideBar/slots/SideBarSlots.d.ts +9 -3
- package/components/SideBar/slots/SideBarSlots.js +36 -28
- package/components/SideBar/styles.js +2 -4
- package/components/SideBar/subcomponents/ContentComponent/index.js +39 -19
- package/components/SideBar/subcomponents/ContentComponent/style.js +171 -22
- package/components/SideBar/subcomponents/{FooterSidebar → Promotion}/index.d.ts +2 -2
- package/components/SideBar/subcomponents/{FooterSidebar → Promotion}/index.js +8 -15
- package/components/SideBar/subcomponents/{FooterSidebar → Promotion}/styles.js +2 -2
- package/components/SideBar/subcomponents/Promotion/types.d.ts +5 -0
- package/components/SideBar/subcomponents/SideBarDesktop/index.js +1 -1
- package/components/SideBar/subcomponents/SideBarDesktop/styles.js +10 -14
- package/components/SideBar/subcomponents/SideBarMobile/index.js +1 -1
- package/components/SideBar/subcomponents/TreeGroupItems/index.d.ts +5 -0
- package/components/SideBar/subcomponents/{ContentGroups → TreeGroupItems}/index.js +16 -18
- package/components/SideBar/subcomponents/{ContentGroups → TreeGroupItems}/styles.js +5 -7
- package/components/SideBar/subcomponents/{ContentGroups/subcomponents/ContainerMenuItemsMain → TreeGroupItems}/subcomponents/ArrowIcon/index.js +10 -7
- package/components/SideBar/subcomponents/{ContentGroups/subcomponents/ContainerMenuItemsMain → TreeGroupItems/subcomponents/NodeMenuItem}/index.d.ts +3 -3
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItem/index.js +69 -0
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItem/types.d.ts +9 -0
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItemMain/NodeMenuItemMain.d.ts +5 -0
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItemMain/NodeMenuItemMain.js +56 -0
- package/components/SideBar/subcomponents/TreeGroupItems/subcomponents/NodeMenuItemMain/index.d.ts +1 -0
- package/components/SideBar/subcomponents/TreeGroupItems/types.d.ts +4 -0
- package/components/SideBar/types.d.ts +7 -3
- package/components/WindowBase/WindowBase.js +7 -1
- package/components/WindowBase/WindowBase.styles.js +50 -15
- package/components/WindowBase/constants.d.ts +1 -0
- package/components/WindowBase/constants.js +5 -1
- package/components/WindowBase/slots/WindowBaseEnum.d.ts +2 -1
- package/components/WindowBase/slots/WindowBaseEnum.js +1 -0
- package/components/WindowBase/slots/WindowBaseSlots.d.ts +3 -0
- package/components/WindowBase/slots/WindowBaseSlots.js +6 -1
- package/components/WindowBase/subcomponents/Header/HeaderWindowBase.js +11 -5
- package/components/WindowBase/subcomponents/Header/types.d.ts +1 -1
- package/components/WindowBase/subcomponents/Header/useButtonActions.js +4 -2
- 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 +5 -0
- package/components/WindowBase/types.d.ts +16 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js +13 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useRightActions.js +26 -20
- package/components/areas/contexts/AreasContext/store.js +2 -2
- package/components/extended/React-Resizable/helpers.js +1 -1
- package/components/extended/React-resizable-panels/SplitLayout.js +6 -3
- package/components/extended/React-resizable-panels/SplitLayout.styles.js +78 -36
- package/components/extended/React-resizable-panels/constants.d.ts +6 -0
- package/components/extended/React-resizable-panels/constants.js +5 -1
- package/components/extended/React-resizable-panels/slots/SplitLayoutEnum.d.ts +2 -1
- package/components/extended/React-resizable-panels/slots/SplitLayoutEnum.js +1 -0
- package/components/extended/React-resizable-panels/slots/SplitLayoutSlots.d.ts +3 -0
- package/components/extended/React-resizable-panels/slots/SplitLayoutSlots.js +7 -1
- package/components/hook-form/RHFAutocomplete/RFHAutocompleteStyles.js +1 -1
- package/components/hook-form/RHFTextField/RHFTextField.js +1 -0
- package/components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.styles.js +3 -38
- package/components/hook-form/RHFormContext/index.d.ts +1 -1
- package/components/mui_extended/Accordion/styles.js +10 -2
- package/components/mui_extended/Button/Button.js +3 -1
- package/components/mui_extended/Button/ButtonStyles.js +6 -1
- package/components/mui_extended/Button/types.d.ts +1 -1
- package/components/mui_extended/CheckBox/CheckBox.styles.js +2 -1
- package/components/mui_extended/Divider/index.d.ts +1 -0
- package/components/mui_extended/Divider/index.js +1 -0
- package/components/mui_extended/NavLink/NavLink.js +3 -1
- package/components/mui_extended/NavLink/NavLink.styles.js +2 -1
- package/components/mui_extended/NavLink/types.d.ts +3 -1
- package/components/mui_extended/Tab/Tab.styles.js +2 -1
- package/components/mui_extended/TabContent/TabContent.styles.js +2 -8
- package/components/mui_extended/TextField/TextField.js +1 -1
- package/components/mui_extended/TextField/TextField.styles.js +20 -18
- package/components/mui_extended/Typography/slots/typographySlots.d.ts +1 -1
- package/components/mui_extended/index.d.ts +1 -0
- package/hooks/useDynamicFilterAndSort/styles.js +1 -1
- package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.d.ts +3 -0
- package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js +334 -88
- package/index.d.ts +1 -0
- package/index.js +23 -20
- package/package.json +4 -3
- 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/DataGridRender.d.ts +2 -0
- package/storybook/components/DynamicFilter/DynamicFilter.stories.d.ts +27 -11
- package/storybook/components/DynamicSort/DynamicSort.stories.d.ts +26 -10
- package/storybook/components/SideBar/subcomponents/FooterPromotion/FooterPromotion.d.ts +4 -0
- package/storybook/components/SideBar/subcomponents/FooterPromotion/constants.d.ts +3 -0
- package/storybook/components/SideBar/subcomponents/FooterPromotion/index.d.ts +1 -0
- package/storybook/components/extended/mui/IconButton/IconButton.stories.d.ts +1 -0
- package/storybook/components/extended/mui/TextField/TextFieldText.stories.d.ts +1 -0
- package/utils/index.d.ts +1 -0
- package/components/SideBar/subcomponents/ContentGroups/index.d.ts +0 -5
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/index.js +0 -63
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/styles.d.ts +0 -2
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/styles.js +0 -47
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/types.d.ts +0 -7
- package/components/SideBar/subcomponents/ContentGroups/types.d.ts +0 -4
- package/components/SideBar/subcomponents/FooterSidebar/types.d.ts +0 -5
- package/components/SideBar/subcomponents/HeaderSidebar/index.js +0 -25
- /package/components/SideBar/subcomponents/{FooterSidebar → Promotion}/styles.d.ts +0 -0
- /package/components/SideBar/subcomponents/{ContentGroups → TreeGroupItems}/styles.d.ts +0 -0
- /package/components/SideBar/subcomponents/{ContentGroups/subcomponents/ContainerMenuItemsMain → TreeGroupItems}/subcomponents/ArrowIcon/index.d.ts +0 -0
- /package/components/SideBar/subcomponents/{ContentGroups/subcomponents/ContainerMenuItemsMain → TreeGroupItems}/subcomponents/ArrowIcon/types.d.ts +0 -0
package/@types/types.d.ts
CHANGED
|
@@ -148,6 +148,7 @@ import { ScrollBarOwnerState, ScrollBarSlotsType } from '../components/ScrollBar
|
|
|
148
148
|
|
|
149
149
|
import { SplitLayoutOwnerState } from '../components/extended/React-resizable-panels/types';
|
|
150
150
|
import { ObjectLogsOwnerState, ObjectLogsSlotsType } from '../components/ObjectLogs/types';
|
|
151
|
+
import { LanguagePopoverOwnerState, LanguagePopoverSlotsType } from '../components/LanguagePopover/types';
|
|
151
152
|
declare module '@mui/material/styles' {
|
|
152
153
|
// Define the slots in the theme
|
|
153
154
|
interface ComponentNameToClassKey {
|
|
@@ -226,6 +227,7 @@ declare module '@mui/material/styles' {
|
|
|
226
227
|
M4LScrollbar: ScrollBarSlotsType;
|
|
227
228
|
M4LSplitLayout: SplitLayoutOwnerState;
|
|
228
229
|
M4LObjectLogs: ObjectLogsSlotsType;
|
|
230
|
+
M4LLanguagePopover: LanguagePopoverSlotsType;
|
|
229
231
|
}
|
|
230
232
|
interface ComponentsPropsList {
|
|
231
233
|
// Extend ComponentsProps or ComponentsOwnerState(this extend ComponentProps)
|
|
@@ -304,6 +306,7 @@ declare module '@mui/material/styles' {
|
|
|
304
306
|
M4LScrollBar: Partial<ScrollBarOwnerState>;
|
|
305
307
|
M4LSplitLayout: Partial<SplitLayoutOwnerState>;
|
|
306
308
|
M4LObjectLogs: Partial<ObjectLogsOwnerState>;
|
|
309
|
+
M4LLanguagePopover: Partial<LanguagePopoverOwnerState>;
|
|
307
310
|
}
|
|
308
311
|
interface Components {
|
|
309
312
|
M4LDynamicFilter?: {
|
|
@@ -691,5 +694,10 @@ declare module '@mui/material/styles' {
|
|
|
691
694
|
styleOverrides?: ComponentsOverrides<Theme>['M4LObjectLogs'];
|
|
692
695
|
variants?: ComponentsVariants['M4LObjectLogs'];
|
|
693
696
|
};
|
|
697
|
+
M4LLanguagePopover?: {
|
|
698
|
+
defaultProps?: ComponentsPropsList['M4LLanguagePopover'];
|
|
699
|
+
styleOverrides?: ComponentsOverrides<Theme>['M4LLanguagePopover'];
|
|
700
|
+
variants?: ComponentsVariants['M4LLanguagePopover'];
|
|
701
|
+
};
|
|
694
702
|
}
|
|
695
703
|
}
|
package/components/Chip/Chip.js
CHANGED
|
@@ -28,16 +28,14 @@ const Chip = forwardRef((props, ref) => {
|
|
|
28
28
|
const { currentSize } = useComponentSize(size);
|
|
29
29
|
const isSkeleton = useModuleSkeleton();
|
|
30
30
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
31
|
-
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
32
31
|
const ownerState = useMemo(() => ({
|
|
33
32
|
interactive: !!onClick,
|
|
34
|
-
size:
|
|
35
|
-
chipSize: adjustedSize,
|
|
33
|
+
size: currentSize,
|
|
36
34
|
variant,
|
|
37
35
|
color,
|
|
38
36
|
opacity,
|
|
39
37
|
externalColor
|
|
40
|
-
}), [
|
|
38
|
+
}), [currentSize, variant, color, opacity, externalColor, onClick]);
|
|
41
39
|
const renderIcon = useMemo(() => (icon, instaceDataTestId) => {
|
|
42
40
|
if (!icon) {
|
|
43
41
|
return null;
|
|
@@ -50,12 +48,12 @@ const Chip = forwardRef((props, ref) => {
|
|
|
50
48
|
{
|
|
51
49
|
ownerState: { ...ownerState },
|
|
52
50
|
src: icon,
|
|
53
|
-
size:
|
|
51
|
+
size: currentSize,
|
|
54
52
|
instaceDataTestId
|
|
55
53
|
}
|
|
56
54
|
);
|
|
57
55
|
}
|
|
58
|
-
}, [ownerState,
|
|
56
|
+
}, [ownerState, currentSize]);
|
|
59
57
|
if (isSkeleton) {
|
|
60
58
|
return /* @__PURE__ */ jsx(
|
|
61
59
|
SkeletonChipStyled,
|
|
@@ -75,7 +73,7 @@ const Chip = forwardRef((props, ref) => {
|
|
|
75
73
|
ChipRootStyled,
|
|
76
74
|
{
|
|
77
75
|
role: "button-chip",
|
|
78
|
-
size:
|
|
76
|
+
size: currentSize,
|
|
79
77
|
onClick,
|
|
80
78
|
ownerState: { ...ownerState },
|
|
81
79
|
className: clsx(className, CHIP_CLASSES.root),
|
|
@@ -85,17 +83,18 @@ const Chip = forwardRef((props, ref) => {
|
|
|
85
83
|
...others,
|
|
86
84
|
children: [
|
|
87
85
|
renderIcon(startIcon, "ChipStartIcon"),
|
|
88
|
-
/* @__PURE__ */ jsx(TextChipStyled, { size:
|
|
86
|
+
/* @__PURE__ */ jsx(TextChipStyled, { size: currentSize, ownerState: { ...ownerState }, color, children: label }),
|
|
89
87
|
renderIcon(endIcon, "ChipEndIcon"),
|
|
90
88
|
onDeleted && /* @__PURE__ */ jsx(
|
|
91
89
|
IconButtonStyled,
|
|
92
90
|
{
|
|
93
91
|
...iconButtonProps,
|
|
94
92
|
src: iconClose,
|
|
95
|
-
size:
|
|
93
|
+
size: currentSize,
|
|
96
94
|
ownerState: { ...ownerState },
|
|
97
95
|
onClick: handleDelete,
|
|
98
|
-
disabled: disabledDeleteButton
|
|
96
|
+
disabled: disabledDeleteButton,
|
|
97
|
+
className: CHIP_CLASSES.closeIcon
|
|
99
98
|
}
|
|
100
99
|
)
|
|
101
100
|
]
|
|
@@ -43,8 +43,8 @@ const chipStyles = {
|
|
|
43
43
|
display: "flex",
|
|
44
44
|
alignItems: "center",
|
|
45
45
|
padding: theme.vars.size.baseSpacings.sp1,
|
|
46
|
-
paddingRight: 0,
|
|
47
46
|
borderRadius: theme.vars.size.borderRadius["r0-5"],
|
|
47
|
+
gap: theme.vars.size.baseSpacings["sp0-5"],
|
|
48
48
|
width: "max-content",
|
|
49
49
|
cursor: "pointer",
|
|
50
50
|
color,
|
|
@@ -72,6 +72,17 @@ const chipStyles = {
|
|
|
72
72
|
border: `${theme.vars.size.borderStroke.container}`,
|
|
73
73
|
borderColor: bgColor
|
|
74
74
|
},
|
|
75
|
+
"&&& .M4LChip-closeIcon": {
|
|
76
|
+
...getSizeStyles(
|
|
77
|
+
theme,
|
|
78
|
+
ownerState?.size || "medium",
|
|
79
|
+
"base",
|
|
80
|
+
(size) => ({
|
|
81
|
+
height: size,
|
|
82
|
+
width: size
|
|
83
|
+
})
|
|
84
|
+
)
|
|
85
|
+
},
|
|
75
86
|
variants: []
|
|
76
87
|
};
|
|
77
88
|
},
|
|
@@ -81,7 +92,7 @@ const chipStyles = {
|
|
|
81
92
|
textChip: ({ theme }) => ({
|
|
82
93
|
whiteSpace: "nowrap",
|
|
83
94
|
paddingLeft: theme.vars.size.baseSpacings.sp1,
|
|
84
|
-
paddingRight: theme.vars.size.baseSpacings.
|
|
95
|
+
paddingRight: theme.vars.size.baseSpacings.sp1
|
|
85
96
|
}),
|
|
86
97
|
/**
|
|
87
98
|
* Styles for the chip icon element.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChipSlots, ChipComplementaryClasses } from './slots/ChipEnum';
|
|
1
2
|
/**
|
|
2
3
|
* Clave de identificación del componente Chip dentro del sistema.
|
|
3
4
|
*
|
|
@@ -6,6 +7,14 @@
|
|
|
6
7
|
* @default 'M4LChip'
|
|
7
8
|
*/
|
|
8
9
|
export declare const CHIP_KEY_COMPONENT = "M4LChip";
|
|
10
|
+
export declare const COMBINED_CHIP_ENUMS: {
|
|
11
|
+
closeIcon: ChipComplementaryClasses.closeIcon;
|
|
12
|
+
root: ChipSlots.root;
|
|
13
|
+
skeletonChip: ChipSlots.skeletonChip;
|
|
14
|
+
chipIcon: ChipSlots.chipIcon;
|
|
15
|
+
textChip: ChipSlots.textChip;
|
|
16
|
+
iconButton: ChipSlots.iconButton;
|
|
17
|
+
};
|
|
9
18
|
/**
|
|
10
19
|
* Inventario de clases CSS para el componente Chip
|
|
11
20
|
*/
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { g as getComponentClasses } from "../../utils/getComponentSlotRoot.js";
|
|
2
|
-
import { C as ChipSlots } from "./slots/ChipEnum.js";
|
|
2
|
+
import { C as ChipComplementaryClasses, a as ChipSlots } from "./slots/ChipEnum.js";
|
|
3
3
|
const CHIP_KEY_COMPONENT = "M4LChip";
|
|
4
|
-
const
|
|
4
|
+
const COMBINED_CHIP_ENUMS = {
|
|
5
|
+
...ChipSlots,
|
|
6
|
+
...ChipComplementaryClasses
|
|
7
|
+
};
|
|
8
|
+
const CHIP_CLASSES = getComponentClasses(CHIP_KEY_COMPONENT, COMBINED_CHIP_ENUMS);
|
|
5
9
|
export {
|
|
6
10
|
CHIP_CLASSES as C,
|
|
7
11
|
CHIP_KEY_COMPONENT as a
|
|
@@ -6,6 +6,11 @@ var ChipSlots = /* @__PURE__ */ ((ChipSlots2) => {
|
|
|
6
6
|
ChipSlots2["iconButton"] = "iconButton";
|
|
7
7
|
return ChipSlots2;
|
|
8
8
|
})(ChipSlots || {});
|
|
9
|
+
var ChipComplementaryClasses = /* @__PURE__ */ ((ChipComplementaryClasses2) => {
|
|
10
|
+
ChipComplementaryClasses2["closeIcon"] = "closeIcon";
|
|
11
|
+
return ChipComplementaryClasses2;
|
|
12
|
+
})(ChipComplementaryClasses || {});
|
|
9
13
|
export {
|
|
10
|
-
|
|
14
|
+
ChipComplementaryClasses as C,
|
|
15
|
+
ChipSlots as a
|
|
11
16
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styled } from "@mui/material/styles";
|
|
2
2
|
import { c as chipStyles } from "../ChipStyles.js";
|
|
3
3
|
import { a as CHIP_KEY_COMPONENT } from "../constants.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as ChipSlots } from "./ChipEnum.js";
|
|
5
5
|
import { S as Skeleton } from "../../mui_extended/Skeleton/Skeleton.js";
|
|
6
6
|
import { T as Typography } from "../../mui_extended/Typography/Typography.js";
|
|
7
7
|
import { I as IconButton } from "../../mui_extended/IconButton/IconButton.js";
|
|
@@ -35,7 +35,9 @@ function DataGrid(props) {
|
|
|
35
35
|
visibleCustomHeader = true,
|
|
36
36
|
defaultUserColumns,
|
|
37
37
|
onChangeUserColumns,
|
|
38
|
-
size
|
|
38
|
+
size,
|
|
39
|
+
externalSortSettings,
|
|
40
|
+
externalFilterSettings
|
|
39
41
|
} = props;
|
|
40
42
|
const {
|
|
41
43
|
withSettings,
|
|
@@ -63,7 +65,11 @@ function DataGrid(props) {
|
|
|
63
65
|
className: classRoot,
|
|
64
66
|
...process.env.NODE_ENV !== "production" ? {
|
|
65
67
|
[TEST_PROP_COLUMNS]: JSON.stringify(columns),
|
|
66
|
-
[TEST_PROP_ID]: getNameDataTestId(
|
|
68
|
+
[TEST_PROP_ID]: getNameDataTestId(
|
|
69
|
+
DATAGRID_PREFIX_NAME,
|
|
70
|
+
"root",
|
|
71
|
+
dataTestId
|
|
72
|
+
),
|
|
67
73
|
[TEST_SKELETON]: isSkeleton ? true : false
|
|
68
74
|
} : {},
|
|
69
75
|
children: /* @__PURE__ */ jsx(
|
|
@@ -83,6 +89,8 @@ function DataGrid(props) {
|
|
|
83
89
|
onChangeUserColumns,
|
|
84
90
|
defaultUserColumns,
|
|
85
91
|
size: currentSize,
|
|
92
|
+
externalSortSettings,
|
|
93
|
+
externalFilterSettings,
|
|
86
94
|
children: /* @__PURE__ */ jsxs(FilterProvider, { initialActiveFilters: false, children: [
|
|
87
95
|
withActions && actionsProps && /* @__PURE__ */ jsx(
|
|
88
96
|
HeaderActions,
|
|
@@ -112,7 +120,13 @@ function DataGrid(props) {
|
|
|
112
120
|
onRowsChange
|
|
113
121
|
}
|
|
114
122
|
),
|
|
115
|
-
withPager && /* @__PURE__ */ jsx(
|
|
123
|
+
withPager && /* @__PURE__ */ jsx(
|
|
124
|
+
ControlNavigate,
|
|
125
|
+
{
|
|
126
|
+
size: currentSize,
|
|
127
|
+
...{ withPager, pagerOptions }
|
|
128
|
+
}
|
|
129
|
+
)
|
|
116
130
|
] })
|
|
117
131
|
}
|
|
118
132
|
)
|
|
@@ -22,7 +22,7 @@ const dataGridStyles = {
|
|
|
22
22
|
height: "100%",
|
|
23
23
|
width: "100%",
|
|
24
24
|
flex: 1,
|
|
25
|
-
overflow: "
|
|
25
|
+
overflow: "hidden",
|
|
26
26
|
"& .rdg .MuiCheckbox-root": {
|
|
27
27
|
"& > svg": {
|
|
28
28
|
color: theme.vars.palette.text.secondary
|
|
@@ -60,23 +60,17 @@ const dataGridStyles = {
|
|
|
60
60
|
/**
|
|
61
61
|
* Estilos del contenedor de las acciones
|
|
62
62
|
*/
|
|
63
|
-
actionsRoot: ({ theme
|
|
63
|
+
actionsRoot: ({ theme }) => ({
|
|
64
64
|
display: "flex",
|
|
65
65
|
alignItems: "center",
|
|
66
66
|
justifyContent: "space-between",
|
|
67
67
|
background: theme.vars.palette.background.default,
|
|
68
68
|
borderRadius: theme.vars.size.borderRadius.r1,
|
|
69
69
|
gap: theme.vars.size.baseSpacings.sp1,
|
|
70
|
-
|
|
71
|
-
...
|
|
72
|
-
theme
|
|
73
|
-
|
|
74
|
-
"container",
|
|
75
|
-
(size) => ({
|
|
76
|
-
minHeight: size,
|
|
77
|
-
height: size
|
|
78
|
-
})
|
|
79
|
-
),
|
|
70
|
+
height: "fit-content",
|
|
71
|
+
...theme.generalSettings.isMobile && {
|
|
72
|
+
minHeight: theme.vars.size.baseSpacings.sp10
|
|
73
|
+
},
|
|
80
74
|
"& .mobile-menu-actions": {
|
|
81
75
|
marginRight: "auto"
|
|
82
76
|
}
|
|
@@ -92,7 +86,8 @@ const dataGridStyles = {
|
|
|
92
86
|
borderRadius: theme.vars.size.borderRadius.r2,
|
|
93
87
|
border: theme.vars.size.borderStroke.container,
|
|
94
88
|
borderColor: theme.vars.palette?.border.disabled,
|
|
95
|
-
padding: theme.vars.size.baseSpacings.sp1
|
|
89
|
+
padding: theme.vars.size.baseSpacings.sp1,
|
|
90
|
+
boxShadow: theme.vars.customShadows?.z1
|
|
96
91
|
}),
|
|
97
92
|
/**
|
|
98
93
|
* Estilos para el contenedor de las acciones derecho
|
|
@@ -142,7 +137,11 @@ const dataGridStyles = {
|
|
|
142
137
|
//Se utiliza directamente el valor porque no está tokenizado
|
|
143
138
|
height: "100%",
|
|
144
139
|
lineHeight: theme.vars.size.baseSpacings.sp4,
|
|
145
|
-
fontSize: getTypographyStyles(
|
|
140
|
+
fontSize: getTypographyStyles(
|
|
141
|
+
theme.generalSettings.isMobile,
|
|
142
|
+
ownerState?.size || "medium",
|
|
143
|
+
"body"
|
|
144
|
+
).fontSize
|
|
146
145
|
}),
|
|
147
146
|
/**
|
|
148
147
|
* Estilos para el valor de RowsCount
|
|
@@ -155,7 +154,11 @@ const dataGridStyles = {
|
|
|
155
154
|
paddingRight: "6px",
|
|
156
155
|
//No hay token para este valor
|
|
157
156
|
paddingTop: theme.vars.size.baseSpacings.sp1,
|
|
158
|
-
fontSize: getTypographyStyles(
|
|
157
|
+
fontSize: getTypographyStyles(
|
|
158
|
+
theme.generalSettings.isMobile,
|
|
159
|
+
ownerState?.size || "medium",
|
|
160
|
+
"body"
|
|
161
|
+
).fontSize
|
|
159
162
|
}),
|
|
160
163
|
/**
|
|
161
164
|
* Estilos para el contenedor de las columnas
|
|
@@ -576,15 +579,10 @@ const dataGridStyles = {
|
|
|
576
579
|
padding: theme.vars.size.baseSpacings.sp1,
|
|
577
580
|
gap: theme.vars.size.baseSpacings.sp1,
|
|
578
581
|
borderRadius: theme.vars.size.borderRadius.r1,
|
|
579
|
-
...getSizeStyles(
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
(size) => ({
|
|
584
|
-
minHeight: size,
|
|
585
|
-
height: size
|
|
586
|
-
})
|
|
587
|
-
)
|
|
582
|
+
...getSizeStyles(theme, ownerState?.size || "medium", "action", (size) => ({
|
|
583
|
+
minHeight: size,
|
|
584
|
+
height: size
|
|
585
|
+
}))
|
|
588
586
|
}),
|
|
589
587
|
/**
|
|
590
588
|
* Estilos de los inputs del header para el filtro
|
|
@@ -603,15 +601,10 @@ const dataGridStyles = {
|
|
|
603
601
|
height: "100%",
|
|
604
602
|
alignItems: "center",
|
|
605
603
|
"& .MuiSkeleton-root": {
|
|
606
|
-
...getSizeStyles(
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
(size) => ({
|
|
611
|
-
minHeight: `${size}!important`,
|
|
612
|
-
height: `${size}!important`
|
|
613
|
-
})
|
|
614
|
-
)
|
|
604
|
+
...getSizeStyles(theme, ownerState?.size || "medium", "base", (size) => ({
|
|
605
|
+
minHeight: `${size}!important`,
|
|
606
|
+
height: `${size}!important`
|
|
607
|
+
}))
|
|
615
608
|
}
|
|
616
609
|
}),
|
|
617
610
|
/**
|
|
@@ -623,6 +616,60 @@ const dataGridStyles = {
|
|
|
623
616
|
flexDirection: "column",
|
|
624
617
|
height: "100%"
|
|
625
618
|
}
|
|
619
|
+
}),
|
|
620
|
+
/**
|
|
621
|
+
* Estilos para el contenedor del nombre de la columna y el icono de sort
|
|
622
|
+
*/
|
|
623
|
+
nameColumnIcon: ({ theme }) => ({
|
|
624
|
+
display: "flex",
|
|
625
|
+
alignItems: "center",
|
|
626
|
+
gap: theme.vars.size.baseSpacings.sp1,
|
|
627
|
+
position: "relative",
|
|
628
|
+
overflow: "visible"
|
|
629
|
+
}),
|
|
630
|
+
/**
|
|
631
|
+
* Estilos para el contenedor del nombre de la columna
|
|
632
|
+
*/
|
|
633
|
+
nameColumn: () => ({
|
|
634
|
+
textOverflow: "ellipsis",
|
|
635
|
+
overflow: "hidden",
|
|
636
|
+
whiteSpace: "nowrap"
|
|
637
|
+
}),
|
|
638
|
+
/**
|
|
639
|
+
* Estilos para el contenedor del icono de la columna
|
|
640
|
+
*/
|
|
641
|
+
iconColumn: ({ theme }) => ({
|
|
642
|
+
display: "flex",
|
|
643
|
+
alignItems: "center",
|
|
644
|
+
gap: theme.vars.size.baseSpacings.sp1
|
|
645
|
+
}),
|
|
646
|
+
/**
|
|
647
|
+
* Estilos para el popover del header actions
|
|
648
|
+
*/
|
|
649
|
+
headerRenderClick: () => ({
|
|
650
|
+
width: "fit-content"
|
|
651
|
+
}),
|
|
652
|
+
/**
|
|
653
|
+
* Estilos para el menuList del header actions
|
|
654
|
+
*/
|
|
655
|
+
menuList: ({ theme }) => ({
|
|
656
|
+
padding: theme.vars.size.baseSpacings.sp3,
|
|
657
|
+
display: "flex",
|
|
658
|
+
flexDirection: "column",
|
|
659
|
+
gap: theme.vars.size.baseSpacings.sp1,
|
|
660
|
+
"& > div": {
|
|
661
|
+
paddingLeft: theme.vars.size.baseSpacings.sp4,
|
|
662
|
+
paddingRight: theme.vars.size.baseSpacings.sp4
|
|
663
|
+
}
|
|
664
|
+
}),
|
|
665
|
+
/**
|
|
666
|
+
* Estilos para el contenedor del boton de acciones del header
|
|
667
|
+
*/
|
|
668
|
+
buttonHeaderActions: () => ({
|
|
669
|
+
display: "flex",
|
|
670
|
+
alignItems: "center",
|
|
671
|
+
justifyContent: "space-between",
|
|
672
|
+
width: "100%"
|
|
626
673
|
})
|
|
627
674
|
};
|
|
628
675
|
export {
|
|
@@ -2,6 +2,8 @@ export declare const DATAGRID_PREFIX_NAME = "M4LDataGrid";
|
|
|
2
2
|
export declare const DATAGRID_SELECT_COLUMN_KEY = "M4LDataGrid-CheckedColumn";
|
|
3
3
|
export declare const DATAGRID_ACTIONS_COLUMN_KEY = "M4LDataGrid-ActionsColumn";
|
|
4
4
|
export declare const TEST_SKELETON = "data-skeleton";
|
|
5
|
+
export declare const DATAGRID_HEADER_RENDER_CLICK_KEY = "M4LDataGrid-HeaderRenderClick";
|
|
6
|
+
export declare const DATAGRID_ID_DICTIONARY = "data_grid";
|
|
5
7
|
export declare enum DATAGRID_SEMANTIC_WIDTHS {
|
|
6
8
|
actions = 40,
|
|
7
9
|
bigChip = 190,
|
|
@@ -2,6 +2,8 @@ const DATAGRID_PREFIX_NAME = "M4LDataGrid";
|
|
|
2
2
|
const DATAGRID_SELECT_COLUMN_KEY = "M4LDataGrid-CheckedColumn";
|
|
3
3
|
const DATAGRID_ACTIONS_COLUMN_KEY = "M4LDataGrid-ActionsColumn";
|
|
4
4
|
const TEST_SKELETON = "data-skeleton";
|
|
5
|
+
const DATAGRID_HEADER_RENDER_CLICK_KEY = "M4LDataGrid-HeaderRenderClick";
|
|
6
|
+
const DATAGRID_ID_DICTIONARY = "data_grid";
|
|
5
7
|
var DATAGRID_SEMANTIC_WIDTHS = /* @__PURE__ */ ((DATAGRID_SEMANTIC_WIDTHS2) => {
|
|
6
8
|
DATAGRID_SEMANTIC_WIDTHS2[DATAGRID_SEMANTIC_WIDTHS2["actions"] = 40] = "actions";
|
|
7
9
|
DATAGRID_SEMANTIC_WIDTHS2[DATAGRID_SEMANTIC_WIDTHS2["bigChip"] = 190] = "bigChip";
|
|
@@ -31,7 +33,9 @@ export {
|
|
|
31
33
|
TEST_SKELETON as T,
|
|
32
34
|
DATAGRID_ROW_HEIGHTS as a,
|
|
33
35
|
DATAGRID_ROW_HEADER_HEIGHTS as b,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
DATAGRID_ID_DICTIONARY as c,
|
|
37
|
+
DATAGRID_SELECT_COLUMN_KEY as d,
|
|
38
|
+
DATAGRID_SEMANTIC_WIDTHS as e,
|
|
39
|
+
DATAGRID_ACTIONS_COLUMN_KEY as f,
|
|
40
|
+
DATAGRID_HEADER_RENDER_CLICK_KEY as g
|
|
37
41
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState,
|
|
2
|
+
import { useState, useEffect, useMemo, useCallback, createContext } from "react";
|
|
3
3
|
import { c as castMapColumnsWidthToRecord } from "../../helpers/castMapColumnsWidthToRecord.js";
|
|
4
4
|
import { useFirstRender } from "@m4l/graphics";
|
|
5
5
|
import { g as getComponentClasses } from "../../../../utils/getComponentSlotRoot.js";
|
|
@@ -32,10 +32,7 @@ function getColumnsConfig(id, columns, defaultUserColumns = void 0) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return columns.map((column, index) => {
|
|
35
|
-
const [columnConfig = { ...column }, columnConfigIndex] = getColumnConfigByKey(
|
|
36
|
-
column.key,
|
|
37
|
-
columnsConfig
|
|
38
|
-
);
|
|
35
|
+
const [columnConfig = { ...column }, columnConfigIndex] = getColumnConfigByKey(column.key, columnsConfig);
|
|
39
36
|
return {
|
|
40
37
|
key: column.key,
|
|
41
38
|
name: typeof column.name === "string" ? column.name : String(column.name),
|
|
@@ -81,10 +78,16 @@ function getColumnsWidth(id, columns, defaultUserColumns) {
|
|
|
81
78
|
function saveColumnsWidth(id, storeColumnsWidth, onChangeUserColumns) {
|
|
82
79
|
if (onChangeUserColumns) {
|
|
83
80
|
const columnsWidthObject = castMapColumnsWidthToRecord(storeColumnsWidth);
|
|
84
|
-
onChangeUserColumns({
|
|
81
|
+
onChangeUserColumns({
|
|
82
|
+
reason: "columnsWidths",
|
|
83
|
+
userConfig: columnsWidthObject
|
|
84
|
+
});
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
localStorage.setItem(
|
|
87
|
+
localStorage.setItem(
|
|
88
|
+
`${id}_columns_width`,
|
|
89
|
+
JSON.stringify([...storeColumnsWidth])
|
|
90
|
+
);
|
|
88
91
|
}
|
|
89
92
|
function saveColumnsConfig(id, columnsConfig, onChangeUserColumns) {
|
|
90
93
|
if (onChangeUserColumns) {
|
|
@@ -118,26 +121,26 @@ function DataGridProvider(props) {
|
|
|
118
121
|
onCheckedRowsChange,
|
|
119
122
|
rowKeyGetter,
|
|
120
123
|
onChangeUserColumns,
|
|
124
|
+
externalSortSettings: sortSettings,
|
|
125
|
+
externalFilterSettings: filterSettings,
|
|
121
126
|
size
|
|
122
127
|
} = props;
|
|
123
128
|
const isFirstRender = useFirstRender([columns, id]);
|
|
124
|
-
const classes = getComponentClasses(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const [columnsWidths, setColumnsWidths] = useState(
|
|
137
|
-
/* @__PURE__ */ new Map()
|
|
129
|
+
const classes = getComponentClasses(DATAGRID_PREFIX_NAME, {
|
|
130
|
+
...DataGridSlots,
|
|
131
|
+
...ActionsSlots,
|
|
132
|
+
...RowsCountSlots,
|
|
133
|
+
...TableSlots,
|
|
134
|
+
...TextEditorSlots,
|
|
135
|
+
...ColumnsConfigSlots,
|
|
136
|
+
...ControlNavigateSlots
|
|
137
|
+
});
|
|
138
|
+
const [columnsWidths, setColumnsWidths] = useState(/* @__PURE__ */ new Map());
|
|
139
|
+
const [columnsConfig, setColumnsConfigOptions] = useState(
|
|
140
|
+
() => []
|
|
138
141
|
);
|
|
139
|
-
const [columnsConfig, setColumnsConfigOptions] = useState(() => []);
|
|
140
142
|
const [rowsFilterCount, setRowFilterCount] = useState(rowsCount);
|
|
143
|
+
const [sortColumns, setSortColumns] = useState([]);
|
|
141
144
|
const [currentRowHeightVariant, setCurrentRowHeightVariant] = useState(() => {
|
|
142
145
|
if (typeof rowHeights !== typeof rowHeaderHeights) {
|
|
143
146
|
throw new Error("Must be same type rowheights and rowHeaderTypes");
|
|
@@ -161,19 +164,44 @@ function DataGridProvider(props) {
|
|
|
161
164
|
rowHeaderHeight: typeof rowHeaderHeights !== "number" ? rowHeaderHeights[getIndexRowHeightVariant(initialRowHeightVariant)] : rowHeaderHeights
|
|
162
165
|
};
|
|
163
166
|
});
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const keys = new Set(columns.map((c) => c.key));
|
|
169
|
+
if (sortSettings?.sortsColumns) {
|
|
170
|
+
for (const sort of sortSettings.sortsColumns) {
|
|
171
|
+
if (!keys.has(sort)) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
`DataGridProvider: Sorts incluye "${sort}", pero no existe ninguna columna con key="${sort}".`
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (filterSettings?.filterColumns) {
|
|
179
|
+
for (const filterField of filterSettings.filterColumns) {
|
|
180
|
+
if (!keys.has(filterField.name)) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`DataGridProvider: Fields incluye "${filterField.name}", pero no existe ninguna columna con key="${filterField.name}".`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, [columns, sortSettings, filterSettings]);
|
|
164
188
|
const finalRowHeights = useMemo(() => rowHeights, [rowHeights]);
|
|
165
189
|
let timerSaveColumns;
|
|
166
190
|
useEffect(() => {
|
|
167
191
|
if (isFirstRender) {
|
|
168
192
|
setColumnsWidths(getColumnsWidth(id, columns, defaultUserColumns));
|
|
169
|
-
setColumnsConfigOptions(
|
|
193
|
+
setColumnsConfigOptions(
|
|
194
|
+
getColumnsConfig(id, columns, defaultUserColumns)
|
|
195
|
+
);
|
|
170
196
|
}
|
|
171
197
|
}, [defaultUserColumns]);
|
|
172
198
|
useEffect(() => {
|
|
173
199
|
if (!isFirstRender) {
|
|
174
200
|
const finalColumnsConfig = [];
|
|
175
201
|
for (let i = 0; i < columnsConfig.length; i++) {
|
|
176
|
-
const columnIndex = columns.findIndex(
|
|
202
|
+
const columnIndex = columns.findIndex(
|
|
203
|
+
(c) => c.key === columnsConfig[i]?.key
|
|
204
|
+
);
|
|
177
205
|
if (columnIndex !== -1) {
|
|
178
206
|
const column = columns[columnIndex];
|
|
179
207
|
finalColumnsConfig.push({
|
|
@@ -185,11 +213,18 @@ function DataGridProvider(props) {
|
|
|
185
213
|
});
|
|
186
214
|
}
|
|
187
215
|
}
|
|
188
|
-
const newColumns = columns.filter(
|
|
216
|
+
const newColumns = columns.filter(
|
|
217
|
+
(column, index) => column.key !== columnsConfig[index]?.key
|
|
218
|
+
);
|
|
189
219
|
if (newColumns.length > 0) {
|
|
190
220
|
const colLength = finalColumnsConfig.length;
|
|
191
|
-
const newColConfig = getColumnsConfig(
|
|
192
|
-
|
|
221
|
+
const newColConfig = getColumnsConfig(
|
|
222
|
+
id,
|
|
223
|
+
newColumns
|
|
224
|
+
).map((columnConfig, index) => {
|
|
225
|
+
const columnIndex = columns.findIndex(
|
|
226
|
+
(c) => c.key === newColumns[index].key
|
|
227
|
+
);
|
|
193
228
|
const column = newColumns[index];
|
|
194
229
|
const indexNewCol = index + colLength;
|
|
195
230
|
return {
|
|
@@ -206,7 +241,11 @@ function DataGridProvider(props) {
|
|
|
206
241
|
if (deepEqual(columnsConfig, finalColumnsConfig)) {
|
|
207
242
|
return;
|
|
208
243
|
}
|
|
209
|
-
console.log(
|
|
244
|
+
console.log(
|
|
245
|
+
"useEffect columnsConfig changed",
|
|
246
|
+
columnsConfig,
|
|
247
|
+
finalColumnsConfig
|
|
248
|
+
);
|
|
210
249
|
setColumnsConfigOptions(finalColumnsConfig);
|
|
211
250
|
}
|
|
212
251
|
}, [columns, id]);
|
|
@@ -223,8 +262,12 @@ function DataGridProvider(props) {
|
|
|
223
262
|
if (sourceKey === targetKey) {
|
|
224
263
|
return;
|
|
225
264
|
}
|
|
226
|
-
const sourceColumnIndex = columnsConfig.findIndex(
|
|
227
|
-
|
|
265
|
+
const sourceColumnIndex = columnsConfig.findIndex(
|
|
266
|
+
(c) => c.key === sourceKey
|
|
267
|
+
);
|
|
268
|
+
const targetColumnIndex = columnsConfig.findIndex(
|
|
269
|
+
(c) => c.key === targetKey
|
|
270
|
+
);
|
|
228
271
|
const reorderedColumnsConfig = [...columnsConfig];
|
|
229
272
|
reorderedColumnsConfig.splice(
|
|
230
273
|
targetColumnIndex,
|
|
@@ -282,6 +325,10 @@ function DataGridProvider(props) {
|
|
|
282
325
|
onCheckedRowsChange,
|
|
283
326
|
rowKeyGetter,
|
|
284
327
|
onChangeUserColumns,
|
|
328
|
+
sortColumns,
|
|
329
|
+
setSortColumns,
|
|
330
|
+
externalSortSettings: sortSettings,
|
|
331
|
+
externalFilterSettings: filterSettings,
|
|
285
332
|
classes,
|
|
286
333
|
size
|
|
287
334
|
},
|
|
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { RowKey, RowHeightVariants, GridProps } from '../../types';
|
|
3
3
|
import { Maybe } from '@m4l/core';
|
|
4
4
|
import { ActionsSlots, ColumnsConfigSlots, ControlNavigateSlots, DataGridSlots, RowsCountSlots, TableSlots, TextEditorSlots } from '../../slots/DataGridEnum';
|
|
5
|
+
import { SortColumn } from 'react-data-grid';
|
|
5
6
|
export interface BaseConfigColumn {
|
|
6
7
|
key: string;
|
|
7
8
|
visible: boolean;
|
|
@@ -22,7 +23,7 @@ export interface IGridConfig {
|
|
|
22
23
|
columnsConfig: BaseConfigColumn[];
|
|
23
24
|
columnsWidths: Record<RowKey, number>;
|
|
24
25
|
}
|
|
25
|
-
export interface DataGridProviderProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Pick<GridProps<TRow, TSummaryRow, TKey>, 'rows' | 'columns' | 'rowActionsGetter' | 'rowHeaderHeights' | 'rowHeights' | 'initialRowHeightVariant' | 'checkedRows' | 'onCheckedRowsChange' | 'rowKeyGetter' | 'onChangeUserColumns' | 'defaultUserColumns'> {
|
|
26
|
+
export interface DataGridProviderProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Pick<GridProps<TRow, TSummaryRow, TKey>, 'rows' | 'columns' | 'rowActionsGetter' | 'rowHeaderHeights' | 'rowHeights' | 'initialRowHeightVariant' | 'checkedRows' | 'onCheckedRowsChange' | 'rowKeyGetter' | 'onChangeUserColumns' | 'defaultUserColumns' | 'externalSortSettings' | 'externalFilterSettings'> {
|
|
26
27
|
id: number | string;
|
|
27
28
|
children: ReactNode;
|
|
28
29
|
rowsCount: number;
|
|
@@ -33,7 +34,7 @@ export type RowHeightState = {
|
|
|
33
34
|
rowHeight: number;
|
|
34
35
|
rowHeaderHeight: number;
|
|
35
36
|
};
|
|
36
|
-
export interface DataGridContextProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Pick<DataGridProviderProps<TRow, TSummaryRow, TKey>, 'rows' | 'checkedRows' | 'onCheckedRowsChange' | 'rowHeights' | 'rowsCount' | 'rowActionsGetter' | 'rowKeyGetter' | 'onChangeUserColumns'> {
|
|
37
|
+
export interface DataGridContextProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Pick<DataGridProviderProps<TRow, TSummaryRow, TKey>, 'rows' | 'checkedRows' | 'onCheckedRowsChange' | 'rowHeights' | 'rowsCount' | 'rowActionsGetter' | 'rowKeyGetter' | 'onChangeUserColumns' | 'externalSortSettings' | 'externalFilterSettings'> {
|
|
37
38
|
columnsConfig: IConfigColumn[];
|
|
38
39
|
columnsWidths: Map<string, Maybe<string | number>>;
|
|
39
40
|
setRowsCount: (newRowsCount: number) => void;
|
|
@@ -46,4 +47,6 @@ export interface DataGridContextProps<TRow, TSummaryRow, TKey extends RowKey = R
|
|
|
46
47
|
onChangeColumnWidth: (columnKey: string, width: number) => void;
|
|
47
48
|
classes?: Record<DataGridSlots | ActionsSlots | RowsCountSlots | TableSlots | TextEditorSlots | ColumnsConfigSlots | ControlNavigateSlots, string>;
|
|
48
49
|
size: GridProps<any, any, any>['size'];
|
|
50
|
+
sortColumns: SortColumn[];
|
|
51
|
+
setSortColumns: React.Dispatch<React.SetStateAction<SortColumn[]>>;
|
|
49
52
|
}
|