rez-table-listing-mui 1.3.42 → 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 +5 -48
  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/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
@@ -1,517 +0,0 @@
1
- import {
2
- ChangeEvent,
3
- Dispatch,
4
- SetStateAction,
5
- useEffect,
6
- useState,
7
- } from "react";
8
- import {
9
- Box,
10
- Button,
11
- Checkbox,
12
- Dialog,
13
- DialogContent,
14
- DialogTitle,
15
- Divider,
16
- FormControlLabel,
17
- IconButton,
18
- TextField,
19
- Typography,
20
- } from "@mui/material";
21
- import { CloseIcon } from "../../../../assets/svg";
22
- import {
23
- FilterFormComponentProps,
24
- FilterMasterStateProps,
25
- } from "../../../types/filter";
26
- import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
27
- import { USER_ID } from "../../../libs/utils/common";
28
- // import { set } from "react-hook-form";
29
-
30
- const primary = "#7A5AF8";
31
-
32
- interface SavedFilterModalViewProps {
33
- open: boolean;
34
- onClose: () => void;
35
- onSave: () => void;
36
- filterMaster: FilterMasterStateProps | null;
37
- setFilterMaster: Dispatch<SetStateAction<FilterMasterStateProps | null>>;
38
- columnsData: FilterFormComponentProps | undefined;
39
- hasSavedFilters?: boolean;
40
- forceShowSharingControls?: boolean;
41
- }
42
-
43
- const SavedFilterModalView = ({
44
- open,
45
- onClose,
46
- onSave,
47
- filterMaster,
48
- setFilterMaster,
49
- columnsData,
50
-
51
- forceShowSharingControls = false,
52
- }: SavedFilterModalViewProps) => {
53
- const [shareWithTeam, setShareWithTeam] = useState<boolean>(false);
54
- const [allowTeamEdit, setAllowTeamEdit] = useState<boolean>(false);
55
- const filterNameValue = filterMaster?.saved_filters?.selectedName ?? "";
56
- const discriptionValue = filterMaster?.saved_filters?.description ?? "";
57
-
58
- const isSaveDisabled =
59
- !filterNameValue.trim() || (allowTeamEdit && !shareWithTeam);
60
-
61
- const selectedFilterId = filterMaster?.saved_filters?.selectedId || "";
62
-
63
- // Reset modal state when modal opens for a new filter
64
- useEffect(() => {
65
- if (!open) return;
66
-
67
- const filterId = filterMaster?.saved_filters?.selectedId;
68
- const filterObj1 = columnsData?.shared_filter?.find(
69
- (f: any) => f.id === filterId
70
- );
71
- // NEW FILTER → RESET everything
72
- if (!filterId && !filterObj1) {
73
- setFilterMaster((prev: any) => {
74
- if (!prev) return prev;
75
- return {
76
- ...prev,
77
- saved_filters: {
78
- ...(prev.saved_filters ?? {}),
79
- selectedId: null,
80
- selectedName: "",
81
- description: "",
82
- is_shared: false,
83
- is_editable: false,
84
- },
85
- };
86
- });
87
- setShareWithTeam(false);
88
- setAllowTeamEdit(false);
89
- return;
90
- }
91
-
92
- // EXISTING FILTER → Load from columnsData.saved_filter
93
- const filterObj = columnsData?.shared_filter?.find(
94
- (f: any) => f.id === filterId
95
- );
96
- if (filterObj) {
97
- setFilterMaster((prev) => {
98
- if (!prev) return prev;
99
- return {
100
- ...prev,
101
- saved_filters: {
102
- ...(prev.saved_filters ?? {}),
103
- selectedId: filterId,
104
- selectedName: filterObj.name || "",
105
- description: filterObj.description || "",
106
- is_shared: filterObj.is_shared || false,
107
- is_editable: filterObj.is_editable === "true",
108
- },
109
- };
110
- });
111
- // const initialShare = filterObj.is_shared ?? false;
112
- // const initialAllow = initialShare
113
- // ? filterObj.is_editable === "true"
114
- // : false;
115
- // setShareWithTeam(initialShare);
116
- // setAllowTeamEdit(initialAllow);
117
- const initialShare =
118
- filterObj.is_shared === true || filterObj.is_shared === "true";
119
- const initialAllow =
120
- initialShare &&
121
- (filterObj.is_editable === true || filterObj.is_editable === "true");
122
-
123
- setShareWithTeam(initialShare);
124
- setAllowTeamEdit(initialAllow);
125
-
126
- persistPreferences(initialShare, initialAllow);
127
- }
128
- }, [
129
- open,
130
- columnsData,
131
- filterMaster?.saved_filters?.selectedId,
132
- setFilterMaster,
133
- ]); // Added dependencies for loading
134
-
135
- // Persist toggle state to filterMaster
136
- const persistPreferences = (sharedValue: boolean, editableValue: boolean) => {
137
- setFilterMaster((prev) => {
138
- if (!prev) return prev;
139
-
140
- return {
141
- ...prev,
142
- saved_filters: {
143
- ...(prev.saved_filters ?? {}),
144
- is_shared: sharedValue,
145
- is_editable: editableValue,
146
- },
147
- };
148
- });
149
- };
150
-
151
- // Handle Share Toggle
152
-
153
- const handleShareToggle = (
154
- _: ChangeEvent<HTMLInputElement>,
155
- checked: boolean
156
- ) => {
157
- setShareWithTeam(checked);
158
-
159
- const nextAllow = checked ? allowTeamEdit : false;
160
- setAllowTeamEdit(nextAllow);
161
-
162
- persistPreferences(checked, nextAllow);
163
- };
164
-
165
- // Handle Allow Edit Toggle
166
-
167
- const handleAllowEditToggle = (
168
- _: ChangeEvent<HTMLInputElement>,
169
- checked: boolean
170
- ) => {
171
- if (!shareWithTeam) return; // Cannot enable edit without sharing
172
-
173
- setAllowTeamEdit(checked);
174
- persistPreferences(shareWithTeam, checked);
175
- };
176
-
177
- const shouldShowSharingControls = forceShowSharingControls || true; // always show
178
-
179
- const getModalTitle = () => {
180
- const selectedId = filterMaster?.saved_filters?.selectedId;
181
-
182
- if (!selectedId) return "Save Filter"; // new filter
183
-
184
- const filterObj = columnsData?.shared_filter?.find(
185
- (f: any) => f.id === selectedId
186
- );
187
- if (filterObj?.is_shared) {
188
- return "Shared Filter";
189
- }
190
- return "My Filter";
191
- };
192
-
193
- const handleSave = () => {
194
- persistPreferences(shareWithTeam, allowTeamEdit);
195
- onSave(); // call original save handler
196
- };
197
-
198
- // Get the selected filter object from columnsData.saved_filter
199
- const selectedFilter = columnsData?.shared_filter?.find(
200
- (f: any) => f.id === selectedFilterId
201
- );
202
-
203
- const selectedSavedFilter = columnsData?.shared_filter?.find(
204
- (f: any) => f.id === selectedFilterId
205
- );
206
-
207
- const isOwner = String(selectedSavedFilter?.is_owner) === "true";
208
-
209
- // Check if we should show prefields
210
- const showPrefields =
211
- (selectedSavedFilter && selectedSavedFilter.is_editable === "true") ||
212
- selectedSavedFilter;
213
-
214
- // Disable checkboxes if prefields are shown
215
- const showCheckboxes = !showPrefields;
216
-
217
- const isNewFilter = !selectedSavedFilter;
218
-
219
- const isshow = isOwner;
220
-
221
- return (
222
- <Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
223
- <DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
224
- <Typography fontSize={18} fontWeight={600} marginTop={1}>
225
- {getModalTitle()}
226
- </Typography>
227
- <Box onClick={onClose} sx={{ cursor: "pointer" }}>
228
- <CloseIcon />
229
- </Box>
230
- </DialogTitle>
231
-
232
- <Divider sx={{ mx: "25px", my: "2px", bgcolor: "#f9f7f727" }} />
233
-
234
- <DialogContent sx={{ pt: 0 }}>
235
- <Typography my={1} fontSize={"14px"}>
236
- Give a name to this filter so you can easily reuse it later.
237
- </Typography>
238
- {/* Filter Name */}
239
- <Typography mt={2} fontSize={11}>
240
- Filter Name
241
- </Typography>
242
- <TextField
243
- fullWidth
244
- size="small"
245
- value={filterNameValue}
246
- onChange={(e) =>
247
- setFilterMaster((prev) => {
248
- if (!prev) return prev;
249
- return {
250
- ...prev,
251
- saved_filters: {
252
- ...(prev.saved_filters ?? {}),
253
- selectedName: e.target.value,
254
- },
255
- };
256
- })
257
- }
258
- sx={{
259
- mb: 0,
260
- "& .MuiOutlinedInput-root": {
261
- width: "50%",
262
- "& fieldset": { borderColor: "#888" },
263
- "&:hover fieldset": { borderColor: "black" },
264
- "&.Mui-focused fieldset": { borderColor: primary },
265
- "& .MuiInputBase-input": { fontSize: "12px" },
266
- },
267
- }}
268
- />
269
- {/* Description */}
270
- <Typography mt={2} fontSize={11}>
271
- Description
272
- </Typography>
273
- <TextField
274
- fullWidth
275
- minRows={3}
276
- value={discriptionValue}
277
- size="small"
278
- sx={{
279
- mb: 1,
280
- "& .MuiOutlinedInput-root": {
281
- "& fieldset": { borderColor: "#888" },
282
- "&:hover fieldset": { borderColor: "black" },
283
- "&.Mui-focused fieldset": { borderColor: primary },
284
- },
285
- }}
286
- onChange={(e) =>
287
- setFilterMaster((prev) => {
288
- if (!prev) return prev;
289
- return {
290
- ...prev,
291
- saved_filters: {
292
- ...(prev.saved_filters ?? {}),
293
- description: e.target.value,
294
- },
295
- };
296
- })
297
- }
298
- />
299
- <Typography sx={{ mb: 1, fontSize: 12, color: "#888" }}>
300
- (Max. 300 Characters)
301
- </Typography>
302
- {/* Sharing Controls */}
303
- {shouldShowSharingControls && (showCheckboxes || isshow) && (
304
- <Box
305
- sx={{
306
- display: "flex",
307
- flexDirection: "column",
308
- gap: 0.5,
309
- "& .MuiFormControlLabel-label": { fontSize: "14px" },
310
- }}
311
- >
312
- <FormControlLabel
313
- control={
314
- <Checkbox
315
- size="small"
316
- checked={shareWithTeam}
317
- onChange={handleShareToggle}
318
- sx={{
319
- color: "black",
320
- "&.Mui-checked": { color: "black" },
321
- }}
322
- />
323
- }
324
- label="Share with team member."
325
- />
326
-
327
- {shareWithTeam && (
328
- <FormControlLabel
329
- control={
330
- <Checkbox
331
- size="small"
332
- checked={allowTeamEdit}
333
- onChange={handleAllowEditToggle}
334
- sx={{
335
- color: "black",
336
- "&.Mui-checked": { color: "black" },
337
- }}
338
- />
339
- }
340
- label="Allow editing to Team member"
341
- />
342
- )}
343
- </Box>
344
- )}
345
- {/* prefields */}
346
- {showPrefields && !isshow && (
347
- <Box
348
- sx={{
349
- display: "grid",
350
- gridTemplateColumns: "1fr 1fr",
351
- gap: 3,
352
- mt: 2,
353
- }}
354
- >
355
- <Box>
356
- <Typography
357
- sx={{
358
- fontSize: "14px",
359
- fontWeight: 500,
360
- color: "#6b6b6b",
361
- mb: 0.5,
362
- }}
363
- >
364
- Created On*
365
- </Typography>
366
-
367
- <TextField
368
- fullWidth
369
- size="small"
370
- value={
371
- selectedFilter?.created_date
372
- ? new Date(selectedFilter.created_date).toLocaleString()
373
- : ""
374
- } // format date
375
- InputProps={{
376
- readOnly: true,
377
- endAdornment: (
378
- <IconButton size="small">
379
- <CalendarTodayIcon fontSize="small" />
380
- </IconButton>
381
- ),
382
- sx: {
383
- backgroundColor: "#0E0C0B0F",
384
- borderRadius: "4px",
385
- },
386
- }}
387
- />
388
- </Box>
389
-
390
- <Box>
391
- <Typography
392
- sx={{
393
- fontSize: "14px",
394
- fontWeight: 500,
395
- color: "#6b6b6b",
396
- mb: 0.5,
397
- }}
398
- >
399
- Created By*
400
- </Typography>
401
- <TextField
402
- fullWidth
403
- size="small"
404
- value={selectedFilter?.created_by || ""}
405
- InputProps={{
406
- readOnly: true,
407
- sx: {
408
- backgroundColor: "#0E0C0B0F",
409
- borderRadius: "4px",
410
- },
411
- }}
412
- />
413
- </Box>
414
-
415
- <Box>
416
- <Typography
417
- sx={{
418
- fontSize: "14px",
419
- fontWeight: 500,
420
- color: "#6b6b6b",
421
- mb: 0.5,
422
- }}
423
- >
424
- Modified On*
425
- </Typography>
426
-
427
- <TextField
428
- fullWidth
429
- size="small"
430
- value={
431
- selectedFilter?.modified_date
432
- ? new Date(selectedFilter.modified_date).toLocaleString()
433
- : ""
434
- }
435
- InputProps={{
436
- readOnly: true,
437
- endAdornment: (
438
- <IconButton size="small">
439
- <CalendarTodayIcon fontSize="small" />
440
- </IconButton>
441
- ),
442
-
443
- sx: {
444
- backgroundColor: "#0E0C0B0F",
445
- borderRadius: "4px",
446
- },
447
- }}
448
- />
449
- </Box>
450
-
451
- <Box>
452
- <Typography
453
- sx={{
454
- fontSize: "14px",
455
- fontWeight: 500,
456
- color: "#6b6b6b",
457
- mb: 0.5,
458
- }}
459
- >
460
- Modified By*
461
- </Typography>
462
- <TextField
463
- fullWidth
464
- size="small"
465
- value={selectedFilter?.modified_by || ""}
466
- InputProps={{
467
- readOnly: true,
468
- sx: {
469
- backgroundColor: "#0E0C0B0F",
470
- borderRadius: "4px",
471
- },
472
- }}
473
- />
474
- </Box>
475
- </Box>
476
- )}
477
- {/* Buttons */}
478
- <Box
479
- sx={{ display: "flex", justifyContent: "flex-end", gap: 1, mt: 3 }}
480
- >
481
- <Button
482
- variant="outlined"
483
- onClick={onClose}
484
- sx={{
485
- borderColor: primary,
486
- color: primary,
487
- "&:hover": {
488
- borderColor: primary,
489
- backgroundColor: "rgba(122, 90, 248, 0.04)",
490
- },
491
- }}
492
- >
493
- Cancel
494
- </Button>
495
-
496
- <Button
497
- variant="contained"
498
- onClick={handleSave}
499
- disabled={isSaveDisabled}
500
- sx={{
501
- backgroundColor: primary,
502
- "&:hover": { backgroundColor: "#6A4DE8" },
503
- "&.Mui-disabled": {
504
- backgroundColor: "#d7cefd",
505
- color: "rgba(255, 255, 255, 0.7)",
506
- },
507
- }}
508
- >
509
- Save
510
- </Button>
511
- </Box>
512
- </DialogContent>
513
- </Dialog>
514
- );
515
- };
516
-
517
- export default SavedFilterModalView;