rez-table-listing-mui 1.3.62 → 2.0.0

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.
Files changed (31) hide show
  1. package/dist/index.d.ts +4 -5
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +1 -1
  7. package/src/listing/components/index.scss +0 -144
  8. package/src/listing/components/login/index.tsx +4 -4
  9. package/src/listing/components/pagination/default/index.tsx +108 -138
  10. package/src/listing/components/pagination/default/pagination.styles.ts +113 -0
  11. package/src/listing/components/{table-body-dnd-cell.tsx → table-body/table-body-dnd-cell.tsx} +18 -25
  12. package/src/listing/components/table-body/table-body.styles.ts +64 -0
  13. package/src/listing/components/{table-body.tsx → table-body/table-body.tsx} +35 -32
  14. package/src/listing/components/table-head/table-head-dnd-cell.tsx +112 -0
  15. package/src/listing/components/table-head/table-head-pin.tsx +29 -0
  16. package/src/listing/components/{table-head-popover.tsx → table-head/table-head-popover.tsx} +4 -16
  17. package/src/listing/components/table-head/table-head-resizer.tsx +22 -0
  18. package/src/listing/components/table-head/table-head.styles.ts +115 -0
  19. package/src/listing/components/{table-head.tsx → table-head/table-head.tsx} +36 -69
  20. package/src/listing/components/table.tsx +2 -2
  21. package/src/listing/components/tabs/index.tsx +23 -41
  22. package/src/listing/components/tabs/tabs.styles.ts +49 -0
  23. package/src/listing/libs/hooks/useEntityTableHooks.ts +3 -3
  24. package/src/listing/libs/utils/apiColumn.ts +7 -3
  25. package/src/listing/libs/utils/common.ts +44 -0
  26. package/src/listing/types/table.ts +2 -2
  27. package/src/view/ListingView.tsx +39 -88
  28. package/src/listing/components/table-head-dnd-cell.tsx +0 -150
  29. package/src/listing/components/table-head-pin.tsx +0 -22
  30. package/src/listing/components/tabs/index.scss +0 -42
  31. package/src/listing/components/tabs/styles.ts +0 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez-table-listing-mui",
3
- "version": "1.3.62",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
@@ -65,152 +65,14 @@
65
65
  max-height: calc(100vh - 56px);
66
66
  }
67
67
 
