rez-table-listing-mui 1.3.41 → 1.3.43

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 (28) hide show
  1. package/dist/index.d.ts +563 -0
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +2 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +1 -1
  7. package/src/listing/components/filter/components/attributes-filter.tsx +2 -2
  8. package/src/listing/components/filter/components/forms/components/Dropdown.tsx +2 -2
  9. package/src/listing/components/filter/components/forms/components/Filter-criteria.tsx +7 -9
  10. package/src/listing/components/filter/components/forms/components/Textfield.tsx +4 -2
  11. package/src/listing/components/filter/components/forms/components/filter-criteria-list.tsx +0 -1
  12. package/src/listing/components/filter/components/forms/index.tsx +14 -23
  13. package/src/listing/components/filter/components/forms/utils/filter-date-input-resolver.tsx +3 -3
  14. package/src/listing/components/filter/components/main-filter.tsx +6 -6
  15. package/src/listing/components/filter/components/saved-edit-filter.tsx +3 -5
  16. package/src/listing/components/filter/components/saved-filter.tsx +124 -300
  17. package/src/listing/components/filter/components/search/index.tsx +0 -1
  18. package/src/listing/components/filter/components/single-filter-rendering.tsx +3 -3
  19. package/src/listing/components/filter/index.tsx +5 -130
  20. package/src/listing/components/login/index.tsx +6 -3
  21. package/src/listing/libs/hooks/useEntityTableAPI.tsx +5 -8
  22. package/src/listing/libs/utils/apiColumn.ts +3 -3
  23. package/src/listing/libs/utils/common.ts +0 -1
  24. package/src/listing/libs/utils/hydrate-saved-filters.ts +2 -2
  25. package/src/listing/types/filter.ts +4 -51
  26. package/src/view/FIlterWrapper.tsx +0 -15
  27. package/src/view/ListingView.tsx +2 -2
  28. package/src/listing/components/common/saved-filter-modal/index.tsx +0 -517
@@ -5,11 +5,7 @@ import {
5
5
  FilterOperationListProps,
6
6
  } from "../../../types/filter";
