@superdispatch/ui-lab 0.17.0 → 0.18.3

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.
@@ -0,0 +1,43 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["fullViewportHeight"];
4
+ import { mergeRefs } from '@superdispatch/ui';
5
+ import { forwardRef, useLayoutEffect, useRef } from 'react';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export var Container = /*#__PURE__*/forwardRef((_ref, ref) => {
8
+ var {
9
+ fullViewportHeight
10
+ } = _ref,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+
13
+ var nodeRef = useRef(null);
14
+ useLayoutEffect(() => {
15
+ if (!fullViewportHeight) {
16
+ if (nodeRef.current) {
17
+ nodeRef.current.style.removeProperty('height');
18
+ nodeRef.current.style.removeProperty('--vh');
19
+ }
20
+
21
+ return;
22
+ }
23
+
24
+ function updateHeight() {
25
+ if (nodeRef.current) {
26
+ // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
27
+ nodeRef.current.style.setProperty('height', 'calc(var(--vh, 1vh) * 100)');
28
+ nodeRef.current.style.setProperty('--vh', "".concat(window.innerHeight * 0.01, "px"));
29
+ }
30
+ }
31
+
32
+ updateHeight();
33
+ window.addEventListener('resize', updateHeight);
34
+ return () => {
35
+ window.removeEventListener('resize', updateHeight);
36
+ };
37
+ }, [fullViewportHeight]);
38
+ return /*#__PURE__*/_jsx("div", _objectSpread({
39
+ ref: mergeRefs(ref, nodeRef)
40
+ }, props));
41
+ });
42
+ if (process.env.NODE_ENV !== "production") Container.displayName = "Container";
43
+ Container.displayName = 'Container';
package/dist-src/index.js CHANGED
@@ -3,9 +3,17 @@ export * from "./banner/Banner.js";
3
3
  export * from "./box/Box.js";
4
4
  export * from "./button-area/ButtonArea.js";
5
5
  export * from "./button/Button.js";
6
+ export * from "./container/Container.js";
6
7
  export * from "./description-item/DescriptionItem.js";
7
8
  export * from "./file-drop-zone/FileDropZone.js";
8
9
  export * from "./file-list-item/FileListItem.js";
10
+ export * from "./navbar/Navbar.js";
11
+ export * from "./navbar/NavbarAvatar.js";
12
+ export * from "./navbar/NavbarBottomBar.js";
13
+ export { useNavbarContext } from "./navbar/NavbarContext.js";
14
+ export * from "./navbar/NavbarItem.js";
15
+ export * from "./navbar/NavbarList.js";
16
+ export * from "./navbar/NavbarMenu.js";
9
17
  export * from "./sidebar/Sidebar.js";
10
18
  export * from "./sidebar/SidebarContainer.js";
11
19
  export * from "./sidebar/SidebarDivider.js";
