@carrier-dpx/air-react-library 0.6.0 → 0.7.0

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 (69) hide show
  1. package/package.json +1 -1
  2. package/src/components/BottomNavigation/BottomNavigation.figma.tsx +54 -0
  3. package/src/components/BottomNavigation/BottomNavigation.tsx +45 -0
  4. package/src/components/BottomNavigation/BottomNavigationAction.figma.tsx +87 -0
  5. package/src/components/BottomNavigation/BottomNavigationAction.tsx +110 -0
  6. package/src/components/BottomNavigation/index.ts +7 -0
  7. package/src/components/Icon/ArrowLeftIcon.figma.tsx +18 -17
  8. package/src/components/Icon/ArrowRightIcon.figma.tsx +18 -17
  9. package/src/components/Icon/CheckIcon.figma.tsx +18 -17
  10. package/src/components/Icon/CloseIcon.figma.tsx +18 -17
  11. package/src/components/Icon/HomeIcon.figma.tsx +18 -17
  12. package/src/components/Icon/Icon.figma.tsx +68 -0
  13. package/src/components/Icon/InfoIcon.figma.tsx +18 -17
  14. package/src/components/Icon/MenuIcon.figma.tsx +18 -17
  15. package/src/components/Icon/SearchIcon.figma.tsx +18 -17
  16. package/src/components/Icon/SettingsIcon.figma.tsx +2 -2
  17. package/src/components/Icon/UserIcon.figma.tsx +18 -17
  18. package/src/components/Icon/icons/demo/AlertIcon.figma.tsx +28 -0
  19. package/src/components/Icon/icons/demo/AlertIcon.tsx +19 -0
  20. package/src/components/Icon/icons/demo/DEMO_USAGE.md +113 -0
  21. package/src/components/Icon/icons/demo/DeviceManagerIcon.figma.tsx +38 -0
  22. package/src/components/Icon/icons/demo/DeviceManagerIcon.tsx +16 -0
  23. package/src/components/Icon/icons/demo/HomeIcon.figma.tsx +28 -0
  24. package/src/components/Icon/icons/demo/HomeIcon.tsx +13 -0
  25. package/src/components/Icon/icons/demo/README.md +57 -0
  26. package/src/components/Icon/icons/demo/SiteIcon.figma.tsx +28 -0
  27. package/src/components/Icon/icons/demo/SiteIcon.tsx +13 -0
  28. package/src/components/Icon/icons/demo/SvgIcon.tsx +39 -0
  29. package/src/components/Icon/icons/demo/WarningIcon.figma.tsx +28 -0
  30. package/src/components/Icon/icons/demo/WarningIcon.tsx +15 -0
  31. package/src/components/Icon/icons/demo/devicemanager_outlined.svg +6 -0
  32. package/src/components/Icon/icons/demo/home_outlined.svg +3 -0
  33. package/src/components/Icon/icons/demo/iconRegistry.ts +97 -0
  34. package/src/components/Icon/icons/demo/index.ts +23 -0
  35. package/src/components/Icon/icons/demo/site_outlined.svg +3 -0
  36. package/src/components/Icon/icons/demo/warning_outlined.svg +5 -0
  37. package/src/components/Navbar/ExtraNavigation/ExtraNavigation.tsx +86 -0
  38. package/src/components/Navbar/ExtraNavigation/index.ts +2 -0
  39. package/src/components/Navbar/ExtraNavigation/styles.tsx +10 -0
  40. package/src/components/Navbar/ExtraNavigation/types.ts +43 -0
  41. package/src/components/Navbar/Navbar.figma.tsx +118 -0
  42. package/src/components/Navbar/Navbar.tsx +110 -0
  43. package/src/components/Navbar/NavbarButtons/Item.figma.tsx +117 -0
  44. package/src/components/Navbar/NavbarButtons/NavbarFooterButton.tsx +57 -0
  45. package/src/components/Navbar/NavbarButtons/NavbarTooltip.tsx +56 -0
  46. package/src/components/Navbar/NavbarButtons/NavigationButton.tsx +98 -0
  47. package/src/components/Navbar/NavbarButtons/index.ts +3 -0
  48. package/src/components/Navbar/NavbarButtons/styles.tsx +112 -0
  49. package/src/components/Navbar/NavbarButtons/types.ts +8 -0
  50. package/src/components/Navbar/NavbarFooter/NavbarFooter.tsx +40 -0
  51. package/src/components/Navbar/NavbarFooter/index.ts +2 -0
  52. package/src/components/Navbar/NavbarFooter/styles.tsx +14 -0
  53. package/src/components/Navbar/NavbarFooter/types.ts +15 -0
  54. package/src/components/Navbar/NavbarLogo/NavbarLogo.tsx +45 -0
  55. package/src/components/Navbar/NavbarLogo/index.ts +2 -0
  56. package/src/components/Navbar/NavbarLogo/styles.ts +18 -0
  57. package/src/components/Navbar/NavbarLogo/types.ts +18 -0
  58. package/src/components/Navbar/NavbarProvider.tsx +15 -0
  59. package/src/components/Navbar/Navigation/Navigation.tsx +113 -0
  60. package/src/components/Navbar/Navigation/helpers.ts +9 -0
  61. package/src/components/Navbar/Navigation/index.ts +2 -0
  62. package/src/components/Navbar/Navigation/styles.tsx +10 -0
  63. package/src/components/Navbar/Navigation/types.ts +68 -0
  64. package/src/components/Navbar/constants.ts +45 -0
  65. package/src/components/Navbar/hooks/useNavbarContext.tsx +12 -0
  66. package/src/components/Navbar/index.tsx +7 -0
  67. package/src/components/Navbar/styles.tsx +44 -0
  68. package/src/components/Navbar/types.ts +67 -0
  69. package/src/index.ts +6 -0
