@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as getTypographyStyles } from "../../../utils/getTypographyStyles.js";
|
|
2
|
-
import { a as getHeightSizeStyles } from "../../../utils/getSizeStyles/getSizeStyles.js";
|
|
2
|
+
import { a as getHeightSizeStyles, g as getSizeStyles } from "../../../utils/getSizeStyles/getSizeStyles.js";
|
|
3
3
|
import { T as TEXT_FIELD_CLASSES } from "./constants.js";
|
|
4
4
|
const textFieldStyles = {
|
|
5
5
|
/**
|
|
@@ -28,17 +28,19 @@ const textFieldStyles = {
|
|
|
28
28
|
// transición
|
|
29
29
|
transition: "all 0.2s ease",
|
|
30
30
|
// Espaciado entre elementos
|
|
31
|
-
...
|
|
32
|
-
theme
|
|
31
|
+
...getSizeStyles(
|
|
32
|
+
theme,
|
|
33
33
|
ownerState?.size || "medium",
|
|
34
34
|
"action",
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
}
|
|
35
|
+
(size) => ({
|
|
36
|
+
height: "auto",
|
|
37
|
+
minHeight: size
|
|
38
|
+
})
|
|
41
39
|
),
|
|
40
|
+
"& .MuiInputBase-input.MuiInputBase-inputMultiline": {
|
|
41
|
+
paddingTop: theme.vars.size.baseSpacings.sp1,
|
|
42
|
+
paddingBottom: theme.vars.size.baseSpacings.sp1
|
|
43
|
+
},
|
|
42
44
|
...ownerState?.readOnly ? {
|
|
43
45
|
backgroundColor: theme.vars.palette.background.neutral
|
|
44
46
|
} : {}
|
|
@@ -59,7 +61,7 @@ const textFieldStyles = {
|
|
|
59
61
|
"body"
|
|
60
62
|
),
|
|
61
63
|
"&::placeholder": {
|
|
62
|
-
color: theme.palette.text.disabled
|
|
64
|
+
color: theme.vars.palette.text.disabled
|
|
63
65
|
},
|
|
64
66
|
"&:-webkit-autofill": {
|
|
65
67
|
backgroundColor: "transparent!important"
|
|
@@ -90,7 +92,7 @@ const textFieldStyles = {
|
|
|
90
92
|
}
|
|
91
93
|
},
|
|
92
94
|
"&:not(.M4LTextField-readOnly ) .MuiInputBase-root:hover": {
|
|
93
|
-
backgroundColor:
|
|
95
|
+
backgroundColor: theme.vars.palette.default.hoverOpacity,
|
|
94
96
|
...ownerState?.error && {
|
|
95
97
|
borderColor: `${ownerState?.paletteColor?.hover}!important`,
|
|
96
98
|
"& .MuiInputAdornment-root .M4LIcon-icon": {
|
|
@@ -98,10 +100,10 @@ const textFieldStyles = {
|
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
},
|
|
101
|
-
"&:not(.M4LTextField-readOnly
|
|
103
|
+
"&:not(.M4LTextField-readOnly):focus": {
|
|
102
104
|
borderColor: `${ownerState?.paletteColor?.enabled}!important`,
|
|
103
105
|
"& .MuiInputAdornment-root .M4LIcon-icon": {
|
|
104
|
-
backgroundColor: ownerState?.paletteColor?.
|
|
106
|
+
backgroundColor: ownerState?.paletteColor?.active
|
|
105
107
|
}
|
|
106
108
|
},
|
|
107
109
|
// Variant Outlined TextField
|
|
@@ -125,15 +127,15 @@ const textFieldStyles = {
|
|
|
125
127
|
...ownerState?.variant === "contained" && {
|
|
126
128
|
[`&.${TEXT_FIELD_CLASSES.contained} .MuiInputBase-root`]: {
|
|
127
129
|
border: "none",
|
|
128
|
-
backgroundColor: ownerState?.readOnly ? theme.vars.palette.background.neutral : theme.vars.palette[ownerState?.color || "default"][ownerState?.error ? "toneOpacity" : "
|
|
130
|
+
backgroundColor: ownerState?.readOnly ? theme.vars.palette.background.neutral : theme.vars.palette[ownerState?.color || "default"][ownerState?.error ? "toneOpacity" : "enabledOpacity"]
|
|
129
131
|
},
|
|
130
132
|
...ownerState?.error && !ownerState?.readOnly && {
|
|
131
|
-
border: theme.vars.size.borderStroke.
|
|
133
|
+
border: theme.vars.size.borderStroke.container,
|
|
132
134
|
borderColor: `${ownerState?.paletteColor?.enabled}!important`
|
|
133
135
|
},
|
|
134
|
-
"&:not(.M4LTextField-readOnly
|
|
135
|
-
border: theme.vars.size.borderStroke.
|
|
136
|
-
borderColor: `${ownerState?.paletteColor?.
|
|
136
|
+
"&:not(.M4LTextField-readOnly):focus-within": {
|
|
137
|
+
border: theme.vars.size.borderStroke.container,
|
|
138
|
+
borderColor: `${ownerState?.paletteColor?.active}!important`
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
}),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const StyledMUITypography: import('@emotion/styled').StyledComponent<Pick<import('@mui/material').TypographyOwnProps & import('@mui/material/OverridableComponent').CommonProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
5
5
|
ref?: ((instance: HTMLSpanElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLSpanElement> | null | undefined;
|
|
6
|
-
}, "children" | "zIndex" | "paragraph" | "border" | "fontWeight" | "lineHeight" | "letterSpacing" | "fontSize" | "textTransform" | "fontFamily" | "typography" | "flex" | "color" | "left" | "right" | "bottom" | "top" | "style" | "position" | "padding" | "variant" | "borderRadius" | "width" | "display" | "borderColor" | "height" | "gap" | "minHeight" | "
|
|
6
|
+
}, "children" | "zIndex" | "paragraph" | "border" | "fontWeight" | "lineHeight" | "letterSpacing" | "fontSize" | "textTransform" | "fontFamily" | "typography" | "flex" | "color" | "left" | "right" | "bottom" | "top" | "style" | "position" | "padding" | "variant" | "borderRadius" | "width" | "display" | "borderColor" | "height" | "gap" | "minHeight" | "margin" | "overflow" | "boxShadow" | "minWidth" | "justifyContent" | "alignItems" | "paddingLeft" | "borderLeft" | "borderTop" | "maxWidth" | "flexDirection" | "paddingRight" | "borderRight" | "flexGrow" | "marginLeft" | "textOverflow" | "borderBottom" | "gridTemplateColumns" | "marginBottom" | "alignContent" | "alignSelf" | "boxSizing" | "columnGap" | "flexBasis" | "flexShrink" | "flexWrap" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateRows" | "justifyItems" | "justifySelf" | "marginBlockEnd" | "marginBlockStart" | "marginInlineEnd" | "marginInlineStart" | "marginRight" | "marginTop" | "maxHeight" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingTop" | "rowGap" | "textAlign" | "visibility" | "whiteSpace" | "gridArea" | "gridColumn" | "gridRow" | "marginBlock" | "marginInline" | "paddingBlock" | "paddingInline" | "className" | "classes" | "sx" | "p" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "align" | "gutterBottom" | "noWrap" | "variantMapping">, "children" | "ref" | "title" | "zIndex" | "id" | "paragraph" | "border" | "fontWeight" | "lineHeight" | "letterSpacing" | "fontSize" | "textTransform" | "fontFamily" | "typography" | "flex" | "hidden" | "color" | "left" | "right" | "bottom" | "top" | "content" | "style" | "position" | "padding" | "variant" | "borderRadius" | "width" | "display" | "borderColor" | "height" | "gap" | "minHeight" | "margin" | "overflow" | "boxShadow" | "minWidth" | "justifyContent" | "alignItems" | "paddingLeft" | "borderLeft" | "borderTop" | "maxWidth" | "flexDirection" | "paddingRight" | "borderRight" | "flexGrow" | "marginLeft" | "textOverflow" | "borderBottom" | "gridTemplateColumns" | "marginBottom" | "alignContent" | "alignSelf" | "boxSizing" | "columnGap" | "flexBasis" | "flexShrink" | "flexWrap" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateRows" | "justifyItems" | "justifySelf" | "marginBlockEnd" | "marginBlockStart" | "marginInlineEnd" | "marginInlineStart" | "marginRight" | "marginTop" | "maxHeight" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingTop" | "rowGap" | "textAlign" | "translate" | "visibility" | "whiteSpace" | "gridArea" | "gridColumn" | "gridRow" | "marginBlock" | "marginInline" | "paddingBlock" | "paddingInline" | "className" | "classes" | "sx" | "p" | "slot" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "align" | "gutterBottom" | "noWrap" | "variantMapping"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
7
7
|
ownerState?: (Partial<import('../types').TypographyOwnerState> & Record<string, unknown>) | undefined;
|
|
8
8
|
}, {}, {}>;
|
|
9
9
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UseDynamicFilterAndSortProps } from './types';
|
|
2
|
+
import { SortSettings, FilterSettings } from '../../components/DataGrid/types';
|
|
2
3
|
/**
|
|
3
4
|
* Hook para manejar los filtros y ordenamientos dinamicos
|
|
4
5
|
*/
|
|
@@ -7,4 +8,6 @@ export declare const useDynamicFilterAndSort: (props: UseDynamicFilterAndSortPro
|
|
|
7
8
|
rightActions: import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
visibleCustomHeader: boolean;
|
|
9
10
|
customHeaderComponent: import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
externalSortSettings: SortSettings | undefined;
|
|
12
|
+
externalFilterSettings: FilterSettings | undefined;
|
|
10
13
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
3
|
-
import { useState, useRef, useMemo, useCallback } from "react";
|
|
3
|
+
import { useState, useRef, useMemo, useCallback, useReducer } from "react";
|
|
4
4
|
import { D as DynamicFilter } from "../../components/DynamicFilter/DynamicFilter.js";
|
|
5
5
|
import { D as DynamicSort } from "../../components/DynamicSort/DynamicSort.js";
|
|
6
6
|
import { I as IconButton } from "../../components/mui_extended/IconButton/IconButton.js";
|
|
@@ -15,14 +15,40 @@ import { g as getPurgedCookie } from "./helpers.js";
|
|
|
15
15
|
import { u as useWindowToolsMF } from "../../components/WindowBase/hooks/useWindowToolsMF/index.js";
|
|
16
16
|
import { a as DICCTIONARY } from "../../components/DynamicFilter/dictionary.js";
|
|
17
17
|
const useDynamicFilterAndSort = (props) => {
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
fields,
|
|
20
|
+
sorts,
|
|
21
|
+
onChangeFilterSort,
|
|
22
|
+
dataTestId,
|
|
23
|
+
withAllField,
|
|
24
|
+
rightActions,
|
|
25
|
+
initialFilterToggleed = true,
|
|
26
|
+
initialSortToggleed = true,
|
|
27
|
+
prefixCookie,
|
|
28
|
+
setCookie,
|
|
29
|
+
getCookie,
|
|
30
|
+
filterSortAutomatic = true,
|
|
31
|
+
visibleRefresh = false,
|
|
32
|
+
withExternalRefresh
|
|
33
|
+
} = props;
|
|
19
34
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
20
|
-
const [togglesLeftActions, setTogglesLeftActions] = useState(() => ({
|
|
35
|
+
const [togglesLeftActions, setTogglesLeftActions] = useState(() => ({
|
|
36
|
+
filter: initialFilterToggleed,
|
|
37
|
+
sort: initialSortToggleed
|
|
38
|
+
}));
|
|
21
39
|
const [initialAppliedFilters] = useState(() => {
|
|
22
|
-
return getPurgedCookie(
|
|
40
|
+
return getPurgedCookie(
|
|
41
|
+
getCookie?.(
|
|
42
|
+
prefixCookie ? `${prefixCookie}_${COOKIE_APPLIED_FILTERS}` : COOKIE_APPLIED_FILTERS
|
|
43
|
+
)
|
|
44
|
+
);
|
|
23
45
|
});
|
|
24
46
|
const [initialAppliedSorts] = useState(() => {
|
|
25
|
-
return getPurgedCookie(
|
|
47
|
+
return getPurgedCookie(
|
|
48
|
+
getCookie?.(
|
|
49
|
+
prefixCookie ? `${prefixCookie}_${COOKIE_APPLIED_SORTS}` : COOKIE_APPLIED_SORTS
|
|
50
|
+
)
|
|
51
|
+
);
|
|
26
52
|
});
|
|
27
53
|
const refOnChangeFilterSort = useRef(0);
|
|
28
54
|
const fireOnChangeFilterRef = useRef(null);
|
|
@@ -33,7 +59,10 @@ const useDynamicFilterAndSort = (props) => {
|
|
|
33
59
|
filter: initialAppliedFilters?.length === 0,
|
|
34
60
|
sort: initialAppliedSorts?.length === 0
|
|
35
61
|
}));
|
|
36
|
-
const visibleCustomHeader = useMemo(
|
|
62
|
+
const visibleCustomHeader = useMemo(
|
|
63
|
+
() => togglesLeftActions.filter || togglesLeftActions.sort,
|
|
64
|
+
[togglesLeftActions]
|
|
65
|
+
);
|
|
37
66
|
const refreshIconUrl = `${host_static_assets}/${environment_assets}/${ASSETS.refresh}`;
|
|
38
67
|
const eventRefs = useRef({
|
|
39
68
|
eventFilters: { filters: initialAppliedFilters, rawFilters: [] },
|
|
@@ -49,35 +78,61 @@ const useDynamicFilterAndSort = (props) => {
|
|
|
49
78
|
}
|
|
50
79
|
return true;
|
|
51
80
|
}, [eventRefs, fields]);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...
|
|
59
|
-
eventFilters
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
eventSorts: { sorts: newSorts, rawSorts }
|
|
74
|
-
};
|
|
75
|
-
if (isValidFilters()) {
|
|
76
|
-
onChangeFilterSort(eventRefs.current);
|
|
77
|
-
} else {
|
|
81
|
+
const [changeFlags, dispatchChangeFlag] = useReducer(
|
|
82
|
+
(state, action) => ({ ...state, [action]: !state[action] }),
|
|
83
|
+
{ filters: false, sorts: false }
|
|
84
|
+
);
|
|
85
|
+
const handleChangeFilters = useCallback(
|
|
86
|
+
(filters, rawFilters) => {
|
|
87
|
+
setInvisibleBadge((prev) => ({ ...prev, filter: filters.length === 0 }));
|
|
88
|
+
if (eventRefs.current?.eventFilters?.filters && !deepEqual(eventRefs.current?.eventFilters?.filters, filters)) {
|
|
89
|
+
setCookie?.(
|
|
90
|
+
prefixCookie ? `${prefixCookie}_${COOKIE_APPLIED_FILTERS}` : COOKIE_APPLIED_FILTERS,
|
|
91
|
+
"window",
|
|
92
|
+
filters
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
eventRefs.current = {
|
|
96
|
+
...eventRefs.current,
|
|
97
|
+
eventFilters: { filters, rawFilters }
|
|
98
|
+
};
|
|
99
|
+
if (refOnChangeFilterSort.current > 0 || refOnChangeFilterSort.current === 0 && !sorts) {
|
|
100
|
+
onChangeFilterSort(eventRefs.current);
|
|
101
|
+
}
|
|
78
102
|
refOnChangeFilterSort.current++;
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
dispatchChangeFlag("filters");
|
|
104
|
+
},
|
|
105
|
+
[onChangeFilterSort, prefixCookie, setCookie, setInvisibleBadge, sorts]
|
|
106
|
+
);
|
|
107
|
+
const handleChangeSorts = useCallback(
|
|
108
|
+
(newSorts, rawSorts) => {
|
|
109
|
+
setInvisibleBadge((prev) => ({ ...prev, sort: newSorts.length === 0 }));
|
|
110
|
+
if (eventRefs.current?.eventSorts?.sorts && !deepEqual(eventRefs.current?.eventSorts?.sorts, newSorts)) {
|
|
111
|
+
setCookie?.(
|
|
112
|
+
prefixCookie ? `${prefixCookie}_${COOKIE_APPLIED_SORTS}` : COOKIE_APPLIED_SORTS,
|
|
113
|
+
"window",
|
|
114
|
+
newSorts
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
eventRefs.current = {
|
|
118
|
+
...eventRefs.current,
|
|
119
|
+
eventSorts: { sorts: newSorts, rawSorts }
|
|
120
|
+
};
|
|
121
|
+
if (isValidFilters()) {
|
|
122
|
+
onChangeFilterSort(eventRefs.current);
|
|
123
|
+
} else {
|
|
124
|
+
refOnChangeFilterSort.current++;
|
|
125
|
+
}
|
|
126
|
+
dispatchChangeFlag("sorts");
|
|
127
|
+
},
|
|
128
|
+
[
|
|
129
|
+
onChangeFilterSort,
|
|
130
|
+
prefixCookie,
|
|
131
|
+
setCookie,
|
|
132
|
+
setInvisibleBadge,
|
|
133
|
+
isValidFilters
|
|
134
|
+
]
|
|
135
|
+
);
|
|
81
136
|
const onRefresh = useCallback(() => {
|
|
82
137
|
if (!filterSortAutomatic) {
|
|
83
138
|
if (fireOnChangeFilterRef.current) {
|
|
@@ -90,73 +145,264 @@ const useDynamicFilterAndSort = (props) => {
|
|
|
90
145
|
if (isValidFilters()) {
|
|
91
146
|
onChangeFilterSort(eventRefs.current);
|
|
92
147
|
} else {
|
|
93
|
-
toast(
|
|
148
|
+
toast(
|
|
149
|
+
{ title: getLabel(DICCTIONARY.error_invalid_filters_before) },
|
|
150
|
+
{ type: "error" }
|
|
151
|
+
);
|
|
94
152
|
}
|
|
95
153
|
}
|
|
96
|
-
}, [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
onClick: onRefresh,
|
|
113
|
-
variant: "outline"
|
|
114
|
-
}
|
|
154
|
+
}, [
|
|
155
|
+
filterSortAutomatic,
|
|
156
|
+
getLabel,
|
|
157
|
+
isValidFilters,
|
|
158
|
+
onChangeFilterSort,
|
|
159
|
+
toast
|
|
160
|
+
]);
|
|
161
|
+
const leftActions = useMemo(
|
|
162
|
+
() => /* @__PURE__ */ jsxs(
|
|
163
|
+
StackLeftActionsStyled,
|
|
164
|
+
{
|
|
165
|
+
direction: "row",
|
|
166
|
+
...getPropDataTestId(
|
|
167
|
+
M4LDYNAMIC_KEY_FILTER_AND_SORT,
|
|
168
|
+
DynamicFilterAndSortSlots.stackLeftActions,
|
|
169
|
+
dataTestId
|
|
115
170
|
),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ jsx(
|
|
173
|
+
ToggleIconButton,
|
|
174
|
+
{
|
|
175
|
+
badgeProps: {
|
|
176
|
+
variant: "dot",
|
|
177
|
+
invisible: invisibleBadge.filter,
|
|
178
|
+
color: "primary"
|
|
179
|
+
},
|
|
180
|
+
icon: `${host_static_assets}/${environment_assets}/${ICON_PATH_FILTER}`,
|
|
181
|
+
isToggled: togglesLeftActions.filter,
|
|
182
|
+
onToggle: () => handleToggles("filter")
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsx(
|
|
186
|
+
ToggleIconButton,
|
|
187
|
+
{
|
|
188
|
+
badgeProps: {
|
|
189
|
+
variant: "dot",
|
|
190
|
+
invisible: invisibleBadge.sort,
|
|
191
|
+
color: "primary"
|
|
192
|
+
},
|
|
193
|
+
icon: `${host_static_assets}/${environment_assets}/${ICON_PATH_SORT}`,
|
|
194
|
+
isToggled: togglesLeftActions.sort,
|
|
195
|
+
onToggle: () => handleToggles("sort")
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
[
|
|
202
|
+
togglesLeftActions,
|
|
203
|
+
invisibleBadge,
|
|
204
|
+
host_static_assets,
|
|
205
|
+
environment_assets,
|
|
206
|
+
dataTestId
|
|
207
|
+
]
|
|
208
|
+
);
|
|
209
|
+
const finalRightActions = useMemo(
|
|
210
|
+
() => /* @__PURE__ */ jsxs(
|
|
211
|
+
StackRightActionsStyled,
|
|
123
212
|
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
213
|
+
direction: "row",
|
|
214
|
+
...getPropDataTestId(
|
|
215
|
+
M4LDYNAMIC_KEY_FILTER_AND_SORT,
|
|
216
|
+
DynamicFilterAndSortSlots.stackRightActions,
|
|
217
|
+
dataTestId
|
|
218
|
+
),
|
|
219
|
+
children: [
|
|
220
|
+
/* @__PURE__ */ jsx(
|
|
221
|
+
IconButton,
|
|
222
|
+
{
|
|
223
|
+
icon: refreshIconUrl,
|
|
224
|
+
"aria-label": "refresh",
|
|
225
|
+
onClick: onRefresh,
|
|
226
|
+
variant: "outline"
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
rightActions
|
|
230
|
+
]
|
|
131
231
|
}
|
|
132
232
|
),
|
|
133
|
-
|
|
134
|
-
|
|
233
|
+
[dataTestId, rightActions, refreshIconUrl, onRefresh]
|
|
234
|
+
);
|
|
235
|
+
const getCurrentSorts = useCallback(() => {
|
|
236
|
+
if (fireOnChangeSortRef.current) {
|
|
237
|
+
return fireOnChangeSortRef.current.getCurrentSorts();
|
|
238
|
+
}
|
|
239
|
+
return [];
|
|
240
|
+
}, [fireOnChangeSortRef]);
|
|
241
|
+
const handleChangeSortExternal = useCallback(
|
|
242
|
+
(sortApplied) => {
|
|
243
|
+
if (fireOnChangeSortRef.current) {
|
|
244
|
+
const sort = sorts?.find((sort2) => sort2.name === sortApplied.columnKey);
|
|
245
|
+
const isFixed = sort?.presence === "fixed";
|
|
246
|
+
switch (sortApplied.action) {
|
|
247
|
+
case "add":
|
|
248
|
+
const newSort = {
|
|
249
|
+
id: fireOnChangeSortRef.current.getNewId(),
|
|
250
|
+
field: {
|
|
251
|
+
name: sortApplied.columnKey,
|
|
252
|
+
type: sort?.type || "string",
|
|
253
|
+
urlIcon: sort?.urlIcon || "",
|
|
254
|
+
label: sort?.label || sortApplied.columnKey
|
|
255
|
+
},
|
|
256
|
+
isSet: true,
|
|
257
|
+
fixed: isFixed,
|
|
258
|
+
fieldType: sort?.type || "string",
|
|
259
|
+
operator: sortApplied.direction
|
|
260
|
+
};
|
|
261
|
+
setTogglesLeftActions((prev) => ({ ...prev, sort: true }));
|
|
262
|
+
fireOnChangeSortRef.current.addExternalSort(newSort);
|
|
263
|
+
break;
|
|
264
|
+
case "remove":
|
|
265
|
+
if (!isFixed) {
|
|
266
|
+
fireOnChangeSortRef.current.removeExternalSort(
|
|
267
|
+
sortApplied.columnKey
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
[fireOnChangeSortRef, sorts]
|
|
275
|
+
);
|
|
276
|
+
const handleChangeFilterExternal = useCallback(
|
|
277
|
+
(event) => {
|
|
278
|
+
if (fireOnChangeFilterRef.current) {
|
|
279
|
+
switch (event.action) {
|
|
280
|
+
case "add":
|
|
281
|
+
setTogglesLeftActions((prev) => ({ ...prev, filter: true }));
|
|
282
|
+
fireOnChangeFilterRef.current.addExternalFilter(event.columnKey);
|
|
283
|
+
break;
|
|
284
|
+
case "openPopoverMenuFields":
|
|
285
|
+
setTogglesLeftActions((prev) => ({ ...prev, filter: true }));
|
|
286
|
+
fireOnChangeFilterRef.current.openPopoverMenuFields();
|
|
287
|
+
break;
|
|
288
|
+
default:
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
[fireOnChangeFilterRef]
|
|
294
|
+
);
|
|
295
|
+
const getCurrentFilters = useCallback(() => {
|
|
296
|
+
if (fireOnChangeFilterRef.current) {
|
|
297
|
+
return fireOnChangeFilterRef.current.getCurrentFilters();
|
|
298
|
+
}
|
|
299
|
+
return [];
|
|
300
|
+
}, [fireOnChangeFilterRef]);
|
|
301
|
+
const dynamicsFiltersSorts = useMemo(
|
|
302
|
+
() => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
303
|
+
/* @__PURE__ */ jsx(
|
|
304
|
+
DynamicFilter,
|
|
305
|
+
{
|
|
306
|
+
ref: fireOnChangeFilterRef,
|
|
307
|
+
visibleRefresh,
|
|
308
|
+
automatic: filterSortAutomatic,
|
|
309
|
+
fields,
|
|
310
|
+
initialAppliedFilters,
|
|
311
|
+
onChangeFilters: handleChangeFilters,
|
|
312
|
+
withAllField
|
|
313
|
+
}
|
|
314
|
+
),
|
|
315
|
+
sorts ? /* @__PURE__ */ jsx(
|
|
316
|
+
DynamicSort,
|
|
317
|
+
{
|
|
318
|
+
ref: fireOnChangeSortRef,
|
|
319
|
+
visibleRefresh,
|
|
320
|
+
automatic: filterSortAutomatic,
|
|
321
|
+
fields: sorts,
|
|
322
|
+
initialAppliedSorts,
|
|
323
|
+
onChangeSorts: handleChangeSorts
|
|
324
|
+
}
|
|
325
|
+
) : null,
|
|
326
|
+
withExternalRefresh && /* @__PURE__ */ jsx(
|
|
327
|
+
IconButton,
|
|
328
|
+
{
|
|
329
|
+
icon: refreshIconUrl,
|
|
330
|
+
"aria-label": "refresh",
|
|
331
|
+
onClick: onRefresh
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
] }),
|
|
335
|
+
[
|
|
336
|
+
visibleRefresh,
|
|
337
|
+
filterSortAutomatic,
|
|
338
|
+
fields,
|
|
339
|
+
initialAppliedFilters,
|
|
340
|
+
handleChangeFilters,
|
|
341
|
+
withAllField,
|
|
342
|
+
sorts,
|
|
343
|
+
initialAppliedSorts,
|
|
344
|
+
handleChangeSorts,
|
|
345
|
+
withExternalRefresh,
|
|
346
|
+
refreshIconUrl,
|
|
347
|
+
onRefresh
|
|
348
|
+
]
|
|
349
|
+
);
|
|
350
|
+
const customHeaderComponent = useMemo(
|
|
351
|
+
() => /* @__PURE__ */ jsx(
|
|
352
|
+
StackCustomHeaderStyled,
|
|
135
353
|
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
354
|
+
direction: "row",
|
|
355
|
+
ownerState: {
|
|
356
|
+
showDynamicFilter: togglesLeftActions.filter,
|
|
357
|
+
showDynamicSort: togglesLeftActions.sort
|
|
358
|
+
},
|
|
359
|
+
...getPropDataTestId(
|
|
360
|
+
M4LDYNAMIC_KEY_FILTER_AND_SORT,
|
|
361
|
+
DynamicFilterAndSortSlots.stackCustomHeader,
|
|
362
|
+
dataTestId
|
|
363
|
+
),
|
|
364
|
+
children: dynamicsFiltersSorts
|
|
142
365
|
}
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
366
|
+
),
|
|
367
|
+
[togglesLeftActions, dataTestId, dynamicsFiltersSorts]
|
|
368
|
+
);
|
|
369
|
+
const externalSortSettings = useMemo(() => {
|
|
370
|
+
if (!sorts || sorts.length === 0) {
|
|
371
|
+
return void 0;
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
sortsColumns: sorts.map((sort) => sort.name),
|
|
375
|
+
sortsApplied: getCurrentSorts().map((sort) => ({
|
|
376
|
+
columnKey: sort.field.name,
|
|
377
|
+
removable: !sort.fixed,
|
|
378
|
+
direction: sort.operator
|
|
379
|
+
})),
|
|
380
|
+
onChange: handleChangeSortExternal
|
|
381
|
+
};
|
|
382
|
+
}, [sorts, changeFlags.sorts, getCurrentSorts, handleChangeSortExternal]);
|
|
383
|
+
const externalFilterSettings = useMemo(() => {
|
|
384
|
+
if (!fields || fields.length === 0) {
|
|
385
|
+
return void 0;
|
|
153
386
|
}
|
|
154
|
-
|
|
387
|
+
return {
|
|
388
|
+
filterColumns: fields.map((filter) => ({
|
|
389
|
+
name: filter.name,
|
|
390
|
+
multiple: filter.multiple || false
|
|
391
|
+
})),
|
|
392
|
+
filtersApplied: getCurrentFilters().map((filter) => ({
|
|
393
|
+
columnKey: filter.field.name,
|
|
394
|
+
isValid: filter.isSet
|
|
395
|
+
})),
|
|
396
|
+
onChange: handleChangeFilterExternal
|
|
397
|
+
};
|
|
398
|
+
}, [fields, changeFlags.filters, getCurrentFilters, handleChangeFilterExternal]);
|
|
155
399
|
return {
|
|
156
400
|
leftActions,
|
|
157
401
|
rightActions: finalRightActions,
|
|
158
402
|
visibleCustomHeader,
|
|
159
|
-
customHeaderComponent
|
|
403
|
+
customHeaderComponent,
|
|
404
|
+
externalSortSettings,
|
|
405
|
+
externalFilterSettings
|
|
160
406
|
};
|
|
161
407
|
};
|
|
162
408
|
export {
|
package/index.d.ts
CHANGED