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.
Files changed (34) hide show
  1. package/dist/index.d.ts +5 -6
  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 +115 -0
  11. package/src/listing/components/search/index.tsx +4 -8
  12. package/src/listing/components/{table-body-dnd-cell.tsx → table-body/table-body-dnd-cell.tsx} +18 -25
  13. package/src/listing/components/table-body/table-body.styles.ts +64 -0
  14. package/src/listing/components/{table-body.tsx → table-body/table-body.tsx} +35 -32
  15. package/src/listing/components/table-head/table-head-dnd-cell.tsx +112 -0
  16. package/src/listing/components/table-head/table-head-pin.tsx +29 -0
  17. package/src/listing/components/{table-head-popover.tsx → table-head/table-head-popover.tsx} +4 -16
  18. package/src/listing/components/table-head/table-head-resizer.tsx +22 -0
  19. package/src/listing/components/table-head/table-head.styles.ts +113 -0
  20. package/src/listing/components/{table-head.tsx → table-head/table-head.tsx} +36 -69
  21. package/src/listing/components/table.tsx +2 -2
  22. package/src/listing/components/tabs/index.tsx +31 -49
  23. package/src/listing/components/tabs/tabs.styles.ts +49 -0
  24. package/src/listing/components/topbar/index.scss +2 -4
  25. package/src/listing/components/topbar/index.tsx +169 -175
  26. package/src/listing/libs/hooks/useEntityTableHooks.ts +3 -3
  27. package/src/listing/libs/utils/apiColumn.ts +7 -3
  28. package/src/listing/libs/utils/common.ts +44 -0
  29. package/src/listing/types/table.ts +2 -2
  30. package/src/view/ListingView.tsx +38 -87
  31. package/src/listing/components/table-head-dnd-cell.tsx +0 -150
  32. package/src/listing/components/table-head-pin.tsx +0 -22
  33. package/src/listing/components/tabs/index.scss +0 -42
  34. package/src/listing/components/tabs/styles.ts +0 -34
@@ -5,9 +5,8 @@ import {
5
5
  FilterationIcon,
6
6
  HideColumnIcon,
7
7
  } from "../../../assets/svg.tsx";
8
- import { Popover } from "@mui/material";
8
+ import { Box, Popover } from "@mui/material";
9
9
  import LayoutSelector from "../table-change-layout.tsx";
10
- import useOutsideClick from "../../libs/hooks/useOutsideClick.tsx";
11
10
  import { Table } from "@tanstack/react-table";
12
11
  import { TopbarOptionsProps } from "../../types/table.ts";
13
12
  import "./index.scss";