68
- .ts__table.ts--striped > .ts__body > .ts__body__tr:nth-of-type(odd) {
69
- background-color: var(--grey-200);
70
- }
71
- .ts__table:not(.ts--striped) > .ts__body > .ts__body__tr:hover {
72
- background-color: var(--grey-100);
73
- box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.05),
74
- inset 0 -2px 2px rgba(0, 0, 0, 0.05);
75
- }
76
- .ts__table:not(.ts--striped) > .ts__head > .ts__head__tr {
77
- background-color: var(--grey-100);
78
-
79
- .ts__head__th {
80
- border: 1px solid var(--grey-500);
81
- }
82
- }
83
-
84
- .ts__table.ts--compact {
85
- .ts__head > .ts__head__tr > .ts__head__th {
86
- padding: 0.25rem 0.5rem;
87
-
88
- .ts__content {
89
- font-size: 0.875rem;
90
- }
91
- }
92
-
93
- .ts__body > .ts__body__tr > .ts__body__td {
94
- padding: 0.25rem 0.5rem;
95
-
96
- .ts__content {
97
- font-size: 0.75rem;
98
- }
99
- }
100
- }
101
-
102
68
  .ts__table {
103
69
  width: max-content;
104
70
  min-width: 100%;
105
71
  border-spacing: 0;
106
72
  border-collapse: separate;
107
-
108
- .ts__head.ts--sticky {
109
- position: sticky;
110
- top: 0rem;
111
- z-index: 3;
112
- }
113
-
114
- .ts__head {
115
- position: relative;
116
- // box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05); //removing shadow below table header
117
-
118
- .ts__head__tr {
119
- background-color: var(--white);
120
-
121
- .ts__head__th {
122
- position: relative;
123
- padding: 0.5rem 1rem;
124
- border: 1px solid var(--grey-500);
125
- cursor: pointer;
126
-
127
- .ts__dnd__button {
128
- color: var(--grey-600);
129
- // width: max-content;
130
- // height: max-content;
131
- // cursor: grabbing;
132
-
133
- &:hover {
134
- scale: 1.1;
135
- color: var(--grey-900);
136
- width: max-content;
137
- height: max-content;
138
- cursor: grabbing;
139
- }
140
- }
141
-
142
- .ts__content {
143
- display: flex;
144
- align-items: center;
145
- gap: 0.25rem;
146
- min-height: 44px; // to give min height of 60 px
147
-
148
- .ts__content__sort {
149
- cursor: pointer;
150
- user-select: none;
151
-
152
- svg {
153
- margin-left: 0.25rem;
154
- }
155
- }
156
-
157
- .ts--head--button {
158
- display: flex;
159
- justify-content: center;
160
- align-items: center;
161
- cursor: pointer;
162
-
163
- &:hover {
164
- scale: 1.1;
165
- }
166
-
167
- svg {
168
- color: var(--grey-700);
169
- }
170
- }
171
- }
172
-
173
- .column__resize {
174
- position: absolute;
175
- top: 0;
176
- right: 0;
177
- height: 100%;
178
- width: 5px;
179
- background: rgba(0, 0, 0, 0.5);
180
- cursor: col-resize;
181
- user-select: none;
182
- touch-action: none;
183
- opacity: 0;
184
-
185
- &:hover {
186
- opacity: 1;
187
- }
188
- }
189
-
190
- .column__resize.is__resizing {
191
- background: rgba(0, 0, 0, 0.8);
192
- opacity: 1;
193
- }
194
- }
195
- }
196
- }
197
-
198
- .ts__body {
199
- .ts__body__tr {
200
- background-color: var(--white);
201
-
202
- .ts__body__td {
203
- font-size: 0.875rem;
204
- padding: 0.5rem 1rem;
205
- border-top: 1px solid var(--grey-300);
206
- border-bottom: 1px solid var(--grey-300);
207
- }
208
- }
209
- }
210
73
  }
211
74
  }
212
75
  }
213
- // Full screen styles fixes
214
76
 
215
77
  :fullscreen {
216
78
  width: 100vw !important;
@@ -229,9 +91,3 @@
229
91
  background: var(--white);
230
92
  overflow: hidden;
231
93
  }
232
-
233
- // .ts__table__wrapper.is-fullscreen {
234
- // height: calc(100vh - 56px);
235
- // max-height: none;
236
- // overflow-y: auto;
237
- // }
@@ -10,8 +10,8 @@ const LoginButton = () => {
10
10
  // const api_url = "https://api.eth-qa.rezolut.in/api/enrol/auth";
11
11
  const api_url = "http://localhost:6010/api/auth";
12
12
  const email_id = "admin@rezolut.in";
13
- const email_otp = "123456";
14
- const sub_domain = "universal";
13
+ const verify_otp = "123456";
14
+ const sub_domain = "platform";
15
15
 
16
16
  setLoading(true);
17
17
 
@@ -26,10 +26,10 @@ const LoginButton = () => {
26
26
  identifier: email_id,
27
27
  service: "email",
28
28
  reset: true,
29
- otp: "123456",
29
+ otp: verify_otp,
30
30
  otp_id: otpAPIResponse.data.otp_id,
31
31
  fcm_token: "",
32
- subdomain: "platform",
32
+ subdomain: sub_domain,
33
33
  })
