rez-table-listing-mui 1.3.62 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/listing/components/index.scss +0 -144
- package/src/listing/components/login/index.tsx +4 -4
- package/src/listing/components/pagination/default/index.tsx +108 -138
- package/src/listing/components/pagination/default/pagination.styles.ts +115 -0
- package/src/listing/components/search/index.tsx +4 -8
- package/src/listing/components/{table-body-dnd-cell.tsx → table-body/table-body-dnd-cell.tsx} +18 -25
- package/src/listing/components/table-body/table-body.styles.ts +64 -0
- package/src/listing/components/{table-body.tsx → table-body/table-body.tsx} +35 -32
- package/src/listing/components/table-head/table-head-dnd-cell.tsx +112 -0
- package/src/listing/components/table-head/table-head-pin.tsx +29 -0
- package/src/listing/components/{table-head-popover.tsx → table-head/table-head-popover.tsx} +4 -16
- package/src/listing/components/table-head/table-head-resizer.tsx +22 -0
- package/src/listing/components/table-head/table-head.styles.ts +113 -0
- package/src/listing/components/{table-head.tsx → table-head/table-head.tsx} +36 -69
- package/src/listing/components/table.tsx +2 -2
- package/src/listing/components/tabs/index.tsx +31 -49
- package/src/listing/components/tabs/tabs.styles.ts +49 -0
- package/src/listing/components/topbar/index.scss +2 -4
- package/src/listing/components/topbar/index.tsx +169 -175
- package/src/listing/libs/hooks/useEntityTableHooks.ts +3 -3
- package/src/listing/libs/utils/apiColumn.ts +7 -3
- package/src/listing/libs/utils/common.ts +44 -0
- package/src/listing/types/table.ts +2 -2
- package/src/view/ListingView.tsx +38 -87
- package/src/listing/components/table-head-dnd-cell.tsx +0 -150
- package/src/listing/components/table-head-pin.tsx +0 -22
- package/src/listing/components/tabs/index.scss +0 -42
- package/src/listing/components/tabs/styles.ts +0 -34
package/src/view/ListingView.tsx
CHANGED
|
@@ -6,7 +6,11 @@ import {
|
|
|
6
6
|
useDetailsQueryAPI,
|
|
7
7
|
useFetchData,
|
|
8
8
|
} from "../listing/libs/hooks/useEntityTableHooks";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ENTITY_TYPE,
|
|
11
|
+
formatTableHeaders,
|
|
12
|
+
MAPPED_ENTITY_TYPE,
|
|
13
|
+
} from "../listing/libs/utils/common";
|
|
10
14
|
import {
|
|
11
15
|
useCommonFilterDropdownAPI,
|
|
12
16
|
useEntityTableAPI,
|
|
@@ -54,8 +58,30 @@ function ListingView() {
|
|
|
54
58
|
filterSettingStates;
|
|
55
59
|
|
|
56
60
|
const { defaultColumns } = useDefaultColumns();
|
|
61
|
+
const { data: getSettingsAPIData } = useGetNavigationLayoutAPI(ENTITY_TYPE);
|
|
62
|
+
const tabsPaylod = {
|
|
63
|
+
entity_type: ENTITY_TYPE,
|
|
64
|
+
defaultTabsConfig: {
|
|
65
|
+
attribute: "status",
|
|
66
|
+
},
|
|
67
|
+
};
|
|
57
68
|
|
|
58
|
-
const {
|
|
69
|
+
const { tableTabs } = useGetTableTabs(tabsPaylod);
|
|
70
|
+
const tabsData = tableTabs;
|
|
71
|
+
|
|
72
|
+
const { metaQuery } = useFetchData(ENTITY_TYPE, {
|
|
73
|
+
tabs: {
|
|
74
|
+
columnName:
|
|
75
|
+
getSettingsAPIData?.mapped_json?.quick_tab?.attribute || "status",
|
|
76
|
+
sortBy: getSettingsAPIData?.mapped_json?.quick_tab?.sorting || "ASC",
|
|
77
|
+
value:
|
|
78
|
+
selectedTab?.tab_name?.toLowerCase() === "all"
|
|
79
|
+
? tabsData?.find((tab: any) => tab?.tab_name?.toLowerCase() === "all")
|
|
80
|
+
?.tab_value
|
|
81
|
+
: selectedTab?.tab_value,
|
|
82
|
+
name: selectedTab?.tab_name,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
59
85
|
|
|
60
86
|
const { detailsQuery } = useDetailsQueryAPI(
|
|
61
87
|
filterMaster?.saved_filters?.selectedId
|
|
@@ -86,93 +112,14 @@ function ListingView() {
|
|
|
86
112
|
column: filterSettingStates?.quickTabStates?.attribute,
|
|
87
113
|
sort_by: filterSettingStates?.quickTabStates?.sorting,
|
|
88
114
|
});
|
|
89
|
-
const tabsPaylod = {
|
|
90
|
-
entity_type: ENTITY_TYPE,
|
|
91
|
-
defaultTabsConfig: {
|
|
92
|
-
attribute: "status",
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const { tableTabs } = useGetTableTabs(tabsPaylod);
|
|
97
115
|
|
|
98
116
|
const queryClient = useQueryClient();
|
|
99
|
-
const { data: getSettingsAPIData } = useGetNavigationLayoutAPI(ENTITY_TYPE);
|
|
100
117
|
|
|
101
118
|
const fetchMeta = async () => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const savedColumnSettings = filterSettingStates.settingsData?.column;
|
|
106
|
-
|
|
107
|
-
const getOrderedColumns = (
|
|
108
|
-
showList: { value: string }[],
|
|
109
|
-
filteredColumns: any[]
|
|
110
|
-
) => {
|
|
111
|
-
// Build ordered columns using showList and filteredColumns
|
|
112
|
-
// const orderedColumns = showList
|
|
113
|
-
// ?.map((showItem) => {
|
|
114
|
-
// return filteredColumns.find(
|
|
115
|
-
// (col) => col?.accessorKey === showItem?.value
|
|
116
|
-
// );
|
|
117
|
-
// })
|
|
118
|
-
// ?.filter((col): col is ColumnDef<any> => col !== undefined); // Ensure non-undefined columns are returned
|
|
119
|
-
|
|
120
|
-
// didnt know what above code was doing so rewrote it as below
|
|
121
|
-
// const res = showList.map((item: any) => ({
|
|
122
|
-
// id: item.value,
|
|
123
|
-
// accessorKey: item.value,
|
|
124
|
-
// header: item.label,
|
|
125
|
-
// }));
|
|
126
|
-
|
|
127
|
-
// return res;
|
|
128
|
-
return allColumns;
|
|
129
|
-
};
|
|
119
|
+
const res = formatTableHeaders(metaQuery?.data?.column_list || []);
|
|
120
|
+
console.log("res", res);
|
|
130
121
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// if (
|
|
134
|
-
// savedColumnSettings &&
|
|
135
|
-
// !savedColumnSettings.isDefault &&
|
|
136
|
-
// savedColumnSettings.tabs
|
|
137
|
-
// ) {
|
|
138
|
-
// // Tab-wise view: find the active tab and use its show_list
|
|
139
|
-
// const activeTabSettings = savedColumnSettings.tabs.find(
|
|
140
|
-
// (tab) => tab.tab_name?.value == selectedTab.toLowerCase()
|
|
141
|
-
// );
|
|
142
|
-
|
|
143
|
-
// if (activeTabSettings?.show_list) {
|
|
144
|
-
// const visibleColumns = new Set(
|
|
145
|
-
// activeTabSettings.show_list.map((c) => c.value)
|
|
146
|
-
// );
|
|
147
|
-
|
|
148
|
-
// // First, filter columns based on visibleColumns
|
|
149
|
-
// const filteredColumns = allColumns.filter((col: any) =>
|
|
150
|
-
// visibleColumns.has(col?.accessorKey)
|
|
151
|
-
// );
|
|
152
|
-
// setColumns(
|
|
153
|
-
// getOrderedColumns(activeTabSettings.show_list, filteredColumns)
|
|
154
|
-
// );
|
|
155
|
-
// } else {
|
|
156
|
-
// // Fallback if no specific settings for the active tab are found
|
|
157
|
-
// setColumns(allColumns);
|
|
158
|
-
// }
|
|
159
|
-
// } else if (savedColumnSettings && savedColumnSettings.show_list) {
|
|
160
|
-
// // Default view: use the main show_list
|
|
161
|
-
// const visibleColumns = new Set(
|
|
162
|
-
// savedColumnSettings.show_list.map((c) => c.value)
|
|
163
|
-
// );
|
|
164
|
-
// const filtered = allColumns.filter((col: any) =>
|
|
165
|
-
// visibleColumns.has(col?.accessorKey)
|
|
166
|
-
// );
|
|
167
|
-
|
|
168
|
-
// setColumns(getOrderedColumns(savedColumnSettings.show_list, filtered));
|
|
169
|
-
// } else {
|
|
170
|
-
// // No settings found, use all columns
|
|
171
|
-
// setColumns(allColumns);
|
|
172
|
-
// }
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.error("Failed to fetch metadata:", error);
|
|
175
|
-
}
|
|
122
|
+
setColumns(res);
|
|
176
123
|
};
|
|
177
124
|
|
|
178
125
|
useEffect(() => {
|
|
@@ -208,7 +155,6 @@ function ListingView() {
|
|
|
208
155
|
|
|
209
156
|
//For server side sorting
|
|
210
157
|
const enableServerSideSorting = true;
|
|
211
|
-
const tabsData = tableTabs?.data;
|
|
212
158
|
|
|
213
159
|
const { tableData, isTableDataPending } = useEntityTableAPI({
|
|
214
160
|
page: 0,
|
|
@@ -400,8 +346,8 @@ function ListingView() {
|
|
|
400
346
|
mapped_json: data,
|
|
401
347
|
type: "filter",
|
|
402
348
|
};
|
|
403
|
-
|
|
404
349
|
await saveLayoutAPI(payload);
|
|
350
|
+
queryClient.invalidateQueries({ queryKey: ["tableTabs"] });
|
|
405
351
|
};
|
|
406
352
|
|
|
407
353
|
const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
|
|
@@ -534,7 +480,6 @@ function ListingView() {
|
|
|
534
480
|
leftSideComponent: (
|
|
535
481
|
<>
|
|
536
482
|
<TableTabs
|
|
537
|
-
columns={columns}
|
|
538
483
|
settingsOptions={{
|
|
539
484
|
showIcon: true,
|
|
540
485
|
onClick: () => setShowListViewSettings(!showListViewSettings),
|
|
@@ -576,6 +521,12 @@ function ListingView() {
|
|
|
576
521
|
showFilterToggle: true,
|
|
577
522
|
onFilterButtonClick: () =>
|
|
578
523
|
tableStates.setShowTableFilter(!tableStates.showTableFilter),
|
|
524
|
+
// showColumnToggle: false,
|
|
525
|
+
// showSearch: false,
|
|
526
|
+
// showChangeLayoutToggle: false,
|
|
527
|
+
// showSortingToggle: false,
|
|
528
|
+
// viewMoreToggle: true,
|
|
529
|
+
// showCompactTableToggle: false,
|
|
579
530
|
}}
|
|
580
531
|
/>
|
|
581
532
|
);
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { flexRender } from "@tanstack/react-table";
|
|
2
|
-
import { useSortable } from "@dnd-kit/sortable";
|
|
3
|
-
import { CSSProperties, useState } from "react";
|
|
4
|
-
import { CSS } from "@dnd-kit/utilities";
|
|
5
|
-
import { DownArrow, DragHandleIcon, UpArrow } from "../../assets/svg";
|
|
6
|
-
import {
|
|
7
|
-
getColumnAlignment,
|
|
8
|
-
getColumnPinningStyles,
|
|
9
|
-
} from "../libs/utils/common";
|
|
10
|
-
import { align } from "../types/common";
|
|
11
|
-
import { TableHeaderProps } from "../types/table";
|
|
12
|
-
import TableHeadPin from "./table-head-pin";
|
|
13
|
-
import TableHeadPopover from "./table-head-popover";
|
|
14
|
-
|
|
15
|
-
function DraggableTableHeader<T>({
|
|
16
|
-
header,
|
|
17
|
-
activeTab,
|
|
18
|
-
featureOptions,
|
|
19
|
-
tableStates,
|
|
20
|
-
filterSettingStates,
|
|
21
|
-
onSaveSettings,
|
|
22
|
-
}: TableHeaderProps<T>) {
|
|
23
|
-
const { enableColumnPinning } = featureOptions;
|
|
24
|
-
|
|
25
|
-
// Popover
|
|
26
|
-
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
|
27
|
-
|
|
28
|
-
const handleHover = (event: React.MouseEvent<HTMLElement>) => {
|
|
29
|
-
setAnchorEl((prev) => (prev ? null : event.currentTarget));
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const handleClose = () => {
|
|
33
|
-
setAnchorEl(null);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const { isDragging, transform, attributes, listeners } = useSortable({
|
|
37
|
-
id: header.column.id,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const isPinned = header.column.getIsPinned();
|
|
41
|
-
|
|
42
|
-
const styles: CSSProperties = {
|
|
43
|
-
opacity: isDragging ? 0.8 : 1,
|
|
44
|
-
position: "relative",
|
|
45
|
-
transform: CSS.Translate.toString(transform),
|
|
46
|
-
transition: "width transform 0.2s ease-in-out",
|
|
47
|
-
width: header.column.getSize(),
|
|
48
|
-
minWidth: `${header.column.columnDef.minSize ?? 180}px`,
|
|
49
|
-
maxWidth: `${header.column.columnDef.maxSize}px`,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
let sortProps: {
|
|
53
|
-
className: string;
|
|
54
|
-
title?: string;
|
|
55
|
-
style?: CSSProperties;
|
|
56
|
-
} = {
|
|
57
|
-
className: "ts__content",
|
|
58
|
-
// style: {
|
|
59
|
-
// justifyContent: getColumnAlignment(
|
|
60
|
-
// (header?.column?.columnDef?.meta as align)?.align
|
|
61
|
-
// ),
|
|
62
|
-
// },
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// if (header.column.getCanSort()) {
|
|
66
|
-
// sortProps = {
|
|
67
|
-
// ...sortProps,
|
|
68
|
-
// title:
|
|
69
|
-
// header.column.getNextSortingOrder() === "asc"
|
|
70
|
-
// ? "Sort ascending"
|
|
71
|
-
// : header.column.getNextSortingOrder() === "desc"
|
|
72
|
-
// ? "Sort descending"
|
|
73
|
-
// : "Clear sort",
|
|
74
|
-
// };
|
|
75
|
-
// }
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<th
|
|
79
|
-
onMouseLeave={handleClose}
|
|
80
|
-
key={header?.id}
|
|
81
|
-
className="ts__head__th"
|
|
82
|
-
colSpan={header.colSpan}
|
|
83
|
-
onClick={handleHover}
|
|
84
|
-
style={{
|
|
85
|
-
width: `${header.column.getSize()}px `,
|
|
86
|
-
minWidth: `${header.column.columnDef.minSize}px`,
|
|
87
|
-
maxWidth: `${header.column.columnDef.maxSize}px`,
|
|
88
|
-
...styles,
|
|
89
|
-
...getColumnPinningStyles(header.column),
|
|
90
|
-
zIndex: isPinned ? 3 : isDragging ? 1 : 0,
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
{header.isPlaceholder ? null : (
|
|
94
|
-
<div {...sortProps}>
|
|
95
|
-
<div
|
|
96
|
-
className={`${
|
|
97
|
-
header.column.getCanSort() ? "ts__content__sort" : ""
|
|
98
|
-
}`.trim()}
|
|
99
|
-
// onClick={header.column.getToggleSortingHandler()}
|
|
100
|
-
>
|
|
101
|
-
{flexRender(header.column.columnDef.header, header.getContext())}
|
|
102
|
-
|
|
103
|
-
{{
|
|
104
|
-
asc: <UpArrow />,
|
|
105
|
-
desc: <DownArrow />,
|
|
106
|
-
}[header.column.getIsSorted() as "asc" | "desc"] ?? null}
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
{enableColumnPinning && (
|
|
110
|
-
<TableHeadPin
|
|
111
|
-
header={header}
|
|
112
|
-
featureOptions={featureOptions}
|
|
113
|
-
tableStates={tableStates}
|
|
114
|
-
filterSettingStates={filterSettingStates}
|
|
115
|
-
/>
|
|
116
|
-
)}
|
|
117
|
-
|
|
118
|
-
<div {...attributes} {...listeners} className="ts__dnd__button">
|
|
119
|
-
<DragHandleIcon />
|
|
120
|
-
</div>
|
|
121
|
-
</div>
|
|
122
|
-
)}
|
|
123
|
-
|
|
124
|
-
{/* column resizing */}
|
|
125
|
-
{header.column.getCanResize() ? (
|
|
126
|
-
<div
|
|
127
|
-
onDoubleClick={() => header.column.resetSize()}
|
|
128
|
-
onMouseDown={header.getResizeHandler()}
|
|
129
|
-
onTouchStart={header.getResizeHandler()}
|
|
130
|
-
className={`column__resize ${
|
|
131
|
-
header.column.getIsResizing() ? "is__resizing" : ""
|
|
132
|
-
}`}
|
|
133
|
-
/>
|
|
134
|
-
) : null}
|
|
135
|
-
|
|
136
|
-
{/* Popover */}
|
|
137
|
-
<TableHeadPopover
|
|
138
|
-
anchorEl={anchorEl}
|
|
139
|
-
activeTab={activeTab}
|
|
140
|
-
onClose={handleClose}
|
|
141
|
-
header={header}
|
|
142
|
-
tableStates={tableStates}
|
|
143
|
-
filterSettingStates={filterSettingStates}
|
|
144
|
-
onSaveSettings={onSaveSettings}
|
|
145
|
-
/>
|
|
146
|
-
</th>
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export default DraggableTableHeader;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { IconPinOffOutline } from "../../assets/svg";
|
|
2
|
-
import { TableHeaderProps } from "../types/table";
|
|
3
|
-
|
|
4
|
-
function TableHeadPin<T>({ header }: TableHeaderProps<T>) {
|
|
5
|
-
return header.column.getIsPinned() !== "left" ? (
|
|
6
|
-
<div className="ts--head--button" onClick={() => header.column.pin("left")}>
|
|
7
|
-
{/* <IconPinOutline /> */}
|
|
8
|
-
</div>
|
|
9
|
-
) : (
|
|
10
|
-
<div
|
|
11
|
-
className="ts--head--button"
|
|
12
|
-
onClick={(e) => {
|
|
13
|
-
e.stopPropagation();
|
|
14
|
-
header.column.pin(false);
|
|
15
|
-
}}
|
|
16
|
-
>
|
|
17
|
-
<IconPinOffOutline />
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default TableHeadPin;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
.table-tabs {
|
|
2
|
-
.tabs {
|
|
3
|
-
display: flex;
|
|
4
|
-
justify-content: flex-start;
|
|
5
|
-
align-items: center;
|
|
6
|
-
margin: 0rem;
|
|
7
|
-
padding: 0rem;
|
|
8
|
-
|
|
9
|
-
.tabs-settings {
|
|
10
|
-
margin-left: 0.1rem;
|
|
11
|
-
margin-right: 0.5rem;
|
|
12
|
-
cursor: pointer;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.tab {
|
|
16
|
-
display: flex;
|
|
17
|
-
gap: 0.5rem;
|
|
18
|
-
padding: 0.5rem 1rem;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
color: var(--grey-900);
|
|
21
|
-
font-size: 0.875rem;
|
|
22
|
-
font-family: "Satoshi";
|
|
23
|
-
font-weight: 700;
|
|
24
|
-
|
|
25
|
-
.tab__label {
|
|
26
|
-
font-family: inherit;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&.active {
|
|
30
|
-
background: var(--grey-500);
|
|
31
|
-
border-top-left-radius: 0.5rem;
|
|
32
|
-
border-top-right-radius: 0.5rem;
|
|
33
|
-
backdrop-filter: blur(200px);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.tabs-dropdown {
|
|
38
|
-
margin-left: 1rem;
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SxProps, Theme } from "@mui/material";
|
|
2
|
-
|
|
3
|
-
interface TabStylesProps {
|
|
4
|
-
tabs: SxProps<Theme>;
|
|
5
|
-
tab: SxProps<Theme>;
|
|
6
|
-
tabCount: SxProps<Theme>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const tableTabsStyles: TabStylesProps = {
|
|
10
|
-
tabs: {
|
|
11
|
-
minHeight: "38px",
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
tab: {
|
|
15
|
-
color: "#888888",
|
|
16
|
-
padding: "8px 12px",
|
|
17
|
-
minHeight: "38px",
|
|
18
|
-
textTransform: "none",
|
|
19
|
-
minWidth: "unset",
|
|
20
|
-
whiteSpace: "nowrap",
|
|
21
|
-
|
|
22
|
-
"&.Mui-selected": {
|
|
23
|
-
color: "#0e0c0b",
|
|
24
|
-
fontWeight: 700,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
tabCount: {
|
|
29
|
-
padding: "2px 3px",
|
|
30
|
-
borderRadius: "6px",
|
|
31
|
-
border: "1px solid #0E0C0BE6",
|
|
32
|
-
color: "#0E0C0B",
|
|
33
|
-
},
|
|
34
|
-
};
|