rez-table-listing-mui 1.2.6 → 1.2.7
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.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/components/tabs/index.tsx +20 -7
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { CraftTableOptionsProps } from "../../types/table-options";
|
|
|
4
4
|
import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined";
|
|
5
5
|
import { settingsOptionsProps } from "../../types/table";
|
|
6
6
|
import { tableTabsStyles } from "./styles";
|
|
7
|
+
import { useMemo } from "react";
|
|
7
8
|
|
|
8
9
|
interface TabDataProps {
|
|
9
10
|
tab_value: string | null;
|
|
@@ -36,12 +37,24 @@ export function TableTabs({
|
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
// Normalize tab_value to uppercase for display + logic
|
|
39
|
-
const normalizedTabs =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const normalizedTabs = useMemo(() => {
|
|
41
|
+
return tabsData
|
|
42
|
+
?.filter((tab) => tab.tab_value)
|
|
43
|
+
?.map((tab) => ({
|
|
44
|
+
...tab,
|
|
45
|
+
tab_value: tab.tab_value?.toUpperCase(),
|
|
46
|
+
}));
|
|
47
|
+
}, [tabsData]);
|
|
48
|
+
|
|
49
|
+
const defaultTab = useMemo(() => {
|
|
50
|
+
return (
|
|
51
|
+
normalizedTabs.find((t) => t.tab_value === "ALL")?.tab_value ||
|
|
52
|
+
normalizedTabs[0]?.tab_value ||
|
|
53
|
+
""
|
|
54
|
+
);
|
|
55
|
+
}, [normalizedTabs]);
|
|
56
|
+
|
|
57
|
+
const selectedTab = activeTab || defaultTab;
|
|
45
58
|
|
|
46
59
|
return (
|
|
47
60
|
<Box display="flex" alignItems="center" justifyContent="flex-start">
|
|
@@ -57,7 +70,7 @@ export function TableTabs({
|
|
|
57
70
|
|
|
58
71
|
{/* Tabs */}
|
|
59
72
|
<Tabs
|
|
60
|
-
value={
|
|
73
|
+
value={selectedTab}
|
|
61
74
|
onChange={(_, newValue) => handleTabClick(newValue)}
|
|
62
75
|
variant="scrollable"
|
|
63
76
|
scrollButtons={false}
|