@superdispatch/ui-lab 0.17.1 → 0.19.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.
@@ -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,19 @@ 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 "./linked-text/LinkedText.js";
11
+ export * from "./multiline-text/MultilineText.js";
12
+ export * from "./navbar/Navbar.js";
13
+ export * from "./navbar/NavbarAvatar.js";
14
+ export * from "./navbar/NavbarBottomBar.js";
15
+ export { useNavbarContext } from "./navbar/NavbarContext.js";
16
+ export * from "./navbar/NavbarItem.js";
17
+ export * from "./navbar/NavbarList.js";
18
+ export * from "./navbar/NavbarMenu.js";
9
19
  export * from "./sidebar/Sidebar.js";
10
20
  export * from "./sidebar/SidebarContainer.js";
11
21
  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,11 @@
1
+ import styled from 'styled-components';
2
+ export var MultilineText = /*#__PURE__*/styled.span.withConfig({
3
+ displayName: "MultilineText",
4
+ componentId: "SD__sc-34heyp-0"
5
+ })(["white-space:pre-wrap;overflow-wrap:", ";"], _ref => {
6
+ var {
7
+ overflowWrap = 'normal'
8
+ } = _ref;
9
+ return overflowWrap;
10
+ });
11
+ MultilineText.displayName = 'MultilineText';
@@ -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,97 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import { Accordion, AccordionSummary } from '@material-ui/core';
3
+ import { ExpandMore } from '@material-ui/icons';
4
+ import { Color, useUID } from '@superdispatch/ui';
5
+ import { useEffect, useState } from 'react';
6
+ import styled, { css } from 'styled-components';
7
+ import { useNavbarContext } from "./NavbarContext.js";
8
+ import { NavbarItem } 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
+ export var NavbarAccordionLabel = /*#__PURE__*/styled.span.withConfig({
13
+ displayName: "NavbarAccordion__NavbarAccordionLabel",
14
+ componentId: "SD__sc-1s7g3kw-0"
15
+ })(["flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;&[data-expanded='false']{display:none;}"]);
16
+ var NavbarAccordionRoot = /*#__PURE__*/styled(Accordion).withConfig({
17
+ displayName: "NavbarAccordion__NavbarAccordionRoot",
18
+ componentId: "SD__sc-1s7g3kw-1"
19
+ })(_ref => {
20
+ var {
21
+ gutter
22
+ } = _ref;
23
+ return css(["width:100%;color:#c2c4c9;font-size:14px;font-weight:400;line-height:20px;text-decoration:none;outline:none;cursor:pointer;background-color:#1b2638;margin-top:", ";&:hover,&[aria-current]{background-color:#2f394a;color:", ";}&.MuiAccordion-root:before{background-color:#1b2638;}&.MuiPaper-elevation0{border:0px;}&&.MuiAccordionSummary-root.Mui-expanded{margin-top:", ";max-height:40px;min-height:40px;}"], gutter ? '16px' : '0', Color.White, gutter ? '16px' : '0');
24
+ });
25
+ var NavbarAccordionSummary = /*#__PURE__*/styled(AccordionSummary).withConfig({
26
+ displayName: "NavbarAccordion__NavbarAccordionSummary",
27
+ componentId: "SD__sc-1s7g3kw-2"
28
+ })(["border-left:4px solid transparent;padding-left:20px;&.MuiAccordionSummary-root{max-height:40px;min-height:40px;}&:hover,&[data-active='true']{border-left-color:", ";}&[data-expanded='false']{.MuiAccordionSummary-expandIcon{display:none;}}"], Color.Blue300);
29
+ var IconWrapper = /*#__PURE__*/styled.div.withConfig({
30
+ displayName: "NavbarAccordion__IconWrapper",
31
+ componentId: "SD__sc-1s7g3kw-3"
32
+ })(["width:24px;margin-right:8px;& svg{font-size:24px;}"]);
33
+ export function NavbarAccordion(_ref2) {
34
+ var {
35
+ label,
36
+ icon,
37
+ gutter,
38
+ items,
39
+ onClick: _onClick
40
+ } = _ref2;
41
+ var uid = useUID();
42
+ var {
43
+ isExpanded: isMenuExpanded,
44
+ isDrawerOpen,
45
+ setDrawerOpen
46
+ } = useNavbarContext();
47
+ var [isExpanded, setExpanded] = useState(false);
48
+ useEffect(() => {
49
+ if (!isMenuExpanded) {
50
+ setExpanded(false);
51
+ }
52
+ }, [isMenuExpanded]);
53
+ return /*#__PURE__*/_jsxs(NavbarAccordionRoot, {
54
+ "aria-labelledby": uid,
55
+ gutter: !!gutter,
56
+ expanded: isExpanded,
57
+ onClick: event => {
58
+ if (isMenuExpanded || isDrawerOpen) {
59
+ setExpanded(!isExpanded);
60
+ }
61
+
62
+ _onClick(event);
63
+ },
64
+ square: true,
65
+ children: [/*#__PURE__*/_jsxs(NavbarAccordionSummary, {
66
+ "data-active": !isExpanded && items.some(item => item.active),
67
+ "data-expanded": isMenuExpanded || isDrawerOpen,
68
+ expandIcon: /*#__PURE__*/_jsx(ExpandMore, {}),
69
+ children: [/*#__PURE__*/_jsx(IconWrapper, {
70
+ children: icon
71
+ }), /*#__PURE__*/_jsx(NavbarAccordionLabel, {
72
+ id: uid,
73
+ "data-expanded": isMenuExpanded || isDrawerOpen,
74
+ children: label
75
+ })]
76
+ }), items.map(item => {
77
+ var index = items.indexOf(item);
78
+ var prev = items[index - 1];
79
+ return /*#__PURE__*/_createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
80
+ key: item.key,
81
+ ident: 1,
82
+ active: item.active,
83
+ gutter: prev && prev.groupKey !== item.groupKey,
84
+ onClick: event => {
85
+ var _item$onClick;
86
+
87
+ event.stopPropagation();
88
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
89
+
90
+ if (!event.isDefaultPrevented()) {
91
+ setDrawerOpen(false);
92
+ }
93
+ }
94
+ }));
95
+ })]
96
+ });
97
+ }
@@ -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,53 @@
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:", ";}&[data-active='true']{border-left-color:", ";}"], Color.White, Color.Blue300, 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
+ active
32
+ } = _ref;
33
+ var uid = useUID();
34
+ return /*#__PURE__*/_jsxs(NavbarItemRoot, {
35
+ as: component,
36
+ onClick: onClick,
37
+ "aria-labelledby": uid,
38
+ "data-active": active,
39
+ style: {
40
+ marginTop: gutter ? '16px' : '0',
41
+ paddingLeft: (ident + 1) * 20
42
+ },
43
+ children: [/*#__PURE__*/_jsx(IconWrapper, {
44
+ children: icon
45
+ }), /*#__PURE__*/_jsx(NavbarLabel, {
46
+ id: uid,
47
+ children: label
48
+ }), badge != null && /*#__PURE__*/_jsx(NavbarBadge, {
49
+ "data-variant": variant,
50
+ children: badge
51
+ })]
52
+ });
53
+ }
@@ -0,0 +1,137 @@
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 { NavbarAccordion } from "./NavbarAccordion.js";
8
+ import { useNavbarContext } from "./NavbarContext.js";
9
+ import { NavbarBadge, NavbarItem, NavbarLabel } from "./NavbarItem.js";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { createElement as _createElement } from "react";
13
+ var Header = /*#__PURE__*/styled.div.withConfig({
14
+ displayName: "NavbarList__Header",
15
+ componentId: "SD__sc-19zrmxc-0"
16
+ })(["margin:0 16px 8px;display:flex;flex-shrink:0;align-items:center;justify-content:space-between;position:sticky;"]);
17
+ var Wrapper = /*#__PURE__*/styled.div.withConfig({
18
+ displayName: "NavbarList__Wrapper",
19
+ componentId: "SD__sc-19zrmxc-1"
20
+ })(["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 => {
21
+ var {
22
+ isMobile
23
+ } = _ref;
24
+ return isMobile ? '280px' : 'initial';
25
+ }, _ref2 => {
26
+ var {
27
+ isMobile
28
+ } = _ref2;
29
+ return isMobile ? '280px' : '240px';
30
+ }, _ref3 => {
31
+ var {
32
+ isMobile
33
+ } = _ref3;
34
+ return isMobile ? '280px' : '72px';
35
+ }, Header);
36
+ var ExpandIconButton = /*#__PURE__*/styled(IconButton).withConfig({
37
+ displayName: "NavbarList__ExpandIconButton",
38
+ componentId: "SD__sc-19zrmxc-2"
39
+ })(["color:", ";&&:focus{background-color:inherit;}"], Color.Silver500);
40
+ var Footer = /*#__PURE__*/styled.div.withConfig({
41
+ displayName: "NavbarList__Footer",
42
+ componentId: "SD__sc-19zrmxc-3"
43
+ })(["flex-grow:1;display:flex;align-items:flex-end;margin:16px 0 8px;position:sticky;"]);
44
+ var Root = /*#__PURE__*/styled.div.withConfig({
45
+ displayName: "NavbarList__Root",
46
+ componentId: "SD__sc-19zrmxc-4"
47
+ })(["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);
48
+ export function NavbarMenuItem(_ref4) {
49
+ var {
50
+ label,
51
+ icon,
52
+ onClick,
53
+ component
54
+ } = _ref4;
55
+ return /*#__PURE__*/_jsx(Root, {
56
+ as: component,
57
+ onClick: onClick,
58
+ children: /*#__PURE__*/_jsxs(Inline, {
59
+ space: "xsmall",
60
+ verticalAlign: "center",
61
+ children: [icon, /*#__PURE__*/_jsx(NavbarLabel, {
62
+ children: label
63
+ })]
64
+ })
65
+ });
66
+ }
67
+ var Content = /*#__PURE__*/styled.div.withConfig({
68
+ displayName: "NavbarList__Content",
69
+ componentId: "SD__sc-19zrmxc-5"
70
+ })(["height:100%;min-height:50px;overflow-y:auto;overflow-x:hidden;&[aria-expanded='false']{", ",", "{display:none;}}"], NavbarBadge, NavbarLabel);
71
+ export function NavbarList(_ref5) {
72
+ var {
73
+ header,
74
+ items,
75
+ footer
76
+ } = _ref5;
77
+ var platform = useResponsiveValue('mobile', 'tablet', 'desktop');
78
+ var isMobile = platform === 'mobile';
79
+ var {
80
+ isExpanded,
81
+ isDrawerOpen,
82
+ setDrawerOpen,
83
+ setIsExpanded
84
+ } = useNavbarContext();
85
+ var isSidebarOpened = isMobile ? isDrawerOpen : isExpanded;
86
+ var filteredItems = useMemo(() => items.filter(item => {
87
+ return !item.hide && (isSidebarOpened || !!item.icon);
88
+ }).map(item => _objectSpread(_objectSpread({}, item), {}, {
89
+ menuGroupKey: item.groupKey
90
+ })), [items, isSidebarOpened]);
91
+ return /*#__PURE__*/_jsxs(Wrapper, {
92
+ isMobile: isMobile,
93
+ "data-expanded": isSidebarOpened,
94
+ children: [/*#__PURE__*/_jsxs(Header, {
95
+ children: [isSidebarOpened && header, !isMobile && /*#__PURE__*/_jsx(ExpandIconButton, {
96
+ disableRipple: true,
97
+ style: isExpanded ? {
98
+ paddingRight: 0
99
+ } : {},
100
+ onClick: () => {
101
+ setIsExpanded(!isExpanded);
102
+ },
103
+ children: isExpanded ? /*#__PURE__*/_jsx(MenuOpen, {}) : /*#__PURE__*/_jsx(MenuIcon, {})
104
+ })]
105
+ }), /*#__PURE__*/_jsx(Content, {
106
+ "aria-expanded": isSidebarOpened,
107
+ children: filteredItems.map(item => {
108
+ var index = filteredItems.indexOf(item);
109
+ var prev = filteredItems[index - 1];
110
+
111
+ if ('items' in item) {
112
+ return /*#__PURE__*/_createElement(NavbarAccordion, _objectSpread(_objectSpread({}, item), {}, {
113
+ key: item.key,
114
+ gutter: prev && prev.groupKey !== item.groupKey,
115
+ onClick: item.onClick
116
+ }));
117
+ }
118
+
119
+ return /*#__PURE__*/_createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
120
+ key: item.key,
121
+ gutter: prev && prev.groupKey !== item.groupKey,
122
+ onClick: event => {
123
+ var _item$onClick;
124
+
125
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
126
+
127
+ if (!event.isDefaultPrevented()) {
128
+ setDrawerOpen(false);
129
+ }
130
+ }
131
+ }));
132
+ })
133
+ }), /*#__PURE__*/_jsx(Footer, {
134
+ children: footer
135
+ })]
136
+ });
137
+ }