rez-table-listing-mui 1.0.47 → 1.0.49
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 +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +25 -13
- package/src/components/filter/components/forms/components/Date.tsx +68 -108
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +13 -5
- package/src/components/filter/components/forms/index.tsx +10 -6
- package/src/components/filter/components/main-filter.tsx +3 -0
- package/src/components/filter/components/saved-edit-filter.tsx +6 -0
- package/src/components/filter/components/saved-filter.tsx +3 -0
- package/src/components/filter/components/search/index.tsx +18 -1
- package/src/components/filter/index.tsx +18 -3
- package/src/components/table-settings/common/listing-values.tsx +60 -27
- package/src/components/table-settings/components/column.tsx +2 -9
- package/src/components/table-settings/components/quick-tab.tsx +4 -0
- package/src/components/table-settings/components/sorting.tsx +0 -11
- package/src/libs/hooks/useCraftTable.tsx +5 -0
- package/src/libs/hooks/useElementWidth.tsx +28 -0
- package/src/libs/hooks/useEntityTableAPI.tsx +1 -1
- package/src/libs/utils/apiColumn.ts +8 -7
- package/src/libs/utils/common.ts +1 -1
- package/src/types/table-options.ts +2 -0
|
@@ -26,8 +26,40 @@ interface ListingValuesProps {
|
|
|
26
26
|
containerId: string;
|
|
27
27
|
tabsApiDataLoading?: boolean;
|
|
28
28
|
onItemToggle: (itemId: string, fromContainerId: string) => void;
|
|
29
|
+
enableDragAndDrop?: boolean;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
const ListingValuesContent = ({
|
|
33
|
+
item,
|
|
34
|
+
containerId,
|
|
35
|
+
onItemToggle,
|
|
36
|
+
}: {
|
|
37
|
+
item: FilterValue;
|
|
38
|
+
containerId: string;
|
|
39
|
+
onItemToggle: (itemId: string, fromContainerId: string) => void;
|
|
40
|
+
}) => {
|
|
41
|
+
return (
|
|
42
|
+
<Box
|
|
43
|
+
sx={{
|
|
44
|
+
display: "flex",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
justifyContent: "space-between",
|
|
47
|
+
gap: 1,
|
|
48
|
+
flex: 1,
|
|
49
|
+
color: containerId === "tabs" ? "black" : "#9e9d9b",
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<Typography>{item.label}</Typography>
|
|
53
|
+
<IconButton
|
|
54
|
+
size="small"
|
|
55
|
+
onClick={() => onItemToggle(item.id, containerId)}
|
|
56
|
+
>
|
|
57
|
+
{containerId === "tabs" ? <EyeIcon /> : <ClosedEyeIcon />}
|
|
58
|
+
</IconButton>
|
|
59
|
+
</Box>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
31
63
|
const ListingValues = ({
|
|
32
64
|
filteredValues,
|
|
33
65
|
buttonText,
|
|
@@ -38,6 +70,7 @@ const ListingValues = ({
|
|
|
38
70
|
containerId,
|
|
39
71
|
tabsApiDataLoading,
|
|
40
72
|
onItemToggle,
|
|
73
|
+
enableDragAndDrop = true,
|
|
41
74
|
}: ListingValuesProps) => {
|
|
42
75
|
const { setNodeRef } = useDroppable({
|
|
43
76
|
id: containerId,
|
|
@@ -73,39 +106,39 @@ const ListingValues = ({
|
|
|
73
106
|
)}
|
|
74
107
|
|
|
75
108
|
<Box ref={setNodeRef} sx={listingValuesStyles.draggableContainer}>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
109
|
+
{enableDragAndDrop ? (
|
|
110
|
+
<SortableContext
|
|
111
|
+
items={filteredValues.map((item) => item.id)}
|
|
112
|
+
strategy={verticalListSortingStrategy}
|
|
113
|
+
>
|
|
114
|
+
<Box sx={listingValuesStyles.draggableCover}>
|
|
115
|
+
{filteredValues.map((item) => (
|
|
116
|
+
<DraggableListItem
|
|
117
|
+
key={item.id}
|
|
118
|
+
id={item.id}
|
|
119
|
+
containerId={containerId}
|
|
120
|
+
>
|
|
121
|
+
<ListingValuesContent
|
|
122
|
+
item={item}
|
|
123
|
+
containerId={containerId}
|
|
124
|
+
onItemToggle={onItemToggle}
|
|
125
|
+
/>
|
|
126
|
+
</DraggableListItem>
|
|
127
|
+
))}
|
|
128
|
+
</Box>
|
|
129
|
+
</SortableContext>
|
|
130
|
+
) : (
|
|
80
131
|
<Box sx={listingValuesStyles.draggableCover}>
|
|
81
132
|
{filteredValues.map((item) => (
|
|
82
|
-
<
|
|
133
|
+
<ListingValuesContent
|
|
83
134
|
key={item.id}
|
|
84
|
-
|
|
135
|
+
item={item}
|
|
85
136
|
containerId={containerId}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
sx={{
|
|
89
|
-
display: "flex",
|
|
90
|
-
alignItems: "center",
|
|
91
|
-
flex: 1,
|
|
92
|
-
color: containerId === "tabs" ? "black" : "#9e9d9b",
|
|
93
|
-
}}
|
|
94
|
-
>
|
|
95
|
-
<Typography>{item.label}</Typography>
|
|
96
|
-
</Box>
|
|
97
|
-
|
|
98
|
-
{/* on click i want to append this item in the show list and remove it from the hide list */}
|
|
99
|
-
<IconButton
|
|
100
|
-
size="small"
|
|
101
|
-
onClick={() => onItemToggle(item.id, containerId)}
|
|
102
|
-
>
|
|
103
|
-
{containerId === "tabs" ? <EyeIcon /> : <ClosedEyeIcon />}
|
|
104
|
-
</IconButton>
|
|
105
|
-
</DraggableListItem>
|
|
137
|
+
onItemToggle={onItemToggle}
|
|
138
|
+
/>
|
|
106
139
|
))}
|
|
107
140
|
</Box>
|
|
108
|
-
|
|
141
|
+
)}
|
|
109
142
|
</Box>
|
|
110
143
|
</Box>
|
|
111
144
|
)}
|
|
@@ -16,7 +16,6 @@ import { craftTableFilterSettingsOptionsProps } from "../../../types/table-optio
|
|
|
16
16
|
import CustomToggleSwitchButton from "./toggle-button-switch";
|
|
17
17
|
import { FilterColumnsDataProps } from "../../../types/filter";
|
|
18
18
|
import { TOGGLE_BUTTON_TABS } from "../constants";
|
|
19
|
-
import { ColumnTabConfigProps } from "../../../types/filter-settings";
|
|
20
19
|
import CustomTabs from "../tabs/horizontal";
|
|
21
20
|
|
|
22
21
|
export interface ColumnItem {
|
|
@@ -39,14 +38,8 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
|
|
|
39
38
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
40
39
|
const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
|
|
41
40
|
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
columnTabState,
|
|
45
|
-
setColumnTabState,
|
|
46
|
-
settingsData,
|
|
47
|
-
sortingTabState,
|
|
48
|
-
setSortingTabState,
|
|
49
|
-
} = filterSettingStates;
|
|
41
|
+
const { quickTabStates, columnTabState, setColumnTabState, settingsData } =
|
|
42
|
+
filterSettingStates;
|
|
50
43
|
|
|
51
44
|
useEffect(() => {
|
|
52
45
|
const mappedColumns: ColumnItem[] =
|
|
@@ -343,6 +343,8 @@ const QuickTab = ({
|
|
|
343
343
|
});
|
|
344
344
|
};
|
|
345
345
|
|
|
346
|
+
const enableDND = quickTabStates?.sorting === "custom" ? true : false;
|
|
347
|
+
|
|
346
348
|
return (
|
|
347
349
|
<Box
|
|
348
350
|
sx={{
|
|
@@ -437,6 +439,7 @@ const QuickTab = ({
|
|
|
437
439
|
containerId="list"
|
|
438
440
|
tabsApiDataLoading={tabsApiDataLoading}
|
|
439
441
|
onItemToggle={handleItemToggle}
|
|
442
|
+
enableDragAndDrop={enableDND}
|
|
440
443
|
/>
|
|
441
444
|
<ListingValues
|
|
442
445
|
buttonText="Hide All"
|
|
@@ -446,6 +449,7 @@ const QuickTab = ({
|
|
|
446
449
|
containerId="tabs"
|
|
447
450
|
// tabsApiDataLoading={tabsApiDataLoading}
|
|
448
451
|
onItemToggle={handleItemToggle}
|
|
452
|
+
enableDragAndDrop={enableDND}
|
|
449
453
|
/>
|
|
450
454
|
</Grid>
|
|
451
455
|
</DndContext>
|
|
@@ -93,16 +93,6 @@ const Sorting = ({
|
|
|
93
93
|
// }
|
|
94
94
|
}, [quickTabStates?.show_list]);
|
|
95
95
|
|
|
96
|
-
// useEffect(() => {
|
|
97
|
-
// const hasEmptySortBy = false;
|
|
98
|
-
|
|
99
|
-
// if (isSortingDefault !== undefined && isSortingDefault) {
|
|
100
|
-
// console.log("first");
|
|
101
|
-
// } else {
|
|
102
|
-
// console.log("second");
|
|
103
|
-
// }
|
|
104
|
-
// }, [isSortingDefault]);
|
|
105
|
-
|
|
106
96
|
const sensors = useSensors(useSensor(PointerSensor));
|
|
107
97
|
|
|
108
98
|
const activeTabIndex = sortingTabState?.tabs?.findIndex(
|
|
@@ -265,7 +255,6 @@ const Sorting = ({
|
|
|
265
255
|
};
|
|
266
256
|
|
|
267
257
|
const { showList, hideList } = getCurrentLists();
|
|
268
|
-
console.log("showList", showList);
|
|
269
258
|
|
|
270
259
|
return (
|
|
271
260
|
<Box sx={{ display: "flex", flexDirection: "column", gap: "0.75rem" }}>
|
|
@@ -40,6 +40,9 @@ export function useCraftTable(paginationPageSize: number = 25) {
|
|
|
40
40
|
|
|
41
41
|
const [showTableFilter, setShowTableFilter] = useState<boolean>(false);
|
|
42
42
|
|
|
43
|
+
//For filter criteria paper
|
|
44
|
+
const [showFilterOptions, setShowFilterOption] = useState<boolean>(false);
|
|
45
|
+
|
|
43
46
|
if (pagination.pageIndex < 0 || pagination.pageSize <= 0) {
|
|
44
47
|
throw new Error(
|
|
45
48
|
"Invalid pagination values: pageIndex and pageSize must be positive."
|
|
@@ -69,6 +72,8 @@ export function useCraftTable(paginationPageSize: number = 25) {
|
|
|
69
72
|
setFilterMaster: setFilterMaster,
|
|
70
73
|
showTableFilter: showTableFilter,
|
|
71
74
|
setShowTableFilter: setShowTableFilter,
|
|
75
|
+
showFilterOptions: showFilterOptions,
|
|
76
|
+
setShowFilterOption: setShowFilterOption,
|
|
72
77
|
};
|
|
73
78
|
|
|
74
79
|
return craftTableOptions;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
// Custom hook to track the width of an element
|
|
4
|
+
const useElementWidth = (ref: React.RefObject<HTMLElement>) => {
|
|
5
|
+
const [width, setWidth] = useState<number>(0);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
// If there's no element to observe, just return early
|
|
9
|
+
if (!ref.current) return;
|
|
10
|
+
|
|
11
|
+
// ResizeObserver callback function
|
|
12
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
13
|
+
if (ref.current) {
|
|
14
|
+
setWidth(ref.current.clientWidth); // Update width state
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Start observing the element's size changes
|
|
19
|
+
resizeObserver.observe(ref.current);
|
|
20
|
+
|
|
21
|
+
// Clean up observer on component unmount
|
|
22
|
+
return () => resizeObserver.disconnect();
|
|
23
|
+
}, [ref, ref.current?.clientWidth]);
|
|
24
|
+
|
|
25
|
+
return width; // Return the current width
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default useElementWidth;
|
|
@@ -258,7 +258,7 @@ export const useSettingsDropDownAPI = ({
|
|
|
258
258
|
// queryFn: () =>
|
|
259
259
|
// saveSettingsData({
|
|
260
260
|
// entity_type: "LAP",
|
|
261
|
-
// mapped_entity_type: "
|
|
261
|
+
// mapped_entity_type: "AYR",
|
|
262
262
|
// layout_json: payload,
|
|
263
263
|
// }),
|
|
264
264
|
// enabled: !!payload && !!Object.entries(payload).length,
|
|
@@ -32,14 +32,15 @@ export const entityTableFilterMaster = async (entity_type: string) => {
|
|
|
32
32
|
`/meta/get-table-data?entity_type=${entity_type}&list_type=${entity_type}`
|
|
33
33
|
);
|
|
34
34
|
|
|
35
|
-
const filteredData = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
35
|
+
// const filteredData = {
|
|
36
|
+
// ...response.data.data,
|
|
37
|
+
// column_list: response.data.data.column_list.filter(
|
|
38
|
+
// (item: any) => item.attribute_key !== "action"
|
|
39
|
+
// ),
|
|
40
|
+
// };
|
|
41
41
|
// return response.data.data;
|
|
42
|
-
return filteredData; // FOR ACTION COLUMN REMOVE
|
|
42
|
+
// return filteredData; // FOR ACTION COLUMN REMOVE
|
|
43
|
+
return response.data.data;
|
|
43
44
|
} catch (error) {
|
|
44
45
|
console.error("Failed to fetch filter operation list meta:", error);
|
|
45
46
|
}
|
package/src/libs/utils/common.ts
CHANGED
|
@@ -43,6 +43,8 @@ export interface CraftTableOptionsProps {
|
|
|
43
43
|
setFilterMaster: Dispatch<SetStateAction<FilterMasterStateProps | null>>;
|
|
44
44
|
showTableFilter: boolean;
|
|
45
45
|
setShowTableFilter: Dispatch<SetStateAction<boolean>>;
|
|
46
|
+
showFilterOptions: boolean;
|
|
47
|
+
setShowFilterOption: Dispatch<SetStateAction<boolean>>;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export interface craftTableFilterSettingsOptionsProps {
|