@@ -48,7 +47,6 @@ function Topbar<T>({
48
47
  const [sortAnchorEl, setSortAnchorEl] = useState<HTMLElement | null>(null);
49
48
  const [groupBy, setGroupBy] = useState<string>("None");
50
49
 
51
- const [showColumnHiding, setShowColumnHiding] = useState(false);
52
50
  const [layoutAnchorEl, setLayoutAnchorEl] = useState<null | HTMLElement>(
53
51
  null
54
52
  );
@@ -60,10 +58,6 @@ function Topbar<T>({
60
58
  table.getAllLeafColumns().map((col) => col.id)
61
59
  );
62
60
 
63
- const { setShowTableFilter } = tableStates;
64
-
65
- // search
66
- const [showSearchInput, setShowSearchInput] = useState(false);
67
61
  const searchContainerRef = useRef<HTMLDivElement>(null);
68
62
 
69
63
  // sync column order with table instance
@@ -78,7 +72,6 @@ function Topbar<T>({
78
72
  setSortAnchorEl(null);
79
73
  setColumnAnchorEl(null);
80
74
  setViewMoreAnchorEl(null);
81
- setShowColumnHiding(false);
82
75
  }
83
76
  }, [isFullscreen]);
84
77
 
@@ -96,22 +89,11 @@ function Topbar<T>({
96
89
 
97
90
  const { container: fullscreenContainer } = useFullscreenPopoverContainer();
98
91
 
99
- const dropdownRef = useRef<HTMLDivElement>(null);
100
- useOutsideClick({
101
- ref: dropdownRef,
102
- handler: () => setShowColumnHiding(false),
103
- });
104
-
105
92
  const handleLayoutSelect = (layout: string) => {
106
93
  setSelectedLayout(layout);
107
94
  setLayoutAnchorEl(null);
108
95
  };
109
96
 
110
- useOutsideClick({
111
- ref: searchContainerRef,
112
- handler: () => setShowSearchInput(false),
113
- });
114
-
115
97
  useEffect(() => {
116
98
  const handleExternalLayoutTrigger = (e: Event) => {
117
99
  const target = (e as CustomEvent).detail?.target as HTMLElement;
@@ -128,7 +110,6 @@ function Topbar<T>({
128
110
  };
129
111
 
130
112
  const handleExternalSearchTrigger = () => {
131
- setShowSearchInput(true);
132
113
  setTimeout(() => {
133
114
  searchContainerRef.current?.querySelector("input")?.focus();
134
115
  }, 100);
@@ -180,96 +161,107 @@ function Topbar<T>({
180
161
  {rightSideComponent}
181
162
  {paginationComponent}
182
163
 
183
- {showSearch && (
184
- <div
185
- title="Search"
186
- className="external-search-trigger"
187
- onClick={() => {
188
- const customEvent = new CustomEvent("triggerSearchInput");
189
- window.dispatchEvent(customEvent);
164
+ <Box
165
+ sx={{
166
+ display: "flex",
167
+ alignItems: "center",
168
+ justifyContent: "center",
169
+ gap: 0.5,
170
+ }}
171
+ >
172
+ {showSearch && (
173
+ <Box
174
+ title="Search"
175
+ className="external-search-trigger"
176
+ onClick={() => {
177
+ const customEvent = new CustomEvent("triggerSearchInput");
178
+ window.dispatchEvent(customEvent);
179
+ }}
180
+ ref={searchContainerRef}
181
+ >
182
+ <TableSearch
183
+ value={searchValue ?? ""}
184
+ onChange={onSearchChange ?? (() => {})}
185
+ />
186
+ </Box>
187
+ )}
188
+
189
+ {showChangeLayoutToggle && (
190
+ <>
191
+ <div className="change-layout ts--button" title="Layout">
192
+ <div
193
+ onClick={(e) => {
194
+ const customEvent = new CustomEvent(
195
+ "triggerLayoutPopover",
196
+ {
197
+ detail: { target: e.currentTarget },
198
+ }
199
+ );
200
+ window.dispatchEvent(customEvent);
201
+ }}
202
+ className="external-layout-trigger"
203
+ >
204
+ <ChangeLayoutIcon />
205
+ </div>
206
+ </div>
207
+ </>
208
+ )}
209
+ <Popover
210
+ open={Boolean(layoutAnchorEl)}
211
+ anchorEl={layoutAnchorEl}
212
+ onClose={() => setLayoutAnchorEl(null)}
213
+ anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
214
+ container={fullscreenContainer}
215
+ sx={{
216
+ mt: 2.2,
190
217
  }}
191
- ref={searchContainerRef}
192
218
  >
193
- <TableSearch
194
- value={searchValue ?? ""}
195
- onChange={onSearchChange ?? (() => {})}
219
+ <LayoutSelector
220
+ onSelect={handleLayoutSelect}
221
+ selectedLayout={selectedLayout}
196
222
  />
197
- </div>
198
- )}
199
-
200
- {showChangeLayoutToggle && (
201
- <>
202
- <div className="change-layout ts--button" title="Layout">
223
+ </Popover>
224
+ {showColumnToggle && (
225
+ <>
203
226
  <div
204
- onClick={(e) => {
205
- const customEvent = new CustomEvent("triggerLayoutPopover", {
206
- detail: { target: e.currentTarget },
207
- });
208
- window.dispatchEvent(customEvent);
209
- }}
210
- className="external-layout-trigger"
227
+ className="hide-column ts--button"
228
+ onClick={(e) => setColumnAnchorEl(e.currentTarget)}
229
+ title="Column"
211
230
  >
212
- <ChangeLayoutIcon />
231
+ <HideColumnIcon />
213
232
  </div>
214
- </div>
215
- </>
216
- )}
217
- <Popover
218
- open={Boolean(layoutAnchorEl)}
219
- anchorEl={layoutAnchorEl}
220
- onClose={() => setLayoutAnchorEl(null)}
221
- anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
222
- container={fullscreenContainer}
223
- sx={{
224
- mt: 2.2,
225
- }}
226
- >
227
- <LayoutSelector
228
- onSelect={handleLayoutSelect}
229
- selectedLayout={selectedLayout}
230
- />
231
- </Popover>
232
- {showColumnToggle && (
233
- <>
234
- <div
235
- className="hide-column ts--button"
236
- onClick={(e) => setColumnAnchorEl(e.currentTarget)}
237
- title="Column"
238
- >
239
- <HideColumnIcon />
240
- </div>
241
- <ColumnToggle
242
- anchorEl={columnAnchorEl}
243
- onClose={() => setColumnAnchorEl(null)}
244
- table={table}
245
- columnOrder={columnOrder}
246
- setColumnOrder={setColumnOrder}
247
- />
248
- </>
249
- )}
233
+ <ColumnToggle
234
+ anchorEl={columnAnchorEl}
235
+ onClose={() => setColumnAnchorEl(null)}
236
+ table={table}
237
+ columnOrder={columnOrder}
238
+ setColumnOrder={setColumnOrder}
239
+ />
240
+ </>
241
+ )}
250
242
 
251
- {showSortingToggle && (
252
- <>
253
- <div
254
- className="filter ts--button"
255
- title="Sort"
256
- onClick={(e) => setSortAnchorEl(e.currentTarget)}
257
- >
258
- <SortingIcon />
259
- </div>
260
- <SortPopover
261
- anchorEl={sortAnchorEl}
262
- onClose={() => setSortAnchorEl(null)}
263
- columns={table.getAllLeafColumns().map((col) => ({
264
- id: col.id,
265
- label: (col.columnDef.meta as any)?.label || col.id,
266
- }))}
267
- onChange={(sortingRules) => table.setSorting(sortingRules)}
268
- />
269
- </>
270
- )}
243
+ {showSortingToggle && (
244
+ <>
245
+ <div
246
+ className="filter ts--button"
247
+ title="Sort"
248
+ onClick={(e) => setSortAnchorEl(e.currentTarget)}
249
+ >
250
+ <SortingIcon />
251
+ </div>
252
+ <SortPopover
253
+ anchorEl={sortAnchorEl}
254
+ onClose={() => setSortAnchorEl(null)}
255
+ columns={table.getAllLeafColumns().map((col) => ({
256
+ id: col.id,
257
+ label: (col.columnDef.meta as any)?.label || col.id,
258
+ }))}
259
+ onChange={(sortingRules) => table.setSorting(sortingRules)}
260
+ />
261
+ </>
262
+ )}
271
263
 
272
- {/* {showFilterToggle && (
264
+ {/* {showFilterToggle && (
273
265
  <div
274
266
  className="filter ts--button"
275
267
  title="Filter"
@@ -298,51 +290,52 @@ function Topbar<T>({
298
290
  </div>
299
291
  )} */}
300
292
 
301
- {showFilterToggle && (
302
- <div
303
- className="filter ts--button"
304
- title="Filter"
305
- onClick={onFilterButtonClick}
306
- style={{
307
- position: "relative",
308
- display: "flex",
309
- justifyContent: "center",
310
- alignItems: "center",
311
- backgroundColor:
312
- tableStates.showTableFilter || tableStates.filters.length > 0
313
- ? "#eae4fe"
314
- : "transparent",
315
- height: "25px",
316
- width: "25px",
317
- borderRadius: "6px",
318
- cursor: "pointer",
319
- }}
320
- >
321
- <FilterationIcon
322
- color={
323
- tableStates.showTableFilter || tableStates.filters.length > 0
324
- ? "#7A5AF8"
325
- : "#1C1B1F"
326
- }
327
- />
328
-
329
- {tableStates.filters.length > 0 && !tableStates.showTableFilter && (
330
- <span
331
- style={{
332
- position: "absolute",
333
- top: "1px",
334
- right: "1px",
335
- width: "6px",
336
- height: "6px",
337
- borderRadius: "50%",
338
- backgroundColor: "#F63D68",
339
- }}
293
+ {showFilterToggle && (
294
+ <div
295
+ className="filter ts--button"
296
+ title="Filter"
297
+ onClick={onFilterButtonClick}
298
+ style={{
299
+ position: "relative",
300
+ display: "flex",
301
+ justifyContent: "center",
302
+ alignItems: "center",
303
+ backgroundColor:
304
+ tableStates.showTableFilter || tableStates.filters.length > 0
305
+ ? "#eae4fe"
306
+ : "transparent",
307
+ height: "25px",
308
+ width: "25px",
309
+ borderRadius: "6px",
310
+ cursor: "pointer",
311
+ }}
312
+ >
313
+ <FilterationIcon
314
+ color={
315
+ tableStates.showTableFilter || tableStates.filters.length > 0
316
+ ? "#7A5AF8"
317
+ : "#1C1B1F"
318
+ }
340
319
  />
341
- )}
342
- </div>
343
- )}
344
320
 
345
- {/* {viewMoreToggle && (
321
+ {tableStates.filters.length > 0 &&
322
+ !tableStates.showTableFilter && (
323
+ <span
324
+ style={{
325
+ position: "absolute",
326
+ top: "1px",
327
+ right: "1px",
328
+ width: "6px",
329
+ height: "6px",
330
+ borderRadius: "50%",
331
+ backgroundColor: "#F63D68",
332
+ }}
333
+ />
334
+ )}
335
+ </div>
336
+ )}
337
+
338
+ {/* {viewMoreToggle && (
346
339
  <div className="view-more ts--button" title="View More">
347
340
  <ViewMore
348
341
  compactMode={isCompactTable}
@@ -357,7 +350,7 @@ function Topbar<T>({
357
350
  />
358
351
  </div>
359
352
  )} */}
360
- {/* {viewMoreToggle && (
353
+ {/* {viewMoreToggle && (
361
354
  <div
362
355
  className="view-more ts--button view-more-trigger"
363
356
  title="View More"
@@ -375,36 +368,37 @@ function Topbar<T>({
375
368
  />
376
369
  </div>
377
370
  )} */}
378
- <Popover
379
- open={isViewMoreOpen}
380
- anchorEl={viewMoreAnchorEl}
381
- onClose={() => setViewMoreAnchorEl(null)}
382
- anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
383
- transformOrigin={{ vertical: "top", horizontal: "left" }}
384
- container={fullscreenContainer}
385
- // PaperProps={{
386
- // sx: {
387
- // mt: 2,
388
- // padding: 0,
389
- // width: 380,
390
- // borderRadius: 1,
391
- // boxShadow: 4,
392
- // },
393
- // }}
394
- >
395
- <ViewMore
396
- compactMode={isCompactTable}
397
- onCompactToggle={(value: string) =>
398
- setIsCompactTable(value === "Compact")
399
- }
400
- isFullscreen={isFullscreen}
401
- onFullscreenToggle={fullscreenToggle}
402
- groupBy={groupBy}
403
- onGroupByChange={(value: string) => setGroupBy(value)}
404
- tableStates={tableStates}
371
+ <Popover
372
+ open={isViewMoreOpen}
373
+ anchorEl={viewMoreAnchorEl}
405
374
  onClose={() => setViewMoreAnchorEl(null)}
406
- />
407
- </Popover>
375
+ anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
376
+ transformOrigin={{ vertical: "top", horizontal: "left" }}
377
+ container={fullscreenContainer}
378
+ // PaperProps={{
379
+ // sx: {
380
+ // mt: 2,
381
+ // padding: 0,
382
+ // width: 380,
383
+ // borderRadius: 1,
384
+ // boxShadow: 4,
385
+ // },
386
+ // }}
387
+ >
388
+ <ViewMore
389
+ compactMode={isCompactTable}
390
+ onCompactToggle={(value: string) =>
391
+ setIsCompactTable(value === "Compact")
392
+ }
393
+ isFullscreen={isFullscreen}
394
+ onFullscreenToggle={fullscreenToggle}
395
+ groupBy={groupBy}
396
+ onGroupByChange={(value: string) => setGroupBy(value)}
397
+ tableStates={tableStates}
398
+ onClose={() => setViewMoreAnchorEl(null)}
399
+ />
400
+ </Popover>
401
+ </Box>
408
402
  </div>
409
403
  </div>
410
404
  );
@@ -14,11 +14,11 @@ export const useDetailsQueryAPI = (value: string | undefined) => {
14
14
  return { detailsQuery };
15
15
  };
16
16
 
17
- export const useFetchData = (entity_type: string) => {
17
+ export const useFetchData = (entity_type: string, payload?: any) => {
18
18
  // First query to get meta data
19
19
  const metaQuery = useQuery({
20
- queryKey: ["meta", entity_type],
21
- queryFn: () => entityTableFilterMaster(entity_type),
20
+ queryKey: ["meta", entity_type, payload],
21
+ queryFn: () => entityTableFilterMaster(entity_type, payload),
22
22
  });
23
23
 
24
24
  return { metaQuery };
@@ -27,10 +27,14 @@ export const entityTableMetaMaster = async (entity_type: string) => {
27
27
  }
28
28
  };
29
29
 
30
- export const entityTableFilterMaster = async (entity_type: string) => {
30
+ export const entityTableFilterMaster = async (
31
+ entity_type: string,
32
+ payload?: any
33
+ ) => {
31
34
  try {
32
35
  const response = await api.post(
33
- `/meta/get-table-data?entity_type=${entity_type}&list_type=${entity_type}`
36
+ `/meta/get-table-data?entity_type=${entity_type}&list_type=${entity_type}`,
37
+ payload
34
38
  );
35
39
 
36
40
  // const filteredData = {
@@ -215,6 +219,6 @@ export const getAttributes = async (entity_type: string) => {
215
219
  };
216
220
 
217
221
  export const getTableTabs = async (payload: any) => {
218
- const response = await api.post(`filter/get-tabs-data`, payload);
222
+ const response = await api.post(`filter/adm/tabs`, payload);
219
223
  return response.data;
220
224
  };
@@ -111,3 +111,47 @@ api.interceptors.request.use(
111
111
  return Promise.reject(error);
112
112
  }
113
113
  );
114
+
115
+ export const formatTableHeaders = (columns: any) => {
116
+ const mapped = columns.map((col: any) => {
117
+ const meta =
118
+ col.attribute_key === "status" ||
119
+ col.attribute_key === "lead_status" ||
120
+ col.attribute_key === "flag" ||
121
+ col.attribute_key === "invitation_status"
122
+ ? { type: "custom", propName: "renderStatus", align: col.align }
123
+ : col.attribute_key === "profile_image" ||
124
+ col.attribute_key === "short_logo"
125
+ ? {
126
+ type: "custom",
127
+ propName: "profileImageFetch",
128
+ align: col.align,
129
+ }
130
+ : col.attribute_key === "start_date" || col.attribute_key === "end_date"
131
+ ? { type: "custom", propName: "dateFormater", align: col.align }
132
+ : col.attribute_key === "action"
133
+ ? { type: "custom", propName: "renderAction", align: col.align }
134
+ : col.attribute_key === "code"
135
+ ? {
136
+ type: "custom",
137
+ propName: "drillCellRenderer",
138
+ align: col.align,
139
+ }
140
+ : col.attribute_key === "primary_mobile"
141
+ ? {
142
+ type: "custom",
143
+ propName: "apiCallonClick",
144
+ align: col.align,
145
+ }
146
+ : undefined;
147
+
148
+ return {
149
+ header: col.name ?? "",
150
+ accessorKey: col.attribute_key ?? "",
151
+ size: col.size,
152
+ meta,
153
+ };
154
+ });
155
+
156
+ return mapped;
157
+ };
@@ -95,7 +95,7 @@ export interface CraftTableProps<T> {
95
95
  filterOptions?: FilterOptionsProps;
96
96
  settingsOptions?: settingsOptionsProps;
97
97
  craftTableFilterSettingsOptions?: craftTableFilterSettingsOptionsProps;
98
- activeTab?: string;
98
+ activeTab?: any;
99
99
  }
100
100
  export interface CraftTableComponentProps<T> {
101
101
  table: Table<T>;
@@ -115,6 +115,6 @@ export interface TableHeaderProps<T> {
115
115
  activeTab?: string;
116
116
  featureOptions: CraftTableFeatureProps;
117
117
  tableStates: CraftTableOptionsProps;
118
- filterSettingStates: craftTableFilterSettingsOptionsProps;
118
+ filterSettingStates?: craftTableFilterSettingsOptionsProps;
119
119
  onSaveSettings?: (columnId: string) => void;
120
120
  }