rez-table-listing-mui 1.0.50 → 1.2.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.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +5 -5
- package/src/components/index-table.tsx +42 -40
- package/src/components/login/index.tsx +1 -1
- package/src/libs/utils/common.ts +1 -1
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -85,12 +85,12 @@ function App() {
|
|
|
85
85
|
) => {
|
|
86
86
|
// Build ordered columns using showList and filteredColumns
|
|
87
87
|
return showList
|
|
88
|
-
|
|
88
|
+
?.map((showItem) => {
|
|
89
89
|
return filteredColumns.find(
|
|
90
|
-
(col) => col
|
|
90
|
+
(col) => col?.accessorKey === showItem?.value
|
|
91
91
|
);
|
|
92
92
|
})
|
|
93
|
-
|
|
93
|
+
?.filter((col): col is ColumnDef<any> => col !== undefined); // Ensure non-undefined columns are returned
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
if (
|
|
@@ -110,7 +110,7 @@ function App() {
|
|
|
110
110
|
|
|
111
111
|
// First, filter columns based on visibleColumns
|
|
112
112
|
const filteredColumns = allColumns.filter((col: any) =>
|
|
113
|
-
visibleColumns.has(col
|
|
113
|
+
visibleColumns.has(col?.accessorKey)
|
|
114
114
|
);
|
|
115
115
|
setColumns(
|
|
116
116
|
getOrderedColumns(activeTabSettings.show_list, filteredColumns)
|
|
@@ -125,7 +125,7 @@ function App() {
|
|
|
125
125
|
savedColumnSettings.show_list.map((c) => c.value)
|
|
126
126
|
);
|
|
127
127
|
const filtered = allColumns.filter((col: any) =>
|
|
128
|
-
visibleColumns.has(col
|
|
128
|
+
visibleColumns.has(col?.accessorKey)
|
|
129
129
|
);
|
|
130
130
|
|
|
131
131
|
setColumns(
|
|
@@ -42,46 +42,48 @@ function TableWrapper<T>({
|
|
|
42
42
|
const [metaColumns, setMetaColumns] = useState<ColumnDef<T>[]>([]);
|
|
43
43
|
|
|
44
44
|
useEffect(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
45
|
+
if (columns?.length > 0) {
|
|
46
|
+
const updatedColumns = columns
|
|
47
|
+
?.filter((col) => {
|
|
48
|
+
const accessorKey =
|
|
49
|
+
"accessorKey" in col
|
|
50
|
+
? (col as { accessorKey: string })?.accessorKey
|
|
51
|
+
: undefined;
|
|
52
|
+
return typeof shouldHideColumn === "function"
|
|
53
|
+
? !shouldHideColumn(accessorKey)
|
|
54
|
+
: true;
|
|
55
|
+
})
|
|
56
|
+
?.map((col, index) => {
|
|
57
|
+
const id =
|
|
58
|
+
"accessorKey" in col
|
|
59
|
+
? (col as { accessorKey: string })?.accessorKey
|
|
60
|
+
: `col_${index}`;
|
|
61
|
+
|
|
62
|
+
const cell = (ctx: any) => {
|
|
63
|
+
if (col?.meta?.type === "custom" && col?.meta?.propName) {
|
|
64
|
+
const customFn = customRenderFn?.[col?.meta?.propName];
|
|
65
|
+
return typeof customFn === "function"
|
|
66
|
+
? customFn({
|
|
67
|
+
value: ctx?.getValue(),
|
|
68
|
+
row: ctx?.row,
|
|
69
|
+
table: ctx?.table?.getRowModel()?.rows,
|
|
70
|
+
})
|
|
71
|
+
: ctx?.getValue();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (typeof col?.cell === "function") {
|
|
75
|
+
return col?.cell(ctx);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return ctx?.getValue();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return { ...col, id, cell };
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
setMetaColumns(updatedColumns);
|
|
85
|
+
}
|
|
86
|
+
}, [columns]);
|
|
85
87
|
|
|
86
88
|
const [columnOrder, setColumnOrder] = useState<string[]>(() =>
|
|
87
89
|
metaColumns.map((c) => c.id!)
|
package/src/libs/utils/common.ts
CHANGED