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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez-table-listing-mui",
3
- "version": "1.0.50",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
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
- .map((showItem) => {
88
+ ?.map((showItem) => {
89
89
  return filteredColumns.find(
90
- (col) => col.accessorKey === showItem.value
90
+ (col) => col?.accessorKey === showItem?.value
91
91
  );
92
92
  })
93
- .filter((col): col is ColumnDef<any> => col !== undefined); // Ensure non-undefined columns are returned
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.accessorKey)
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.accessorKey)
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.column_list.find(
124
+ const selected = columnsData?.column_list?.find(
125
125
  (col) => col.datasource_list === selectedAttribute
126
126
  )?.attribute_key;
127
127
 
@@ -45,7 +45,8 @@ const FormMultiSelect = ({
45
45
  {...field}
46
46
  sx={{
47
47
  "& .MuiOutlinedInput-input": {
48
- padding: "12px 20px",
48
+ padding: "10px 20px",
49
+ height: "21px",
49
50
  },
50
51
  }}
51
52
  multiple
@@ -42,46 +42,48 @@ function TableWrapper<T>({
42
42
  const [metaColumns, setMetaColumns] = useState<ColumnDef<T>[]>([]);
43
43
 
44
44
  useEffect(() => {
45
- const updatedColumns = columns
46
- .filter((col) => {
47
- const accessorKey =
48
- "accessorKey" in col
49
- ? (col as { accessorKey: string }).accessorKey
50
- : undefined;
51
- return typeof shouldHideColumn === "function"
52
- ? !shouldHideColumn(accessorKey)
53
- : true;
54
- })
55
- .map((col, index) => {
56
- const id =
57
- "accessorKey" in col
58
- ? (col as { accessorKey: string }).accessorKey
59
- : `col_${index}`;
60
-
61
- const cell = (ctx: any) => {
62
- if (col.meta?.type === "custom" && col?.meta?.propName) {
63
- const customFn = customRenderFn?.[col.meta.propName];
64
- return typeof customFn === "function"
65
- ? customFn({
66
- value: ctx.getValue(),
67
- row: ctx.row,
68
- table: ctx.table.getRowModel().rows,
69
- })
70
- : ctx.getValue();
71
- }
72
-
73
- if (typeof col.cell === "function") {
74
- return col.cell(ctx);
75
- }
76
-
77
- return ctx.getValue();
78
- };
79
-
80
- return { ...col, id, cell };
81
- });
82
-
83
- setMetaColumns(updatedColumns);
84
- }, [columns, tableStates]);
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!)
@@ -11,7 +11,7 @@ const LoginButton = () => {
11
11
  const response = await axios.post(
12
12
  "http://localhost:4010/api/auth/login",
13
13
  {
14
- email_id: "darshil@rezolut.in",
14
+ email_id: "admin@rezolut.in",
15
15
  password: "Admin@123",
16
16
  }
17
17
  );
@@ -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: React.FC<TableSearchProps> = ({ value, onChange }) => {
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
- <div className="search-wrapper" ref={searchContainerRef}>
53
- <div
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
- </div>
67
- <input
77
+ </Box> */}
78
+
79
+ <TextField
68
80
  type="text"
69
- className={`search-input ${showSearchInput ? "expanded" : ""}`}
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
- </div>
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
- 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
- }
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 {
@@ -77,7 +77,7 @@ export function customDebounce<T extends (...args: any[]) => any>(
77
77
  }
78
78
 
79
79
  //ENTITY TYPE
80
- export const ENTITY_TYPE = "NTM";
80
+ export const ENTITY_TYPE = "ROL";
81
81
 
82
82
  // uat http://13.200.182.92:4010/api
83
83
  // local http://localhost:4010/api