@superdispatch/ui-lab 0.17.1 → 0.18.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-web/index.js CHANGED
@@ -1,15 +1,16 @@
1
- import { CheckCircle, Info, Error, Image, Refresh, Delete, OpenInNew } from '@material-ui/icons';
1
+ import { CheckCircle, Info, Error, Image, Refresh, Delete, Menu, MenuOpen, MoreHoriz, OpenInNew } from '@material-ui/icons';
2
2
  import { Alert as Alert$1 } from '@material-ui/lab';
3
- import { Color, parseResponsiveProp, isColorProp, parseSpaceProp, Stack, useUID, isEmptyReactNode, Columns, Column, Inline, CardButton, useResponsiveValue } from '@superdispatch/ui';
4
- import { forwardRef, useState, useEffect, Suspense, memo, useContext, createContext, useMemo, useRef, useLayoutEffect } from 'react';
3
+ import { Color, parseResponsiveProp, isColorProp, parseSpaceProp, Stack, mergeRefs, useUID, isEmptyReactNode, Columns, Column, Inline, CardButton, useResponsiveValue, AdaptiveVerticalToolbar } from '@superdispatch/ui';
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, Divider, Checkbox, Avatar } from '@material-ui/core';
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';
11
11
  import { mdiUpload, mdiFilePdfBox, mdiTextBox } from '@mdi/js';
12
12
  import Dropzone from 'react-dropzone';
13
+ import { noop } from 'lodash';
13
14
 
