rez-table-listing-mui 1.0.37 → 1.0.39
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/dist/index.d.ts +100 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +82 -27
- package/src/components/common/confirm-modal/index.tsx +8 -3
- package/src/components/filter/components/forms/components/Date.tsx +109 -161
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +12 -55
- package/src/components/filter/components/forms/index.tsx +1 -1
- package/src/components/filter/components/saved-filter.tsx +6 -3
- package/src/components/filter/index.tsx +1 -1
- package/src/components/filter/style.ts +0 -1
- package/src/components/index-table.tsx +5 -2
- package/src/components/index.scss +2 -0
- package/src/components/login/index.tsx +1 -1
- package/src/components/search/index.tsx +31 -6
- package/src/components/table-head-popover.tsx +1 -1
- package/src/components/table-settings/common/draggable-listitem.tsx +66 -0
- package/src/components/table-settings/common/listing-values.tsx +117 -0
- package/src/components/table-settings/components/column.tsx +332 -0
- package/src/components/table-settings/components/custom-button.tsx +15 -0
- package/src/components/table-settings/components/custom-dialog.tsx +27 -0
- package/src/components/table-settings/components/quick-tab.tsx +335 -0
- package/src/components/table-settings/components/sorting.tsx +619 -0
- package/src/components/table-settings/components/toggle-button-switch.tsx +45 -0
- package/src/components/table-settings/constants.ts +12 -0
- package/src/components/table-settings/index.tsx +133 -0
- package/src/components/table-settings/style.ts +115 -0
- package/src/components/table-settings/tabs/horizontal/index.tsx +21 -0
- package/src/components/table-settings/tabs/styles.ts +67 -0
- package/src/components/table-settings/tabs/vertical/custom-tab-panel.tsx +29 -0
- package/src/components/table-settings/tabs/vertical/index.tsx +38 -0
- package/src/components/tabs/index.tsx +30 -36
- package/src/index.ts +1 -0
- package/src/libs/hooks/useCraftTableFilterSettings.tsx +176 -0
- package/src/libs/hooks/useEntityTableAPI.tsx +82 -1
- package/src/libs/utils/apiColumn.ts +25 -0
- package/src/libs/utils/common.ts +2 -2
- package/src/types/common.ts +6 -0
- package/src/types/filter-settings.ts +97 -0
- package/src/types/filter.ts +6 -0
- package/src/types/table-options.ts +19 -0
- package/src/types/table.ts +10 -1
- package/.env.uat +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
DialogTitle,
|
|
4
|
+
IconButton,
|
|
5
|
+
Box,
|
|
6
|
+
Typography,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogActions,
|
|
9
|
+
} from "@mui/material";
|
|
10
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
11
|
+
import CustomVerticalTabs from "./tabs/vertical";
|
|
12
|
+
import CustomTabPanel from "./tabs/vertical/custom-tab-panel";
|
|
13
|
+
import QuickTab from "./components/quick-tab";
|
|
14
|
+
import Column from "./components/column";
|
|
15
|
+
import Sorting from "./components/sorting";
|
|
16
|
+
import { QuickFilterModalProps } from "../../types/filter-settings";
|
|
17
|
+
import { CustomDialog, DialogTransition } from "./components/custom-dialog";
|
|
18
|
+
import { dialogStyles } from "./style";
|
|
19
|
+
import CustomButton from "./components/custom-button";
|
|
20
|
+
import { SETTINGS_TABS } from "./constants";
|
|
21
|
+
|
|
22
|
+
const QuickFilterSettings = ({
|
|
23
|
+
show,
|
|
24
|
+
filterSettingStates,
|
|
25
|
+
onClose,
|
|
26
|
+
columnsData,
|
|
27
|
+
tabsApiData,
|
|
28
|
+
tabsApiDataLoading,
|
|
29
|
+
}: QuickFilterModalProps) => {
|
|
30
|
+
const [tabValue, setTabValue] = useState(0);
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
showListViewSettings,
|
|
34
|
+
setSettingsData,
|
|
35
|
+
quickTabStates,
|
|
36
|
+
sortingTabState,
|
|
37
|
+
columnTabState,
|
|
38
|
+
} = filterSettingStates;
|
|
39
|
+
|
|
40
|
+
const hasAPIData = Boolean(Object.entries(columnsData).length);
|
|
41
|
+
|
|
42
|
+
const handleTabChange = (_: React.SyntheticEvent, newValue: number) => {
|
|
43
|
+
setTabValue(newValue);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<CustomDialog
|
|
48
|
+
open={show || showListViewSettings}
|
|
49
|
+
fullWidth
|
|
50
|
+
maxWidth="lg"
|
|
51
|
+
slots={{
|
|
52
|
+
transition: DialogTransition,
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<DialogTitle sx={dialogStyles.dialogTitle}>
|
|
56
|
+
<Typography sx={{ fontSize: "1.125rem" }}>List View Setting</Typography>
|
|
57
|
+
<IconButton
|
|
58
|
+
size="small"
|
|
59
|
+
color="inherit"
|
|
60
|
+
onClick={() => {
|
|
61
|
+
onClose && onClose();
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<CloseIcon />
|
|
65
|
+
</IconButton>
|
|
66
|
+
</DialogTitle>
|
|
67
|
+
|
|
68
|
+
<DialogContent>
|
|
69
|
+
{!hasAPIData ? ( // check if columns data is available
|
|
70
|
+
<Typography>Please pass meta data in component</Typography>
|
|
71
|
+
) : (
|
|
72
|
+
<>
|
|
73
|
+
<CustomVerticalTabs
|
|
74
|
+
value={tabValue}
|
|
75
|
+
onChange={handleTabChange}
|
|
76
|
+
tabItems={SETTINGS_TABS}
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
<Box sx={{ flex: "1" }}>
|
|
80
|
+
<CustomTabPanel value={tabValue} index={0}>
|
|
81
|
+
{tabValue === 0 && (
|
|
82
|
+
<QuickTab
|
|
83
|
+
filterSettingStates={filterSettingStates}
|
|
84
|
+
columnsData={columnsData}
|
|
85
|
+
tabsApiData={tabsApiData}
|
|
86
|
+
tabsApiDataLoading={tabsApiDataLoading}
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
</CustomTabPanel>
|
|
90
|
+
|
|
91
|
+
<CustomTabPanel value={tabValue} index={1}>
|
|
92
|
+
{tabValue === 1 && (
|
|
93
|
+
<Column
|
|
94
|
+
filterSettingStates={filterSettingStates}
|
|
95
|
+
columnsData={columnsData}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
</CustomTabPanel>
|
|
99
|
+
|
|
100
|
+
<CustomTabPanel value={tabValue} index={2}>
|
|
101
|
+
{tabValue === 2 && (
|
|
102
|
+
<Sorting
|
|
103
|
+
filterSettingStates={filterSettingStates}
|
|
104
|
+
columnsData={columnsData}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
</CustomTabPanel>
|
|
108
|
+
</Box>
|
|
109
|
+
</>
|
|
110
|
+
)}
|
|
111
|
+
</DialogContent>
|
|
112
|
+
|
|
113
|
+
{hasAPIData && (
|
|
114
|
+
<DialogActions>
|
|
115
|
+
<CustomButton
|
|
116
|
+
onClick={() => {
|
|
117
|
+
setSettingsData((prev: any) => ({
|
|
118
|
+
...prev,
|
|
119
|
+
quick_tab: quickTabStates,
|
|
120
|
+
columns: columnTabState,
|
|
121
|
+
sorting: sortingTabState,
|
|
122
|
+
}));
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
Save Quick Filter
|
|
126
|
+
</CustomButton>
|
|
127
|
+
</DialogActions>
|
|
128
|
+
)}
|
|
129
|
+
</CustomDialog>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default QuickFilterSettings;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { SxProps, Theme } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
interface DialogStyleProps {
|
|
4
|
+
dialogTitle: SxProps<Theme>;
|
|
5
|
+
dialogContent: SxProps<Theme>;
|
|
6
|
+
dialogActionsButton: SxProps<Theme>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ListingValuesStyleProps {
|
|
10
|
+
wrapper: SxProps<Theme>;
|
|
11
|
+
heading: SxProps<Theme>;
|
|
12
|
+
button: SxProps<Theme>;
|
|
13
|
+
draggableContainer: SxProps<Theme>;
|
|
14
|
+
draggableCover: SxProps<Theme>;
|
|
15
|
+
itemLabel: SxProps<Theme>;
|
|
16
|
+
headerContainer: SxProps<Theme>;
|
|
17
|
+
}
|
|
18
|
+
interface TabStyleProps {
|
|
19
|
+
mainTabsHeader: SxProps<Theme>;
|
|
20
|
+
mainTabSelect: SxProps<Theme>;
|
|
21
|
+
mainTabDropdown: SxProps<Theme>;
|
|
22
|
+
selectDropdownSeparator: SxProps<Theme>;
|
|
23
|
+
checkboxStyle: SxProps<Theme>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const dialogStyles: DialogStyleProps = {
|
|
27
|
+
dialogTitle: {
|
|
28
|
+
backgroundColor: "#FBFBFC",
|
|
29
|
+
display: "flex",
|
|
30
|
+
justifyContent: "space-between",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
padding: "0.75rem",
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
dialogContent: {
|
|
36
|
+
display: "flex",
|
|
37
|
+
gap: "1rem",
|
|
38
|
+
paddingTop: "1rem !important",
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
dialogActionsButton: {
|
|
42
|
+
backgroundColor: "#7A5AF8",
|
|
43
|
+
color: "#fff",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const listingValuesStyles: ListingValuesStyleProps = {
|
|
48
|
+
wrapper: {
|
|
49
|
+
border: "0.5px solid #0E0C0B1F",
|
|
50
|
+
borderRadius: "8px",
|
|
51
|
+
minHeight: "10rem",
|
|
52
|
+
},
|
|
53
|
+
heading: { fontWeight: 400, color: "#0E0C0BB2", fontSize: "16px" },
|
|
54
|
+
button: { fontSize: "13px", textTransform: "none", color: "#0E0C0BB2" },
|
|
55
|
+
draggableContainer: {
|
|
56
|
+
maxHeight: 200,
|
|
57
|
+
borderRadius: 1,
|
|
58
|
+
p: 1,
|
|
59
|
+
mt: 2,
|
|
60
|
+
transition: "background-color 0.2s ease",
|
|
61
|
+
},
|
|
62
|
+
draggableCover: {
|
|
63
|
+
minHeight: "200px",
|
|
64
|
+
maxHeight: "200px",
|
|
65
|
+
overflowY: "auto",
|
|
66
|
+
},
|
|
67
|
+
itemLabel: { display: "flex", alignItems: "center", flex: 1 },
|
|
68
|
+
headerContainer: {
|
|
69
|
+
display: "flex",
|
|
70
|
+
justifyContent: "space-between",
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
mb: 2,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const TabsStyles: TabStyleProps = {
|
|
77
|
+
mainTabsHeader: {
|
|
78
|
+
fontStyle: "italic",
|
|
79
|
+
mb: 2,
|
|
80
|
+
display: "block",
|
|
81
|
+
fontWeight: 400,
|
|
82
|
+
fontSize: "12px",
|
|
83
|
+
color: "#0E0C0BB2",
|
|
84
|
+
},
|
|
85
|
+
mainTabDropdown: {
|
|
86
|
+
display: "flex",
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
justifyContent: "space-between",
|
|
89
|
+
width: "50%",
|
|
90
|
+
paddingRight: 1,
|
|
91
|
+
},
|
|
92
|
+
mainTabSelect: {
|
|
93
|
+
width: "65%",
|
|
94
|
+
"& .MuiOutlinedInput-root": {
|
|
95
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
96
|
+
borderColor: "#7A5AF8",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
selectDropdownSeparator: {
|
|
102
|
+
width: "30%",
|
|
103
|
+
"& .MuiOutlinedInput-root": {
|
|
104
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
105
|
+
borderColor: "#7A5AF8",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
checkboxStyle: {
|
|
111
|
+
p: 2,
|
|
112
|
+
display: "flex",
|
|
113
|
+
flexDirection: "column",
|
|
114
|
+
},
|
|
115
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Tabs, TabsProps } from "@mui/material";
|
|
2
|
+
import { horizontalTabStyles } from "../styles";
|
|
3
|
+
|
|
4
|
+
const CustomTabs = ({ children, ...props }: TabsProps) => {
|
|
5
|
+
const { value, onChange } = props;
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<Tabs
|
|
9
|
+
value={value}
|
|
10
|
+
onChange={onChange}
|
|
11
|
+
aria-label="horizontal-tabs"
|
|
12
|
+
variant="scrollable"
|
|
13
|
+
sx={horizontalTabStyles.mainTabsContainer}
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</Tabs>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default CustomTabs;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SxProps, Theme } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
interface VerticalTabStyleProps {
|
|
4
|
+
mainTabsContainer: SxProps<Theme>;
|
|
5
|
+
mainTabContainer: SxProps<Theme>;
|
|
6
|
+
mainTabLabel: SxProps<Theme>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const verticalTabStyles: VerticalTabStyleProps = {
|
|
10
|
+
mainTabsContainer: {
|
|
11
|
+
backgroundColor: "#FAFAF9",
|
|
12
|
+
height: "100%",
|
|
13
|
+
minWidth: "6.75rem",
|
|
14
|
+
position: "sticky",
|
|
15
|
+
top: "0",
|
|
16
|
+
left: "0",
|
|
17
|
+
|
|
18
|
+
"& .MuiTabs-indicator": {
|
|
19
|
+
display: "none",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
mainTabContainer: {
|
|
24
|
+
borderRadius: "0.375rem",
|
|
25
|
+
padding: "0.5rem 1.25rem",
|
|
26
|
+
alignItems: "flex-start",
|
|
27
|
+
color: "rgba(14, 12, 11, 0.9)",
|
|
28
|
+
textTransform: "initial",
|
|
29
|
+
minHeight: "38px",
|
|
30
|
+
|
|
31
|
+
"&.Mui-selected": {
|
|
32
|
+
backgroundColor: "rgba(122, 90, 248, 0.16)",
|
|
33
|
+
color: "#7A5AF8",
|
|
34
|
+
borderRadius: "0.375rem",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
mainTabLabel: {},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
interface HorizontalTabStyleProps {
|
|
42
|
+
mainTabsContainer: SxProps<Theme>;
|
|
43
|
+
mainTabContainer: SxProps<Theme>;
|
|
44
|
+
mainTabLabel: SxProps<Theme>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const horizontalTabStyles: HorizontalTabStyleProps = {
|
|
48
|
+
mainTabsContainer: {
|
|
49
|
+
mb: 2,
|
|
50
|
+
"& .MuiTab-root": {
|
|
51
|
+
color: "#0E0C0BE5",
|
|
52
|
+
textTransform: "none",
|
|
53
|
+
fontWeight: 500,
|
|
54
|
+
},
|
|
55
|
+
"& .Mui-selected": {
|
|
56
|
+
color: "#7A5AF8",
|
|
57
|
+
},
|
|
58
|
+
"& .MuiTabs-indicator": {
|
|
59
|
+
backgroundColor: "#7A5AF8",
|
|
60
|
+
height: 3,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
mainTabContainer: {},
|
|
65
|
+
|
|
66
|
+
mainTabLabel: {},
|
|
67
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Box from "@mui/material/Box";
|
|
3
|
+
|
|
4
|
+
interface TabPanelProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
index: number;
|
|
7
|
+
value: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const CustomTabPanel = ({
|
|
11
|
+
children,
|
|
12
|
+
value,
|
|
13
|
+
index,
|
|
14
|
+
...props
|
|
15
|
+
}: TabPanelProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
role="tabpanel"
|
|
19
|
+
hidden={value !== index}
|
|
20
|
+
id={`simple-tabpanel-${index}`}
|
|
21
|
+
aria-labelledby={`simple-tab-${index}`}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
{value === index && <Box>{children}</Box>}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default CustomTabPanel;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Tabs, Tab, TabsProps, Box } from "@mui/material";
|
|
2
|
+
import { verticalTabStyles } from "../styles";
|
|
3
|
+
|
|
4
|
+
interface StyledTabsProps extends TabsProps {
|
|
5
|
+
tabItems: { label: string }[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const CustomVerticalTabs = ({ tabItems, ...props }: StyledTabsProps) => {
|
|
9
|
+
const { value, onChange } = props;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Tabs
|
|
13
|
+
value={value}
|
|
14
|
+
onChange={onChange}
|
|
15
|
+
aria-label="vertical-tabs"
|
|
16
|
+
orientation="vertical"
|
|
17
|
+
variant="scrollable"
|
|
18
|
+
sx={verticalTabStyles.mainTabsContainer}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
{tabItems.map((tab, idx) => {
|
|
22
|
+
return (
|
|
23
|
+
<Tab
|
|
24
|
+
key={idx}
|
|
25
|
+
sx={verticalTabStyles.mainTabContainer}
|
|
26
|
+
label={
|
|
27
|
+
<Box sx={verticalTabStyles.mainTabLabel}>
|
|
28
|
+
<span>{tab.label}</span>
|
|
29
|
+
</Box>
|
|
30
|
+
}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
})}
|
|
34
|
+
</Tabs>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default CustomVerticalTabs;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "./index.scss";
|
|
2
2
|
import { formatClassName } from "../../libs/utils/common";
|
|
3
|
-
import { CircularProgress } from "@mui/material";
|
|
3
|
+
import { CircularProgress, IconButton } from "@mui/material";
|
|
4
4
|
import { CraftTableOptionsProps } from "../../types/table-options";
|
|
5
|
+
import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined";
|
|
6
|
+
import { settingsOptionsProps } from "../../types/table";
|
|
5
7
|
|
|
6
8
|
interface TabDataProps {
|
|
7
9
|
tab_value: string | null;
|
|
@@ -10,10 +12,12 @@ interface TabDataProps {
|
|
|
10
12
|
|
|
11
13
|
interface TableTabsProps {
|
|
12
14
|
loading?: boolean;
|
|
13
|
-
tabsData
|
|
15
|
+
tabsData?: TabDataProps[];
|
|
14
16
|
activeTab?: string;
|
|
15
17
|
tableStates: CraftTableOptionsProps;
|
|
16
18
|
onClick: (state: string) => void;
|
|
19
|
+
columns?: any[];
|
|
20
|
+
settingsOptions?: settingsOptionsProps;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
export function TableTabs({
|
|
@@ -22,12 +26,19 @@ export function TableTabs({
|
|
|
22
26
|
activeTab = "ALL",
|
|
23
27
|
onClick,
|
|
24
28
|
tableStates,
|
|
29
|
+
settingsOptions,
|
|
25
30
|
}: TableTabsProps) {
|
|
26
31
|
const handleTabClick = (tab: string) => {
|
|
27
|
-
onClick
|
|
32
|
+
onClick(tab);
|
|
28
33
|
tableStates.setPagination((prev) => ({ ...prev, pageIndex: 0 }));
|
|
29
34
|
};
|
|
30
35
|
|
|
36
|
+
// Normalize tab_value to uppercase for display + logic
|
|
37
|
+
const normalizedTabs = tabsData.map((tab) => ({
|
|
38
|
+
...tab,
|
|
39
|
+
tab_value: tab.tab_value?.toUpperCase() ?? "UNKNOWN",
|
|
40
|
+
}));
|
|
41
|
+
|
|
31
42
|
return (
|
|
32
43
|
<div className="table-tabs">
|
|
33
44
|
{loading ? (
|
|
@@ -35,49 +46,32 @@ export function TableTabs({
|
|
|
35
46
|
<CircularProgress size={24} />
|
|
36
47
|
</div>
|
|
37
48
|
) : (
|
|
38
|
-
<
|
|
39
|
-
{
|
|
40
|
-
|
|
49
|
+
<div className="tabs">
|
|
50
|
+
{settingsOptions?.showIcon && (
|
|
51
|
+
<IconButton
|
|
52
|
+
onClick={settingsOptions?.onClick}
|
|
53
|
+
style={{ zIndex: 1000, marginRight: "0.75rem" }}
|
|
54
|
+
>
|
|
55
|
+
<SettingsOutlinedIcon />
|
|
56
|
+
</IconButton>
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
<ul className="tabs">
|
|
60
|
+
{normalizedTabs.map(({ tab_value, tab_value_count }) => (
|
|
41
61
|
<li
|
|
42
62
|
key={tab_value}
|
|
43
63
|
className={formatClassName(
|
|
44
64
|
`tab ${activeTab === tab_value ? "active" : ""}`
|
|
45
65
|
)}
|
|
46
|
-
onClick={() => handleTabClick(tab_value
|
|
66
|
+
onClick={() => handleTabClick(tab_value)}
|
|
47
67
|
>
|
|
48
|
-
<span className="tab__label">
|
|
49
|
-
{typeof tab_value === "string"
|
|
50
|
-
? tab_value.toUpperCase()
|
|
51
|
-
: "UNKNOWN"}
|
|
52
|
-
</span>
|
|
68
|
+
<span className="tab__label">{tab_value}</span>
|
|
53
69
|
<span className="count">{tab_value_count}</span>
|
|
54
70
|
</li>
|
|
55
71
|
))}
|
|
56
|
-
|
|
72
|
+
</ul>
|
|
73
|
+
</div>
|
|
57
74
|
)}
|
|
58
|
-
|
|
59
|
-
{/* <Popover
|
|
60
|
-
open={Boolean(anchorEl)}
|
|
61
|
-
anchorEl={anchorEl}
|
|
62
|
-
onClose={() => setAnchorEl(null)}
|
|
63
|
-
anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
|
|
64
|
-
>
|
|
65
|
-
<Box p={2} sx={{ width: 200 }}>
|
|
66
|
-
<Typography variant="subtitle1" gutterBottom>
|
|
67
|
-
Select a Column
|
|
68
|
-
</Typography>
|
|
69
|
-
<List dense>
|
|
70
|
-
{columns.map(({ accessorKey, header }) => (
|
|
71
|
-
<ListItemButton
|
|
72
|
-
key={accessorKey}
|
|
73
|
-
onClick={() => handleColumnSelect(accessorKey)}
|
|
74
|
-
>
|
|
75
|
-
<ListItemText primary={header} />
|
|
76
|
-
</ListItemButton>
|
|
77
|
-
))}
|
|
78
|
-
</List>
|
|
79
|
-
</Box>
|
|
80
|
-
</Popover> */}
|
|
81
75
|
</div>
|
|
82
76
|
);
|
|
83
77
|
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { craftTableFilterSettingsOptionsProps } from "../../types/table-options";
|
|
3
|
+
import {
|
|
4
|
+
ColumnTabConfigProps,
|
|
5
|
+
QuickTabConfigProps,
|
|
6
|
+
SettingsDataProps,
|
|
7
|
+
SortingConfigProps,
|
|
8
|
+
} from "../../types/filter-settings";
|
|
9
|
+
|
|
10
|
+
export function useCraftTableFilterSettings() {
|
|
11
|
+
//states for the quick filter layout
|
|
12
|
+
const [showListViewSettings, setShowListViewSettings] =
|
|
13
|
+
useState<boolean>(false);
|
|
14
|
+
|
|
15
|
+
const [settingsData, setSettingsData] = useState<SettingsDataProps>({
|
|
16
|
+
// quick_tab: {
|
|
17
|
+
// attribute: "status",
|
|
18
|
+
// sorting: "asc",
|
|
19
|
+
// hide_list: ["active", "inactive", "pending"],
|
|
20
|
+
// show_list: [],
|
|
21
|
+
// isAllSelected: true,
|
|
22
|
+
// isCombineOther: false,
|
|
23
|
+
// },
|
|
24
|
+
// column: {
|
|
25
|
+
// isDefault: true,
|
|
26
|
+
// show_list: [
|
|
27
|
+
// {
|
|
28
|
+
// label: "Customer Name",
|
|
29
|
+
// value: "customer_name",
|
|
30
|
+
// },
|
|
31
|
+
// {
|
|
32
|
+
// label: "Customer ID",
|
|
33
|
+
// value: "customer_id",
|
|
34
|
+
// },
|
|
35
|
+
// ],
|
|
36
|
+
// hide_list: [
|
|
37
|
+
// {
|
|
38
|
+
// label: "Email",
|
|
39
|
+
// value: "email",
|
|
40
|
+
// },
|
|
41
|
+
// {
|
|
42
|
+
// label: "Phone",
|
|
43
|
+
// value: "phone",
|
|
44
|
+
// },
|
|
45
|
+
// ],
|
|
46
|
+
// tabs: [
|
|
47
|
+
// {
|
|
48
|
+
// tab_name: "Active",
|
|
49
|
+
// show_list: [
|
|
50
|
+
// {
|
|
51
|
+
// label: "Customer Name",
|
|
52
|
+
// value: "customer_name",
|
|
53
|
+
// },
|
|
54
|
+
// {
|
|
55
|
+
// label: "Status",
|
|
56
|
+
// value: "status",
|
|
57
|
+
// },
|
|
58
|
+
// ],
|
|
59
|
+
// hide_list: [
|
|
60
|
+
// {
|
|
61
|
+
// label: "Email",
|
|
62
|
+
// value: "email",
|
|
63
|
+
// },
|
|
64
|
+
// ],
|
|
65
|
+
// },
|
|
66
|
+
// {
|
|
67
|
+
// tab_name: "Inactive",
|
|
68
|
+
// show_list: [
|
|
69
|
+
// {
|
|
70
|
+
// label: "Customer ID",
|
|
71
|
+
// value: "customer_id",
|
|
72
|
+
// },
|
|
73
|
+
// {
|
|
74
|
+
// label: "Status",
|
|
75
|
+
// value: "status",
|
|
76
|
+
// },
|
|
77
|
+
// ],
|
|
78
|
+
// hide_list: [
|
|
79
|
+
// {
|
|
80
|
+
// label: "Phone",
|
|
81
|
+
// value: "phone",
|
|
82
|
+
// },
|
|
83
|
+
// ],
|
|
84
|
+
// },
|
|
85
|
+
// {
|
|
86
|
+
// tab_name: "Pending",
|
|
87
|
+
// show_list: [
|
|
88
|
+
// {
|
|
89
|
+
// label: "Customer Name",
|
|
90
|
+
// value: "customer_name",
|
|
91
|
+
// },
|
|
92
|
+
// {
|
|
93
|
+
// label: "Customer ID",
|
|
94
|
+
// value: "customer_id",
|
|
95
|
+
// },
|
|
96
|
+
// ],
|
|
97
|
+
// hide_list: [
|
|
98
|
+
// {
|
|
99
|
+
// label: "Email",
|
|
100
|
+
// value: "email",
|
|
101
|
+
// },
|
|
102
|
+
// {
|
|
103
|
+
// label: "Phone",
|
|
104
|
+
// value: "phone",
|
|
105
|
+
// },
|
|
106
|
+
// ],
|
|
107
|
+
// },
|
|
108
|
+
// ],
|
|
109
|
+
// },
|
|
110
|
+
// sorting: {
|
|
111
|
+
// isDefault: true,
|
|
112
|
+
// sortby: [
|
|
113
|
+
// {
|
|
114
|
+
// column: "customer_id",
|
|
115
|
+
// order: "asc",
|
|
116
|
+
// },
|
|
117
|
+
// ],
|
|
118
|
+
// tabs: [
|
|
119
|
+
// {
|
|
120
|
+
// tab_name: "active",
|
|
121
|
+
// sortby: [
|
|
122
|
+
// {
|
|
123
|
+
// column: "customer_name",
|
|
124
|
+
// order: "asc",
|
|
125
|
+
// },
|
|
126
|
+
// ],
|
|
127
|
+
// },
|
|
128
|
+
// {
|
|
129
|
+
// tab_name: "inactive",
|
|
130
|
+
// sortby: [
|
|
131
|
+
// {
|
|
132
|
+
// column: "customer_id",
|
|
133
|
+
// order: "desc",
|
|
134
|
+
// },
|
|
135
|
+
// ],
|
|
136
|
+
// },
|
|
137
|
+
// {
|
|
138
|
+
// tab_name: "pending",
|
|
139
|
+
// sortby: [
|
|
140
|
+
// {
|
|
141
|
+
// column: "status",
|
|
142
|
+
// order: "asc",
|
|
143
|
+
// },
|
|
144
|
+
// ],
|
|
145
|
+
// },
|
|
146
|
+
// ],
|
|
147
|
+
// },
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Quick FIlter settings local states
|
|
151
|
+
const [quickTabStates, setQuickTabStates] = useState<QuickTabConfigProps>(
|
|
152
|
+
settingsData?.quick_tab || {}
|
|
153
|
+
);
|
|
154
|
+
const [columnTabState, setColumnTabState] = useState<ColumnTabConfigProps>(
|
|
155
|
+
settingsData?.column || {}
|
|
156
|
+
);
|
|
157
|
+
const [sortingTabState, setSortingTabState] = useState<SortingConfigProps>(
|
|
158
|
+
settingsData?.sorting || {}
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const craftTableFilterSettingsOptions: craftTableFilterSettingsOptionsProps =
|
|
162
|
+
{
|
|
163
|
+
settingsData: settingsData,
|
|
164
|
+
setSettingsData: setSettingsData,
|
|
165
|
+
showListViewSettings: showListViewSettings,
|
|
166
|
+
setShowListViewSettings: setShowListViewSettings,
|
|
167
|
+
quickTabStates: quickTabStates,
|
|
168
|
+
setQuickTabStates: setQuickTabStates,
|
|
169
|
+
columnTabState: columnTabState,
|
|
170
|
+
setColumnTabState: setColumnTabState,
|
|
171
|
+
sortingTabState: sortingTabState,
|
|
172
|
+
setSortingTabState: setSortingTabState,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
return craftTableFilterSettingsOptions;
|
|
176
|
+
}
|