rez-table-listing-mui 1.0.39 → 1.0.41
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/dist/index.d.ts +16 -24
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +22 -15
- package/src/assets/svg.tsx +61 -1
- package/src/components/common/loader/loader.tsx +20 -0
- package/src/components/table-settings/common/draggable-listitem.tsx +7 -6
- package/src/components/table-settings/common/listing-values.tsx +23 -24
- package/src/components/table-settings/components/column.tsx +111 -49
- package/src/components/table-settings/components/quick-tab.tsx +143 -29
- package/src/components/table-settings/components/sorting.tsx +201 -457
- package/src/components/table-settings/components/toggle-button-switch.tsx +1 -0
- package/src/components/table-settings/index.tsx +43 -19
- package/src/components/table-settings/style.ts +1 -4
- package/src/components/table-settings/tabs/vertical/custom-tab-panel.tsx +4 -3
- package/src/index.ts +2 -1
- package/src/libs/hooks/useCraftTableFilterSettings.tsx +25 -6
- package/src/libs/hooks/useEntityTableAPI.tsx +43 -10
- package/src/libs/utils/apiColumn.ts +24 -2
- package/src/main.tsx +12 -1
- package/src/types/filter-settings.ts +10 -0
- package/src/types/table-options.ts +3 -0
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Checkbox,
|
|
9
9
|
FormControlLabel,
|
|
10
10
|
Grid,
|
|
11
|
+
Alert,
|
|
11
12
|
} from "@mui/material";
|
|
12
13
|
|
|
13
14
|
import ListingValues from "../common/listing-values";
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
SettingsQuickTabProps,
|
|
27
28
|
} from "../../../types/filter-settings";
|
|
28
29
|
import { TabsStyles } from "../style";
|
|
30
|
+
import { ColumnItem, TabData } from "./column";
|
|
29
31
|
|
|
30
32
|
const QuickTab = ({
|
|
31
33
|
filterSettingStates,
|
|
@@ -33,7 +35,8 @@ const QuickTab = ({
|
|
|
33
35
|
tabsApiData,
|
|
34
36
|
tabsApiDataLoading,
|
|
35
37
|
}: SettingsQuickTabProps) => {
|
|
36
|
-
const { quickTabStates, setQuickTabStates } =
|
|
38
|
+
const { quickTabStates, setQuickTabStates, settingsData, setColumnTabState } =
|
|
39
|
+
filterSettingStates;
|
|
37
40
|
|
|
38
41
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
39
42
|
|
|
@@ -54,20 +57,81 @@ const QuickTab = ({
|
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (settingsData?.quick_tab?.attribute !== quickTabStates?.attribute) {
|
|
61
|
+
setQuickTabStates((prev) => ({
|
|
62
|
+
...prev,
|
|
63
|
+
hide_list: tabsApiData, // All data goes to hide_list initially
|
|
64
|
+
show_list: [], // Empty the show_list when attribute/sorting changes
|
|
65
|
+
}));
|
|
66
|
+
} else {
|
|
67
|
+
setQuickTabStates((prev) => ({
|
|
68
|
+
...prev,
|
|
69
|
+
hide_list: settingsData?.quick_tab?.hide_list,
|
|
70
|
+
show_list: settingsData?.quick_tab?.show_list,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
62
73
|
}, [columnsData.column_list, tabsApiData]);
|
|
63
74
|
|
|
75
|
+
// When quickTabState show_list or hide_list changes, update the columnTabState
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (Object.entries(settingsData?.column || {}).length) {
|
|
78
|
+
const mappedColumns: ColumnItem[] =
|
|
79
|
+
columnsData?.column_list?.map((column) => ({
|
|
80
|
+
label: column?.name,
|
|
81
|
+
value: column?.attribute_key,
|
|
82
|
+
})) || [];
|
|
83
|
+
//Later changed TabData to interface from filter settings types file
|
|
84
|
+
const mappedTabs: TabData[] =
|
|
85
|
+
quickTabStates?.show_list?.map((tab) => ({
|
|
86
|
+
tab_name: tab,
|
|
87
|
+
show_list: mappedColumns,
|
|
88
|
+
hide_list: [],
|
|
89
|
+
})) || [];
|
|
90
|
+
|
|
91
|
+
if (settingsData?.column?.isDefault) {
|
|
92
|
+
setColumnTabState((prev) => ({
|
|
93
|
+
...prev,
|
|
94
|
+
show_list: mappedColumns,
|
|
95
|
+
hide_list: [],
|
|
96
|
+
}));
|
|
97
|
+
} else {
|
|
98
|
+
setColumnTabState((prev) => ({
|
|
99
|
+
...prev,
|
|
100
|
+
tabs: mappedTabs,
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, [quickTabStates.show_list, quickTabStates.hide_list]);
|
|
105
|
+
|
|
64
106
|
// useEffect(() => {
|
|
65
107
|
// setQuickTabStates((prev) => ({
|
|
66
108
|
// ...prev,
|
|
67
109
|
// hide_list: tabsApiData, // All data goes to hide_list initially
|
|
68
110
|
// show_list: [], // Empty the show_list when attribute/sorting changes
|
|
69
111
|
// }));
|
|
70
|
-
// }, [quickTabStates.attribute, quickTabStates.sorting]);
|
|
112
|
+
// }, [tabsApiData, quickTabStates.attribute, quickTabStates.sorting]);
|
|
113
|
+
|
|
114
|
+
// if (!Object.entries(quickTabStates).length) {
|
|
115
|
+
// // Logic for column
|
|
116
|
+
// setColumnTabState((prev) => ({ ...prev, isDefault: true }));
|
|
117
|
+
// // Logic for sorting
|
|
118
|
+
// setSortingTabState((prev) => ({ ...prev, isDefault: true, tabs: [] }));
|
|
119
|
+
// } else {
|
|
120
|
+
// // Logic for sorting
|
|
121
|
+
// if (!sortingTabState.tabs?.length) {
|
|
122
|
+
// const emptySortBy: SortingConfigSortByProps[] = [
|
|
123
|
+
// { column: "", order: "asc" },
|
|
124
|
+
// ];
|
|
125
|
+
// setSortingTabState((prev) => ({
|
|
126
|
+
// ...prev,
|
|
127
|
+
// tabs: quickTabStates?.show_list?.map((tab) => ({
|
|
128
|
+
// tab_name: tab,
|
|
129
|
+
// sortby: emptySortBy,
|
|
130
|
+
// })),
|
|
131
|
+
// }));
|
|
132
|
+
// }
|
|
133
|
+
// }
|
|
134
|
+
// }, [quickTabStates]);
|
|
71
135
|
|
|
72
136
|
const sortingOptions = [
|
|
73
137
|
{ label: "A-Z", value: "asc" },
|
|
@@ -131,7 +195,9 @@ const QuickTab = ({
|
|
|
131
195
|
let newShowList = [...(quickTabStates.show_list ?? [])];
|
|
132
196
|
let newHideList = [...(quickTabStates.hide_list ?? [])];
|
|
133
197
|
if (currentContainer === "list" && overContainer === "tabs") {
|
|
198
|
+
if (newShowList.length >= 5) return; // prevent overflow
|
|
134
199
|
// Move from hide to show
|
|
200
|
+
|
|
135
201
|
const idx = newHideList.indexOf(String(active.id));
|
|
136
202
|
if (idx !== -1) {
|
|
137
203
|
newHideList.splice(idx, 1);
|
|
@@ -159,15 +225,24 @@ const QuickTab = ({
|
|
|
159
225
|
|
|
160
226
|
// Show All/Hide All logic (local only)
|
|
161
227
|
const handleShowAll = () => {
|
|
228
|
+
const currentShowList = quickTabStates.show_list || [];
|
|
229
|
+
const currentHideList = quickTabStates.hide_list || [];
|
|
230
|
+
|
|
231
|
+
const availableSlots = 5 - currentShowList.length;
|
|
232
|
+
|
|
233
|
+
if (availableSlots <= 0) return; // Already at limit
|
|
234
|
+
|
|
235
|
+
const limitedHideList = currentHideList.slice(0, availableSlots);
|
|
236
|
+
|
|
162
237
|
setQuickTabStates({
|
|
163
238
|
...quickTabStates,
|
|
164
|
-
show_list: [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
hide_list: [],
|
|
239
|
+
show_list: [...currentShowList, ...limitedHideList],
|
|
240
|
+
hide_list: currentHideList.filter(
|
|
241
|
+
(item) => !limitedHideList.includes(item)
|
|
242
|
+
),
|
|
169
243
|
});
|
|
170
244
|
};
|
|
245
|
+
|
|
171
246
|
const handleHideAll = () => {
|
|
172
247
|
setQuickTabStates({
|
|
173
248
|
...quickTabStates,
|
|
@@ -197,13 +272,48 @@ const QuickTab = ({
|
|
|
197
272
|
});
|
|
198
273
|
};
|
|
199
274
|
|
|
275
|
+
const handleItemToggle = (itemId: string, fromContainerId: string) => {
|
|
276
|
+
const toShowList = [...(quickTabStates.show_list ?? [])];
|
|
277
|
+
const toHideList = [...(quickTabStates.hide_list ?? [])];
|
|
278
|
+
|
|
279
|
+
if (fromContainerId === "list") {
|
|
280
|
+
if (toShowList.length >= 5) return; // prevent overflow
|
|
281
|
+
// Move from hide_list to show_list
|
|
282
|
+
const index = toHideList.indexOf(itemId);
|
|
283
|
+
if (index > -1) {
|
|
284
|
+
toHideList.splice(index, 1);
|
|
285
|
+
toShowList.push(itemId);
|
|
286
|
+
}
|
|
287
|
+
} else if (fromContainerId === "tabs") {
|
|
288
|
+
// Move from show_list to hide_list
|
|
289
|
+
const index = toShowList.indexOf(itemId);
|
|
290
|
+
if (index > -1) {
|
|
291
|
+
toShowList.splice(index, 1);
|
|
292
|
+
toHideList.push(itemId);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
setQuickTabStates({
|
|
297
|
+
...quickTabStates,
|
|
298
|
+
show_list: toShowList,
|
|
299
|
+
hide_list: toHideList,
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
200
303
|
return (
|
|
201
|
-
<Box
|
|
304
|
+
<Box
|
|
305
|
+
sx={{
|
|
306
|
+
display: "flex",
|
|
307
|
+
flexDirection: "column",
|
|
308
|
+
// gap: "0.5rem",
|
|
309
|
+
height: "100%",
|
|
310
|
+
}}
|
|
311
|
+
>
|
|
202
312
|
<Typography variant="caption" sx={TabsStyles.mainTabsHeader}>
|
|
203
313
|
*Quick filter settings will be reflected in horizontal tabs
|
|
204
314
|
</Typography>
|
|
205
|
-
<Box
|
|
206
|
-
<Grid container
|
|
315
|
+
<Box>
|
|
316
|
+
<Grid container>
|
|
207
317
|
<Grid size={12}>
|
|
208
318
|
<Box>
|
|
209
319
|
<Grid sx={TabsStyles.mainTabDropdown} size={6}>
|
|
@@ -252,6 +362,22 @@ const QuickTab = ({
|
|
|
252
362
|
</Grid>
|
|
253
363
|
</Box>
|
|
254
364
|
</Grid>
|
|
365
|
+
<Grid
|
|
366
|
+
sx={{
|
|
367
|
+
marginLeft: "33.2rem",
|
|
368
|
+
}}
|
|
369
|
+
size={12}
|
|
370
|
+
>
|
|
371
|
+
<Alert
|
|
372
|
+
severity="info"
|
|
373
|
+
sx={{
|
|
374
|
+
fontSize: "12px",
|
|
375
|
+
color: "#088AB2",
|
|
376
|
+
}}
|
|
377
|
+
>
|
|
378
|
+
Please select at least 1 and at most 5 values to display as tabs.
|
|
379
|
+
</Alert>
|
|
380
|
+
</Grid>
|
|
255
381
|
<DndContext
|
|
256
382
|
sensors={sensors}
|
|
257
383
|
collisionDetection={closestCenter}
|
|
@@ -267,6 +393,7 @@ const QuickTab = ({
|
|
|
267
393
|
setSearchTerm={setSearchTerm}
|
|
268
394
|
containerId="list"
|
|
269
395
|
tabsApiDataLoading={tabsApiDataLoading}
|
|
396
|
+
onItemToggle={handleItemToggle}
|
|
270
397
|
/>
|
|
271
398
|
<ListingValues
|
|
272
399
|
buttonText="Hide All"
|
|
@@ -275,6 +402,7 @@ const QuickTab = ({
|
|
|
275
402
|
filteredValues={showListValues}
|
|
276
403
|
containerId="tabs"
|
|
277
404
|
// tabsApiDataLoading={tabsApiDataLoading}
|
|
405
|
+
onItemToggle={handleItemToggle}
|
|
278
406
|
/>
|
|
279
407
|
</Grid>
|
|
280
408
|
</DndContext>
|
|
@@ -314,20 +442,6 @@ const QuickTab = ({
|
|
|
314
442
|
</Grid>
|
|
315
443
|
</Grid>
|
|
316
444
|
</Box>
|
|
317
|
-
{/* <DialogActions sx={{ justifyContent: "flex-end", padding: "16px 24px" }}>
|
|
318
|
-
<Button
|
|
319
|
-
variant="contained"
|
|
320
|
-
sx={{ textTransform: "none" }}
|
|
321
|
-
onClick={() => {
|
|
322
|
-
setSettingsData((prev: any) => ({
|
|
323
|
-
...prev,
|
|
324
|
-
quick_tab: quickTabStates,
|
|
325
|
-
}));
|
|
326
|
-
}}
|
|
327
|
-
>
|
|
328
|
-
Save Quick Tab
|
|
329
|
-
</Button>
|
|
330
|
-
</DialogActions> */}
|
|
331
445
|
</Box>
|
|
332
446
|
);
|
|
333
447
|
};
|