14
15
  function colorMixin(textColor, backgroundColor, buttonHoverColor) {
15
16
  return css(["color:", ";background-color:", ";& .MuiAlert-icon{color:", ";}& .MuiAlert-action{& .MuiIconButton-root{&:hover,&:active{color:", ";}}}"], textColor, backgroundColor, textColor, buttonHoverColor);
@@ -521,6 +522,45 @@ var AnchorButton = /*#__PURE__*/forwardRef((_ref5, ref) => {
521
522
  });
522
523
  if (process.env.NODE_ENV !== "production") AnchorButton.displayName = "AnchorButton";
523
524
 
525
+ var _excluded$3 = ["fullViewportHeight"];
526
+ var Container = /*#__PURE__*/forwardRef((_ref, ref) => {
527
+ var {
528
+ fullViewportHeight
529
+ } = _ref,
530
+ props = _objectWithoutProperties(_ref, _excluded$3);
531
+
532
+ var nodeRef = useRef(null);
533
+ useLayoutEffect(() => {
534
+ if (!fullViewportHeight) {
535
+ if (nodeRef.current) {
536
+ nodeRef.current.style.removeProperty('height');
537
+ nodeRef.current.style.removeProperty('--vh');
538
+ }
539
+
540
+ return;
541
+ }
542
+
543
+ function updateHeight() {
544
+ if (nodeRef.current) {
545
+ // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
546
+ nodeRef.current.style.setProperty('height', 'calc(var(--vh, 1vh) * 100)');
547
+ nodeRef.current.style.setProperty('--vh', "".concat(window.innerHeight * 0.01, "px"));
548
+ }
549
+ }
550
+
551
+ updateHeight();
552
+ window.addEventListener('resize', updateHeight);
553
+ return () => {
554
+ window.removeEventListener('resize', updateHeight);
555
+ };
556
+ }, [fullViewportHeight]);
557
+ return /*#__PURE__*/jsx("div", _objectSpread({
558
+ ref: mergeRefs(ref, nodeRef)
559
+ }, props));
560
+ });
561
+ if (process.env.NODE_ENV !== "production") Container.displayName = "Container";
562
+ Container.displayName = 'Container';
563
+
524
564
  function mergeStyles(styles) {
525
565
  for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
526
566
  sources[_key - 1] = arguments[_key];
@@ -546,7 +586,7 @@ function mergeStyles(styles) {
546
586
  return styles;
547
587
  }
548
588
 
549
- var _excluded$3 = ["variant", "as", "align", "color", "display", "noWrap", "wrapOverflow"];
589
+ var _excluded$4 = ["variant", "as", "align", "color", "display", "noWrap", "wrapOverflow"];
550
590
  var normalizeTextColor = /*#__PURE__*/createRuleNormalizer({
551
591
  inherit: 'inherit',
552
592
  primary: Color.Dark500,
@@ -648,7 +688,7 @@ var TextBox = /*#__PURE__*/forwardRef((_ref3, ref) => {
648
688
  noWrap = false,
649
689
  wrapOverflow = false
650
690
  } = _ref3,
651
- props = _objectWithoutProperties(_ref3, _excluded$3);
691
+ props = _objectWithoutProperties(_ref3, _excluded$4);
652
692
 
653
693
  var $align = parseResponsiveProp(align);
654
694
  var $color = parseResponsiveProp(color);
@@ -729,7 +769,7 @@ var DescriptionItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
729
769
  });
730
770
  if (process.env.NODE_ENV !== "production") DescriptionItem.displayName = "DescriptionItem";
731
771
 
732
- var _excluded$4 = ["disabled", "children", "hintText", "startIcon", "fallback", "accept", "maxSize", "maxFiles", "onDropRejected", "onDropAccepted"];
772
+ var _excluded$5 = ["disabled", "children", "hintText", "startIcon", "fallback", "accept", "maxSize", "maxFiles", "onDropRejected", "onDropAccepted"];
733
773
  function toBytes(input, unit) {
734
774
  if (unit === 'gb') return input * (1 << 30);
735
775
  if (unit === 'mb') return input * (1 << 20);
@@ -800,7 +840,7 @@ var FileDropZone = /*#__PURE__*/forwardRef((props, ref) => {
800
840
  onDropRejected: _onDropRejected,
801
841
  onDropAccepted: _onDropAccepted
802
842
  } = props,
803
- dropzoneProps = _objectWithoutProperties(props, _excluded$4);
843
+ dropzoneProps = _objectWithoutProperties(props, _excluded$5);
804
844
 
805
845
  return /*#__PURE__*/jsx(Suspense, {
806
846
  fallback: fallback,
@@ -965,6 +1005,449 @@ var FileListItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
965
1005
  });
966
1006
  if (process.env.NODE_ENV !== "production") FileListItem.displayName = "FileListItem";
967
1007
 
1008
+ var NavbarContext = /*#__PURE__*/createContext({
1009
+ isDrawerOpen: false,
1010
+ isExpanded: false,
1011
+ setIsExpanded: noop,
1012
+ setDrawerOpen: noop
1013
+ });
1014
+ function useNavbarContext() {
1015
+ return useContext(NavbarContext);
1016
+ }
1017
+
1018
+ var StyledBottomNavigation = /*#__PURE__*/styled(BottomNavigation).withConfig({
1019
+ displayName: "NavbarBottomBar__StyledBottomNavigation",
1020
+ componentId: "SD__sc-9z6v3k-0"
1021
+ })(["background:", ";"], Color.Dark500);
1022
+ var StyledBottomNavigationAction = /*#__PURE__*/styled(BottomNavigationAction).withConfig({
1023
+ displayName: "NavbarBottomBar__StyledBottomNavigationAction",
1024
+ componentId: "SD__sc-9z6v3k-1"
1025
+ })(["&&{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);
1026
+ var IconWrapper = /*#__PURE__*/styled.div.withConfig({
1027
+ displayName: "NavbarBottomBar__IconWrapper",
1028
+ componentId: "SD__sc-9z6v3k-2"
1029
+ })(["position:relative;"]);
1030
+ var IconLabel = /*#__PURE__*/styled.div.withConfig({
1031
+ displayName: "NavbarBottomBar__IconLabel",
1032
+ componentId: "SD__sc-9z6v3k-3"
1033
+ })(["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);
1034
+ function NavbarBottomBar(_ref) {
1035
+ var {
1036
+ items,
1037
+ hasMenuBadge
1038
+ } = _ref;
1039
+ var {
1040
+ isDrawerOpen,
1041
+ setDrawerOpen
1042
+ } = useNavbarContext();
1043
+ var activeItem = useMemo(() => items.find(item => item.active), [items]);
1044
+ return /*#__PURE__*/jsxs(StyledBottomNavigation, {
1045
+ value: activeItem === null || activeItem === void 0 ? void 0 : activeItem.value,
1046
+ showLabels: true,
1047
+ onChange: (_event, newValue) => {
1048
+ if (newValue) {
1049
+ if (newValue === 'menu') {
1050
+ setDrawerOpen(!isDrawerOpen);
1051
+ } else {
1052
+ setDrawerOpen(false);
1053
+ }
1054
+ }
1055
+ },
1056
+ children: [items.map(item => /*#__PURE__*/createElement(StyledBottomNavigationAction, _objectSpread(_objectSpread({}, item), {}, {
1057
+ key: item.value,
1058
+ icon: item.hasBadge ? /*#__PURE__*/jsxs(IconWrapper, {
1059
+ children: [/*#__PURE__*/jsx(IconLabel, {}), item.icon]
1060
+ }) : item.icon
1061
+ }))), /*#__PURE__*/jsx(StyledBottomNavigationAction, {
1062
+ value: "menu",
1063
+ label: "Menu",
1064
+ icon: hasMenuBadge ? /*#__PURE__*/jsxs(IconWrapper, {
1065
+ children: [/*#__PURE__*/jsx(IconLabel, {}), /*#__PURE__*/jsx(Menu, {
1066
+ fontSize: "small"
1067
+ })]
1068
+ }) : /*#__PURE__*/jsx(Menu, {
1069
+ fontSize: "small"
1070
+ })
1071
+ })]
1072
+ });
1073
+ }
1074
+
1075
+ var NavbarBadge = /*#__PURE__*/styled.span.withConfig({
1076
+ displayName: "NavbarItem__NavbarBadge",
1077
+ componentId: "SD__sc-1pvzq3w-0"
1078
+ })(["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);
1079
+ var NavbarLabel = /*#__PURE__*/styled.span.withConfig({
1080
+ displayName: "NavbarItem__NavbarLabel",
1081
+ componentId: "SD__sc-1pvzq3w-1"
1082
+ })(["flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"]);
1083
+ var NavbarItemRoot = /*#__PURE__*/styled.div.withConfig({
1084
+ displayName: "NavbarItem__NavbarItemRoot",
1085
+ 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);
1087
+ var IconWrapper$1 = /*#__PURE__*/styled.div.withConfig({
1088
+ displayName: "NavbarItem__IconWrapper",
1089
+ componentId: "SD__sc-1pvzq3w-3"
1090
+ })(["width:24px;margin-right:8px;& svg{font-size:24px;}"]);
1091
+ function NavbarItem(_ref) {
1092
+ var {
1093
+ label,
1094
+ gutter,
1095
+ badge,
1096
+ icon,
1097
+ component,
1098
+ onClick,
1099
+ variant,
1100
+ ident = 0
1101
+ } = _ref;
1102
+ var uid = useUID();
1103
+ return /*#__PURE__*/jsxs(NavbarItemRoot, {
1104
+ as: component,
1105
+ onClick: onClick,
1106
+ "aria-labelledby": uid,
1107
+ style: {
1108
+ marginTop: gutter ? '16px' : '0',
1109
+ paddingLeft: (ident + 1) * 20
1110
+ },
1111
+ children: [/*#__PURE__*/jsx(IconWrapper$1, {
1112
+ children: icon
1113
+ }), /*#__PURE__*/jsx(NavbarLabel, {
1114
+ id: uid,
1115
+ children: label
1116
+ }), badge != null && /*#__PURE__*/jsx(NavbarBadge, {
1117
+ "data-variant": variant,
1118
+ children: badge
1119
+ })]
1120
+ });
1121
+ }
1122
+
1123
+ var Header = /*#__PURE__*/styled.div.withConfig({
1124
+ displayName: "NavbarList__Header",
1125
+ componentId: "SD__sc-19zrmxc-0"
1126
+ })(["margin:0 16px 8px;display:flex;flex-shrink:0;align-items:center;justify-content:space-between;"]);
1127
+ var Wrapper = /*#__PURE__*/styled.div.withConfig({
1128
+ displayName: "NavbarList__Wrapper",
1129
+ componentId: "SD__sc-19zrmxc-1"
1130
+ })(["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 => {
1131
+ var {
1132
+ isMobile
1133
+ } = _ref;
1134
+ return isMobile ? '280px' : 'initial';
1135
+ }, _ref2 => {
1136
+ var {
1137
+ isMobile
1138
+ } = _ref2;
1139
+ return isMobile ? '280px' : '240px';
1140
+ }, _ref3 => {
1141
+ var {
1142
+ isMobile
1143
+ } = _ref3;
1144
+ return isMobile ? '280px' : '72px';
1145
+ }, Header);
1146
+ var ExpandIconButton = /*#__PURE__*/styled(IconButton).withConfig({
1147
+ displayName: "NavbarList__ExpandIconButton",
1148
+ componentId: "SD__sc-19zrmxc-2"
1149
+ })(["color:", ";&&:focus{background-color:inherit;}"], Color.Silver500);
1150
+ var Footer = /*#__PURE__*/styled.div.withConfig({
1151
+ displayName: "NavbarList__Footer",
1152
+ componentId: "SD__sc-19zrmxc-3"
1153
+ })(["flex-grow:1;display:flex;align-items:flex-end;margin:16px 0 8px;"]);
1154
+ var Root = /*#__PURE__*/styled.div.withConfig({
1155
+ displayName: "NavbarList__Root",
1156
+ componentId: "SD__sc-19zrmxc-4"
1157
+ })(["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);
1158
+ function NavbarMenuItem(_ref4) {
1159
+ var {
1160
+ label,
1161
+ icon,
1162
+ onClick,
1163
+ component
1164
+ } = _ref4;
1165
+ return /*#__PURE__*/jsx(Root, {
1166
+ as: component,
1167
+ onClick: onClick,
1168
+ children: /*#__PURE__*/jsxs(Inline, {
1169
+ space: "xsmall",
1170
+ verticalAlign: "center",
1171
+ children: [icon, /*#__PURE__*/jsx(NavbarLabel, {
1172
+ children: label
1173
+ })]
1174
+ })
1175
+ });
1176
+ }
1177
+ var Content = /*#__PURE__*/styled.div.withConfig({
1178
+ displayName: "NavbarList__Content",
1179
+ componentId: "SD__sc-19zrmxc-5"
1180
+ })(["height:100%;min-height:50px;&[aria-expanded='false']{", ",", "{visibility:hidden;}}"], NavbarBadge, NavbarLabel);
1181
+ function NavbarList(_ref5) {
1182
+ var {
1183
+ header,
1184
+ items,
1185
+ footer
1186
+ } = _ref5;
1187
+ var platform = useResponsiveValue('mobile', 'tablet', 'desktop');
1188
+ var isMobile = platform === 'mobile';
1189
+ var {
1190
+ isExpanded,
1191
+ isDrawerOpen,
1192
+ setDrawerOpen,
1193
+ setIsExpanded
1194
+ } = useNavbarContext();
1195
+ var isSidebarOpened = isMobile ? isDrawerOpen : isExpanded;
1196
+ var filteredItems = useMemo(() => items.filter(item => {
1197
+ return !item.hide && (isSidebarOpened || !!item.icon);
1198
+ }).map(item => _objectSpread(_objectSpread({}, item), {}, {
1199
+ menuGroupKey: item.groupKey
1200
+ })), [items, isSidebarOpened]);
1201
+ return /*#__PURE__*/jsxs(Wrapper, {
1202
+ isMobile: isMobile,
1203
+ "data-expanded": isSidebarOpened,
1204
+ children: [/*#__PURE__*/jsxs(Header, {
1205
+ children: [isSidebarOpened && header, !isMobile && /*#__PURE__*/jsx(ExpandIconButton, {
1206
+ disableRipple: true,
1207
+ style: isExpanded ? {
1208
+ paddingRight: 0
1209
+ } : {},
1210
+ onClick: () => {
1211
+ setIsExpanded(!isExpanded);
1212
+ },
1213
+ children: isExpanded ? /*#__PURE__*/jsx(MenuOpen, {}) : /*#__PURE__*/jsx(Menu, {})
1214
+ })]
1215
+ }), /*#__PURE__*/jsx(Content, {
1216
+ "aria-expanded": isSidebarOpened,
1217
+ children: /*#__PURE__*/jsx(AdaptiveVerticalToolbar, {
1218
+ disableGutters: true,
1219
+ items: filteredItems,
1220
+ renderItem: item => {
1221
+ var navbarItem = item;
1222
+ var index = filteredItems.indexOf(navbarItem);
1223
+ var prev = filteredItems[index - 1];
1224
+ return /*#__PURE__*/jsx(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
1225
+ gutter: prev && prev.groupKey !== navbarItem.groupKey,
1226
+ onClick: event => {
1227
+ var _item$onClick;
1228
+
1229
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
1230
+
1231
+ if (!event.isDefaultPrevented()) {
1232
+ setDrawerOpen(false);
1233
+ }
1234
+ }
1235
+ }));
1236
+ },
1237
+ renderMenuItem: item => /*#__PURE__*/jsx(NavbarMenuItem, _objectSpread(_objectSpread({}, item), {}, {
1238
+ onClick: event => {
1239
+ var _item$onClick2;
1240
+
1241
+ (_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item, event);
1242
+
1243
+ if (!event.isDefaultPrevented()) {
1244
+ setDrawerOpen(false);
1245
+ }
1246
+ }
1247
+ })),
1248
+ moreElement: /*#__PURE__*/jsx(NavbarItem, {
1249
+ icon: /*#__PURE__*/jsx(MoreHoriz, {}),
1250
+ label: "More"
1251
+ })
1252
+ })
1253
+ }), /*#__PURE__*/jsx(Footer, {
1254
+ children: footer
1255
+ })]
1256
+ });
1257
+ }
1258
+
1259
+ var Aside = /*#__PURE__*/styled.aside.withConfig({
1260
+ displayName: "Navbar__Aside",
1261
+ componentId: "SD__sc-1oiqig8-0"
1262
+ })(["display:flex;flex-direction:column;overflow:auto;"]);
1263
+ var Main = /*#__PURE__*/styled.main.withConfig({
1264
+ displayName: "Navbar__Main",
1265
+ componentId: "SD__sc-1oiqig8-1"
1266
+ })(["flex:1;display:flex;flex-direction:column;overflow:auto;"]);
1267
+ function Navbar(_ref) {
1268
+ var {
1269
+ footer,
1270
+ items,
1271
+ header,
1272
+ bottomItems,
1273
+ children,
1274
+ containerStyle,
1275
+ hasExtraBadge
1276
+ } = _ref;
1277
+ var theme = useTheme();
1278
+ var [isDrawerOpen, setDrawerOpen] = useState(false);
1279
+ var platform = useResponsiveValue('mobile', 'tablet', 'desktop');
1280
+ var isMobile = platform === 'mobile';
1281
+ var matches = useMediaQuery(theme.breakpoints.up('md'), {
1282
+ noSsr: true
1283
+ });
1284
+ var [isExpanded, setIsExpanded] = useState(matches);
1285
+ var hasBadge = hasExtraBadge || items.some(item => item.badge);
1286
+ var ctx = useMemo(() => ({
1287
+ isDrawerOpen,
1288
+ isExpanded,
1289
+ setIsExpanded,
1290
+ setDrawerOpen
1291
+ }), [isDrawerOpen, isExpanded, setIsExpanded, setDrawerOpen]);
1292
+ return /*#__PURE__*/jsx(NavbarContext.Provider, {
1293
+ value: ctx,
1294
+ children: /*#__PURE__*/jsxs("div", {
1295
+ style: _objectSpread({
1296
+ display: 'flex',
1297
+ height: '100%',
1298
+ flexDirection: isMobile ? 'column' : 'row'
1299
+ }, containerStyle),
1300
+ children: [!isMobile && /*#__PURE__*/jsx(Aside, {
1301
+ children: /*#__PURE__*/jsx(NavbarList, {
1302
+ header: header,
1303
+ items: items,
1304
+ footer: footer
1305
+ })
1306
+ }), /*#__PURE__*/jsx(Main, {
1307
+ children: children
1308
+ }), isMobile && /*#__PURE__*/jsx(NavbarBottomBar, {
1309
+ items: bottomItems,
1310
+ hasMenuBadge: hasBadge
1311
+ }), /*#__PURE__*/jsx(Drawer, {
1312
+ open: isDrawerOpen,
1313
+ anchor: "right",
1314
+ onClose: () => {
1315
+ setDrawerOpen(false);
1316
+ },
1317
+ PaperProps: {
1318
+ style: {
1319
+ width: '280px',
1320
+ minWidth: '280px'
1321
+ }
1322
+ },
1323
+ children: /*#__PURE__*/jsx(NavbarList, {
1324
+ header: header,
1325
+ items: items,
1326
+ footer: footer
1327
+ })
1328
+ })]
1329
+ })
1330
+ });
1331
+ }
1332
+
1333
+ var _excluded$6 = ["title", "subtitle", "children"];
1334
+ var StyledTypography = /*#__PURE__*/styled(Typography).withConfig({
1335
+ displayName: "NavbarAvatar__StyledTypography",
1336
+ componentId: "SD__sc-19q2zd0-0"
1337
+ })(["color:", ";text-overflow:ellipsis;white-space:nowrap;overflow:hidden;&:hover{color:", ";}"], Color.Silver500, Color.White);
1338
+ function NavbarAvatar(_ref) {
1339
+ var {
1340
+ title,
1341
+ subtitle,
1342
+ children
1343
+ } = _ref,
1344
+ props = _objectWithoutProperties(_ref, _excluded$6);
1345
+
1346
+ var {
1347
+ isExpanded,
1348
+ isDrawerOpen
1349
+ } = useNavbarContext();
1350
+
1351
+ if (isExpanded || isDrawerOpen) {
1352
+ return /*#__PURE__*/jsxs(Columns, {
1353
+ space: "xsmall",
1354
+ align: "center",
1355
+ children: [/*#__PURE__*/jsx(Column, {
1356
+ width: "content",
1357
+ children: /*#__PURE__*/jsx(Avatar, _objectSpread(_objectSpread({}, props), {}, {
1358
+ children: children
1359
+ }))
1360
+ }), /*#__PURE__*/jsx(Column, {
1361
+ children: /*#__PURE__*/jsxs(Stack, {
1362
+ space: "none",
1363
+ children: [/*#__PURE__*/jsx(StyledTypography, {
1364
+ children: title
1365
+ }), /*#__PURE__*/jsx(StyledTypography, {
1366
+ children: subtitle
1367
+ })]
1368
+ })
1369
+ })]
1370
+ });
1371
+ }
1372
+
1373
+ return /*#__PURE__*/jsx(Avatar, _objectSpread(_objectSpread({}, props), {}, {
1374
+ children: children
1375
+ }));
1376
+ }
1377
+
1378
+ var Divider = /*#__PURE__*/styled.div.withConfig({
1379
+ displayName: "NavbarMenu__Divider",
1380
+ componentId: "SD__sc-1c8icpt-0"
1381
+ })(["border-bottom:1px solid ", ";margin:8px -16px;"], Color.Silver400);
1382
+ var StyledMenuItem = /*#__PURE__*/styled(MenuItem).withConfig({
1383
+ displayName: "NavbarMenu__StyledMenuItem",
1384
+ componentId: "SD__sc-1c8icpt-1"
1385
+ })(["& svg{font-size:24px;color:", ";}"], Color.Dark100);
1386
+ var Wrapper$1 = /*#__PURE__*/styled.div.withConfig({
1387
+ displayName: "NavbarMenu__Wrapper",
1388
+ componentId: "SD__sc-1c8icpt-2"
1389
+ })(["width:100%;padding:8px 16px;cursor:pointer;background:", ";border-left:4px solid ", ";&:hover{border-left-color:", ";background:", ";}"], Color.Dark400, _ref => {
1390
+ var {
1391
+ active
1392
+ } = _ref;
1393
+ return active ? Color.Blue300 : 'transparent';
1394
+ }, Color.Blue300, Color.Dark400);
1395
+ function NavbarMenu(_ref2) {
1396
+ var {
1397
+ items,
1398
+ children
1399
+ } = _ref2;
1400
+ var {
1401
+ setDrawerOpen
1402
+ } = useNavbarContext();
1403
+ var [anchor, setAnchor] = useState(null);
1404
+
1405
+ function showProfileMenu(event) {
1406
+ setAnchor(event.currentTarget);
1407
+ }
1408
+
1409
+ function hideProfileMenu() {
1410
+ setAnchor(null);
1411
+ setDrawerOpen(false);
1412
+ }
1413
+
1414
+ return /*#__PURE__*/jsxs(Fragment, {
1415
+ children: [/*#__PURE__*/jsx(Wrapper$1, {
1416
+ onClick: showProfileMenu,
1417
+ active: !!anchor,
1418
+ children: children
1419
+ }), /*#__PURE__*/jsx(Menu$1, {
1420
+ open: !!anchor,
1421
+ anchorEl: anchor,
1422
+ onClose: hideProfileMenu,
1423
+ onClick: hideProfileMenu,
1424
+ anchorOrigin: {
1425
+ vertical: 'top',
1426
+ horizontal: 'center'
1427
+ },
1428
+ transformOrigin: {
1429
+ vertical: 'bottom',
1430
+ horizontal: 'center'
1431
+ },
1432
+ children: items.filter(item => item.visible !== false).flatMap((item, index, arr) => {
1433
+ return [/*#__PURE__*/jsx(StyledMenuItem, {
1434
+ onClick: item.onClick,
1435
+ children: /*#__PURE__*/jsxs(Inline, {
1436
+ space: "small",
1437
+ verticalAlign: "center",
1438
+ children: [item.icon, /*#__PURE__*/jsx(Typography, {
1439
+ style: {
1440
+ color: Color.Dark500
1441
+ },
1442
+ children: item.label
1443
+ })]
1444
+ })
1445
+ }, item.key), index !== arr.length - 1 && /*#__PURE__*/jsx(Divider, {}, "".concat(item.key, "-divider"))];
1446
+ })
1447
+ })]
1448
+ });
1449
+ }
1450
+
968
1451
  var SidebarRoot = /*#__PURE__*/styled.aside.withConfig({
969
1452
  displayName: "Sidebar__SidebarRoot",
970
1453
  componentId: "SD__sc-b77o22-0"
@@ -1049,7 +1532,7 @@ var SidebarDividerRoot = /*#__PURE__*/styled.div.withConfig({
1049
1532
  var SidebarDivider = /*#__PURE__*/forwardRef((_, ref) => {
1050
1533
  return /*#__PURE__*/jsx(SidebarDividerRoot, {
1051
1534
  ref: ref,
1052
- children: /*#__PURE__*/jsx(Divider, {})
1535
+ children: /*#__PURE__*/jsx(Divider$1, {})
1053
1536
  });
1054
1537
  });
1055
1538
  if (process.env.NODE_ENV !== "production") SidebarDivider.displayName = "SidebarDivider";
@@ -1287,5 +1770,5 @@ var SidebarSubheader = /*#__PURE__*/forwardRef((_ref, ref) => {
1287
1770
  });
1288
1771
  if (process.env.NODE_ENV !== "production") SidebarSubheader.displayName = "SidebarSubheader";
1289
1772
 
1290
- export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, DescriptionItem, FileDropZone, FileListItem, Sidebar, SidebarContainer, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes };
1773
+ 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 };
1291
1774
  //# sourceMappingURL=index.js.map