@@ -0,0 +1,57 @@
1
+ import React, { FC, useMemo } from "react";
2
+ import { styled } from "@mui/material/styles";
3
+ import styles from "./styles";
4
+ import Button, { ButtonProps } from "../../Button";
5
+ import Box from "../../Box";
6
+ import { CSSObject } from "@mui/material";
7
+ import { getSxStyles } from "../../utils/styles";
8
+ import { NavbarButtonClasses } from "./types";
9
+
10
+ /**
11
+ * The NavbarFooterButton used for footer.
12
+ *
13
+ * //Named Import
14
+ * `import { NavbarFooterButton } from '@carrier-io/air-react'`
15
+ */
16
+
17
+ export interface NavbarFooterButtonProps
18
+ extends Pick<
19
+ ButtonProps,
20
+ "sx" | "children" | "onClick" | "id" | "size" | "disabled"
21
+ > {
22
+ /** The color of the component. */
23
+ color?: "primary" | "secondary" | "info";
24
+ }
25
+
26
+ const ContainerFooterButtonStyled = styled(Box)(
27
+ styles[NavbarButtonClasses.ContainerFooterBtn]
28
+ );
29
+
30
+ export const NavbarFooterButton: FC<NavbarFooterButtonProps> = ({
31
+ size = "large",
32
+ ...props
33
+ }) => {
34
+ const maxSize = useMemo(() => {
35
+ if (size === "large") return 42;
36
+ if (size === "medium") return 36;
37
+ return 30;
38
+ }, [size]);
39
+
40
+ return (
41
+ <ContainerFooterButtonStyled
42
+ className={NavbarButtonClasses.ContainerFooterBtn}
43
+ >
44
+ <Button
45
+ {...props}
46
+ size={size}
47
+ sx={(theme) =>
48
+ ({
49
+ ...getSxStyles(theme, props.sx),
50
+ maxHeight: maxSize,
51
+ maxWidth: maxSize,
52
+ } as CSSObject)
53
+ }
54
+ />
55
+ </ContainerFooterButtonStyled>
56
+ );
57
+ };
@@ -0,0 +1,56 @@
1
+ import { FC, SyntheticEvent, useState } from "react";
2
+ import Tooltip, { TooltipProps } from "../../Tooltip";
3
+ import Typography from "../../Typography";
4
+ import Fade from "../../Fade";
5
+ import { useNavbarContext } from "../hooks/useNavbarContext";
6
+
7
+ /**
8
+ * The NavbarTooltip used for navigation and extra buttons.
9
+ *
10
+ * //Named Import
11
+ * `import { NavbarTooltip } from '@carrier-io/air-react'`
12
+ */
13
+
14
+ interface NavbarTooltipProps extends TooltipProps {}
15
+
16
+ export const NavbarTooltip: FC<NavbarTooltipProps> = ({
17
+ title,
18
+ children,
19
+ TransitionComponent = Fade,
20
+ disableHoverListener,
21
+ ...rest
22
+ }) => {
23
+ const enabled = rest.open;
24
+
25
+ const [open, setOpen] = useState<boolean>(false);
26
+ const { tooltipProps: NavbarTooltipProps = {} } = useNavbarContext();
27
+
28
+ const handleOpenTooltip = (_e: SyntheticEvent) => {
29
+ setOpen(true);
30
+ };
31
+
32
+ const handleCloseTooltip = (_e: SyntheticEvent | Event) => {
33
+ setOpen(false);
34
+ };
35
+
36
+ return (
37
+ <Tooltip
38
+ open={enabled && open}
39
+ onOpen={handleOpenTooltip}
40
+ onClose={handleCloseTooltip}
41
+ title={
42
+ <Typography variant="caption" component="span">
43
+ <b>{title}</b>
44
+ </Typography>
45
+ }
46
+ placement="right"
47
+ arrow
48
+ enterDelay={800}
49
+ TransitionComponent={TransitionComponent}
50
+ disableHoverListener={disableHoverListener}
51
+ {...NavbarTooltipProps}
52
+ >
53
+ {children}
54
+ </Tooltip>
55
+ );
56
+ };
@@ -0,0 +1,98 @@
1
+ import { FC } from "react";
2
+ import clsx from "clsx";
3
+ import { styled } from "@mui/material/styles";
4
+ import { useNavbarContext } from "../hooks/useNavbarContext";
5
+ import { NavbarButtonClasses as Classes } from "./types";
6
+ import styles from "../NavbarButtons/styles";
7
+ import Button, { ButtonProps } from "../../Button";
8
+ import Typography from "../../Typography";
9
+ import { NavbarTooltip } from "./NavbarTooltip";
10
+ import { getSxStyles } from "../../utils/styles";
11
+ import { CSSObject } from "@mui/material";
12
+ import { navChildMarginPx } from "../constants";
13
+ import { ActiveButtonType } from "../Navigation";
14
+
15
+ /**
16
+ * The NavigationButton used for navigation buttons.
17
+ *
18
+ * //Named Import
19
+ * `import { NavigationButton } from '@carrier-io/air-react'`
20
+ */
21
+
22
+ export interface NavigationButtonProps
23
+ extends Pick<ButtonProps, "sx" | "children"> {
24
+ data: { label?: string; id: string };
25
+ onClick: () => void;
26
+ disableTooltip: boolean;
27
+ withOffset?: boolean;
28
+ active?: boolean;
29
+ activeButtonType?: ActiveButtonType;
30
+ disabled?: boolean;
31
+ disableRipple?: boolean;
32
+ disableTouchRipple?: boolean;
33
+ }
34
+
35
+ const ButtonStyled = styled(Button)(styles[Classes.NavbarBtn]);
36
+
37
+ export const NavigationButton: FC<NavigationButtonProps> = ({
38
+ data,
39
+ onClick,
40
+ disableTooltip,
41
+ active,
42
+ activeButtonType,
43
+ withOffset = false,
44
+ children,
45
+ disabled = false,
46
+ disableRipple = false,
47
+ disableTouchRipple = false,
48
+ ...rest
49
+ }) => {
50
+ const { openedDrawer } = useNavbarContext();
51
+ const { id, label } = data;
52
+
53
+ // Tooltip uses label if it's non-empty and not just whitespace,
54
+ // otherwise falls back to id
55
+ const tooltipTitle = label?.trim() ? label : id;
56
+
57
+ const classNames = clsx({
58
+ [Classes.NavbarBtn]: true,
59
+ [Classes.BasicBtn]: activeButtonType === ActiveButtonType.Basic,
60
+ [Classes.WithIndicatorBtn]: activeButtonType === ActiveButtonType.Indicator,
61
+ [Classes.ActiveBtn]: active,
62
+ [Classes.WithOffsetBtn]: withOffset,
63
+ });
64
+
65
+ return (
66
+ <NavbarTooltip
67
+ title={tooltipTitle}
68
+ disableHoverListener={openedDrawer ? true : disableTooltip}
69
+ >
70
+ <ButtonStyled
71
+ {...rest}
72
+ variant="text"
73
+ onClick={() => onClick?.()}
74
+ className={classNames}
75
+ disabled={disabled}
76
+ disableRipple={disableRipple}
77
+ disableTouchRipple={disableTouchRipple}
78
+ data-testId={`navbar-button-${id}`}
79
+ sx={(theme) =>
80
+ ({
81
+ ...getSxStyles(theme, rest.sx),
82
+ margin: navChildMarginPx + "px 0px",
83
+ } as CSSObject)
84
+ }
85
+ >
86
+ {children}
87
+ {label && (
88
+ <Typography
89
+ component="span"
90
+ variant={withOffset ? "subtitle2" : "subtitle1"}
91
+ >
92
+ {label}
93
+ </Typography>
94
+ )}
95
+ </ButtonStyled>
96
+ </NavbarTooltip>
97
+ );
98
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./NavbarTooltip";
2
+ export * from "./NavigationButton";
3
+ export * from "./NavbarFooterButton";
@@ -0,0 +1,112 @@
1
+ import {
2
+ NAV_ICON_PADDING,
3
+ NAV_ICON_SIZE_PX,
4
+ navItemPaddingPx,
5
+ navItemSizePx,
6
+ NAV_ANIMATION,
7
+ navIsInWideMode,
8
+ navChildHeightPx,
9
+ } from "../constants";
10
+ import { NavbarStyleFunc } from "../types";
11
+ import { NavbarButtonClasses } from "./types";
12
+ import { StyledComponentDefaultProps } from "../../types/common";
13
+
14
+ interface NavbarStyledProps extends StyledComponentDefaultProps {
15
+ openedDrawer?: boolean;
16
+ }
17
+
18
+ export default {
19
+ [NavbarButtonClasses.ContainerFooterBtn]: ({
20
+ theme,
21
+ openedDrawer,
22
+ }: NavbarStyledProps) => ({
23
+ display: "flex",
24
+ alignItems: "center",
25
+ justifyContent: "center",
26
+ transition: NAV_ANIMATION,
27
+ width: openedDrawer
28
+ ? "100%"
29
+ : `calc(${NAV_ICON_SIZE_PX} + ${navItemPaddingPx(
30
+ navIsInWideMode
31
+ )} * 2)!important`,
32
+ margin: "6px",
33
+ "& button": {
34
+ width: "calc(100% - 24px)",
35
+ color: openedDrawer ? "" : "transparent!important",
36
+ minWidth: 0,
37
+ display: "inline-flex",
38
+ alignItems: "center",
39
+ justifyContent: "flex-start",
40
+ whiteSpace: "nowrap",
41
+ marginLeft: "-5px",
42
+ },
43
+ "& .MuiSvgIcon-root": {
44
+ color: theme.palette.common.white,
45
+ },
46
+ }),
47
+ [NavbarButtonClasses.NavbarBtn]: ({
48
+ theme,
49
+ }: StyledComponentDefaultProps) => ({
50
+ display: "inline-flex",
51
+ alignItems: "center",
52
+ justifyContent: "flex-start",
53
+ whiteSpace: "nowrap",
54
+ color: theme.palette.action.active,
55
+ borderRadius: 0,
56
+ padding: 0,
57
+ minWidth: 0,
58
+ height: navChildHeightPx,
59
+ "&:hover": {
60
+ background: theme.palette.action.hover,
61
+ color: theme.palette.text.primary,
62
+ },
63
+ "& .MuiSvgIcon-root": {
64
+ width: NAV_ICON_SIZE_PX,
65
+ height: NAV_ICON_SIZE_PX,
66
+ margin: navItemPaddingPx(navIsInWideMode),
67
+ padding: NAV_ICON_PADDING,
68
+ boxSizing: "content-box",
69
+ },
70
+ [`&.${NavbarButtonClasses.BasicBtn}`]: {
71
+ background: "none",
72
+ "& .MuiSvgIcon-root": {
73
+ borderRadius: "4px",
74
+ },
75
+ "&:hover": {
76
+ background: "none",
77
+ "& .MuiSvgIcon-root": {
78
+ background: theme.palette.action.hover,
79
+ },
80
+ },
81
+ [`&.${NavbarButtonClasses.ActiveBtn}`]: {
82
+ color: theme.palette.primary.main,
83
+ "& .MuiSvgIcon-root": {
84
+ background: theme.palette.primary.outlinedHoverBackground,
85
+ },
86
+ },
87
+ },
88
+ [`&.${NavbarButtonClasses.WithIndicatorBtn}`]: {
89
+ position: "relative",
90
+ [`&.${NavbarButtonClasses.ActiveBtn}`]: {
91
+ color: theme.palette.primary.main,
92
+ background: theme.palette.primary.outlinedHoverBackground,
93
+ "&::after": {
94
+ content: `""`,
95
+ height: "22px",
96
+ width: "4px",
97
+ background: theme.palette.primary.main,
98
+ position: "absolute",
99
+ right: 0,
100
+ borderRadius: "4px 0 0 4px",
101
+ },
102
+ },
103
+ },
104
+ [`&.${NavbarButtonClasses.WithOffsetBtn}`]: {
105
+ paddingLeft: `calc(${navItemSizePx(navIsInWideMode)} - ${navItemPaddingPx(
106
+ navIsInWideMode
107
+ )})`,
108
+ },
109
+ }),
110
+ } as {
111
+ [key: string]: NavbarStyleFunc;
112
+ };
@@ -0,0 +1,8 @@
1
+ export enum NavbarButtonClasses {
2
+ ContainerFooterBtn = "FdsNavbarFooterButton-container",
3
+ NavbarBtn = "FdsNavbarButton",
4
+ WithIndicatorBtn = "FdsNavbarButton-withIndicator",
5
+ BasicBtn = "FdsNavbarButton-basic",
6
+ ActiveBtn = "FdsNavbarButton-active",
7
+ WithOffsetBtn = "FdsNavbarButton-withOffset",
8
+ }
@@ -0,0 +1,40 @@
1
+ import { FC } from "react";
2
+ import { styled } from "@mui/material/styles";
3
+ import { NavbarFooterProps } from "./types";
4
+ import footerStyles from "./styles";
5
+ import Box from "../../Box";
6
+ import SvgIcon from "src/components/SvgIcon";
7
+
8
+ /**
9
+ * The NavbarFooter component allows adding buttons to the footer.
10
+ *
11
+ * //Named Import
12
+ * `import { NavbarFooter } from '@carrier-io/air-react'`
13
+ */
14
+
15
+ const ContainerStyled = styled(Box)(footerStyles.container);
16
+ export const NavbarFooter: FC<NavbarFooterProps> = (props) => {
17
+ const { wideMode, children, showCarrierLogo, ...rest } = props;
18
+
19
+ const logoSXSAdjustment = wideMode
20
+ ? { width: 40, height: 15, ml: 2, mt: 3 }
21
+ : { width: 40, height: 15, ml: 1, mt: 3 };
22
+
23
+ return (
24
+ <ContainerStyled {...rest}>
25
+ {children}
26
+ {showCarrierLogo ? (
27
+ <SvgIcon viewBox="0 0 40 15" sx={logoSXSAdjustment}>
28
+ <path
29
+ d="M20 15C30.666 15 39.3125 11.6421 39.3125 7.5C39.3125 3.35786 30.666 0 20 0C9.334 0 0.6875 3.35786 0.6875 7.5C0.6875 11.6421 9.334 15 20 15Z"
30
+ fill="#152C73"
31
+ />
32
+ <path
33
+ d="M20.0001 0.849854C9.66788 0.849854 1.29242 3.83761 1.29242 7.50031C1.29242 11.163 9.66788 14.1508 20.0001 14.1508C30.3323 14.1508 38.7077 11.163 38.7077 7.50031C38.7077 3.83761 30.3323 0.849854 20.0001 0.849854ZM20.0001 13.713C9.81004 13.713 1.54992 10.9128 1.54992 7.50031C1.54992 4.08778 9.81004 1.28766 20.0001 1.28766C30.1901 1.28766 38.4502 4.08778 38.4502 7.50031C38.4502 10.9128 30.1901 13.713 20.0001 13.713ZM15.703 8.46321C15.5488 8.70036 15.2014 9.11341 14.9574 9.11341C14.893 9.11341 14.8541 9.07562 14.8541 9.00135C14.8541 8.90102 14.893 8.77593 14.893 8.77593L15.935 5.90024H15.0606L14.9453 6.21295C14.7911 5.97581 14.5845 5.88851 14.3284 5.88851C13.3118 5.88851 11.6528 7.30095 11.6528 8.75118C11.6528 9.37661 12.039 9.73884 12.5661 9.73884C13.0932 9.73884 13.5693 9.31407 13.9166 8.80069H13.9421C13.9287 8.88799 13.9032 9.02611 13.9032 9.15119C13.9032 9.46391 14.0709 9.70105 14.3927 9.70105C15.1129 9.70105 15.7433 8.77593 15.9498 8.46321H15.703ZM14.673 6.92569C14.673 6.92569 14.39 7.58761 14.1071 8.11271C13.875 8.53749 13.3614 9.17465 12.9872 9.17465C12.7176 9.17465 12.5755 8.98702 12.5755 8.6743C12.5755 7.61236 13.7463 6.13738 14.4021 6.13738C14.6207 6.13738 14.7495 6.32501 14.7495 6.56216C14.7508 6.67552 14.7253 6.78757 14.673 6.92569ZM27.7975 9.30104C27.308 9.30104 27.0894 8.95053 27.0894 8.56355C27.0894 8.42543 27.1028 8.22607 27.1283 8.11401C29.0072 8.05147 29.8427 7.40128 29.8427 6.70157C29.8427 6.1895 29.4055 5.839 28.7229 5.839C27.1792 5.839 26.1237 7.26447 26.1237 8.45149C26.1237 9.30104 26.6508 9.73884 27.5266 9.73884C28.3634 9.73884 29.1869 9.08865 29.5463 8.55182H29.3277C29.0072 8.86323 28.4667 9.30104 27.7975 9.30104ZM28.6209 6.07484C28.9173 6.07484 29.0327 6.28722 29.0327 6.5374C29.0327 6.92439 28.5311 7.82475 27.1926 7.84951C27.3214 7.08856 27.9383 6.07484 28.6209 6.07484ZM17.3111 9.62548H16.4487C16.4487 9.62548 17.1689 7.63842 17.3875 6.93742C17.4264 6.81233 17.4519 6.67552 17.4519 6.61297C17.4519 6.56346 17.4264 6.51264 17.362 6.51264C17.2722 6.51264 17.0536 6.61297 16.6539 7.16283H16.4219C16.898 6.40058 17.4894 5.88721 17.9012 5.88721C18.1707 5.88721 18.2874 6.03705 18.2874 6.27419C18.2874 6.43707 18.2096 6.74979 18.0299 7.37392C18.8024 6.01099 19.2906 5.82336 19.5991 5.83639C19.9209 5.83639 20.1006 6.04878 20.1006 6.31198C20.1006 6.58691 19.882 6.91136 19.5468 6.91136C19.3281 6.91136 19.1739 6.74848 19.1739 6.47355C19.1739 6.4488 19.1739 6.41101 19.1739 6.38625C18.9553 6.49831 18.3893 6.98563 17.7067 8.59873L17.3111 9.62548ZM11.5334 4.6624C11.4047 4.62461 11.2249 4.59985 11.0439 4.59985C9.31918 4.59985 7.82782 6.21295 7.82782 7.84951C7.82782 9.04956 8.58691 9.36228 9.20518 9.36228C9.92537 9.36228 10.4404 9.08735 10.9165 8.6743H11.174C10.8132 9.16162 10.0421 9.77402 8.9222 9.77402C7.39061 9.77402 6.79916 8.87366 6.79916 7.83648C6.79916 5.91196 8.90879 4.28583 11.1217 4.28583C11.984 4.28583 12.4722 4.58552 12.4722 5.0103C12.4722 5.28523 12.267 5.52237 11.9183 5.52237C11.6353 5.52237 11.4167 5.3595 11.4167 5.05981C11.4181 4.96339 11.469 4.78748 11.5334 4.6624ZM24.7222 5.90024H25.5846L24.5559 8.71339C24.5425 8.75118 24.4916 8.90102 24.4916 9.02611C24.4916 9.11341 24.5305 9.15119 24.5948 9.15119C24.8268 9.15119 25.2252 8.78896 25.4693 8.46321H25.7013C25.315 9.08865 24.6337 9.73884 24.0155 9.73884C23.7191 9.73884 23.5259 9.56424 23.5259 9.28931C23.5259 9.12644 23.5769 8.86454 23.7311 8.46452L24.7222 5.90024ZM25.9695 4.81224C25.9695 5.17447 25.661 5.52498 25.3003 5.52498C25.0951 5.52498 24.9395 5.39989 24.9395 5.13799C24.9395 4.77576 25.248 4.42525 25.6087 4.42525C25.8153 4.42525 25.9695 4.55034 25.9695 4.81224ZM21.081 9.62548H20.2187C20.2187 9.62548 20.9389 7.63842 21.1575 6.93742C21.1964 6.81233 21.2218 6.67552 21.2218 6.61297C21.2218 6.56346 21.1964 6.51264 21.132 6.51264C21.0421 6.51264 20.8235 6.61297 20.4239 7.16283H20.1918C20.668 6.40058 21.2594 5.88721 21.6711 5.88721C21.9407 5.88721 22.0574 6.03705 22.0574 6.27419C22.0574 6.43707 21.9796 6.74979 21.7999 7.37392C22.5724 6.01099 23.0606 5.82336 23.369 5.83639C23.6909 5.83639 23.8706 6.04878 23.8706 6.31198C23.8706 6.58691 23.652 6.91136 23.3167 6.91136C23.0981 6.91136 22.9439 6.74848 22.9439 6.47355C22.9439 6.4488 22.9439 6.41101 22.9439 6.38625C22.7253 6.49831 22.1593 6.98563 21.4767 8.59873L21.081 9.62548ZM31.1812 9.62548H30.3188C30.3188 9.62548 31.039 7.63842 31.2576 6.93742C31.2965 6.81233 31.322 6.67552 31.322 6.61297C31.322 6.56346 31.2965 6.51264 31.2322 6.51264C31.1423 6.51264 30.9237 6.61297 30.524 7.16283H30.292C30.7681 6.40058 31.3596 5.88721 31.7713 5.88721C32.0409 5.88721 32.1575 6.03705 32.1575 6.27419C32.1575 6.43707 32.0798 6.74979 31.9 7.37392C32.6725 6.01099 33.1607 5.82336 33.4692 5.83639C33.7911 5.83639 33.9708 6.04878 33.9708 6.31198C33.9708 6.58691 33.7522 6.91136 33.4169 6.91136C33.1983 6.91136 33.044 6.74848 33.044 6.47355C33.044 6.4488 33.044 6.41101 33.044 6.38625C32.8254 6.49831 32.2595 6.98563 31.5768 8.59873L31.1812 9.62548Z"
34
+ fill="white"
35
+ />
36
+ </SvgIcon>
37
+ ) : null}
38
+ </ContainerStyled>
39
+ );
40
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./NavbarFooter";
2
+ export * from "./types";
@@ -0,0 +1,14 @@
1
+ import { CSSObject } from "@mui/material";
2
+
3
+ export default {
4
+ container: {
5
+ display: "flex",
6
+ flexDirection: "column",
7
+ marginBottom: "24px",
8
+ width: "100%",
9
+ position: "absolute",
10
+ bottom: 0,
11
+ },
12
+ } as {
13
+ [key in "container"]: CSSObject;
14
+ };
@@ -0,0 +1,15 @@
1
+ import { BoxProps } from "../../Box";
2
+ import { NavbarProps } from "../types";
3
+
4
+ export interface NavbarFooterProps extends Pick<BoxProps, "children" | "sx"> {
5
+ /**
6
+ * Adds CarrierLogo as the last element.
7
+ */
8
+ showCarrierLogo?: boolean;
9
+
10
+ /**
11
+ * property directly depends on Navbar WideMode prop.
12
+ * NavbarProps Value
13
+ */
14
+ wideMode?: NavbarProps["wideMode"];
15
+ }
@@ -0,0 +1,45 @@
1
+ import { FC } from "react";
2
+ import { styled } from "@mui/material/styles";
3
+ import btnStyles from "../NavbarButtons/styles";
4
+ import logoStyles from "./styles";
5
+ import { NavbarLogoProps } from "./types";
6
+ import { useNavbarContext } from "../hooks/useNavbarContext";
7
+ import Box from "../../Box";
8
+ import Button from "../../Button";
9
+ import Zoom from "../../Zoom/Zoom";
10
+ import { NavbarTooltip } from "../NavbarButtons";
11
+ import { NavbarButtonClasses } from "../NavbarButtons/types";
12
+
13
+ const LogoContainerStyled = styled(Box)(logoStyles.container);
14
+ const ButtonStyled = styled(Button)(btnStyles[NavbarButtonClasses.NavbarBtn]);
15
+
16
+ /**
17
+ * The NavbarLogo component allows adding logo.
18
+ *
19
+ * //Named Import
20
+ * `import { NavbarLogo } from '@carrier-io/air-react'`
21
+ */
22
+
23
+ export const NavbarLogo: FC<NavbarLogoProps> = ({
24
+ label,
25
+ disableTooltip = false,
26
+ onClick,
27
+ children,
28
+ ...rest
29
+ }) => {
30
+ const { openedDrawer } = useNavbarContext();
31
+
32
+ return (
33
+ <LogoContainerStyled {...rest}>
34
+ <NavbarTooltip
35
+ title={label ?? ""}
36
+ TransitionComponent={Zoom}
37
+ disableHoverListener={openedDrawer ? true : disableTooltip}
38
+ >
39
+ <ButtonStyled variant="text" onClick={(e) => onClick?.(e)}>
40
+ {children}
41
+ </ButtonStyled>
42
+ </NavbarTooltip>
43
+ </LogoContainerStyled>
44
+ );
45
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./NavbarLogo";
2
+ export * from "./types";
@@ -0,0 +1,18 @@
1
+ import { CSSObject } from "@mui/material";
2
+ import {
3
+ navItemSizePx,
4
+ navLogoLeftMargin,
5
+ navIsInWideMode,
6
+ } from "../constants";
7
+
8
+ export default {
9
+ container: () =>
10
+ ({
11
+ width: "100%",
12
+ "& button": {
13
+ marginRight: navItemSizePx(navIsInWideMode),
14
+ marginLeft: navLogoLeftMargin(navIsInWideMode),
15
+ paddingLeft: "4px",
16
+ },
17
+ } as CSSObject),
18
+ };
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { BoxProps } from "../../Box";
3
+
4
+ export interface NavbarLogoProps extends Pick<BoxProps, "children" | "sx"> {
5
+ /**
6
+ * Tooltip label.
7
+ */
8
+ label?: string;
9
+ /**
10
+ * Allow show tooltip.
11
+ * @default false
12
+ */
13
+ disableTooltip?: boolean;
14
+ /**
15
+ * Callback fired when logo is clicked.
16
+ */
17
+ onClick?: (e: React.MouseEvent<HTMLElement>) => void;
18
+ }
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { NavbarTooltipProps } from "./types";
3
+
4
+ const state: {
5
+ openedDrawer: boolean;
6
+ tooltipProps?: NavbarTooltipProps;
7
+ } = {
8
+ openedDrawer: false,
9
+ };
10
+
11
+ export const NavbarContext = React.createContext(state);
12
+
13
+ export const NavbarProvider = ({ value, children }: any) => (
14
+ <NavbarContext.Provider value={value}>{children}</NavbarContext.Provider>
15
+ );
@@ -0,0 +1,113 @@
1
+ import { FC, useCallback, useEffect, useState } from "react";
2
+ import { styled } from "@mui/material/styles";
3
+ import {
4
+ ActiveButtonType,
5
+ ClickNavItem,
6
+ NavigationItem,
7
+ NavigationProps,
8
+ } from "./types";
9
+ import navigationStyles from "./styles";
10
+ import Box from "../../Box";
11
+ import Divider from "../../Divider";
12
+ import { NavigationButton } from "../NavbarButtons";
13
+ import { getCurrentNavItemByPath } from "./helpers";
14
+
15
+ /**
16
+ * The Navigation component allows adding navigation buttons.
17
+ *
18
+ * //Named Import
19
+ * `import { Navigation } from '@carrier/air-react'`
20
+ */
21
+
22
+ const ContainerStyled = styled(Box)(navigationStyles.container);
23
+
24
+ export const Navigation: FC<NavigationProps> = ({
25
+ currentPathname,
26
+ items,
27
+ onClick,
28
+ activeButtonType = ActiveButtonType.Basic,
29
+ disableTooltip = false,
30
+ disableRipple = false,
31
+ disableTouchRipple = false,
32
+ isDefaultActive = true,
33
+ ...rest
34
+ }) => {
35
+ const [selectedNavigationItem, setSelectedNavigationItem] = useState<
36
+ NavigationItem | undefined
37
+ >(isDefaultActive ? items[0] : undefined);
38
+
39
+ useEffect(() => {
40
+ const currentNavigationItem = getCurrentNavItemByPath(
41
+ items,
42
+ currentPathname
43
+ );
44
+
45
+ if (!isDefaultActive) {
46
+ return setSelectedNavigationItem(currentNavigationItem);
47
+ }
48
+ }, []);
49
+
50
+ useEffect(() => {
51
+ const currentNavigationItem = getCurrentNavItemByPath(
52
+ items,
53
+ currentPathname
54
+ );
55
+
56
+ if (!isDefaultActive) {
57
+ return setSelectedNavigationItem(currentNavigationItem);
58
+ }
59
+ setSelectedNavigationItem(currentNavigationItem ?? items[0]);
60
+ }, [items, currentPathname]);
61
+
62
+ const handleClick: ClickNavItem = useCallback(
63
+ (params) => {
64
+ if (onClick) {
65
+ onClick(params);
66
+ }
67
+ },
68
+ [onClick]
69
+ );
70
+
71
+ return (
72
+ <ContainerStyled {...rest}>
73
+ {items.map((item, idx) => {
74
+ if (item.type === "DIVIDER") {
75
+ return (
76
+ <Divider key={`divider_${idx.toString()}`} sx={{ margin: "9px 0" }}>
77
+ {item.children}
78
+ </Divider>
79
+ );
80
+ }
81
+
82
+ return (
83
+ <NavigationButton
84
+ key={item.id}
85
+ data={{
86
+ id: item.id,
87
+ label: item.label,
88
+ }}
89
+ onClick={() =>
90
+ handleClick({
91
+ path: item.path || null,
92
+ id: item.id,
93
+ })
94
+ }
95
+ disableTooltip={disableTooltip}
96
+ disabled={item.disabled}
97
+ disableRipple={disableRipple}
98
+ disableTouchRipple={disableTouchRipple}
99
+ active={
100
+ selectedNavigationItem &&
101
+ (!selectedNavigationItem.type ||
102
+ selectedNavigationItem.type === "ITEM") &&
103
+ selectedNavigationItem.id === item.id
104
+ }
105
+ activeButtonType={activeButtonType}
106
+ >
107
+ {item.icon}
108
+ </NavigationButton>
109
+ );
110
+ })}
111
+ </ContainerStyled>
112
+ );
113
+ };
@@ -0,0 +1,9 @@
1
+ import { NavigationItem } from "./types";
2
+
3
+ export const getCurrentNavItemByPath = (
4
+ items: NavigationItem[],
5
+ path: string
6
+ ) =>
7
+ items.find(
8
+ (item) => (!item.type || item.type === "ITEM") && item.path === path
9
+ );
@@ -0,0 +1,2 @@
1
+ export * from "./Navigation";
2
+ export * from "./types";
@@ -0,0 +1,10 @@
1
+ import { CSSObject } from "@mui/material";
2
+
3
+ export default {
4
+ container: {
5
+ display: "flex",
6
+ flexDirection: "column",
7
+ },
8
+ } as {
9
+ [key in "container"]: CSSObject;
10
+ };