34
34
  .then((otpVerifyResponse) => {
35
35
  const token = otpVerifyResponse.data.accessToken;
@@ -1,15 +1,22 @@
1
1
  import { Table } from "@tanstack/react-table";
2
- import {
3
- TableFirstPageIcon,
4
- TableLastPageIcon,
5
- // TableNextPageIcon,
6
- // TablePreviousPageIcon,
7
- } from "../../../../assets/svg";
8
- import TablePreviousPageIcon from "@mui/icons-material/NavigateBeforeRounded";
9
- import TableNextPageIcon from "@mui/icons-material/NavigateNextRounded";
10
- import "./index.scss";
2
+ import { TableFirstPageIcon, TableLastPageIcon } from "../../../../assets/svg";
3
+ import NavigateBeforeRounded from "@mui/icons-material/NavigateBeforeRounded";
4
+ import NavigateNextRounded from "@mui/icons-material/NavigateNextRounded";
5
+ import { MenuItem, Typography } from "@mui/material";
11
6
  import { CraftTablePaginationProps } from "../../../types/table";
12
7
 
8
+ import {
9
+ PaginationContainer,
10
+ GoToPageContainer,
11
+ RowsPerPageContainer,
12
+ RecordsRangeContainer,
13
+ PageRangeContainer,
14
+ PaginationButtons,
15
+ PaginationButton,
16
+ RowsPerPageSelect,
17
+ GoToPageInput,
18
+ } from "./pagination.styles";
19
+
13
20
  interface DefaultPaginationProps<T> {
14
21
  table: Table<T>;
15
22
  rowsPerPageArray: number[];
@@ -25,145 +32,108 @@ function DefaultPagination<T>({
25
32
  const pageCount = table.getPageCount();
26
33
  const pageSize = table.getState().pagination.pageSize;
27
34
  const rowCount = table.getRowCount();
35
+
28
36
  const recordsRangeFirst = pageIndex * pageSize - pageSize + 1;
29
37
  const recordsRangeLast = Math.min(pageIndex * pageSize, rowCount);
30
38
 
39
+ const isFullView = paginationOptions?.paginationView === "full";
40
+
31
41
  return (
32
- <div className="pagination_container">
33
- {paginationOptions?.paginationView === "full" ? (
34
- <>
35
- <span className="go_to_page_container">
36
- &nbsp;&nbsp;Go to page&nbsp;:&nbsp;
37
- <input
38
- type="number"
39
- defaultValue={pageIndex}
40
- onKeyDown={(e) => {
41
- if (e.key === "Enter") {
42
- const page = e.currentTarget.value
43
- ? Number(e.currentTarget.value) - 1
44
- : 0;
45
- table.setPageIndex(page);
46
- }
47
- }}
48
- style={{ width: "60px", textAlign: "center" }}
49
- min={1}
50
- max={table?.getPageCount()}
51
- />
52
- &nbsp;
53
- </span>
42
+ <PaginationContainer>
43
+ {isFullView && (
44
+ <GoToPageContainer>
45
+ <Typography variant="body2" fontSize={14} mr={1}>
46
+ Go to page:
47
+ </Typography>
48
+ <GoToPageInput
49
+ defaultValue={pageIndex}
50
+ type="number"
51
+ inputProps={{
52
+ min: 1,
53
+ max: pageCount,
54
+ }}
55
+ onKeyDown={(e) => {
56
+ if (e.key === "Enter") {
57
+ const page = e.currentTarget.value
58
+ ? Number(e.currentTarget.value) - 1
59
+ : 0;
60
+ table.setPageIndex(page);
61
+ }
62
+ }}
63
+ />
64
+ </GoToPageContainer>
65
+ )}
66
+
67
+ <RowsPerPageContainer>
68
+ {isFullView && (
69
+ <Typography variant="body2" fontSize={14} mr={1}>
70
+ Rows per page:
71
+ </Typography>
72
+ )}
73
+ <RowsPerPageSelect
74
+ value={pageSize}
75
+ onChange={(e) => table.setPageSize(Number(e.target.value))}
76
+ >
77
+ {rowsPerPageArray.map((size) => (
78
+ <MenuItem key={size} value={size} sx={{ fontSize: 12 }}>
79
+ {size}
80
+ </MenuItem>
81
+ ))}
82
+ </RowsPerPageSelect>
83
+ </RowsPerPageContainer>
54
84
 
55
- <div className="rows_per_page_container">
56
- <span>Rows Per Page&nbsp;:&nbsp;</span>
57
- <select
58
- value={table.getState().pagination.pageSize}
59
- onChange={(e) => {
60
- table.setPageSize(Number(e.target.value));
61
- }}
62
- >
63
- {rowsPerPageArray.map((pageSize) => (
64
- <option key={pageSize} value={pageSize}>
65
- {pageSize}
66
- </option>
67
- ))}
68
- </select>
69
- </div>
85
+ <RecordsRangeContainer>
86
+ <strong>
87
+ {recordsRangeFirst} – {recordsRangeLast} of {rowCount}
88
+ </strong>
89
+ </RecordsRangeContainer>
70
90
 
71
- <div className="records_range_container">
72
- <span>Showing&nbsp;</span>
73
- <strong>
74
- {recordsRangeFirst} - {recordsRangeLast} of {rowCount}
75
- </strong>
76
- </div>
91
+ {isFullView && (
92
+ <PageRangeContainer>
93
+ <strong>
94
+ Page {pageIndex} of {pageCount}
95
+ </strong>
96
+ </PageRangeContainer>
97
+ )}
77
98
 
78
- <span className="page_range_container">
79
- <span>&nbsp;Page&nbsp;</span>
80
- <strong>
81
- {pageIndex} of {pageCount}
82
- &nbsp;
83
- </strong>
84
- </span>
99
+ <PaginationButtons>
100
+ {isFullView && (
101
+ <PaginationButton
102
+ title="First Page"
103
+ disabled={!table.getCanPreviousPage()}
104
+ onClick={() => table.setPageIndex(0)}
105
+ >
106
+ <TableFirstPageIcon />
107
+ </PaginationButton>
108
+ )}
85
109
 
86
- <div className="pagination_btn_container">
87
- <button
88
- title="First Page"
89
- className="pagination_btn"
90
- disabled={!table.getCanPreviousPage()}
91
- onClick={() => table.setPageIndex(0)}
92
- >
93
- <TableFirstPageIcon />
94
- </button>
95
- <button
96
- title="Previous Page"
97
- className="pagination_btn"
98
- disabled={!table.getCanPreviousPage()}
99
- onClick={() => table.previousPage()}
100
- >
101
- <TablePreviousPageIcon fontSize="small" />
102
- </button>
103
- <button
104
- title="Next Page"
105
- className="pagination_btn"
106
- disabled={!table.getCanNextPage()}
107
- onClick={() => table.nextPage()}
108
- >
109
- <TableNextPageIcon />
110
- </button>
111
- <button
112
- title="Last Page"
113
- className="pagination_btn"
114
- disabled={!table.getCanNextPage()}
115
- onClick={() => table.setPageIndex(pageCount - 1)}
116
- >
117
- <TableLastPageIcon />
118
- </button>
119
- </div>
120
- </>
121
- ) : (
122
- <>
123
- <div className="rows_per_page_container">
124
- {/* <span>Rows Per Page&nbsp;:&nbsp;</span> */}
125
- <select
126
- value={table.getState().pagination.pageSize}
127
- onChange={(e) => {
128
- table.setPageSize(Number(e.target.value));
129
- }}
130
- >
131
- {rowsPerPageArray.map((pageSize) => (
132
- <option key={pageSize} value={pageSize}>
133
- {pageSize}
134
- </option>
135
- ))}
136
- </select>
137
- </div>
110
+ <PaginationButton
111
+ title="Previous Page"
112
+ disabled={!table.getCanPreviousPage()}
113
+ onClick={() => table.previousPage()}
114
+ >
115
+ <NavigateBeforeRounded fontSize="small" />
116
+ </PaginationButton>
138
117
 
139
- <div className="records_range_container">
140
- {/* <span>Showing&nbsp;</span> */}
141
- <strong>
142
- {recordsRangeFirst} - {recordsRangeLast} of {rowCount}
143
- </strong>
144
- </div>
118
+ <PaginationButton
119
+ title="Next Page"
120
+ disabled={!table.getCanNextPage()}
121
+ onClick={() => table.nextPage()}
122
+ >
123
+ <NavigateNextRounded fontSize="small" />
124
+ </PaginationButton>
145
125
 
146
- <div className="pagination_btn_container">
147
- <button
148
- title="Previous Page"
149
- className="pagination_btn"
150
- disabled={!table.getCanPreviousPage()}
151
- onClick={() => table.previousPage()}
152
- >
153
- <TablePreviousPageIcon />
154
- </button>
155
- <button
156
- title="Next Page"
157
- className="pagination_btn"
158
- disabled={!table.getCanNextPage()}
159
- onClick={() => table.nextPage()}
160
- >
161
- <TableNextPageIcon />
162
- </button>
163
- </div>
164
- </>
165
- )}
166
- </div>
126
+ {isFullView && (
127
+ <PaginationButton
128
+ title="Last Page"
129
+ disabled={!table.getCanNextPage()}
130
+ onClick={() => table.setPageIndex(pageCount - 1)}
131
+ >
132
+ <TableLastPageIcon />
133
+ </PaginationButton>
134
+ )}
135
+ </PaginationButtons>
136
+ </PaginationContainer>
167
137
  );
168
138
  }
169
139
 
@@ -0,0 +1,113 @@
1
+ import { styled } from "@mui/material/styles";
2
+ import { Box, IconButton, Select, InputBase } from "@mui/material";
3
+
4
+ /* Root container */
5
+ export const PaginationContainer = styled(Box)(({ theme }) => ({
6
+ padding: theme.spacing(0.5),
7
+ display: "flex",
8
+ justifyContent: "flex-end",
9
+ alignItems: "center",
10
+ gap: theme.spacing(2),
11
+ fontSize: theme.typography.pxToRem(14),
12
+ backgroundColor: theme.palette.common.white,
13
+
14
+ [theme.breakpoints.down("md")]: {
15
+ justifyContent: "center",
16
+ fontSize: theme.typography.pxToRem(12),
17
+ },
18
+ }));
19
+
20
+ /* Hide go-to-page on <= 991px */
21
+ export const GoToPageContainer = styled(Box)(({ theme }) => ({
22
+ display: "flex",
23
+ alignItems: "center",
24
+
25
+ [theme.breakpoints.down("md")]: {
26
+ display: "none",
27
+ },
28
+ }));
29
+
30
+ /* Rows per page */
31
+ export const RowsPerPageContainer = styled(Box)(({ theme }) => ({
32
+ display: "flex",
33
+ alignItems: "center",
34
+
35
+ [theme.breakpoints.down("sm")]: {
36
+ display: "none",
37
+ },
38
+ }));
39
+
40
+ /* Records range */
41
+ export const RecordsRangeContainer = styled(Box)(({ theme }) => ({
42
+ whiteSpace: "nowrap",
43
+ fontSize: theme.typography.pxToRem(14),
44
+
45
+ [theme.breakpoints.down("sm")]: {
46
+ display: "none",
47
+ },
48
+ }));
49
+
50
+ /* Page range */
51
+ export const PageRangeContainer = styled(Box)(({ theme }) => ({
52
+ whiteSpace: "nowrap",
53
+ fontSize: theme.typography.pxToRem(14),
54
+ }));
55
+
56
+ /* Buttons wrapper */
57
+ export const PaginationButtons = styled(Box)(({ theme }) => ({
58
+ display: "flex",
59
+ gap: theme.spacing(1),
60
+ }));
61
+
62
+ /* Pagination button */
63
+ export const PaginationButton = styled(IconButton)(({ theme }) => ({
64
+ borderRadius: "50%",
65
+ height: 24,
66
+ width: 24,
67
+ padding: 2,
68
+ transition: "0.4s",
69
+
70
+ "&:hover": {
71
+ backgroundColor: theme.palette.grey[300],
72
+ boxShadow: "0 1px 2px 0 rgba(60,64,67,.6), 0 1px 3px 1px rgba(60,64,67,.3)",
73
+ },
74
+
75
+ "&.Mui-disabled": {
76
+ color: theme.palette.action.disabled,
77
+ },
78
+
79
+ [theme.breakpoints.down("sm")]: {
80
+ height: 24,
81
+ width: 24,
82
+ padding: 0,
83
+
84
+ "& svg": {
85
+ width: 20,
86
+ height: 20,
87
+ },
88
+ },
89
+ }));
90
+
91
+ /* Select (rows per page) */
92
+ export const RowsPerPageSelect = styled(Select)(({ theme }) => ({
93
+ borderRadius: theme.shape.borderRadius,
94
+ padding: theme.spacing(0),
95
+ fontSize: theme.typography.pxToRem(12),
96
+
97
+ "& .MuiSelect-select": {
98
+ padding: theme.spacing(0.5, 0.75),
99
+ },
100
+ }));
101
+
102
+ /* Input for go-to-page */
103
+ export const GoToPageInput = styled(InputBase)(({ theme }) => ({
104
+ width: 60,
105
+ textAlign: "center",
106
+ borderRadius: theme.shape.borderRadius,
107
+ border: `1px solid ${theme.palette.divider}`,
108
+ fontSize: theme.typography.pxToRem(12),
109
+
110
+ "& .MuiInputBase-input": {
111
+ padding: theme.spacing(0.25, 0.75),
112
+ },
113
+ }));
@@ -1,13 +1,13 @@
1
1
  import { useSortable } from "@dnd-kit/sortable";
2
2
  import { CSS } from "@dnd-kit/utilities";
3
3
  import { Cell, flexRender } from "@tanstack/react-table";
4
- import { CSSProperties } from "react";
5
- import { align } from "../types/common";
6
- import { getColumnPinningStylesBody } from "../libs/utils/common";
4
+ import { align } from "../../types/common";
5
+ import { getColumnPinningStylesBody } from "../../libs/utils/common";
7
6
  import {
8
7
  CraftTableFeatureProps,
9
8
  CraftTableOptionsProps,
10
- } from "../types/table-options";
9
+ } from "../../types/table-options";
10
+ import { TableBodyCell } from "./table-body.styles";
11
11
 
12
12
  interface DragAlongCellProps<T> {
13
13
  cell: Cell<T, unknown>;
@@ -28,34 +28,27 @@ function DragAlongCell<T>({
28
28
 
29
29
  const isPinned = cell.column.getIsPinned();
30
30
 
31
- const style: CSSProperties = {
32
- opacity: isDragging ? 0.8 : 1,
33
- transform: CSS.Translate.toString(transform),
34
- transition: "width transform 0.2s ease-in-out",
35
- width: cell.column.getSize(),
36
- ...getColumnPinningStylesBody(cell.column),
37
- ...((wrapColumns.all_wrap || wrapColumns[cell.column.id]) && {
38
- wordBreak: "break-all",
39
- // whiteSpace: "normal",
40
- }),
41
- };
42
-
43
31
  return (
44
- <td
32
+ <TableBodyCell
45
33
  ref={setNodeRef}
46
- {...{
47
- style: {
48
- ...style,
49
- zIndex: isPinned ? 2 : isDragging ? 1 : 0,
50
- },
51
- align: (cell.column.columnDef.meta as align)?.align || "left",
52
- className: "ts__body__td",
34
+ align={(cell.column.columnDef.meta as align)?.align || "left"}
35
+ style={{
36
+ opacity: isDragging ? 0.8 : 1,
37
+ transform: CSS.Translate.toString(transform),
38
+ transition: "width transform 0.2s ease-in-out",
39
+ width: cell.column.getSize(),
40
+ ...getColumnPinningStylesBody(cell.column),
41
+ ...((wrapColumns.all_wrap || wrapColumns[cell.column.id]) && {
42
+ wordBreak: "break-all",
43
+ whiteSpace: "normal",
44
+ }),
45
+ zIndex: isPinned ? 2 : isDragging ? 1 : 0,
53
46
  }}
54
47
  >
55
48
  {cell.getIsPlaceholder()
56
49
  ? null
57
50
  : flexRender(cell.column.columnDef.cell, cell.getContext())}
58
- </td>
51
+ </TableBodyCell>
59
52
  );
60
53
  }
61
54