@pipelinesolucoes/menu 1.0.2 → 1.0.3-beta.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.
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { TypographyVariant } from "@mui/material";
|
|
2
3
|
import { NavItem } from "../types/NavItem";
|
|
3
4
|
interface SideNavProps {
|
|
4
5
|
items: NavItem[];
|
|
5
6
|
menuWidth?: number;
|
|
7
|
+
itemMenuBackgroundColorSemContent?: string;
|
|
8
|
+
itemMenuColorSemContent?: string;
|
|
9
|
+
itemMenuVariantSemContent?: TypographyVariant;
|
|
6
10
|
menuBackground?: string;
|
|
7
11
|
itemMenuBackgroundColor?: string;
|
|
8
12
|
itemMenuBackgroundColorSelected?: string;
|
|
9
13
|
itemMenuBackgroundColorHover?: string;
|
|
10
14
|
itemMenuColor?: string;
|
|
11
15
|
itemMenuColorSelected?: string;
|
|
16
|
+
itemMenuVariant?: TypographyVariant;
|
|
12
17
|
borderRadius?: string;
|
|
13
18
|
itemMenuBorderRadius?: string;
|
|
14
19
|
contentBackground?: string;
|
|
@@ -33,7 +38,7 @@ export declare const SideNavContent: import("@emotion/styled").StyledComponent<i
|
|
|
33
38
|
* - conteúdo no topo do menu (`renderTopMenu`)
|
|
34
39
|
* - conteúdo fixado na base do menu (`renderBottomMenu`)
|
|
35
40
|
*/
|
|
36
|
-
declare function SideNav({ items, menuWidth, menuBackground, borderRadius, itemMenuBorderRadius, itemMenuBackgroundColor, itemMenuBackgroundColorHover, itemMenuBackgroundColorSelected, itemMenuColor, itemMenuColorSelected, contentBackground, renderTopMenu, renderBottomMenu, height, contentGap, }: SideNavProps): import("react/jsx-runtime").JSX.Element | null;
|
|
41
|
+
declare function SideNav({ items, menuWidth, itemMenuBackgroundColorSemContent, itemMenuColorSemContent, itemMenuVariantSemContent, menuBackground, borderRadius, itemMenuBorderRadius, itemMenuBackgroundColor, itemMenuBackgroundColorHover, itemMenuBackgroundColorSelected, itemMenuColor, itemMenuColorSelected, itemMenuVariant, contentBackground, renderTopMenu, renderBottomMenu, height, contentGap, }: SideNavProps): import("react/jsx-runtime").JSX.Element | null;
|
|
37
42
|
declare namespace SideNav {
|
|
38
43
|
var displayName: string;
|
|
39
44
|
}
|
|
@@ -31,24 +31,15 @@ const MenuItemBox = styled(Box, {
|
|
|
31
31
|
"itemMenuBackgroundColorHover",
|
|
32
32
|
"itemMenuColor",
|
|
33
33
|
"itemMenuColorSelected",
|
|
34
|
+
"typographyVariant",
|
|
34
35
|
].includes(prop),
|
|
35
|
-
})(({ active, itemMenuBorderRadius, itemMenuBackgroundColor, itemMenuBackgroundColorSelected, itemMenuBackgroundColorHover, itemMenuColor, itemMenuColorSelected, }) => ({
|
|
36
|
-
cursor: "pointer",
|
|
37
|
-
padding: "8px 16px",
|
|
38
|
-
borderRadius: itemMenuBorderRadius,
|
|
39
|
-
backgroundColor: active
|
|
36
|
+
})(({ theme, active, itemMenuBorderRadius, itemMenuBackgroundColor, itemMenuBackgroundColorSelected, itemMenuBackgroundColorHover, itemMenuColor, itemMenuColorSelected, typographyVariant }) => (Object.assign(Object.assign({ cursor: "pointer", padding: "8px 16px", borderRadius: itemMenuBorderRadius, backgroundColor: active
|
|
40
37
|
? itemMenuBackgroundColorSelected
|
|
41
|
-
: itemMenuBackgroundColor,
|
|
42
|
-
color: active ? itemMenuColorSelected : itemMenuColor,
|
|
43
|
-
width: "100%",
|
|
44
|
-
transition: "all 0.2s ease",
|
|
45
|
-
userSelect: "none",
|
|
46
|
-
"&:hover": {
|
|
38
|
+
: itemMenuBackgroundColor, color: active ? itemMenuColorSelected : itemMenuColor, width: "100%", transition: "all 0.2s ease", userSelect: "none" }, (typographyVariant && theme.typography[typographyVariant])), { "&:hover": {
|
|
47
39
|
backgroundColor: active
|
|
48
40
|
? itemMenuBackgroundColorSelected
|
|
49
41
|
: itemMenuBackgroundColorHover,
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
42
|
+
} })));
|
|
52
43
|
export const SideNavContent = styled(Box, {
|
|
53
44
|
shouldForwardProp: (prop) => !["contentGap", "contentBackground", "borderRadius", "height"].includes(prop),
|
|
54
45
|
})(({ contentGap = 2, contentBackground = "transparent", borderRadius = 2, height = "100%", }) => ({
|
|
@@ -73,7 +64,7 @@ export const SideNavContent = styled(Box, {
|
|
|
73
64
|
* - conteúdo no topo do menu (`renderTopMenu`)
|
|
74
65
|
* - conteúdo fixado na base do menu (`renderBottomMenu`)
|
|
75
66
|
*/
|
|
76
|
-
export default function SideNav({ items, menuWidth = 180, menuBackground = "transparent", borderRadius = "0", itemMenuBorderRadius = "16px", itemMenuBackgroundColor = "transparent", itemMenuBackgroundColorHover = "grey.300", itemMenuBackgroundColorSelected = "primary.main", itemMenuColor = "black", itemMenuColorSelected = "black", contentBackground = "grey.50", renderTopMenu, renderBottomMenu, height = "500px", contentGap = 2, }) {
|
|
67
|
+
export default function SideNav({ items, menuWidth = 180, itemMenuBackgroundColorSemContent = "transparent", itemMenuColorSemContent = "black", itemMenuVariantSemContent = "body1", menuBackground = "transparent", borderRadius = "0", itemMenuBorderRadius = "16px", itemMenuBackgroundColor = "transparent", itemMenuBackgroundColorHover = "grey.300", itemMenuBackgroundColorSelected = "primary.main", itemMenuColor = "black", itemMenuColorSelected = "black", itemMenuVariant = "body1", contentBackground = "grey.50", renderTopMenu, renderBottomMenu, height = "500px", contentGap = 2, }) {
|
|
77
68
|
var _a;
|
|
78
69
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
79
70
|
if (!items || items.length === 0) {
|
|
@@ -85,14 +76,10 @@ export default function SideNav({ items, menuWidth = 180, menuBackground = "tran
|
|
|
85
76
|
if (((_a = item.label) === null || _a === void 0 ? void 0 : _a.toUpperCase()) == "DIVIDER") {
|
|
86
77
|
return (_jsx(Divider, {}));
|
|
87
78
|
}
|
|
88
|
-
return (_jsx(MenuItemBox, { itemMenuBorderRadius: itemMenuBorderRadius, itemMenuBackgroundColor:
|
|
79
|
+
return (_jsx(MenuItemBox, { typographyVariant: itemMenuVariantSemContent, itemMenuBorderRadius: itemMenuBorderRadius, itemMenuBackgroundColor: itemMenuBackgroundColorSemContent, itemMenuColor: itemMenuColorSemContent, children: item.label }, `${item.label}-${idx}`));
|
|
89
80
|
}
|
|
90
|
-
return (_jsx(MenuItemBox, { itemMenuBorderRadius: itemMenuBorderRadius, itemMenuBackgroundColor: itemMenuBackgroundColor, itemMenuBackgroundColorHover: itemMenuBackgroundColorHover, itemMenuBackgroundColorSelected: itemMenuBackgroundColorSelected, itemMenuColor: itemMenuColor, itemMenuColorSelected: itemMenuColorSelected, onClick: () => setActiveIndex(idx), children: item.label }, `${item.label}-${idx}`));
|
|
91
|
-
}) }), renderBottomMenu && (_jsx(Box, { sx: {
|
|
92
|
-
mt: 2,
|
|
93
|
-
pt: 2,
|
|
94
|
-
flexShrink: 0,
|
|
95
|
-
}, children: renderBottomMenu }))] }), _jsx(SideNavContent, { contentBackground: contentBackground, contentGap: contentGap, children: _jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -10 }, transition: { duration: 0.2 }, style: { width: "100%" }, children: (_a = items[activeIndex]) === null || _a === void 0 ? void 0 : _a.content }, activeIndex) }) })] }));
|
|
81
|
+
return (_jsx(MenuItemBox, { typographyVariant: itemMenuVariant, itemMenuBorderRadius: itemMenuBorderRadius, itemMenuBackgroundColor: itemMenuBackgroundColor, itemMenuBackgroundColorHover: itemMenuBackgroundColorHover, itemMenuBackgroundColorSelected: itemMenuBackgroundColorSelected, itemMenuColor: itemMenuColor, itemMenuColorSelected: itemMenuColorSelected, onClick: () => setActiveIndex(idx), children: item.label }, `${item.label}-${idx}`));
|
|
82
|
+
}) }), renderBottomMenu && (_jsx(Box, { sx: { mt: 2, pt: 2, flexShrink: 0, }, children: renderBottomMenu }))] }), _jsx(SideNavContent, { contentBackground: contentBackground, contentGap: contentGap, height: height, borderRadius: borderRadius, children: _jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -10 }, transition: { duration: 0.2 }, style: { width: "100%" }, children: (_a = items[activeIndex]) === null || _a === void 0 ? void 0 : _a.content }, activeIndex) }) })] }));
|
|
96
83
|
}
|
|
97
84
|
SideNav.displayName = "SideNav";
|
|
98
85
|
//# sourceMappingURL=SideNav.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNav.js","sourceRoot":"","sources":["../../src/components/SideNav.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,EAAa,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SideNav.js","sourceRoot":"","sources":["../../src/components/SideNav.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,EAAa,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAqB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAyBxD,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC,OAAO,EAAE,MAAM;IACf,mBAAmB,EAAE,UAAU;IAC/B,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,CAAC;CACX,CAAC,CAAC,CAAC;AAEJ,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,EAAE;IACnC,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1B,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC,QAAQ,CACjE,IAAc,CACf;CACJ,CAAC,CA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