@@ -0,0 +1,40 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["color", "target", "rel"],
4
+ _excluded2 = ["children", "linkComponent"];
5
+ import { Link } from '@material-ui/core';
6
+ import { forwardRef } from 'react';
7
+ import { Anchorme } from 'react-anchorme';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ var DefaultLinkComponent = /*#__PURE__*/forwardRef((_ref, ref) => {
10
+ var {
11
+ color,
12
+ target = '_blank',
13
+ rel = 'noreferrer noopener'
14
+ } = _ref,
15
+ props = _objectWithoutProperties(_ref, _excluded);
16
+
17
+ return /*#__PURE__*/_jsx(Link, _objectSpread(_objectSpread({}, props), {}, {
18
+ ref: ref,
19
+ rel: rel,
20
+ target: target
21
+ }));
22
+ });
23
+ if (process.env.NODE_ENV !== "production") DefaultLinkComponent.displayName = "DefaultLinkComponent";
24
+ DefaultLinkComponent.displayName = 'DefaultLinkComponent';
25
+ export function LinkedText(_ref2) {
26
+ var {
27
+ children,
28
+ linkComponent = DefaultLinkComponent
29
+ } = _ref2,
30
+ props = _objectWithoutProperties(_ref2, _excluded2);
31
+
32
+ if (!children) {
33
+ return null;
34
+ }
35
+
36
+ return /*#__PURE__*/_jsx(Anchorme, _objectSpread(_objectSpread({}, props), {}, {
37
+ linkComponent: linkComponent,
38
+ children: children
39
+ }));
40
+ }
@@ -0,0 +1,83 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import { Drawer, useMediaQuery, useTheme } from '@material-ui/core';
3
+ import { useResponsiveValue } from '@superdispatch/ui';
4
+ import { useMemo, useState } from 'react';
5
+ import styled from 'styled-components';
6
+ import { NavbarBottomBar } from "./NavbarBottomBar.js";
7
+ import { NavbarContext } from "./NavbarContext.js";
8
+ import { NavbarList } from "./NavbarList.js";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ var Aside = /*#__PURE__*/styled.aside.withConfig({
12
+ displayName: "Navbar__Aside",
13
+ componentId: "SD__sc-1oiqig8-0"
14
+ })(["display:flex;flex-direction:column;overflow:auto;"]);
15
+ var Main = /*#__PURE__*/styled.main.withConfig({
16
+ displayName: "Navbar__Main",
17
+ componentId: "SD__sc-1oiqig8-1"
18
+ })(["flex:1;display:flex;flex-direction:column;overflow:scroll;"]);
19
+ export function Navbar(_ref) {
20
+ var {
21
+ footer,
22
+ items,
23
+ header,
24
+ bottomItems,
25
+ children,
26
+ containerStyle,
27
+ hasExtraBadge
28
+ } = _ref;
29
+ var theme = useTheme();
30
+ var [isDrawerOpen, setDrawerOpen] = useState(false);
31
+ var platform = useResponsiveValue('mobile', 'tablet', 'desktop');
32
+ var isMobile = platform === 'mobile';
33
+ var matches = useMediaQuery(theme.breakpoints.up('md'), {
34
+ noSsr: true
35
+ });
36
+ var [isExpanded, setIsExpanded] = useState(matches);
37
+ var hasBadge = hasExtraBadge || items.some(item => item.badge);
38
+ var ctx = useMemo(() => ({
39
+ isDrawerOpen,
40
+ isExpanded,
41
+ setIsExpanded,
42
+ setDrawerOpen
43
+ }), [isDrawerOpen, isExpanded, setIsExpanded, setDrawerOpen]);
44
+ return /*#__PURE__*/_jsx(NavbarContext.Provider, {
45
+ value: ctx,
46
+ children: /*#__PURE__*/_jsxs("div", {
47
+ style: _objectSpread({
48
+ display: 'flex',
49
+ height: '100%',
50
+ flexDirection: isMobile ? 'column' : 'row'
51
+ }, containerStyle),
52
+ children: [!isMobile && /*#__PURE__*/_jsx(Aside, {
53
+ children: /*#__PURE__*/_jsx(NavbarList, {
54
+ header: header,
55
+ items: items,
56
+ footer: footer
57
+ })
58
+ }), /*#__PURE__*/_jsx(Main, {
59
+ children: children
60
+ }), isMobile && /*#__PURE__*/_jsx(NavbarBottomBar, {
61
+ items: bottomItems,
62
+ hasMenuBadge: hasBadge
63
+ }), /*#__PURE__*/_jsx(Drawer, {
64
+ open: isDrawerOpen,
65
+ anchor: "right",
66
+ onClose: () => {
67
+ setDrawerOpen(false);
68
+ },
69
+ PaperProps: {
70
+ style: {
71
+ width: '280px',
72
+ minWidth: '280px'
73
+ }
74
+ },
75
+ children: /*#__PURE__*/_jsx(NavbarList, {
76
+ header: header,
77
+ items: items,
78
+ footer: footer
79
+ })
80
+ })]
81
+ })
82
+ });
83
+ }
@@ -0,0 +1,54 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["title", "subtitle", "children"];
4
+ import { Avatar, Typography } from '@material-ui/core';
5
+ import { Color, Column, Columns, Stack } from '@superdispatch/ui';
6
+ import styled from 'styled-components';
7
+ import { useNavbarContext } from "./NavbarContext.js";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ var StyledTypography = /*#__PURE__*/styled(Typography).withConfig({
11
+ displayName: "NavbarAvatar__StyledTypography",
12
+ componentId: "SD__sc-19q2zd0-0"
13
+ })(["color:", ";text-overflow:ellipsis;white-space:nowrap;overflow:hidden;&:hover{color:", ";}"], Color.Silver500, Color.White);
14
+ export function NavbarAvatar(_ref) {
15
+ var {
16
+ title,
17
+ subtitle,
18
+ children
19
+ } = _ref,
20
+ props = _objectWithoutProperties(_ref, _excluded);
21
+
22
+ var {
23
+ isExpanded,
24
+ isDrawerOpen
25
+ } = useNavbarContext();
26
+
27
+ if (isExpanded || isDrawerOpen) {
28
+ return /*#__PURE__*/_jsxs(Columns, {
29
+ space: "xsmall",
30
+ align: "center",
31
+ children: [/*#__PURE__*/_jsx(Column, {
32
+ width: "content",
33
+ children: /*#__PURE__*/_jsx(Avatar, _objectSpread(_objectSpread({}, props), {}, {
34
+ children: children
35
+ }))
36
+ }), /*#__PURE__*/_jsx(Column, {
37
+ children: /*#__PURE__*/_jsxs(Stack, {
38
+ space: "none",
39
+ children: [/*#__PURE__*/_jsx(StyledTypography, {
40
+ variant: "caption",
41
+ children: title
42
+ }), /*#__PURE__*/_jsx(StyledTypography, {
43
+ variant: "caption",
44
+ children: subtitle
45
+ })]
46
+ })
47
+ })]
48
+ });
49
+ }
50
+
51
+ return /*#__PURE__*/_jsx(Avatar, _objectSpread(_objectSpread({}, props), {}, {
52
+ children: children
53
+ }));
54
+ }
@@ -0,0 +1,66 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import { BottomNavigation, BottomNavigationAction } from '@material-ui/core';
3
+ import { Menu } from '@material-ui/icons';
4
+ import { Color } from '@superdispatch/ui';
5
+ import { useMemo } from 'react';
6
+ import styled from 'styled-components';
7
+ import { useNavbarContext } from "./NavbarContext.js";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { createElement as _createElement } from "react";
11
+ var StyledBottomNavigation = /*#__PURE__*/styled(BottomNavigation).withConfig({
12
+ displayName: "NavbarBottomBar__StyledBottomNavigation",
13
+ componentId: "SD__sc-9z6v3k-0"
14
+ })(["background:", ";"], Color.Dark500);
15
+ var StyledBottomNavigationAction = /*#__PURE__*/styled(BottomNavigationAction).withConfig({
16
+ displayName: "NavbarBottomBar__StyledBottomNavigationAction",
17
+ componentId: "SD__sc-9z6v3k-1"
18
+ })(["&&{background:#1b2638;color:", ";padding:6px 0 8px;line-height:20px;}&:first-child{padding-left:12px;}&:last-child{padding-right:12px;}&.Mui-selected{color:", ";.MuiBottomNavigationAction-label{font-size:0.75rem;}}"], Color.Silver500, Color.White);
19
+ var IconWrapper = /*#__PURE__*/styled.div.withConfig({
20
+ displayName: "NavbarBottomBar__IconWrapper",
21
+ componentId: "SD__sc-9z6v3k-2"
22
+ })(["position:relative;"]);
23
+ var IconLabel = /*#__PURE__*/styled.div.withConfig({
24
+ displayName: "NavbarBottomBar__IconLabel",
25
+ componentId: "SD__sc-9z6v3k-3"
26
+ })(["display:flex;align-items:center;justify-content:center;font-size:12px;border-radius:50%;color:", ";background:", ";position:absolute;top:0;right:0;width:8px;height:8px;"], Color.White, Color.Red300);
27
+ export function NavbarBottomBar(_ref) {
28
+ var {
29
+ items,
30
+ hasMenuBadge
31
+ } = _ref;
32
+ var {
33
+ isDrawerOpen,
34
+ setDrawerOpen
35
+ } = useNavbarContext();
36
+ var activeItem = useMemo(() => items.find(item => item.active), [items]);
37
+ return /*#__PURE__*/_jsxs(StyledBottomNavigation, {
38
+ value: activeItem === null || activeItem === void 0 ? void 0 : activeItem.value,
39
+ showLabels: true,
40
+ onChange: (_event, newValue) => {
41
+ if (newValue) {
42
+ if (newValue === 'menu') {
43
+ setDrawerOpen(!isDrawerOpen);
44
+ } else {
45
+ setDrawerOpen(false);
46
+ }
47
+ }
48
+ },
49
+ children: [items.map(item => /*#__PURE__*/_createElement(StyledBottomNavigationAction, _objectSpread(_objectSpread({}, item), {}, {
50
+ key: item.value,
51
+ icon: item.hasBadge ? /*#__PURE__*/_jsxs(IconWrapper, {
52
+ children: [/*#__PURE__*/_jsx(IconLabel, {}), item.icon]
53
+ }) : item.icon
54
+ }))), /*#__PURE__*/_jsx(StyledBottomNavigationAction, {
55
+ value: "menu",
56
+ label: "Menu",
57
+ icon: hasMenuBadge ? /*#__PURE__*/_jsxs(IconWrapper, {
58
+ children: [/*#__PURE__*/_jsx(IconLabel, {}), /*#__PURE__*/_jsx(Menu, {
59
+ fontSize: "small"
60
+ })]
61
+ }) : /*#__PURE__*/_jsx(Menu, {
62
+ fontSize: "small"
63
+ })
64
+ })]
65
+ });
66
+ }
@@ -0,0 +1,11 @@
1
+ import { noop } from 'lodash';
2
+ import { createContext, useContext } from 'react';
3
+ export var NavbarContext = /*#__PURE__*/createContext({
4
+ isDrawerOpen: false,
5
+ isExpanded: false,
6
+ setIsExpanded: noop,
7
+ setDrawerOpen: noop
8
+ });
9
+ export function useNavbarContext() {
10
+ return useContext(NavbarContext);
11
+ }
@@ -0,0 +1,51 @@
1
+ import { Color, useUID } from '@superdispatch/ui';
2
+ import styled from 'styled-components';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ export var NavbarBadge = /*#__PURE__*/styled.span.withConfig({
6
+ displayName: "NavbarItem__NavbarBadge",
7
+ componentId: "SD__sc-1pvzq3w-0"
8
+ })(["flex-shrink:0;padding:4px 6px;min-width:20px;line-height:12px;font-size:12px;font-weight:400;border-radius:10px;text-align:center;background:#131c2a;&[data-variant='primary']{color:", ";background:", ";}&[data-variant='danger']{color:", ";background:", ";}"], Color.White, Color.Blue300, Color.White, Color.Red500);
9
+ export var NavbarLabel = /*#__PURE__*/styled.span.withConfig({
10
+ displayName: "NavbarItem__NavbarLabel",
11
+ componentId: "SD__sc-1pvzq3w-1"
12
+ })(["flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"]);
13
+ var NavbarItemRoot = /*#__PURE__*/styled.div.withConfig({
14
+ displayName: "NavbarItem__NavbarItemRoot",
15
+ componentId: "SD__sc-1pvzq3w-2"
16
+ })(["width:100%;display:flex;align-items:center;color:#c2c4c9;font-size:14px;font-weight:400;line-height:20px;text-decoration:none;outline:none;cursor:pointer;padding:8px 16px;border-left:4px solid transparent;&:hover,&[aria-current]{background-color:#2f394a;color:", ";border-left-color:", ";}"], Color.White, Color.Blue300);
17
+ var IconWrapper = /*#__PURE__*/styled.div.withConfig({
18
+ displayName: "NavbarItem__IconWrapper",
19
+ componentId: "SD__sc-1pvzq3w-3"
20
+ })(["width:24px;margin-right:8px;& svg{font-size:24px;}"]);
21
+ export function NavbarItem(_ref) {
22
+ var {
23
+ label,
24
+ gutter,
25
+ badge,
26
+ icon,
27
+ component,
28
+ onClick,
29
+ variant,
30
+ ident = 0
31
+ } = _ref;
32
+ var uid = useUID();
33
+ return /*#__PURE__*/_jsxs(NavbarItemRoot, {
34
+ as: component,
35
+ onClick: onClick,
36
+ "aria-labelledby": uid,
37
+ style: {
38
+ marginTop: gutter ? '16px' : '0',
39
+ paddingLeft: (ident + 1) * 20
40
+ },
41
+ children: [/*#__PURE__*/_jsx(IconWrapper, {
42
+ children: icon
43
+ }), /*#__PURE__*/_jsx(NavbarLabel, {
44
+ id: uid,
45
+ children: label
46
+ }), badge != null && /*#__PURE__*/_jsx(NavbarBadge, {
47
+ "data-variant": variant,
48
+ children: badge
49
+ })]
50
+ });
51
+ }
@@ -0,0 +1,127 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import { IconButton } from '@material-ui/core';
3
+ import { Menu as MenuIcon, MenuOpen } from '@material-ui/icons';
4
+ import { Color, Inline, useResponsiveValue } from '@superdispatch/ui';
5
+ import { useMemo } from 'react';
6
+ import styled from 'styled-components';
7
+ import { useNavbarContext } from "./NavbarContext.js";
8
+ import { NavbarBadge, NavbarItem, NavbarLabel } from "./NavbarItem.js";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { createElement as _createElement } from "react";
12
+ var Header = /*#__PURE__*/styled.div.withConfig({
13
+ displayName: "NavbarList__Header",
14
+ componentId: "SD__sc-19zrmxc-0"
15
+ })(["margin:0 16px 8px;display:flex;flex-shrink:0;align-items:center;justify-content:space-between;position:sticky;"]);
16
+ var Wrapper = /*#__PURE__*/styled.div.withConfig({
17
+ displayName: "NavbarList__Wrapper",
18
+ componentId: "SD__sc-19zrmxc-1"
19
+ })(["display:flex;flex:1;flex-direction:column;overflow:hidden;padding-top:16px;background:#1b2638;transition:width 0.3s linear;height:100%;width:", ";&[data-expanded='true']{width:", ";}&[data-expanded='false']{width:", ";& > ", "{justify-content:center;}}"], _ref => {
20
+ var {
21
+ isMobile
22
+ } = _ref;
23
+ return isMobile ? '280px' : 'initial';
24
+ }, _ref2 => {
25
+ var {
26
+ isMobile
27
+ } = _ref2;
28
+ return isMobile ? '280px' : '240px';
29
+ }, _ref3 => {
30
+ var {
31
+ isMobile
32
+ } = _ref3;
33
+ return isMobile ? '280px' : '72px';
34
+ }, Header);
35
+ var ExpandIconButton = /*#__PURE__*/styled(IconButton).withConfig({
36
+ displayName: "NavbarList__ExpandIconButton",
37
+ componentId: "SD__sc-19zrmxc-2"
38
+ })(["color:", ";&&:focus{background-color:inherit;}"], Color.Silver500);
39
+ var Footer = /*#__PURE__*/styled.div.withConfig({
40
+ displayName: "NavbarList__Footer",
41
+ componentId: "SD__sc-19zrmxc-3"
42
+ })(["flex-grow:1;display:flex;align-items:flex-end;margin:16px 0 8px;position:sticky;"]);
43
+ var Root = /*#__PURE__*/styled.div.withConfig({
44
+ displayName: "NavbarList__Root",
45
+ componentId: "SD__sc-19zrmxc-4"
46
+ })(["color:inherit;background-color:unset;border-left:unset;font-size:14px;font-weight:400;line-height:20px;text-decoration:none;padding:8px 16px;svg{font-size:24px;color:", ";}"], Color.Dark100);
47
+ export function NavbarMenuItem(_ref4) {
48
+ var {
49
+ label,
50
+ icon,
51
+ onClick,
52
+ component
53
+ } = _ref4;
54
+ return /*#__PURE__*/_jsx(Root, {
55
+ as: component,
56
+ onClick: onClick,
57
+ children: /*#__PURE__*/_jsxs(Inline, {
58
+ space: "xsmall",
59
+ verticalAlign: "center",
60
+ children: [icon, /*#__PURE__*/_jsx(NavbarLabel, {
61
+ children: label
62
+ })]
63
+ })
64
+ });
65
+ }
66
+ var Content = /*#__PURE__*/styled.div.withConfig({
67
+ displayName: "NavbarList__Content",
68
+ componentId: "SD__sc-19zrmxc-5"
69
+ })(["height:100%;min-height:50px;overflow:scroll;&[aria-expanded='false']{", ",", "{visibility:hidden;}}"], NavbarBadge, NavbarLabel);
70
+ export function NavbarList(_ref5) {
71
+ var {
72
+ header,
73
+ items,
74
+ footer
75
+ } = _ref5;
76
+ var platform = useResponsiveValue('mobile', 'tablet', 'desktop');
77
+ var isMobile = platform === 'mobile';
78
+ var {
79
+ isExpanded,
80
+ isDrawerOpen,
81
+ setDrawerOpen,
82
+ setIsExpanded
83
+ } = useNavbarContext();
84
+ var isSidebarOpened = isMobile ? isDrawerOpen : isExpanded;
85
+ var filteredItems = useMemo(() => items.filter(item => {
86
+ return !item.hide && (isSidebarOpened || !!item.icon);
87
+ }).map(item => _objectSpread(_objectSpread({}, item), {}, {
88
+ menuGroupKey: item.groupKey
89
+ })), [items, isSidebarOpened]);
90
+ return /*#__PURE__*/_jsxs(Wrapper, {
91
+ isMobile: isMobile,
92
+ "data-expanded": isSidebarOpened,
93
+ children: [/*#__PURE__*/_jsxs(Header, {
94
+ children: [isSidebarOpened && header, !isMobile && /*#__PURE__*/_jsx(ExpandIconButton, {
95
+ disableRipple: true,
96
+ style: isExpanded ? {
97
+ paddingRight: 0
98
+ } : {},
99
+ onClick: () => {
100
+ setIsExpanded(!isExpanded);
101
+ },
102
+ children: isExpanded ? /*#__PURE__*/_jsx(MenuOpen, {}) : /*#__PURE__*/_jsx(MenuIcon, {})
103
+ })]
104
+ }), /*#__PURE__*/_jsx(Content, {
105
+ "aria-expanded": isSidebarOpened,
106
+ children: filteredItems.map(item => {
107
+ var index = filteredItems.indexOf(item);
108
+ var prev = filteredItems[index - 1];
109
+ return /*#__PURE__*/_createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
110
+ key: item.key,
111
+ gutter: prev && prev.groupKey !== item.groupKey,
112
+ onClick: event => {
113
+ var _item$onClick;
114
+
115
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
116
+
117
+ if (!event.isDefaultPrevented()) {
118
+ setDrawerOpen(false);
119
+ }
120
+ }
121
+ }));
122
+ })
123
+ }), /*#__PURE__*/_jsx(Footer, {
124
+ children: footer
125
+ })]
126
+ });
127
+ }
@@ -0,0 +1,80 @@
1
+ import { Menu, MenuItem, Typography } from '@material-ui/core';
2
+ import { Color, Inline } from '@superdispatch/ui';
3
+ import { useState } from 'react';
4
+ import styled from 'styled-components';
5
+ import { useNavbarContext } from "./NavbarContext.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { Fragment as _Fragment } from "react/jsx-runtime";
9
+ var Divider = /*#__PURE__*/styled.div.withConfig({
10
+ displayName: "NavbarMenu__Divider",
11
+ componentId: "SD__sc-1c8icpt-0"
12
+ })(["border-bottom:1px solid ", ";margin:8px -16px;"], Color.Silver400);
13
+ var StyledMenuItem = /*#__PURE__*/styled(MenuItem).withConfig({
14
+ displayName: "NavbarMenu__StyledMenuItem",
15
+ componentId: "SD__sc-1c8icpt-1"
16
+ })(["& svg{font-size:24px;color:", ";}"], Color.Dark100);
17
+ var Wrapper = /*#__PURE__*/styled.div.withConfig({
18
+ displayName: "NavbarMenu__Wrapper",
19
+ componentId: "SD__sc-1c8icpt-2"
20
+ })(["width:100%;padding:8px 16px;cursor:pointer;background:", ";border-left:4px solid ", ";&:hover{border-left-color:", ";background:", ";}"], Color.Dark400, _ref => {
21
+ var {
22
+ active
23
+ } = _ref;
24
+ return active ? Color.Blue300 : 'transparent';
25
+ }, Color.Blue300, Color.Dark400);
26
+ export function NavbarMenu(_ref2) {
27
+ var {
28
+ items,
29
+ children
30
+ } = _ref2;
31
+ var {
32
+ setDrawerOpen
33
+ } = useNavbarContext();
34
+ var [anchor, setAnchor] = useState(null);
35
+
36
+ function showProfileMenu(event) {
37
+ setAnchor(event.currentTarget);
38
+ }
39
+
40
+ function hideProfileMenu() {
41
+ setAnchor(null);
42
+ setDrawerOpen(false);
43
+ }
44
+
45
+ return /*#__PURE__*/_jsxs(_Fragment, {
46
+ children: [/*#__PURE__*/_jsx(Wrapper, {
47
+ onClick: showProfileMenu,
48
+ active: !!anchor,
49
+ children: children
50
+ }), /*#__PURE__*/_jsx(Menu, {
51
+ open: !!anchor,
52
+ anchorEl: anchor,
53
+ onClose: hideProfileMenu,
54
+ onClick: hideProfileMenu,
55
+ anchorOrigin: {
56
+ vertical: 'top',
57
+ horizontal: 'center'
58
+ },
59
+ transformOrigin: {
60
+ vertical: 'bottom',
61
+ horizontal: 'center'
62
+ },
63
+ children: items.filter(item => item.visible !== false).flatMap((item, index, arr) => {
64
+ return [/*#__PURE__*/_jsx(StyledMenuItem, {
65
+ onClick: item.onClick,
66
+ children: /*#__PURE__*/_jsxs(Inline, {
67
+ space: "small",
68
+ verticalAlign: "center",
69
+ children: [item.icon, /*#__PURE__*/_jsx(Typography, {
70
+ style: {
71
+ color: Color.Dark500
72
+ },
73
+ children: item.label
74
+ })]
75
+ })
76
+ }, item.key), index !== arr.length - 1 && /*#__PURE__*/_jsx(Divider, {}, "".concat(item.key, "-divider"))];
77
+ })
78
+ })]
79
+ });
80
+ }