@superdispatch/ui-lab 0.18.0 → 0.20.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.
- package/dist-node/index.js +336 -48
- package/dist-node/index.js.map +1 -1
- package/dist-src/index.js +4 -0
- package/dist-src/linked-text/LinkedText.js +40 -0
- package/dist-src/multiline-text/MultilineText.js +11 -0
- package/dist-src/navbar/Navbar.js +1 -1
- package/dist-src/navbar/NavbarAccordion.js +97 -0
- package/dist-src/navbar/NavbarAvatar.js +2 -0
- package/dist-src/navbar/NavbarItem.js +4 -2
- package/dist-src/navbar/NavbarList.js +23 -31
- package/dist-src/sidebar/Sidebar.js +1 -1
- package/dist-src/sidebar/SidebarBackButton.js +38 -0
- package/dist-src/sidebar/SidebarContainer.js +44 -10
- package/dist-src/sidebar/SidebarContent.js +88 -0
- package/dist-src/sidebar/SidebarMenuItem.js +14 -3
- package/dist-src/sidebar/SidebarMenuItemAvatar.js +1 -0
- package/dist-types/index.d.ts +53 -5
- package/dist-web/index.js +338 -55
- package/dist-web/index.js.map +1 -1
- package/package.json +4 -3
package/dist-src/index.js
CHANGED
|
@@ -7,6 +7,8 @@ export * from "./container/Container.js";
|
|
|
7
7
|
export * from "./description-item/DescriptionItem.js";
|
|
8
8
|
export * from "./file-drop-zone/FileDropZone.js";
|
|
9
9
|
export * from "./file-list-item/FileListItem.js";
|
|
10
|
+
export * from "./linked-text/LinkedText.js";
|
|
11
|
+
export * from "./multiline-text/MultilineText.js";
|
|
10
12
|
export * from "./navbar/Navbar.js";
|
|
11
13
|
export * from "./navbar/NavbarAvatar.js";
|
|
12
14
|
export * from "./navbar/NavbarBottomBar.js";
|
|
@@ -15,7 +17,9 @@ export * from "./navbar/NavbarItem.js";
|
|
|
15
17
|
export * from "./navbar/NavbarList.js";
|
|
16
18
|
export * from "./navbar/NavbarMenu.js";
|
|
17
19
|
export * from "./sidebar/Sidebar.js";
|
|
20
|
+
export * from "./sidebar/SidebarBackButton.js";
|
|
18
21
|
export * from "./sidebar/SidebarContainer.js";
|
|
22
|
+
export * from "./sidebar/SidebarContent.js";
|
|
19
23
|
export * from "./sidebar/SidebarDivider.js";
|
|
20
24
|
export * from "./sidebar/SidebarMenuItem.js";
|
|
21
25
|
export * from "./sidebar/SidebarMenuItemAction.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';
|
|
@@ -15,7 +15,7 @@ var Aside = /*#__PURE__*/styled.aside.withConfig({
|
|
|
15
15
|
var Main = /*#__PURE__*/styled.main.withConfig({
|
|
16
16
|
displayName: "Navbar__Main",
|
|
17
17
|
componentId: "SD__sc-1oiqig8-1"
|
|
18
|
-
})(["flex:1;display:flex;flex-direction:column;overflow:
|
|
18
|
+
})(["flex:1;display:flex;flex-direction:column;overflow:scroll;"]);
|
|
19
19
|
export function Navbar(_ref) {
|
|
20
20
|
var {
|
|
21
21
|
footer,
|
|
@@ -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
|
+
}
|
|
@@ -37,8 +37,10 @@ export function NavbarAvatar(_ref) {
|
|
|
37
37
|
children: /*#__PURE__*/_jsxs(Stack, {
|
|
38
38
|
space: "none",
|
|
39
39
|
children: [/*#__PURE__*/_jsx(StyledTypography, {
|
|
40
|
+
variant: "caption",
|
|
40
41
|
children: title
|
|
41
42
|
}), /*#__PURE__*/_jsx(StyledTypography, {
|
|
43
|
+
variant: "caption",
|
|
42
44
|
children: subtitle
|
|
43
45
|
})]
|
|
44
46
|
})
|
|
@@ -13,7 +13,7 @@ export var NavbarLabel = /*#__PURE__*/styled.span.withConfig({
|
|
|
13
13
|
var NavbarItemRoot = /*#__PURE__*/styled.div.withConfig({
|
|
14
14
|
displayName: "NavbarItem__NavbarItemRoot",
|
|
15
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);
|
|
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
17
|
var IconWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
18
18
|
displayName: "NavbarItem__IconWrapper",
|
|
19
19
|
componentId: "SD__sc-1pvzq3w-3"
|
|
@@ -27,13 +27,15 @@ export function NavbarItem(_ref) {
|
|
|
27
27
|
component,
|
|
28
28
|
onClick,
|
|
29
29
|
variant,
|
|
30
|
-
ident = 0
|
|
30
|
+
ident = 0,
|
|
31
|
+
active
|
|
31
32
|
} = _ref;
|
|
32
33
|
var uid = useUID();
|
|
33
34
|
return /*#__PURE__*/_jsxs(NavbarItemRoot, {
|
|
34
35
|
as: component,
|
|
35
36
|
onClick: onClick,
|
|
36
37
|
"aria-labelledby": uid,
|
|
38
|
+
"data-active": active,
|
|
37
39
|
style: {
|
|
38
40
|
marginTop: gutter ? '16px' : '0',
|
|
39
41
|
paddingLeft: (ident + 1) * 20
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import { IconButton } from '@material-ui/core';
|
|
3
|
-
import { Menu as MenuIcon, MenuOpen
|
|
4
|
-
import {
|
|
3
|
+
import { Menu as MenuIcon, MenuOpen } from '@material-ui/icons';
|
|
4
|
+
import { Color, Inline, useResponsiveValue } from '@superdispatch/ui';
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
+
import { NavbarAccordion } from "./NavbarAccordion.js";
|
|
7
8
|
import { useNavbarContext } from "./NavbarContext.js";
|
|
8
9
|
import { NavbarBadge, NavbarItem, NavbarLabel } from "./NavbarItem.js";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { createElement as _createElement } from "react";
|
|
11
13
|
var Header = /*#__PURE__*/styled.div.withConfig({
|
|
12
14
|
displayName: "NavbarList__Header",
|
|
13
15
|
componentId: "SD__sc-19zrmxc-0"
|
|
14
|
-
})(["margin:0 16px 8px;display:flex;flex-shrink:0;align-items:center;justify-content:space-between;"]);
|
|
16
|
+
})(["margin:0 16px 8px;display:flex;flex-shrink:0;align-items:center;justify-content:space-between;position:sticky;"]);
|
|
15
17
|
var Wrapper = /*#__PURE__*/styled.div.withConfig({
|
|
16
18
|
displayName: "NavbarList__Wrapper",
|
|
17
19
|
componentId: "SD__sc-19zrmxc-1"
|
|
@@ -38,7 +40,7 @@ var ExpandIconButton = /*#__PURE__*/styled(IconButton).withConfig({
|
|
|
38
40
|
var Footer = /*#__PURE__*/styled.div.withConfig({
|
|
39
41
|
displayName: "NavbarList__Footer",
|
|
40
42
|
componentId: "SD__sc-19zrmxc-3"
|
|
41
|
-
})(["flex-grow:1;display:flex;align-items:flex-end;margin:16px 0 8px;"]);
|
|
43
|
+
})(["flex-grow:1;display:flex;align-items:flex-end;margin:16px 0 8px;position:sticky;"]);
|
|
42
44
|
var Root = /*#__PURE__*/styled.div.withConfig({
|
|
43
45
|
displayName: "NavbarList__Root",
|
|
44
46
|
componentId: "SD__sc-19zrmxc-4"
|
|
@@ -65,7 +67,7 @@ export function NavbarMenuItem(_ref4) {
|
|
|
65
67
|
var Content = /*#__PURE__*/styled.div.withConfig({
|
|
66
68
|
displayName: "NavbarList__Content",
|
|
67
69
|
componentId: "SD__sc-19zrmxc-5"
|
|
68
|
-
})(["height:100%;min-height:50px;&[aria-expanded='false']{", ",", "{
|
|
70
|
+
})(["height:100%;min-height:50px;overflow-y:auto;overflow-x:hidden;&[aria-expanded='false']{", ",", "{display:none;}}"], NavbarBadge, NavbarLabel);
|
|
69
71
|
export function NavbarList(_ref5) {
|
|
70
72
|
var {
|
|
71
73
|
header,
|
|
@@ -102,41 +104,31 @@ export function NavbarList(_ref5) {
|
|
|
102
104
|
})]
|
|
103
105
|
}), /*#__PURE__*/_jsx(Content, {
|
|
104
106
|
"aria-expanded": isSidebarOpened,
|
|
105
|
-
children:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
renderItem: item => {
|
|
109
|
-
var navbarItem = item;
|
|
110
|
-
var index = filteredItems.indexOf(navbarItem);
|
|
111
|
-
var prev = filteredItems[index - 1];
|
|
112
|
-
return /*#__PURE__*/_jsx(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
113
|
-
gutter: prev && prev.groupKey !== navbarItem.groupKey,
|
|
114
|
-
onClick: event => {
|
|
115
|
-
var _item$onClick;
|
|
107
|
+
children: filteredItems.map(item => {
|
|
108
|
+
var index = filteredItems.indexOf(item);
|
|
109
|
+
var prev = filteredItems[index - 1];
|
|
116
110
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
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
|
|
123
116
|
}));
|
|
124
|
-
}
|
|
125
|
-
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return /*#__PURE__*/_createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
120
|
+
key: item.key,
|
|
121
|
+
gutter: prev && prev.groupKey !== item.groupKey,
|
|
126
122
|
onClick: event => {
|
|
127
|
-
var _item$
|
|
123
|
+
var _item$onClick;
|
|
128
124
|
|
|
129
|
-
(_item$
|
|
125
|
+
(_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
|
|
130
126
|
|
|
131
127
|
if (!event.isDefaultPrevented()) {
|
|
132
128
|
setDrawerOpen(false);
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
|
-
}))
|
|
136
|
-
moreElement: /*#__PURE__*/_jsx(NavbarItem, {
|
|
137
|
-
icon: /*#__PURE__*/_jsx(MoreHoriz, {}),
|
|
138
|
-
label: "More"
|
|
139
|
-
})
|
|
131
|
+
}));
|
|
140
132
|
})
|
|
141
133
|
}), /*#__PURE__*/_jsx(Footer, {
|
|
142
134
|
children: footer
|
|
@@ -7,7 +7,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
var SidebarRoot = /*#__PURE__*/styled.aside.withConfig({
|
|
8
8
|
displayName: "Sidebar__SidebarRoot",
|
|
9
9
|
componentId: "SD__sc-b77o22-0"
|
|
10
|
-
})(["top:0;position:sticky;overflow-y:auto;overflow-x:hidden;
|
|
10
|
+
})(["top:0;position:sticky;overflow-y:auto;overflow-x:hidden;height:100vh;background-color:", ";border-right:1px solid ", ";"], Color.White, Color.Silver400);
|
|
11
11
|
var SidebarHeader = /*#__PURE__*/styled.div.withConfig({
|
|
12
12
|
displayName: "Sidebar__SidebarHeader",
|
|
13
13
|
componentId: "SD__sc-b77o22-1"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["onClick", "children"];
|
|
4
|
+
import { IconButton } from '@material-ui/core';
|
|
5
|
+
import { ArrowBack } from '@material-ui/icons';
|
|
6
|
+
import { useCollapseBreakpoint } from '@superdispatch/ui';
|
|
7
|
+
import { useSidebarContext } from "./SidebarContainer.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export function SidebarBackButton(_ref) {
|
|
10
|
+
var {
|
|
11
|
+
onClick: _onClick,
|
|
12
|
+
children = /*#__PURE__*/_jsx(ArrowBack, {
|
|
13
|
+
fontSize: "small"
|
|
14
|
+
})
|
|
15
|
+
} = _ref,
|
|
16
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
17
|
+
|
|
18
|
+
var isCollapsed = useCollapseBreakpoint('sm');
|
|
19
|
+
var {
|
|
20
|
+
openSidebar
|
|
21
|
+
} = useSidebarContext();
|
|
22
|
+
|
|
23
|
+
if (!isCollapsed) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return /*#__PURE__*/_jsx(IconButton, _objectSpread(_objectSpread({}, props), {}, {
|
|
28
|
+
size: "small",
|
|
29
|
+
onClick: event => {
|
|
30
|
+
_onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
31
|
+
|
|
32
|
+
if (!event.isDefaultPrevented()) {
|
|
33
|
+
openSidebar();
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
children: children
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
@@ -1,25 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCollapseBreakpoint } from '@superdispatch/ui';
|
|
2
|
+
import { createContext, forwardRef, useContext, useMemo, useState } from 'react';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
var
|
|
6
|
-
|
|
6
|
+
var Context = /*#__PURE__*/createContext(null);
|
|
7
|
+
export function useSidebarContext() {
|
|
8
|
+
var context = useContext(Context);
|
|
9
|
+
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error('SidebarContext is used outside Provider');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
16
|
+
var SidebarContainerSidebar = /*#__PURE__*/styled.div.withConfig({
|
|
17
|
+
displayName: "SidebarContainer__SidebarContainerSidebar",
|
|
7
18
|
componentId: "SD__sc-uibj1m-0"
|
|
8
|
-
})(["
|
|
19
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;width:240px;"]);
|
|
9
20
|
var SidebarContainerContent = /*#__PURE__*/styled.div.withConfig({
|
|
10
21
|
displayName: "SidebarContainer__SidebarContainerContent",
|
|
11
22
|
componentId: "SD__sc-uibj1m-1"
|
|
12
|
-
})(["height:inherit;max-height:inherit;min-height:inherit;
|
|
23
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;"]);
|
|
24
|
+
var SidebarContainerRoot = /*#__PURE__*/styled.div.withConfig({
|
|
25
|
+
displayName: "SidebarContainer__SidebarContainerRoot",
|
|
26
|
+
componentId: "SD__sc-uibj1m-2"
|
|
27
|
+
})(["display:flex;height:inherit;max-height:inherit;min-height:inherit;& ", "{width:calc(100% - 240px);min-width:calc(100% - 240px);max-width:calc(100% - 240px);}&[data-visibility='sidebar'] ", "{width:100%;}&[data-visibility='sidebar'] ", "{display:none;}&[data-visibility='content'] ", "{display:none;}&[data-visibility='content'] ", "{width:100%;max-width:unset;}"], SidebarContainerContent, SidebarContainerSidebar, SidebarContainerContent, SidebarContainerSidebar, SidebarContainerContent);
|
|
13
28
|
export var SidebarContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
29
|
var {
|
|
15
30
|
sidebar,
|
|
16
31
|
children
|
|
17
32
|
} = _ref;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
var isCollapsed = useCollapseBreakpoint('sm');
|
|
34
|
+
var [visibilityState, setVisibilityState] = useState('sidebar');
|
|
35
|
+
var visibility = isCollapsed ? visibilityState : 'both';
|
|
36
|
+
var context = useMemo(() => {
|
|
37
|
+
return {
|
|
38
|
+
openSidebar: () => {
|
|
39
|
+
setVisibilityState('sidebar');
|
|
40
|
+
},
|
|
41
|
+
openSidebarContent: () => {
|
|
42
|
+
setVisibilityState('content');
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
return /*#__PURE__*/_jsx(Context.Provider, {
|
|
47
|
+
value: context,
|
|
48
|
+
children: /*#__PURE__*/_jsxs(SidebarContainerRoot, {
|
|
49
|
+
ref: ref,
|
|
50
|
+
"data-visibility": visibility,
|
|
51
|
+
children: [/*#__PURE__*/_jsx(SidebarContainerSidebar, {
|
|
52
|
+
children: sidebar
|
|
53
|
+
}), /*#__PURE__*/_jsx(SidebarContainerContent, {
|
|
54
|
+
children: children
|
|
55
|
+
})]
|
|
56
|
+
})
|
|
23
57
|
});
|
|
24
58
|
});
|
|
25
59
|
if (process.env.NODE_ENV !== "production") SidebarContainer.displayName = "SidebarContainer";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AppBar, Toolbar } from '@material-ui/core';
|
|
2
|
+
import { Column, Columns, Stack } from '@superdispatch/ui';
|
|
3
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
import { Box } from "../box/Box.js";
|
|
6
|
+
import { TextBox } from "../text-box/TextBox.js";
|
|
7
|
+
import { SidebarBackButton } from "./SidebarBackButton.js";
|
|
8
|
+
import { useSidebarContext } from "./SidebarContainer.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
var SidebarAppBar = /*#__PURE__*/styled(AppBar).withConfig({
|
|
12
|
+
displayName: "SidebarContent__SidebarAppBar",
|
|
13
|
+
componentId: "SD__sc-zpgf61-0"
|
|
14
|
+
})(_ref => {
|
|
15
|
+
var {
|
|
16
|
+
theme
|
|
17
|
+
} = _ref;
|
|
18
|
+
return css(["", "{&&{border-left:transparent;}}"], theme.breakpoints.up('sm'));
|
|
19
|
+
});
|
|
20
|
+
export function SidebarContent(_ref2) {
|
|
21
|
+
var {
|
|
22
|
+
dense,
|
|
23
|
+
action,
|
|
24
|
+
title,
|
|
25
|
+
children,
|
|
26
|
+
onBack,
|
|
27
|
+
openOnMount,
|
|
28
|
+
closeOnUnmount
|
|
29
|
+
} = _ref2;
|
|
30
|
+
var isOpenedOnMount = useRef(false);
|
|
31
|
+
var isClosedOnMount = useRef(false);
|
|
32
|
+
var {
|
|
33
|
+
openSidebarContent,
|
|
34
|
+
openSidebar
|
|
35
|
+
} = useSidebarContext();
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
if (openOnMount) {
|
|
38
|
+
if (isOpenedOnMount.current) {
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.warn('[SidebarContent]: "openOnMount" should not change during lifecycle of the component.');
|
|
41
|
+
} else {
|
|
42
|
+
isOpenedOnMount.current = true;
|
|
43
|
+
openSidebarContent();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, [openOnMount, openSidebarContent]);
|
|
47
|
+
useLayoutEffect(() => {
|
|
48
|
+
return () => {
|
|
49
|
+
if (closeOnUnmount) {
|
|
50
|
+
if (isClosedOnMount.current) {
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
52
|
+
console.warn('[SidebarContent]: "closeOnUnmount" should not change during lifecycle of the component.');
|
|
53
|
+
} else {
|
|
54
|
+
isClosedOnMount.current = true;
|
|
55
|
+
openSidebar();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}, [openSidebar, closeOnUnmount]);
|
|
60
|
+
return /*#__PURE__*/_jsxs(Stack, {
|
|
61
|
+
space: "none",
|
|
62
|
+
children: [/*#__PURE__*/_jsx(SidebarAppBar, {
|
|
63
|
+
children: /*#__PURE__*/_jsx(Toolbar, {
|
|
64
|
+
children: /*#__PURE__*/_jsxs(Columns, {
|
|
65
|
+
align: "center",
|
|
66
|
+
space: "small",
|
|
67
|
+
children: [/*#__PURE__*/_jsx(Column, {
|
|
68
|
+
width: "content",
|
|
69
|
+
children: /*#__PURE__*/_jsx(SidebarBackButton, {
|
|
70
|
+
onClick: onBack
|
|
71
|
+
})
|
|
72
|
+
}), /*#__PURE__*/_jsx(Column, {
|
|
73
|
+
children: /*#__PURE__*/_jsx(TextBox, {
|
|
74
|
+
variant: "heading-2",
|
|
75
|
+
children: title
|
|
76
|
+
})
|
|
77
|
+
}), /*#__PURE__*/_jsx(Column, {
|
|
78
|
+
width: "content",
|
|
79
|
+
children: action
|
|
80
|
+
})]
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
84
|
+
padding: dense ? 'none' : 'medium',
|
|
85
|
+
children: children
|
|
86
|
+
})]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Color, Column, Columns, Inline } from '@superdispatch/ui';
|
|
|
4
4
|
import { forwardRef, useLayoutEffect, useRef, useState } from 'react';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
6
|
import { TextBox } from "../text-box/TextBox.js";
|
|
7
|
+
import { useSidebarContext } from "./SidebarContainer.js";
|
|
7
8
|
import { SidebarMenuItemContextProvider } from "./SidebarMenuItemContext.js";
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -29,17 +30,21 @@ export var SidebarMenuItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
29
30
|
var {
|
|
30
31
|
action,
|
|
31
32
|
avatar,
|
|
32
|
-
onClick,
|
|
33
|
+
onClick: _onClick,
|
|
33
34
|
external,
|
|
34
35
|
children,
|
|
35
36
|
disabled,
|
|
36
37
|
selected,
|
|
37
38
|
secondaryActions,
|
|
38
|
-
badge: badgeProp
|
|
39
|
+
badge: badgeProp,
|
|
40
|
+
openContentOnClick
|
|
39
41
|
} = _ref2;
|
|
40
42
|
var [hovered, setHovered] = useState(false);
|
|
41
43
|
var actionsRef = useRef(null);
|
|
42
44
|
var actionsPlaceholderRef = useRef(null);
|
|
45
|
+
var {
|
|
46
|
+
openSidebarContent
|
|
47
|
+
} = useSidebarContext();
|
|
43
48
|
useLayoutEffect(() => {
|
|
44
49
|
if (actionsRef.current && actionsPlaceholderRef.current) {
|
|
45
50
|
actionsPlaceholderRef.current.style.width = "".concat(Math.max(0, actionsRef.current.offsetWidth - 8), "px");
|
|
@@ -56,9 +61,15 @@ export var SidebarMenuItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
56
61
|
setHovered(false);
|
|
57
62
|
},
|
|
58
63
|
children: [/*#__PURE__*/_jsx(ButtonBase, {
|
|
59
|
-
onClick: onClick,
|
|
60
64
|
disabled: disabled,
|
|
61
65
|
"aria-current": selected,
|
|
66
|
+
onClick: event => {
|
|
67
|
+
_onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
68
|
+
|
|
69
|
+
if (!event.isDefaultPrevented() && openContentOnClick) {
|
|
70
|
+
openSidebarContent();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
62
73
|
children: /*#__PURE__*/_jsxs(Columns, {
|
|
63
74
|
align: "center",
|
|
64
75
|
space: "xsmall",
|
|
@@ -35,6 +35,7 @@ export var SidebarMenuItemAvatar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
35
35
|
color: "primary",
|
|
36
36
|
checked: value,
|
|
37
37
|
disabled: disabled,
|
|
38
|
+
onClick: stopPropagation,
|
|
38
39
|
onMouseDown: stopPropagation,
|
|
39
40
|
onTouchStart: stopPropagation,
|
|
40
41
|
onChange: (_, checked) => {
|