7
7
  import {
8
- Accordion,
9
- AccordionDetails,
10
- AccordionSummary,
11
8
  Box,
12
- Divider,
13
9
  IconButton,
14
10
  List,
15
11
  ListItem,
@@ -19,8 +15,8 @@ import {
19
15
  import CustomSearch from "./search";
20
16
  import { DeleteIcon, EditIcon } from "../../../../assets/svg";
21
17
  import SavedFilterEditComponent from "./saved-edit-filter";
18
+ import { filterStyles } from "../style";
22
19
  import { CheckBox } from "../../../../assets/svg";
23
- import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
24
20
 
25
21
  const SavedFilter = ({
26
22
  columnsData,
@@ -29,77 +25,31 @@ const SavedFilter = ({
29
25
  editMode,
30
26
  setEditMode,
31
27
  setDeleteFilterModalOpen,
32
- onSaveFilterButtonClick,
28
+ setSavedFilterModalOpen,
33
29
  tabValue,
34
30
  onChangeFunction,
35
31
  filterComponentOptions,
36
32
  }: FilterFormComponentProps) => {
37
33
  const { filters, filterMaster, setFilterMaster, setFilterToDelete } =
38
34
  tableStates;
39
-
40
35
  const [searchTerm, setSearchTerm] = useState<string>("");
41
36
 
42
- const MyFilter = (f: any): FilterOperationListProps => {
43
- return {
44
- label: f.name || f.label || "Unnamed Filter",
45
- value: f.id || f.value,
46
- code: f.code ?? "",
47
- is_shared: false,
48
- created_by: f.created_by || "",
49
- description: f.description || "",
50
- is_owner: true, // My filter = always owner
51
- is_editable: f.is_editable === true || f.is_editable === "true",
52
- };
53
- };
54
-
55
- const SharedFilter = (f: any): FilterOperationListProps => {
56
- const prefs =
57
- f.sharedPreferences || f.preferences || f.meta || f.shared_meta || {};
58
-
59
- return {
60
- label: f.name || f.label || "Unnamed Filter",
61
- value: f.id || f.value,
62
- code: f.code ?? "",
63
- is_shared: f.is_shared ?? prefs.is_shared ?? true,
64
- created_by: f.created_by || "shared_filter",
65
- description: f.description || "",
66
- is_owner: f.is_owner === true || prefs.is_owner === "true",
67
- is_editable:
68
- f.is_editable === true ||
69
- f.is_editable === "true" ||
70
- prefs.is_editable === true ||
71
- prefs.is_editable === "true",
72
- };
73
- };
74
-
75
- // SEPARATE DATA MAPPINGS
76
-
77
- const myFilters: FilterOperationListProps[] =
78
- columnsData?.saved_filter?.map(MyFilter) ?? [];
79
-
80
- const sharedFilters: FilterOperationListProps[] =
81
- columnsData?.shared_filter?.map(SharedFilter) ?? [];
82
-
83
- // Reset on unmount
37
+ // reset savedFilterEditValue when component unmounts
84
38
  useEffect(() => {
85
39
  return () => {
86
- const editModeFromTab =
40
+ const editModeFromTabOptions =
87
41
  filterComponentOptions?.tabOptions?.savedFilter?.editMode;
88
-
89
- if (!editModeFromTab) {
42
+ if (!editModeFromTabOptions) {
90
43
  setEditMode && setEditMode(false);
91
44
  setFilterMaster(
92
45
  (prev) =>
93
46
  ({
94
47
  ...prev,
95
48
  saved_filters: {
96
- ...(prev?.saved_filters ?? {}),
49
+ ...prev?.attributes,
97
50
  selectedId: "",
98
51
  selectedName: "",
99
- description: "",
100
52
  selectedCode: "",
101
- shareWithTeam: undefined,
102
- allowTeamEdit: undefined,
103
53
  },
104
54
  } as FilterMasterStateProps)
105
55
  );
@@ -107,20 +57,14 @@ const SavedFilter = ({
107
57
  };
108
58
  }, []);
109
59
 
110
- // APPLY FILTER
111
-
112
- const applyFilterStates = (filter: FilterOperationListProps) => {
113
- const newFilterMaster = {
60
+ const handleListItemClick = (filter: FilterOperationListProps) => {
61
+ const newFilterMasterState = {
114
62
  ...filterMaster,
115
63
  saved_filters: {
116
- ...(filterMaster?.saved_filters ?? {}),
117
- selectedId: filter.value,
118
- selectedName: filter.label,
119
- description: filter.description,
120
- selectedCode: filter.code,
121
- shareWithTeam: filter.is_shared,
122
- allowTeamEdit: filter.is_editable,
123
- is_owner: filter.is_owner,
64
+ ...filterMaster?.attributes,
65
+ selectedId: filter?.value,
66
+ selectedName: filter?.label,
67
+ selectedCode: filter?.code,
124
68
  },
125
69
  attributes: {
126
70
  ...filterMaster?.attributes,
@@ -129,161 +73,125 @@ const SavedFilter = ({
129
73
  activeFilterTabIndex: tabValue,
130
74
  } as FilterMasterStateProps;
131
75
 
132
- setFilterMaster(newFilterMaster);
76
+ setFilterMaster(newFilterMasterState);
133
77
 
134
- onChangeFunction &&
135
- onChangeFunction({
136
- filterMaster: newFilterMaster,
137
- filters,
138
- });
139
- };
78
+ const newState = {
79
+ filterMaster: newFilterMasterState,
80
+ filters: filters,
81
+ };
140
82
 
141
- const handleListItemClick = (filter: FilterOperationListProps) => {
142
- applyFilterStates(filter);
83
+ onChangeFunction && onChangeFunction(newState);
84
+
85
+ // setEditfilter state on edit icon click
143
86
  setEditMode && setEditMode(true);
144
87
  setFilterToDelete(filter);
145
88
  };
146
89
 
147
- const handleApplyFilter = (filter: FilterOperationListProps) => {
148
- applyFilterStates(filter);
149
- };
150
-
151
- const [openAccordion, setOpenAccordion] = useState<"my" | "shared" | null>(
152
- "my"
153
- );
154
-
155
- const toggleAccodion = (accordion: "my" | "shared" | null) => {
156
- setOpenAccordion((prev) => (prev === accordion ? null : accordion));
157
- };
90
+ const handleAppyFilter = (filter: FilterOperationListProps) => {
91
+ const newFilterMasterState = {
92
+ ...filterMaster,
93
+ saved_filters: {
94
+ ...filterMaster?.attributes,
95
+ selectedId: filter?.value,
96
+ selectedName: filter?.label,
97
+ selectedCode: filter?.code,
98
+ },
99
+ attributes: {
100
+ ...filterMaster?.attributes,
101
+ radio: [],
102
+ },
103
+ activeFilterTabIndex: tabValue,
104
+ } as FilterMasterStateProps;
158
105
 
159
- // RENDER: MY FILTERS
106
+ setFilterMaster(newFilterMasterState);
160
107
 
161
- const renderMyFilters = (source: FilterOperationListProps[]) =>
162
- source.length === 0 ? (
163
- <Typography>No My Filters</Typography>
164
- ) : (
165
- <List sx={{ display: "flex", flexDirection: "column", gap: 1 }}>
166
- {source
167
- .filter((f) =>
168
- f.label?.toLowerCase().includes(searchTerm.toLowerCase())
169
- )
170
- .map((filter) => (
171
- <ListItem
172
- key={filter.value}
173
- sx={{
174
- cursor: "pointer",
175
- borderRadius: "8px",
176
- bgcolor: "#f2f6f8ff",
177
- display: "flex",
178
- justifyContent: "space-between",
179
- gap: 1,
180
- alignItems: "center",
181
- "&:hover .action-icons": {
182
- opacity: 1,
183
- visibility: "visible",
184
- },
185
- }}
186
- onClick={() => handleApplyFilter(filter)}
187
- >
188
- {filter.value === filterMaster?.saved_filters?.selectedId && (
189
- <Box sx={{ display: "flex", alignItems: "center" }}>
190
- <CheckBox />
191
- </Box>
192
- )}
108
+ const newState = {
109
+ filterMaster: newFilterMasterState,
110
+ filters: filters,
111
+ };
193
112
 
194
- <ListItemText primary={filter.label} />
113
+ onChangeFunction && onChangeFunction(newState);
114
+ };
195
115
 
196
- <Box
197
- onClick={(e) => e.stopPropagation()}
198
- className="action-icons"
116
+ const renderList = () => (
117
+ <>
118
+ <CustomSearch
119
+ value={searchTerm}
120
+ onChange={setSearchTerm}
121
+ className="search-input"
122
+ />
123
+
124
+ {columnsData?.saved_filter?.length === 0 ? (
125
+ <Typography sx={{ mt: 2 }}>No saved filters yet.</Typography>
126
+ ) : (
127
+ <List
128
+ sx={{
129
+ display: "flex",
130
+ flexDirection: "column",
131
+ gap: 1,
132
+ mt: 2,
133
+ }}
134
+ >
135
+ {columnsData?.saved_filter
136
+ ?.filter((filter) =>
137
+ filter.label?.toLowerCase().includes(searchTerm.toLowerCase())
138
+ )
139
+ ?.map((filter) => (
140
+ <ListItem
141
+ key={filter?.value}
199
142
  sx={{
143
+ cursor: "pointer",
144
+ border:
145
+ filter?.value ===
146
+ tableStates?.filterMaster?.saved_filters?.selectedId
147
+ ? `3px solid #7a5af8`
148
+ : "1px solid #C5C5C5",
149
+ borderRadius: "8px",
200
150
  display: "flex",
151
+ justifyContent: "space-between",
201
152
  gap: 1,
202
- opacity: 0,
203
- visibility: "hidden",
204
- transition: "opacity 0.2s ease, visibility 0.2s ease",
153
+ alignItems: "center",
154
+ "&:hover .action-icons": {
155
+ opacity: 1,
156
+ visibility: "visible",
157
+ },
205
158
  }}
159
+ onClick={() => handleAppyFilter(filter)}
206
160
  >
207
- <IconButton
208
- size="large"
209
- onClick={() => handleListItemClick(filter)}
210
- >
211
- <EditIcon />
212
- </IconButton>
213
-
214
- <IconButton
215
- size="small"
216
- onClick={() => {
217
- setFilterToDelete(filter);
218
- setDeleteFilterModalOpen?.(true);
161
+ {filter?.value ===
162
+ tableStates?.filterMaster?.saved_filters?.selectedId && (
163
+ <Box
164
+ sx={{
165
+ display: "flex",
166
+ alignItems: "center",
167
+ cursor: "pointer",
168
+ color: "green",
169
+ rounded: "full",
170
+ }}
171
+ >
172
+ <CheckBox />
173
+ </Box>
174
+ )}
175
+ <ListItemText primary={filter?.label} />
176
+
177
+ <Box
178
+ onClick={(e) => e.stopPropagation()}
179
+ className="action-icons"
180
+ sx={{
181
+ display: "flex",
182
+ gap: 1,
183
+ opacity: 0,
184
+ visibility: "hidden",
185
+ transition: "opacity 0.2s ease, visibility 0.2s ease",
219
186
  }}
220
187
  >
221
- <DeleteIcon />
222
- </IconButton>
223
- </Box>
224
- </ListItem>
225
- ))}
226
- </List>
227
- );
228
-
229
- // ----------------------------------------
230
- // RENDER: SHARED FILTERS
231
- // ----------------------------------------
232
- const renderSharedFilters = (source: FilterOperationListProps[]) =>
233
- source.length === 0 ? (
234
- <Typography>No Shared Filters</Typography>
235
- ) : (
236
- <List sx={{ display: "flex", flexDirection: "column", gap: 1 }}>
237
- {source
238
- .filter((f) =>
239
- f.label?.toLowerCase().includes(searchTerm.toLowerCase())
240
- )
241
- .map((filter) => (
242
- <ListItem
243
- key={filter.value}
244
- sx={{
245
- cursor: "pointer",
246
- borderRadius: "8px",
247
- bgcolor: "#f2f6f8ff",
248
- display: "flex",
249
- justifyContent: "space-between",
250
- gap: 1,
251
- alignItems: "center",
252
- "&:hover .action-icons": {
253
- opacity: 1,
254
- visibility: "visible",
255
- },
256
- }}
257
- onClick={() => handleApplyFilter(filter)}
258
- >
259
- {filter.value === filterMaster?.saved_filters?.selectedId && (
260
- <Box sx={{ display: "flex", alignItems: "center" }}>
261
- <CheckBox />
262
- </Box>
263
- )}
264
-
265
- <ListItemText primary={filter.label} />
266
-
267
- <Box
268
- onClick={(e) => e.stopPropagation()}
269
- className="action-icons"
270
- sx={{
271
- display: "flex",
272
- gap: 1,
273
- opacity: 0,
274
- visibility: "hidden",
275
- transition: "opacity 0.2s ease, visibility 0.2s ease",
276
- }}
277
- >
278
- {(filter.is_editable || filter.is_owner) && (
279
188
  <IconButton
280
189
  size="large"
281
190
  onClick={() => handleListItemClick(filter)}
282
191
  >
283
192
  <EditIcon />
284
193
  </IconButton>
285
- )}
286
- {filter.is_owner && (
194
+
287
195
  <IconButton
288
196
  size="small"
289
197
  onClick={() => {
@@ -293,108 +201,24 @@ const SavedFilter = ({
293
201
  >
294
202
  <DeleteIcon />
295
203
  </IconButton>
296
- )}
297
- </Box>
298
- </ListItem>
299
- ))}
300
- </List>
301
- );
302
-
303
- // ----------------------------------------
304
- // RENDER MAIN COMPONENT
305
- // ----------------------------------------
306
- return (
307
- <Box className="saved-filter-component-wrapper">
308
- {!editMode && (
309
- <>
310
- {/* Search */}
311
- <Box sx={{ mb: 2 }}>
312
- <CustomSearch
313
- value={searchTerm}
314
- onChange={setSearchTerm}
315
- className="search-input"
316
- />
317
- </Box>
204
+ </Box>
205
+ </ListItem>
206
+ ))}
207
+ </List>
208
+ )}
209
+ </>
210
+ );
318
211
 
319
- {/* ---- My Filters ---- */}
320
- <Box
321
- sx={{
322
- background: "#fff",
323
- borderRadius: "12px",
324
- border: "1px solid #eee",
325
- mb: 2,
326
- overflow: "hidden",
327
- }}
328
- >
329
- <Accordion
330
- disableGutters
331
- elevation={0}
332
- expanded={openAccordion === "my"}
333
- onChange={() =>
334
- // setOpenAccordion(openAccordion === "my" ? "shared" : "my")
335
- toggleAccodion("my")
336
- }
337
- >
338
- <AccordionSummary
339
- expandIcon={<ExpandMoreIcon fontSize="small" />}
340
- >
341
- <Typography fontWeight={600}>My Filters</Typography>
342
- </AccordionSummary>
343
- <Divider sx={{ width: "100%" }} />
344
- <AccordionDetails
345
- sx={{
346
- p: "9px",
347
- maxHeight: "230px",
348
- overflowY: "auto",
349
- scrollbarWidth: "thin",
350
- }}
351
- >
352
- {renderMyFilters(myFilters)}
353
- </AccordionDetails>
354
- </Accordion>
355
- </Box>
212
+ const mainBoxStyles = {
213
+ ...filterStyles.filterMainComponentWrapper,
214
+ ...filterStyles.scrollbarCustom,
215
+ };
356
216
 
357
- {/* ---- Shared Filters ---- */}
358
- <Box
359
- sx={{
360
- background: "#fff",
361
- borderRadius: "12px",
362
- border: "1px solid #eee",
363
- mb: 2,
364
- overflow: "hidden",
365
- }}
366
- >
367
- <Accordion
368
- disableGutters
369
- elevation={0}
370
- expanded={openAccordion === "shared"}
371
- onChange={() =>
372
- // setOpenAccordion(openAccordion === "shared" ? "my" : "shared")
373
- toggleAccodion("shared")
374
- }
375
- >
376
- <AccordionSummary
377
- expandIcon={<ExpandMoreIcon fontSize="small" />}
378
- >
379
- <Typography fontWeight={600}>Shared Filters</Typography>
380
- </AccordionSummary>
381
- <Divider sx={{ width: "100%" }} />
382
- <AccordionDetails
383
- sx={{
384
- p: "9px",
385
- maxHeight: "230px",
386
- overflowY: "auto",
387
- scrollbarWidth: "thin",
388
- }}
389
- >
390
- {renderSharedFilters(sharedFilters)}
391
- </AccordionDetails>
392
- </Accordion>
393
- </Box>
394
- </>
395
- )}
217
+ return (
218
+ <Box sx={mainBoxStyles} className="saved-filter-component-wrapper">
219
+ {/* Render search input and list */}
220
+ {!editMode && renderList()}
396
221
 
397
- {/* Edit Component */}
398
222
  {editMode && (
399
223
  <SavedFilterEditComponent
400
224
  columnsData={columnsData}
@@ -404,7 +228,7 @@ const SavedFilter = ({
404
228
  setEditMode={setEditMode}
405
229
  searchTerm={searchTerm}
406
230
  setSearchTerm={setSearchTerm}
407
- onSaveFilterButtonClick={onSaveFilterButtonClick}
231
+ setSavedFilterModalOpen={setSavedFilterModalOpen}
408
232
  setDeleteFilterModalOpen={setDeleteFilterModalOpen}
409
233
  onChangeFunction={onChangeFunction}
410
234
  filterComponentOptions={filterComponentOptions}
@@ -51,7 +51,6 @@ const CustomSearch = ({
51
51
  edge="end"
52
52
  onClick={handleClear}
53
53
  sx={{ color: "#888888", fontSize: "20px" }}
54
- className="cross-icon"
55
54
  >
56
55
  <CloseIcon />
57
56
  </IconButton>
@@ -13,7 +13,7 @@ const SingleFilterRendering = ({
13
13
  columnsData,
14
14
  dropdownData,
15
15
  tableStates,
16
- onSaveFilterButtonClick,
16
+ setSavedFilterModalOpen,
17
17
  onChangeFunction,
18
18
  filterComponentOptions,
19
19
  editMode,
@@ -50,7 +50,7 @@ const SingleFilterRendering = ({
50
50
  {showFilter === "main" && (
51
51
  <MainFilter
52
52
  {...commonProps}
53
- onSaveFilterButtonClick={onSaveFilterButtonClick}
53
+ setSavedFilterModalOpen={setSavedFilterModalOpen}
54
54
  filterComponentOptions={filterComponentOptions}
55
55
  />
56
56
  )}
@@ -59,7 +59,7 @@ const SingleFilterRendering = ({
59
59
  <SavedFilter
60
60
  {...commonProps}
61
61
  {...editProps}
62
- onSaveFilterButtonClick={onSaveFilterButtonClick}
62
+ setSavedFilterModalOpen={setSavedFilterModalOpen}
63
63
  filterComponentOptions={filterComponentOptions}
64
64
  />
65
65
  )}