rez-table-listing-mui 1.0.50 → 1.2.3
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/filter/components/attributes-filter.tsx +1 -1
- package/src/components/filter/components/forms/components/Multi-Select.tsx +2 -1
- package/src/components/index-table.tsx +42 -40
- package/src/components/login/index.tsx +1 -1
- package/src/components/search/index.tsx +63 -8
- package/src/components/search/style.tsx +40 -0
- package/src/components/topbar/index.scss +26 -26
- 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(
|
|
@@ -121,7 +121,7 @@ const AttributesFilter = ({
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
const selectedAttributeOptions = useMemo(() => {
|
|
124
|
-
const selected = columnsData
|
|
124
|
+
const selected = columnsData?.column_list?.find(
|
|
125
125
|
(col) => col.datasource_list === selectedAttribute
|
|
126
126
|
)?.attribute_key;
|
|
127
127
|
|
|
@@ -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!)
|
|
@@ -2,13 +2,16 @@ import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
|
2
2
|
import { SearchIcon } from "../../assets/svg";
|
|
3
3
|
import useOutsideClick from "../../libs/hooks/useOutsideClick";
|
|
4
4
|
import { customDebounce } from "../../libs/utils/debounce";
|
|
5
|
+
import { Box, IconButton, InputAdornment, TextField } from "@mui/material";
|
|
6
|
+
import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
|
|
7
|
+
import { searchStyles } from "./style";
|
|
5
8
|
|
|
6
9
|
interface TableSearchProps {
|
|
7
10
|
value: string;
|
|
8
11
|
onChange: (value: string) => void;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
const TableSearch
|
|
14
|
+
const TableSearch = ({ value, onChange }: TableSearchProps): JSX.Element => {
|
|
12
15
|
const [showSearchInput, setShowSearchInput] = useState(false);
|
|
13
16
|
const [localValue, setLocalValue] = useState(value);
|
|
14
17
|
const searchContainerRef = useRef<HTMLDivElement>(null);
|
|
@@ -49,8 +52,16 @@ const TableSearch: React.FC<TableSearchProps> = ({ value, onChange }) => {
|
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
return (
|
|
52
|
-
<
|
|
53
|
-
|
|
55
|
+
<Box
|
|
56
|
+
ref={searchContainerRef}
|
|
57
|
+
className="search-container"
|
|
58
|
+
sx={{
|
|
59
|
+
display: "flex",
|
|
60
|
+
position: "relative",
|
|
61
|
+
top: "10px",
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{/* <Box
|
|
54
65
|
className="search-icon ts--button"
|
|
55
66
|
onClick={() => {
|
|
56
67
|
setShowSearchInput((prev) => !prev);
|
|
@@ -63,16 +74,60 @@ const TableSearch: React.FC<TableSearchProps> = ({ value, onChange }) => {
|
|
|
63
74
|
}}
|
|
64
75
|
>
|
|
65
76
|
<SearchIcon />
|
|
66
|
-
</
|
|
67
|
-
|
|
77
|
+
</Box> */}
|
|
78
|
+
|
|
79
|
+
<TextField
|
|
68
80
|
type="text"
|
|
69
|
-
|
|
70
|
-
placeholder="Type to search"
|
|
81
|
+
placeholder="Search"
|
|
71
82
|
value={localValue}
|
|
72
83
|
onChange={handleChange}
|
|
73
84
|
onKeyDown={handleKeyDown}
|
|
85
|
+
className={`search-input ${showSearchInput ? "expanded" : ""}`}
|
|
86
|
+
sx={searchStyles.searchField(showSearchInput)}
|
|
87
|
+
InputProps={{
|
|
88
|
+
startAdornment: (
|
|
89
|
+
<InputAdornment position="start">
|
|
90
|
+
<IconButton
|
|
91
|
+
size="small"
|
|
92
|
+
onClick={() => {
|
|
93
|
+
setShowSearchInput((prev) => !prev);
|
|
94
|
+
if (!showSearchInput) {
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
searchContainerRef.current
|
|
97
|
+
?.querySelector("input")
|
|
98
|
+
?.focus();
|
|
99
|
+
}, 100);
|
|
100
|
+
}
|
|
101
|
+
}}
|
|
102
|
+
sx={{ color: "black", fontSize: "14px" }}
|
|
103
|
+
edge="start"
|
|
104
|
+
>
|
|
105
|
+
<SearchIcon />
|
|
106
|
+
</IconButton>
|
|
107
|
+
</InputAdornment>
|
|
108
|
+
),
|
|
109
|
+
endAdornment:
|
|
110
|
+
showSearchInput && localValue !== "" ? (
|
|
111
|
+
<InputAdornment position="end">
|
|
112
|
+
<IconButton
|
|
113
|
+
size="small"
|
|
114
|
+
onClick={() => {
|
|
115
|
+
setLocalValue("");
|
|
116
|
+
handleChange({ target: { value: "" } } as any);
|
|
117
|
+
}}
|
|
118
|
+
sx={{ color: "black", fontSize: "14px" }}
|
|
119
|
+
edge="end"
|
|
120
|
+
>
|
|
121
|
+
<CloseRoundedIcon
|
|
122
|
+
fontSize="small"
|
|
123
|
+
sx={{ color: "black", fontSize: "14px" }}
|
|
124
|
+
/>
|
|
125
|
+
</IconButton>
|
|
126
|
+
</InputAdornment>
|
|
127
|
+
) : null,
|
|
128
|
+
}}
|
|
74
129
|
/>
|
|
75
|
-
</
|
|
130
|
+
</Box>
|
|
76
131
|
);
|
|
77
132
|
};
|
|
78
133
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Theme } from "@emotion/react";
|
|
2
|
+
import { SxProps } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
export interface StyleProps {
|
|
5
|
+
searchField: (showSearchInput: boolean) => SxProps<Theme>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const searchStyles: StyleProps = {
|
|
9
|
+
searchField: (showSearchInput: boolean): SxProps<Theme> => ({
|
|
10
|
+
width: showSearchInput ? "180px" : "40px",
|
|
11
|
+
transition: "all 0.3s ease",
|
|
12
|
+
opacity: showSearchInput ? 1 : 0.8,
|
|
13
|
+
marginRight: "0.5rem",
|
|
14
|
+
|
|
15
|
+
"& .MuiOutlinedInput-root": {
|
|
16
|
+
paddingRight: "4px",
|
|
17
|
+
height: "32px",
|
|
18
|
+
borderRadius: "6px",
|
|
19
|
+
backgroundColor: "#fff",
|
|
20
|
+
border: showSearchInput ? "1px solid #ccc" : "none",
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
24
|
+
border: "none",
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
"&:hover .MuiOutlinedInput-notchedOutline": {
|
|
28
|
+
border: "none",
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {},
|
|
32
|
+
|
|
33
|
+
" & .css-4bojcr-MuiInputBase-root-MuiOutlinedInput-root ": {
|
|
34
|
+
paddingLeft: "6px !important",
|
|
35
|
+
},
|
|
36
|
+
"& .css-1mnoz6i-MuiInputBase-root-MuiOutlinedInput-root": {
|
|
37
|
+
paddingLeft: "6px !important",
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
@@ -27,32 +27,32 @@
|
|
|
27
27
|
margin-bottom: 1.2rem;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.search-input {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.search-input.expanded {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
30
|
+
// .search-input {
|
|
31
|
+
// width: 0;
|
|
32
|
+
// opacity: 0;
|
|
33
|
+
// margin-left: 8px;
|
|
34
|
+
// padding: 6px 8px;
|
|
35
|
+
// font-size: 0.875rem;
|
|
36
|
+
// border: 1px solid #ccc;
|
|
37
|
+
// border-radius: 4px;
|
|
38
|
+
// background-color: #f5f5f5;
|
|
39
|
+
// color: #000;
|
|
40
|
+
// transition: width 0.3s ease, opacity 0.3s ease;
|
|
41
|
+
// // position: absolute;
|
|
42
|
+
// // right: 40px;
|
|
43
|
+
// // top: 50%;
|
|
44
|
+
// // transform: translateY(-50%);
|
|
45
|
+
|
|
46
|
+
// &:focus {
|
|
47
|
+
// outline: none;
|
|
48
|
+
// border-color: #000;
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
// .search-input.expanded {
|
|
53
|
+
// width: 200px;
|
|
54
|
+
// opacity: 1;
|
|
55
|
+
// }
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
.ts--button {
|
package/src/libs/utils/common.ts
CHANGED