@superdispatch/ui-lab 0.18.3 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-node/index.js +323 -18
- package/dist-node/index.js.map +1 -1
- package/dist-src/index.js +4 -0
- package/dist-src/multiline-text/MultilineText.js +11 -0
- package/dist-src/navbar/NavbarAccordion.js +97 -0
- package/dist-src/navbar/NavbarItem.js +4 -2
- package/dist-src/navbar/NavbarList.js +11 -1
- 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 +325 -25
- package/dist-web/index.js.map +1 -1
- package/package.json +3 -3
package/dist-web/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { CheckCircle, Info, Error, Image, Refresh, Delete, Menu, MenuOpen, OpenInNew } from '@material-ui/icons';
|
|
1
|
+
import { CheckCircle, Info, Error as Error$1, Image, Refresh, Delete, Menu, ExpandMore, MenuOpen, ArrowBack, OpenInNew } from '@material-ui/icons';
|
|
2
2
|
import { Alert as Alert$1 } from '@material-ui/lab';
|
|
3
|
-
import { Color, parseResponsiveProp, isColorProp, parseSpaceProp, Stack, mergeRefs, useUID, isEmptyReactNode, Columns, Column, Inline, CardButton, useResponsiveValue } from '@superdispatch/ui';
|
|
3
|
+
import { Color, parseResponsiveProp, isColorProp, parseSpaceProp, Stack, mergeRefs, useUID, isEmptyReactNode, Columns, Column, Inline, CardButton, useResponsiveValue, useCollapseBreakpoint } from '@superdispatch/ui';
|
|
4
4
|
import { forwardRef, useState, useEffect, useRef, useLayoutEffect, Suspense, memo, useContext, createContext, useMemo, createElement } from 'react';
|
|
5
5
|
import styled, { css, keyframes } from 'styled-components';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
8
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
9
9
|
import { CSSTransition } from 'react-transition-group';
|
|
10
|
-
import { ButtonBase, Typography, CircularProgress, SvgIcon, Link, Tooltip, IconButton, BottomNavigation, BottomNavigationAction, useTheme, useMediaQuery, Drawer, Avatar, MenuItem, Menu as Menu$1, Divider as Divider$1, Checkbox } from '@material-ui/core';
|
|
10
|
+
import { ButtonBase, Typography, CircularProgress, SvgIcon, Link, Tooltip, IconButton, BottomNavigation, BottomNavigationAction, AccordionSummary, Accordion, useTheme, useMediaQuery, Drawer, Avatar, MenuItem, Menu as Menu$1, Toolbar, AppBar, Divider as Divider$1, Checkbox } from '@material-ui/core';
|
|
11
11
|
import { mdiUpload, mdiFilePdfBox, mdiTextBox } from '@mdi/js';
|
|
12
12
|
import Dropzone from 'react-dropzone';
|
|
13
|
+
import { Anchorme } from 'react-anchorme';
|
|
13
14
|
import { noop } from 'lodash';
|
|
14
15
|
|
|
15
16
|
function colorMixin(textColor, backgroundColor, buttonHoverColor) {
|
|
@@ -28,7 +29,7 @@ function toMaterialSeverity(severity) {
|
|
|
28
29
|
var iconMapping = {
|
|
29
30
|
success: /*#__PURE__*/jsx(CheckCircle, {}),
|
|
30
31
|
info: /*#__PURE__*/jsx(Info, {}),
|
|
31
|
-
error: /*#__PURE__*/jsx(Error, {})
|
|
32
|
+
error: /*#__PURE__*/jsx(Error$1, {})
|
|
32
33
|
};
|
|
33
34
|
var Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
34
35
|
var {
|
|
@@ -806,7 +807,7 @@ function UploadRejection(_ref2) {
|
|
|
806
807
|
align: "center",
|
|
807
808
|
children: [/*#__PURE__*/jsx(Column, {
|
|
808
809
|
width: "content",
|
|
809
|
-
children: /*#__PURE__*/jsx(Error, {})
|
|
810
|
+
children: /*#__PURE__*/jsx(Error$1, {})
|
|
810
811
|
}), /*#__PURE__*/jsx(Column, {
|
|
811
812
|
children: error.code === 'file-too-large' ? maxSize == null ? 'Attachment size is too large' : "Attachment size should be less than ".concat(formatBytes(maxSize)) : error.message
|
|
812
813
|
})]
|
|
@@ -941,7 +942,7 @@ var FileListItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
941
942
|
space: "xsmall",
|
|
942
943
|
children: [/*#__PURE__*/jsx(Column, {
|
|
943
944
|
width: "content",
|
|
944
|
-
children: status === 'error' ? /*#__PURE__*/jsx(Error, {
|
|
945
|
+
children: status === 'error' ? /*#__PURE__*/jsx(Error$1, {
|
|
945
946
|
color: "error",
|
|
946
947
|
fontSize: "small"
|
|
947
948
|
}) : fileType === 'pdf' ? /*#__PURE__*/jsx(PdfIcon, {
|
|
@@ -1005,6 +1006,52 @@ var FileListItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
1005
1006
|
});
|
|
1006
1007
|
if (process.env.NODE_ENV !== "production") FileListItem.displayName = "FileListItem";
|
|
1007
1008
|
|
|
1009
|
+
var _excluded$6 = ["color", "target", "rel"],
|
|
1010
|
+
_excluded2$2 = ["children", "linkComponent"];
|
|
1011
|
+
var DefaultLinkComponent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
1012
|
+
var {
|
|
1013
|
+
color,
|
|
1014
|
+
target = '_blank',
|
|
1015
|
+
rel = 'noreferrer noopener'
|
|
1016
|
+
} = _ref,
|
|
1017
|
+
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
1018
|
+
|
|
1019
|
+
return /*#__PURE__*/jsx(Link, _objectSpread(_objectSpread({}, props), {}, {
|
|
1020
|
+
ref: ref,
|
|
1021
|
+
rel: rel,
|
|
1022
|
+
target: target
|
|
1023
|
+
}));
|
|
1024
|
+
});
|
|
1025
|
+
if (process.env.NODE_ENV !== "production") DefaultLinkComponent.displayName = "DefaultLinkComponent";
|
|
1026
|
+
DefaultLinkComponent.displayName = 'DefaultLinkComponent';
|
|
1027
|
+
function LinkedText(_ref2) {
|
|
1028
|
+
var {
|
|
1029
|
+
children,
|
|
1030
|
+
linkComponent = DefaultLinkComponent
|
|
1031
|
+
} = _ref2,
|
|
1032
|
+
props = _objectWithoutProperties(_ref2, _excluded2$2);
|
|
1033
|
+
|
|
1034
|
+
if (!children) {
|
|
1035
|
+
return null;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
return /*#__PURE__*/jsx(Anchorme, _objectSpread(_objectSpread({}, props), {}, {
|
|
1039
|
+
linkComponent: linkComponent,
|
|
1040
|
+
children: children
|
|
1041
|
+
}));
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
var MultilineText = /*#__PURE__*/styled.span.withConfig({
|
|
1045
|
+
displayName: "MultilineText",
|
|
1046
|
+
componentId: "SD__sc-34heyp-0"
|
|
1047
|
+
})(["white-space:pre-wrap;overflow-wrap:", ";"], _ref => {
|
|
1048
|
+
var {
|
|
1049
|
+
overflowWrap = 'normal'
|
|
1050
|
+
} = _ref;
|
|
1051
|
+
return overflowWrap;
|
|
1052
|
+
});
|
|
1053
|
+
MultilineText.displayName = 'MultilineText';
|
|
1054
|
+
|
|
1008
1055
|
var NavbarContext = /*#__PURE__*/createContext({
|
|
1009
1056
|
isDrawerOpen: false,
|
|
1010
1057
|
isExpanded: false,
|
|
@@ -1083,7 +1130,7 @@ var NavbarLabel = /*#__PURE__*/styled.span.withConfig({
|
|
|
1083
1130
|
var NavbarItemRoot = /*#__PURE__*/styled.div.withConfig({
|
|
1084
1131
|
displayName: "NavbarItem__NavbarItemRoot",
|
|
1085
1132
|
componentId: "SD__sc-1pvzq3w-2"
|
|
1086
|
-
})(["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);
|
|
1133
|
+
})(["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);
|
|
1087
1134
|
var IconWrapper$1 = /*#__PURE__*/styled.div.withConfig({
|
|
1088
1135
|
displayName: "NavbarItem__IconWrapper",
|
|
1089
1136
|
componentId: "SD__sc-1pvzq3w-3"
|
|
@@ -1097,13 +1144,15 @@ function NavbarItem(_ref) {
|
|
|
1097
1144
|
component,
|
|
1098
1145
|
onClick,
|
|
1099
1146
|
variant,
|
|
1100
|
-
ident = 0
|
|
1147
|
+
ident = 0,
|
|
1148
|
+
active
|
|
1101
1149
|
} = _ref;
|
|
1102
1150
|
var uid = useUID();
|
|
1103
1151
|
return /*#__PURE__*/jsxs(NavbarItemRoot, {
|
|
1104
1152
|
as: component,
|
|
1105
1153
|
onClick: onClick,
|
|
1106
1154
|
"aria-labelledby": uid,
|
|
1155
|
+
"data-active": active,
|
|
1107
1156
|
style: {
|
|
1108
1157
|
marginTop: gutter ? '16px' : '0',
|
|
1109
1158
|
paddingLeft: (ident + 1) * 20
|
|
@@ -1120,6 +1169,93 @@ function NavbarItem(_ref) {
|
|
|
1120
1169
|
});
|
|
1121
1170
|
}
|
|
1122
1171
|
|
|
1172
|
+
var NavbarAccordionLabel = /*#__PURE__*/styled.span.withConfig({
|
|
1173
|
+
displayName: "NavbarAccordion__NavbarAccordionLabel",
|
|
1174
|
+
componentId: "SD__sc-1s7g3kw-0"
|
|
1175
|
+
})(["flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;&[data-expanded='false']{display:none;}"]);
|
|
1176
|
+
var NavbarAccordionRoot = /*#__PURE__*/styled(Accordion).withConfig({
|
|
1177
|
+
displayName: "NavbarAccordion__NavbarAccordionRoot",
|
|
1178
|
+
componentId: "SD__sc-1s7g3kw-1"
|
|
1179
|
+
})(_ref => {
|
|
1180
|
+
var {
|
|
1181
|
+
gutter
|
|
1182
|
+
} = _ref;
|
|
1183
|
+
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');
|
|
1184
|
+
});
|
|
1185
|
+
var NavbarAccordionSummary = /*#__PURE__*/styled(AccordionSummary).withConfig({
|
|
1186
|
+
displayName: "NavbarAccordion__NavbarAccordionSummary",
|
|
1187
|
+
componentId: "SD__sc-1s7g3kw-2"
|
|
1188
|
+
})(["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);
|
|
1189
|
+
var IconWrapper$2 = /*#__PURE__*/styled.div.withConfig({
|
|
1190
|
+
displayName: "NavbarAccordion__IconWrapper",
|
|
1191
|
+
componentId: "SD__sc-1s7g3kw-3"
|
|
1192
|
+
})(["width:24px;margin-right:8px;& svg{font-size:24px;}"]);
|
|
1193
|
+
function NavbarAccordion(_ref2) {
|
|
1194
|
+
var {
|
|
1195
|
+
label,
|
|
1196
|
+
icon,
|
|
1197
|
+
gutter,
|
|
1198
|
+
items,
|
|
1199
|
+
onClick: _onClick
|
|
1200
|
+
} = _ref2;
|
|
1201
|
+
var uid = useUID();
|
|
1202
|
+
var {
|
|
1203
|
+
isExpanded: isMenuExpanded,
|
|
1204
|
+
isDrawerOpen,
|
|
1205
|
+
setDrawerOpen
|
|
1206
|
+
} = useNavbarContext();
|
|
1207
|
+
var [isExpanded, setExpanded] = useState(false);
|
|
1208
|
+
useEffect(() => {
|
|
1209
|
+
if (!isMenuExpanded) {
|
|
1210
|
+
setExpanded(false);
|
|
1211
|
+
}
|
|
1212
|
+
}, [isMenuExpanded]);
|
|
1213
|
+
return /*#__PURE__*/jsxs(NavbarAccordionRoot, {
|
|
1214
|
+
"aria-labelledby": uid,
|
|
1215
|
+
gutter: !!gutter,
|
|
1216
|
+
expanded: isExpanded,
|
|
1217
|
+
onClick: event => {
|
|
1218
|
+
if (isMenuExpanded || isDrawerOpen) {
|
|
1219
|
+
setExpanded(!isExpanded);
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
_onClick(event);
|
|
1223
|
+
},
|
|
1224
|
+
square: true,
|
|
1225
|
+
children: [/*#__PURE__*/jsxs(NavbarAccordionSummary, {
|
|
1226
|
+
"data-active": !isExpanded && items.some(item => item.active),
|
|
1227
|
+
"data-expanded": isMenuExpanded || isDrawerOpen,
|
|
1228
|
+
expandIcon: /*#__PURE__*/jsx(ExpandMore, {}),
|
|
1229
|
+
children: [/*#__PURE__*/jsx(IconWrapper$2, {
|
|
1230
|
+
children: icon
|
|
1231
|
+
}), /*#__PURE__*/jsx(NavbarAccordionLabel, {
|
|
1232
|
+
id: uid,
|
|
1233
|
+
"data-expanded": isMenuExpanded || isDrawerOpen,
|
|
1234
|
+
children: label
|
|
1235
|
+
})]
|
|
1236
|
+
}), items.map(item => {
|
|
1237
|
+
var index = items.indexOf(item);
|
|
1238
|
+
var prev = items[index - 1];
|
|
1239
|
+
return /*#__PURE__*/createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
1240
|
+
key: item.key,
|
|
1241
|
+
ident: 1,
|
|
1242
|
+
active: item.active,
|
|
1243
|
+
gutter: prev && prev.groupKey !== item.groupKey,
|
|
1244
|
+
onClick: event => {
|
|
1245
|
+
var _item$onClick;
|
|
1246
|
+
|
|
1247
|
+
event.stopPropagation();
|
|
1248
|
+
(_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
|
|
1249
|
+
|
|
1250
|
+
if (!event.isDefaultPrevented()) {
|
|
1251
|
+
setDrawerOpen(false);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}));
|
|
1255
|
+
})]
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1123
1259
|
var Header = /*#__PURE__*/styled.div.withConfig({
|
|
1124
1260
|
displayName: "NavbarList__Header",
|
|
1125
1261
|
componentId: "SD__sc-19zrmxc-0"
|
|
@@ -1177,7 +1313,7 @@ function NavbarMenuItem(_ref4) {
|
|
|
1177
1313
|
var Content = /*#__PURE__*/styled.div.withConfig({
|
|
1178
1314
|
displayName: "NavbarList__Content",
|
|
1179
1315
|
componentId: "SD__sc-19zrmxc-5"
|
|
1180
|
-
})(["height:100%;min-height:50px;overflow:
|
|
1316
|
+
})(["height:100%;min-height:50px;overflow-y:auto;overflow-x:hidden;&[aria-expanded='false']{", ",", "{display:none;}}"], NavbarBadge, NavbarLabel);
|
|
1181
1317
|
function NavbarList(_ref5) {
|
|
1182
1318
|
var {
|
|
1183
1319
|
header,
|
|
@@ -1217,6 +1353,15 @@ function NavbarList(_ref5) {
|
|
|
1217
1353
|
children: filteredItems.map(item => {
|
|
1218
1354
|
var index = filteredItems.indexOf(item);
|
|
1219
1355
|
var prev = filteredItems[index - 1];
|
|
1356
|
+
|
|
1357
|
+
if ('items' in item) {
|
|
1358
|
+
return /*#__PURE__*/createElement(NavbarAccordion, _objectSpread(_objectSpread({}, item), {}, {
|
|
1359
|
+
key: item.key,
|
|
1360
|
+
gutter: prev && prev.groupKey !== item.groupKey,
|
|
1361
|
+
onClick: item.onClick
|
|
1362
|
+
}));
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1220
1365
|
return /*#__PURE__*/createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
1221
1366
|
key: item.key,
|
|
1222
1367
|
gutter: prev && prev.groupKey !== item.groupKey,
|
|
@@ -1311,7 +1456,7 @@ function Navbar(_ref) {
|
|
|
1311
1456
|
});
|
|
1312
1457
|
}
|
|
1313
1458
|
|
|
1314
|
-
var _excluded$
|
|
1459
|
+
var _excluded$7 = ["title", "subtitle", "children"];
|
|
1315
1460
|
var StyledTypography = /*#__PURE__*/styled(Typography).withConfig({
|
|
1316
1461
|
displayName: "NavbarAvatar__StyledTypography",
|
|
1317
1462
|
componentId: "SD__sc-19q2zd0-0"
|
|
@@ -1322,7 +1467,7 @@ function NavbarAvatar(_ref) {
|
|
|
1322
1467
|
subtitle,
|
|
1323
1468
|
children
|
|
1324
1469
|
} = _ref,
|
|
1325
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1470
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
1326
1471
|
|
|
1327
1472
|
var {
|
|
1328
1473
|
isExpanded,
|
|
@@ -1434,7 +1579,7 @@ function NavbarMenu(_ref2) {
|
|
|
1434
1579
|
var SidebarRoot = /*#__PURE__*/styled.aside.withConfig({
|
|
1435
1580
|
displayName: "Sidebar__SidebarRoot",
|
|
1436
1581
|
componentId: "SD__sc-b77o22-0"
|
|
1437
|
-
})(["top:0;position:sticky;overflow-y:auto;overflow-x:hidden;
|
|
1582
|
+
})(["top:0;position:sticky;overflow-y:auto;overflow-x:hidden;height:100vh;background-color:", ";border-right:1px solid ", ";"], Color.White, Color.Silver400);
|
|
1438
1583
|
var SidebarHeader = /*#__PURE__*/styled.div.withConfig({
|
|
1439
1584
|
displayName: "Sidebar__SidebarHeader",
|
|
1440
1585
|
componentId: "SD__sc-b77o22-1"
|
|
@@ -1486,28 +1631,172 @@ var Sidebar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
1486
1631
|
});
|
|
1487
1632
|
if (process.env.NODE_ENV !== "production") Sidebar.displayName = "Sidebar";
|
|
1488
1633
|
|
|
1489
|
-
var
|
|
1490
|
-
|
|
1634
|
+
var Context = /*#__PURE__*/createContext(null);
|
|
1635
|
+
function useSidebarContext() {
|
|
1636
|
+
var context = useContext(Context);
|
|
1637
|
+
|
|
1638
|
+
if (!context) {
|
|
1639
|
+
throw new Error('SidebarContext is used outside Provider');
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
return context;
|
|
1643
|
+
}
|
|
1644
|
+
var SidebarContainerSidebar = /*#__PURE__*/styled.div.withConfig({
|
|
1645
|
+
displayName: "SidebarContainer__SidebarContainerSidebar",
|
|
1491
1646
|
componentId: "SD__sc-uibj1m-0"
|
|
1492
|
-
})(["
|
|
1647
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;width:240px;"]);
|
|
1493
1648
|
var SidebarContainerContent = /*#__PURE__*/styled.div.withConfig({
|
|
1494
1649
|
displayName: "SidebarContainer__SidebarContainerContent",
|
|
1495
1650
|
componentId: "SD__sc-uibj1m-1"
|
|
1496
|
-
})(["height:inherit;max-height:inherit;min-height:inherit;
|
|
1651
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;"]);
|
|
1652
|
+
var SidebarContainerRoot = /*#__PURE__*/styled.div.withConfig({
|
|
1653
|
+
displayName: "SidebarContainer__SidebarContainerRoot",
|
|
1654
|
+
componentId: "SD__sc-uibj1m-2"
|
|
1655
|
+
})(["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);
|
|
1497
1656
|
var SidebarContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
1498
1657
|
var {
|
|
1499
1658
|
sidebar,
|
|
1500
1659
|
children
|
|
1501
1660
|
} = _ref;
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1661
|
+
var isCollapsed = useCollapseBreakpoint('sm');
|
|
1662
|
+
var [visibilityState, setVisibilityState] = useState('sidebar');
|
|
1663
|
+
var visibility = isCollapsed ? visibilityState : 'both';
|
|
1664
|
+
var context = useMemo(() => {
|
|
1665
|
+
return {
|
|
1666
|
+
openSidebar: () => {
|
|
1667
|
+
setVisibilityState('sidebar');
|
|
1668
|
+
},
|
|
1669
|
+
openSidebarContent: () => {
|
|
1670
|
+
setVisibilityState('content');
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
}, []);
|
|
1674
|
+
return /*#__PURE__*/jsx(Context.Provider, {
|
|
1675
|
+
value: context,
|
|
1676
|
+
children: /*#__PURE__*/jsxs(SidebarContainerRoot, {
|
|
1677
|
+
ref: ref,
|
|
1678
|
+
"data-visibility": visibility,
|
|
1679
|
+
children: [/*#__PURE__*/jsx(SidebarContainerSidebar, {
|
|
1680
|
+
children: sidebar
|
|
1681
|
+
}), /*#__PURE__*/jsx(SidebarContainerContent, {
|
|
1682
|
+
children: children
|
|
1683
|
+
})]
|
|
1684
|
+
})
|
|
1507
1685
|
});
|
|
1508
1686
|
});
|
|
1509
1687
|
if (process.env.NODE_ENV !== "production") SidebarContainer.displayName = "SidebarContainer";
|
|
1510
1688
|
|
|
1689
|
+
var _excluded$8 = ["onClick", "children"];
|
|
1690
|
+
function SidebarBackButton(_ref) {
|
|
1691
|
+
var {
|
|
1692
|
+
onClick: _onClick,
|
|
1693
|
+
children = /*#__PURE__*/jsx(ArrowBack, {
|
|
1694
|
+
fontSize: "small"
|
|
1695
|
+
})
|
|
1696
|
+
} = _ref,
|
|
1697
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
1698
|
+
|
|
1699
|
+
var isCollapsed = useCollapseBreakpoint('sm');
|
|
1700
|
+
var {
|
|
1701
|
+
openSidebar
|
|
1702
|
+
} = useSidebarContext();
|
|
1703
|
+
|
|
1704
|
+
if (!isCollapsed) {
|
|
1705
|
+
return null;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
return /*#__PURE__*/jsx(IconButton, _objectSpread(_objectSpread({}, props), {}, {
|
|
1709
|
+
size: "small",
|
|
1710
|
+
onClick: event => {
|
|
1711
|
+
_onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
1712
|
+
|
|
1713
|
+
if (!event.isDefaultPrevented()) {
|
|
1714
|
+
openSidebar();
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
children: children
|
|
1718
|
+
}));
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
var SidebarAppBar = /*#__PURE__*/styled(AppBar).withConfig({
|
|
1722
|
+
displayName: "SidebarContent__SidebarAppBar",
|
|
1723
|
+
componentId: "SD__sc-zpgf61-0"
|
|
1724
|
+
})(_ref => {
|
|
1725
|
+
var {
|
|
1726
|
+
theme
|
|
1727
|
+
} = _ref;
|
|
1728
|
+
return css(["", "{&&{border-left:transparent;}}"], theme.breakpoints.up('sm'));
|
|
1729
|
+
});
|
|
1730
|
+
function SidebarContent(_ref2) {
|
|
1731
|
+
var {
|
|
1732
|
+
dense,
|
|
1733
|
+
action,
|
|
1734
|
+
title,
|
|
1735
|
+
children,
|
|
1736
|
+
onBack,
|
|
1737
|
+
openOnMount,
|
|
1738
|
+
closeOnUnmount
|
|
1739
|
+
} = _ref2;
|
|
1740
|
+
var isOpenedOnMount = useRef(false);
|
|
1741
|
+
var isClosedOnMount = useRef(false);
|
|
1742
|
+
var {
|
|
1743
|
+
openSidebarContent,
|
|
1744
|
+
openSidebar
|
|
1745
|
+
} = useSidebarContext();
|
|
1746
|
+
useLayoutEffect(() => {
|
|
1747
|
+
if (openOnMount) {
|
|
1748
|
+
if (isOpenedOnMount.current) {
|
|
1749
|
+
// eslint-disable-next-line no-console
|
|
1750
|
+
console.warn('[SidebarContent]: "openOnMount" should not change during lifecycle of the component.');
|
|
1751
|
+
} else {
|
|
1752
|
+
isOpenedOnMount.current = true;
|
|
1753
|
+
openSidebarContent();
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}, [openOnMount, openSidebarContent]);
|
|
1757
|
+
useLayoutEffect(() => {
|
|
1758
|
+
return () => {
|
|
1759
|
+
if (closeOnUnmount) {
|
|
1760
|
+
if (isClosedOnMount.current) {
|
|
1761
|
+
// eslint-disable-next-line no-console
|
|
1762
|
+
console.warn('[SidebarContent]: "closeOnUnmount" should not change during lifecycle of the component.');
|
|
1763
|
+
} else {
|
|
1764
|
+
isClosedOnMount.current = true;
|
|
1765
|
+
openSidebar();
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
}, [openSidebar, closeOnUnmount]);
|
|
1770
|
+
return /*#__PURE__*/jsxs(Stack, {
|
|
1771
|
+
space: "none",
|
|
1772
|
+
children: [/*#__PURE__*/jsx(SidebarAppBar, {
|
|
1773
|
+
children: /*#__PURE__*/jsx(Toolbar, {
|
|
1774
|
+
children: /*#__PURE__*/jsxs(Columns, {
|
|
1775
|
+
align: "center",
|
|
1776
|
+
space: "small",
|
|
1777
|
+
children: [/*#__PURE__*/jsx(Column, {
|
|
1778
|
+
width: "content",
|
|
1779
|
+
children: /*#__PURE__*/jsx(SidebarBackButton, {
|
|
1780
|
+
onClick: onBack
|
|
1781
|
+
})
|
|
1782
|
+
}), /*#__PURE__*/jsx(Column, {
|
|
1783
|
+
children: /*#__PURE__*/jsx(TextBox, {
|
|
1784
|
+
variant: "heading-2",
|
|
1785
|
+
children: title
|
|
1786
|
+
})
|
|
1787
|
+
}), /*#__PURE__*/jsx(Column, {
|
|
1788
|
+
width: "content",
|
|
1789
|
+
children: action
|
|
1790
|
+
})]
|
|
1791
|
+
})
|
|
1792
|
+
})
|
|
1793
|
+
}), /*#__PURE__*/jsx(Box, {
|
|
1794
|
+
padding: dense ? 'none' : ['small', 'medium'],
|
|
1795
|
+
children: children
|
|
1796
|
+
})]
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1511
1800
|
var SidebarDividerRoot = /*#__PURE__*/styled.div.withConfig({
|
|
1512
1801
|
displayName: "SidebarDivider__SidebarDividerRoot",
|
|
1513
1802
|
componentId: "SD__sc-5lwi2i-0"
|
|
@@ -1562,17 +1851,21 @@ var SidebarMenuItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
1562
1851
|
var {
|
|
1563
1852
|
action,
|
|
1564
1853
|
avatar,
|
|
1565
|
-
onClick,
|
|
1854
|
+
onClick: _onClick,
|
|
1566
1855
|
external,
|
|
1567
1856
|
children,
|
|
1568
1857
|
disabled,
|
|
1569
1858
|
selected,
|
|
1570
1859
|
secondaryActions,
|
|
1571
|
-
badge: badgeProp
|
|
1860
|
+
badge: badgeProp,
|
|
1861
|
+
openContentOnClick
|
|
1572
1862
|
} = _ref2;
|
|
1573
1863
|
var [hovered, setHovered] = useState(false);
|
|
1574
1864
|
var actionsRef = useRef(null);
|
|
1575
1865
|
var actionsPlaceholderRef = useRef(null);
|
|
1866
|
+
var {
|
|
1867
|
+
openSidebarContent
|
|
1868
|
+
} = useSidebarContext();
|
|
1576
1869
|
useLayoutEffect(() => {
|
|
1577
1870
|
if (actionsRef.current && actionsPlaceholderRef.current) {
|
|
1578
1871
|
actionsPlaceholderRef.current.style.width = "".concat(Math.max(0, actionsRef.current.offsetWidth - 8), "px");
|
|
@@ -1589,9 +1882,15 @@ var SidebarMenuItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
1589
1882
|
setHovered(false);
|
|
1590
1883
|
},
|
|
1591
1884
|
children: [/*#__PURE__*/jsx(ButtonBase, {
|
|
1592
|
-
onClick: onClick,
|
|
1593
1885
|
disabled: disabled,
|
|
1594
1886
|
"aria-current": selected,
|
|
1887
|
+
onClick: event => {
|
|
1888
|
+
_onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
1889
|
+
|
|
1890
|
+
if (!event.isDefaultPrevented() && openContentOnClick) {
|
|
1891
|
+
openSidebarContent();
|
|
1892
|
+
}
|
|
1893
|
+
},
|
|
1595
1894
|
children: /*#__PURE__*/jsxs(Columns, {
|
|
1596
1895
|
align: "center",
|
|
1597
1896
|
space: "xsmall",
|
|
@@ -1704,6 +2003,7 @@ var SidebarMenuItemAvatar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
1704
2003
|
color: "primary",
|
|
1705
2004
|
checked: value,
|
|
1706
2005
|
disabled: disabled,
|
|
2006
|
+
onClick: stopPropagation,
|
|
1707
2007
|
onMouseDown: stopPropagation,
|
|
1708
2008
|
onTouchStart: stopPropagation,
|
|
1709
2009
|
onChange: (_, checked) => {
|
|
@@ -1753,5 +2053,5 @@ var SidebarSubheader = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
1753
2053
|
});
|
|
1754
2054
|
if (process.env.NODE_ENV !== "production") SidebarSubheader.displayName = "SidebarSubheader";
|
|
1755
2055
|
|
|
1756
|
-
export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, Container, DescriptionItem, FileDropZone, FileListItem, Navbar, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarItem, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, Sidebar, SidebarContainer, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes, useNavbarContext };
|
|
2056
|
+
export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, Container, DescriptionItem, FileDropZone, FileListItem, LinkedText, MultilineText, Navbar, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarItem, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, Sidebar, SidebarBackButton, SidebarContainer, SidebarContent, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes, useNavbarContext, useSidebarContext };
|
|
1757
2057
|
//# sourceMappingURL=index.js.map
|