@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.
package/dist-web/index.js CHANGED
@@ -1,15 +1,17 @@
1
- import { CheckCircle, Info, Error, Image, Refresh, Delete, OpenInNew } from '@material-ui/icons';
1
+ import { CheckCircle, Info, Error, Image, Refresh, Delete, Menu, ExpandMore, MenuOpen, 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 } 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, AccordionSummary, Accordion, 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 { Anchorme } from 'react-anchorme';
14
+ import { noop } from 'lodash';
13
15
 
14
16
  function colorMixin(textColor, backgroundColor, buttonHoverColor) {
15
17
  return css(["color:", ";background-color:", ";& .MuiAlert-icon{color:", ";}& .MuiAlert-action{& .MuiIconButton-root{&:hover,&:active{color:", ";}}}"], textColor, backgroundColor, textColor, buttonHoverColor);
@@ -521,6 +523,45 @@ var AnchorButton = /*#__PURE__*/forwardRef((_ref5, ref) => {
521
523
  });
522
524
  if (process.env.NODE_ENV !== "production") AnchorButton.displayName = "AnchorButton";
523
525
 
526
+ var _excluded$3 = ["fullViewportHeight"];
527
+ var Container = /*#__PURE__*/forwardRef((_ref, ref) => {
528
+ var {
529
+ fullViewportHeight
530
+ } = _ref,
531
+ props = _objectWithoutProperties(_ref, _excluded$3);
532
+
533
+ var nodeRef = useRef(null);
534
+ useLayoutEffect(() => {
535
+ if (!fullViewportHeight) {
536
+ if (nodeRef.current) {
537
+ nodeRef.current.style.removeProperty('height');
538
+ nodeRef.current.style.removeProperty('--vh');
539
+ }
540
+
541
+ return;
542
+ }
543
+
544
+ function updateHeight() {
545
+ if (nodeRef.current) {
546
+ // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
547
+ nodeRef.current.style.setProperty('height', 'calc(var(--vh, 1vh) * 100)');
548
+ nodeRef.current.style.setProperty('--vh', "".concat(window.innerHeight * 0.01, "px"));
549
+ }
550
+ }
551
+
552
+ updateHeight();
553
+ window.addEventListener('resize', updateHeight);
554
+ return () => {
555
+ window.removeEventListener('resize', updateHeight);
556
+ };
557
+ }, [fullViewportHeight]);
558
+ return /*#__PURE__*/jsx("div", _objectSpread({
559
+ ref: mergeRefs(ref, nodeRef)
560
+ }, props));
561
+ });
562
+ if (process.env.NODE_ENV !== "production") Container.displayName = "Container";
563
+ Container.displayName = 'Container';
564
+
524
565
  function mergeStyles(styles) {
525
566
  for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
526
567
  sources[_key - 1] = arguments[_key];
@@ -546,7 +587,7 @@ function mergeStyles(styles) {
546
587
  return styles;
547
588
  }
548
589
 
549
- var _excluded$3 = ["variant", "as", "align", "color", "display", "noWrap", "wrapOverflow"];
590
+ var _excluded$4 = ["variant", "as", "align", "color", "display", "noWrap", "wrapOverflow"];
550
591
  var normalizeTextColor = /*#__PURE__*/createRuleNormalizer({
551
592
  inherit: 'inherit',
552
593
  primary: Color.Dark500,
@@ -648,7 +689,7 @@ var TextBox = /*#__PURE__*/forwardRef((_ref3, ref) => {
648
689
  noWrap = false,
649
690
  wrapOverflow = false
650
691
  } = _ref3,
651
- props = _objectWithoutProperties(_ref3, _excluded$3);
692
+ props = _objectWithoutProperties(_ref3, _excluded$4);
652
693
 
653
694
  var $align = parseResponsiveProp(align);
654
695
  var $color = parseResponsiveProp(color);
@@ -729,7 +770,7 @@ var DescriptionItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
729
770
  });
730
771
  if (process.env.NODE_ENV !== "production") DescriptionItem.displayName = "DescriptionItem";
731
772
 
732
- var _excluded$4 = ["disabled", "children", "hintText", "startIcon", "fallback", "accept", "maxSize", "maxFiles", "onDropRejected", "onDropAccepted"];
773
+ var _excluded$5 = ["disabled", "children", "hintText", "startIcon", "fallback", "accept", "maxSize", "maxFiles", "onDropRejected", "onDropAccepted"];
733
774
  function toBytes(input, unit) {
734
775
  if (unit === 'gb') return input * (1 << 30);
735
776
  if (unit === 'mb') return input * (1 << 20);
@@ -800,7 +841,7 @@ var FileDropZone = /*#__PURE__*/forwardRef((props, ref) => {
800
841
  onDropRejected: _onDropRejected,
801
842
  onDropAccepted: _onDropAccepted
802
843
  } = props,
803
- dropzoneProps = _objectWithoutProperties(props, _excluded$4);
844
+ dropzoneProps = _objectWithoutProperties(props, _excluded$5);
804
845
 
805
846
  return /*#__PURE__*/jsx(Suspense, {
806
847
  fallback: fallback,
@@ -965,6 +1006,576 @@ var FileListItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
965
1006
  });
966
1007
  if (process.env.NODE_ENV !== "production") FileListItem.displayName = "FileListItem";
967
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
+
1055
+ var NavbarContext = /*#__PURE__*/createContext({
1056
+ isDrawerOpen: false,
1057
+ isExpanded: false,
1058
+ setIsExpanded: noop,
1059
+ setDrawerOpen: noop
1060
+ });
1061
+ function useNavbarContext() {
1062
+ return useContext(NavbarContext);
1063
+ }
1064
+
1065
+ var StyledBottomNavigation = /*#__PURE__*/styled(BottomNavigation).withConfig({
1066
+ displayName: "NavbarBottomBar__StyledBottomNavigation",
1067
+ componentId: "SD__sc-9z6v3k-0"
1068
+ })(["background:", ";"], Color.Dark500);
1069
+ var StyledBottomNavigationAction = /*#__PURE__*/styled(BottomNavigationAction).withConfig({
1070
+ displayName: "NavbarBottomBar__StyledBottomNavigationAction",
1071
+ componentId: "SD__sc-9z6v3k-1"
1072
+ })(["&&{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);
1073
+ var IconWrapper = /*#__PURE__*/styled.div.withConfig({
1074
+ displayName: "NavbarBottomBar__IconWrapper",
1075
+ componentId: "SD__sc-9z6v3k-2"
1076
+ })(["position:relative;"]);
1077
+ var IconLabel = /*#__PURE__*/styled.div.withConfig({
1078
+ displayName: "NavbarBottomBar__IconLabel",
1079
+ componentId: "SD__sc-9z6v3k-3"
1080
+ })(["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);
1081
+ function NavbarBottomBar(_ref) {
1082
+ var {
1083
+ items,
1084
+ hasMenuBadge
1085
+ } = _ref;
1086
+ var {
1087
+ isDrawerOpen,
1088
+ setDrawerOpen
1089
+ } = useNavbarContext();
1090
+ var activeItem = useMemo(() => items.find(item => item.active), [items]);
1091
+ return /*#__PURE__*/jsxs(StyledBottomNavigation, {
1092
+ value: activeItem === null || activeItem === void 0 ? void 0 : activeItem.value,
1093
+ showLabels: true,
1094
+ onChange: (_event, newValue) => {
1095
+ if (newValue) {
1096
+ if (newValue === 'menu') {
1097
+ setDrawerOpen(!isDrawerOpen);
1098
+ } else {
1099
+ setDrawerOpen(false);
1100
+ }
1101
+ }
1102
+ },
1103
+ children: [items.map(item => /*#__PURE__*/createElement(StyledBottomNavigationAction, _objectSpread(_objectSpread({}, item), {}, {
1104
+ key: item.value,
1105
+ icon: item.hasBadge ? /*#__PURE__*/jsxs(IconWrapper, {
1106
+ children: [/*#__PURE__*/jsx(IconLabel, {}), item.icon]
1107
+ }) : item.icon
1108
+ }))), /*#__PURE__*/jsx(StyledBottomNavigationAction, {
1109
+ value: "menu",
1110
+ label: "Menu",
1111
+ icon: hasMenuBadge ? /*#__PURE__*/jsxs(IconWrapper, {
1112
+ children: [/*#__PURE__*/jsx(IconLabel, {}), /*#__PURE__*/jsx(Menu, {
1113
+ fontSize: "small"
1114
+ })]
1115
+ }) : /*#__PURE__*/jsx(Menu, {
1116
+ fontSize: "small"
1117
+ })
1118
+ })]
1119
+ });
1120
+ }
1121
+
1122
+ var NavbarBadge = /*#__PURE__*/styled.span.withConfig({
1123
+ displayName: "NavbarItem__NavbarBadge",
1124
+ componentId: "SD__sc-1pvzq3w-0"
1125
+ })(["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);
1126
+ var NavbarLabel = /*#__PURE__*/styled.span.withConfig({
1127
+ displayName: "NavbarItem__NavbarLabel",
1128
+ componentId: "SD__sc-1pvzq3w-1"
1129
+ })(["flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"]);
1130
+ var NavbarItemRoot = /*#__PURE__*/styled.div.withConfig({
1131
+ displayName: "NavbarItem__NavbarItemRoot",
1132
+ componentId: "SD__sc-1pvzq3w-2"
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);
1134
+ var IconWrapper$1 = /*#__PURE__*/styled.div.withConfig({
1135
+ displayName: "NavbarItem__IconWrapper",
1136
+ componentId: "SD__sc-1pvzq3w-3"
1137
+ })(["width:24px;margin-right:8px;& svg{font-size:24px;}"]);
1138
+ function NavbarItem(_ref) {
1139
+ var {
1140
+ label,
1141
+ gutter,
1142
+ badge,
1143
+ icon,
1144
+ component,
1145
+ onClick,
1146
+ variant,
1147
+ ident = 0,
1148
+ active
1149
+ } = _ref;
1150
+ var uid = useUID();
1151
+ return /*#__PURE__*/jsxs(NavbarItemRoot, {
1152
+ as: component,
1153
+ onClick: onClick,
1154
+ "aria-labelledby": uid,
1155
+ "data-active": active,
1156
+ style: {
1157
+ marginTop: gutter ? '16px' : '0',
1158
+ paddingLeft: (ident + 1) * 20
1159
+ },
1160
+ children: [/*#__PURE__*/jsx(IconWrapper$1, {
1161
+ children: icon
1162
+ }), /*#__PURE__*/jsx(NavbarLabel, {
1163
+ id: uid,
1164
+ children: label
1165
+ }), badge != null && /*#__PURE__*/jsx(NavbarBadge, {
1166
+ "data-variant": variant,
1167
+ children: badge
1168
+ })]
1169
+ });
1170
+ }
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
+
1259
+ var Header = /*#__PURE__*/styled.div.withConfig({
1260
+ displayName: "NavbarList__Header",
1261
+ componentId: "SD__sc-19zrmxc-0"
1262
+ })(["margin:0 16px 8px;display:flex;flex-shrink:0;align-items:center;justify-content:space-between;position:sticky;"]);
1263
+ var Wrapper = /*#__PURE__*/styled.div.withConfig({
1264
+ displayName: "NavbarList__Wrapper",
1265
+ componentId: "SD__sc-19zrmxc-1"
1266
+ })(["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 => {
1267
+ var {
1268
+ isMobile
1269
+ } = _ref;
1270
+ return isMobile ? '280px' : 'initial';
1271
+ }, _ref2 => {
1272
+ var {
1273
+ isMobile
1274
+ } = _ref2;
1275
+ return isMobile ? '280px' : '240px';
1276
+ }, _ref3 => {
1277
+ var {
1278
+ isMobile
1279
+ } = _ref3;
1280
+ return isMobile ? '280px' : '72px';
1281
+ }, Header);
1282
+ var ExpandIconButton = /*#__PURE__*/styled(IconButton).withConfig({
1283
+ displayName: "NavbarList__ExpandIconButton",
1284
+ componentId: "SD__sc-19zrmxc-2"
1285
+ })(["color:", ";&&:focus{background-color:inherit;}"], Color.Silver500);
1286
+ var Footer = /*#__PURE__*/styled.div.withConfig({
1287
+ displayName: "NavbarList__Footer",
1288
+ componentId: "SD__sc-19zrmxc-3"
1289
+ })(["flex-grow:1;display:flex;align-items:flex-end;margin:16px 0 8px;position:sticky;"]);
1290
+ var Root = /*#__PURE__*/styled.div.withConfig({
1291
+ displayName: "NavbarList__Root",
1292
+ componentId: "SD__sc-19zrmxc-4"
1293
+ })(["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);
1294
+ function NavbarMenuItem(_ref4) {
1295
+ var {
1296
+ label,
1297
+ icon,
1298
+ onClick,
1299
+ component
1300
+ } = _ref4;
1301
+ return /*#__PURE__*/jsx(Root, {
1302
+ as: component,
1303
+ onClick: onClick,
1304
+ children: /*#__PURE__*/jsxs(Inline, {
1305
+ space: "xsmall",
1306
+ verticalAlign: "center",
1307
+ children: [icon, /*#__PURE__*/jsx(NavbarLabel, {
1308
+ children: label
1309
+ })]
1310
+ })
1311
+ });
1312
+ }
1313
+ var Content = /*#__PURE__*/styled.div.withConfig({
1314
+ displayName: "NavbarList__Content",
1315
+ componentId: "SD__sc-19zrmxc-5"
1316
+ })(["height:100%;min-height:50px;overflow-y:auto;overflow-x:hidden;&[aria-expanded='false']{", ",", "{display:none;}}"], NavbarBadge, NavbarLabel);
1317
+ function NavbarList(_ref5) {
1318
+ var {
1319
+ header,
1320
+ items,
1321
+ footer
1322
+ } = _ref5;
1323
+ var platform = useResponsiveValue('mobile', 'tablet', 'desktop');
1324
+ var isMobile = platform === 'mobile';
1325
+ var {
1326
+ isExpanded,
1327
+ isDrawerOpen,
1328
+ setDrawerOpen,
1329
+ setIsExpanded
1330
+ } = useNavbarContext();
1331
+ var isSidebarOpened = isMobile ? isDrawerOpen : isExpanded;
1332
+ var filteredItems = useMemo(() => items.filter(item => {
1333
+ return !item.hide && (isSidebarOpened || !!item.icon);
1334
+ }).map(item => _objectSpread(_objectSpread({}, item), {}, {
1335
+ menuGroupKey: item.groupKey
1336
+ })), [items, isSidebarOpened]);
1337
+ return /*#__PURE__*/jsxs(Wrapper, {
1338
+ isMobile: isMobile,
1339
+ "data-expanded": isSidebarOpened,
1340
+ children: [/*#__PURE__*/jsxs(Header, {
1341
+ children: [isSidebarOpened && header, !isMobile && /*#__PURE__*/jsx(ExpandIconButton, {
1342
+ disableRipple: true,
1343
+ style: isExpanded ? {
1344
+ paddingRight: 0
1345
+ } : {},
1346
+ onClick: () => {
1347
+ setIsExpanded(!isExpanded);
1348
+ },
1349
+ children: isExpanded ? /*#__PURE__*/jsx(MenuOpen, {}) : /*#__PURE__*/jsx(Menu, {})
1350
+ })]
1351
+ }), /*#__PURE__*/jsx(Content, {
1352
+ "aria-expanded": isSidebarOpened,
1353
+ children: filteredItems.map(item => {
1354
+ var index = filteredItems.indexOf(item);
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
+
1365
+ return /*#__PURE__*/createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
1366
+ key: item.key,
1367
+ gutter: prev && prev.groupKey !== item.groupKey,
1368
+ onClick: event => {
1369
+ var _item$onClick;
1370
+
1371
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
1372
+
1373
+ if (!event.isDefaultPrevented()) {
1374
+ setDrawerOpen(false);
1375
+ }
1376
+ }
1377
+ }));
1378
+ })
1379
+ }), /*#__PURE__*/jsx(Footer, {
1380
+ children: footer
1381
+ })]
1382
+ });
1383
+ }
1384
+
1385
+ var Aside = /*#__PURE__*/styled.aside.withConfig({
1386
+ displayName: "Navbar__Aside",
1387
+ componentId: "SD__sc-1oiqig8-0"
1388
+ })(["display:flex;flex-direction:column;overflow:auto;"]);
1389
+ var Main = /*#__PURE__*/styled.main.withConfig({
1390
+ displayName: "Navbar__Main",
1391
+ componentId: "SD__sc-1oiqig8-1"
1392
+ })(["flex:1;display:flex;flex-direction:column;overflow:scroll;"]);
1393
+ function Navbar(_ref) {
1394
+ var {
1395
+ footer,
1396
+ items,
1397
+ header,
1398
+ bottomItems,
1399
+ children,
1400
+ containerStyle,
1401
+ hasExtraBadge
1402
+ } = _ref;
1403
+ var theme = useTheme();
1404
+ var [isDrawerOpen, setDrawerOpen] = useState(false);
1405
+ var platform = useResponsiveValue('mobile', 'tablet', 'desktop');
1406
+ var isMobile = platform === 'mobile';
1407
+ var matches = useMediaQuery(theme.breakpoints.up('md'), {
1408
+ noSsr: true
1409
+ });
1410
+ var [isExpanded, setIsExpanded] = useState(matches);
1411
+ var hasBadge = hasExtraBadge || items.some(item => item.badge);
1412
+ var ctx = useMemo(() => ({
1413
+ isDrawerOpen,
1414
+ isExpanded,
1415
+ setIsExpanded,
1416
+ setDrawerOpen
1417
+ }), [isDrawerOpen, isExpanded, setIsExpanded, setDrawerOpen]);
1418
+ return /*#__PURE__*/jsx(NavbarContext.Provider, {
1419
+ value: ctx,
1420
+ children: /*#__PURE__*/jsxs("div", {
1421
+ style: _objectSpread({
1422
+ display: 'flex',
1423
+ height: '100%',
1424
+ flexDirection: isMobile ? 'column' : 'row'
1425
+ }, containerStyle),
1426
+ children: [!isMobile && /*#__PURE__*/jsx(Aside, {
1427
+ children: /*#__PURE__*/jsx(NavbarList, {
1428
+ header: header,
1429
+ items: items,
1430
+ footer: footer
1431
+ })
1432
+ }), /*#__PURE__*/jsx(Main, {
1433
+ children: children
1434
+ }), isMobile && /*#__PURE__*/jsx(NavbarBottomBar, {
1435
+ items: bottomItems,
1436
+ hasMenuBadge: hasBadge
1437
+ }), /*#__PURE__*/jsx(Drawer, {
1438
+ open: isDrawerOpen,
1439
+ anchor: "right",
1440
+ onClose: () => {
1441
+ setDrawerOpen(false);
1442
+ },
1443
+ PaperProps: {
1444
+ style: {
1445
+ width: '280px',
1446
+ minWidth: '280px'
1447
+ }
1448
+ },
1449
+ children: /*#__PURE__*/jsx(NavbarList, {
1450
+ header: header,
1451
+ items: items,
1452
+ footer: footer
1453
+ })
1454
+ })]
1455
+ })
1456
+ });
1457
+ }
1458
+
1459
+ var _excluded$7 = ["title", "subtitle", "children"];
1460
+ var StyledTypography = /*#__PURE__*/styled(Typography).withConfig({
1461
+ displayName: "NavbarAvatar__StyledTypography",
1462
+ componentId: "SD__sc-19q2zd0-0"
1463
+ })(["color:", ";text-overflow:ellipsis;white-space:nowrap;overflow:hidden;&:hover{color:", ";}"], Color.Silver500, Color.White);
1464
+ function NavbarAvatar(_ref) {
1465
+ var {
1466
+ title,
1467
+ subtitle,
1468
+ children
1469
+ } = _ref,
1470
+ props = _objectWithoutProperties(_ref, _excluded$7);
1471
+
1472
+ var {
1473
+ isExpanded,
1474
+ isDrawerOpen
1475
+ } = useNavbarContext();
1476
+
1477
+ if (isExpanded || isDrawerOpen) {
1478
+ return /*#__PURE__*/jsxs(Columns, {
1479
+ space: "xsmall",
1480
+ align: "center",
1481
+ children: [/*#__PURE__*/jsx(Column, {
1482
+ width: "content",
1483
+ children: /*#__PURE__*/jsx(Avatar, _objectSpread(_objectSpread({}, props), {}, {
1484
+ children: children
1485
+ }))
1486
+ }), /*#__PURE__*/jsx(Column, {
1487
+ children: /*#__PURE__*/jsxs(Stack, {
1488
+ space: "none",
1489
+ children: [/*#__PURE__*/jsx(StyledTypography, {
1490
+ variant: "caption",
1491
+ children: title
1492
+ }), /*#__PURE__*/jsx(StyledTypography, {
1493
+ variant: "caption",
1494
+ children: subtitle
1495
+ })]
1496
+ })
1497
+ })]
1498
+ });
1499
+ }
1500
+
1501
+ return /*#__PURE__*/jsx(Avatar, _objectSpread(_objectSpread({}, props), {}, {
1502
+ children: children
1503
+ }));
1504
+ }
1505
+
1506
+ var Divider = /*#__PURE__*/styled.div.withConfig({
1507
+ displayName: "NavbarMenu__Divider",
1508
+ componentId: "SD__sc-1c8icpt-0"
1509
+ })(["border-bottom:1px solid ", ";margin:8px -16px;"], Color.Silver400);
1510
+ var StyledMenuItem = /*#__PURE__*/styled(MenuItem).withConfig({
1511
+ displayName: "NavbarMenu__StyledMenuItem",
1512
+ componentId: "SD__sc-1c8icpt-1"
1513
+ })(["& svg{font-size:24px;color:", ";}"], Color.Dark100);
1514
+ var Wrapper$1 = /*#__PURE__*/styled.div.withConfig({
1515
+ displayName: "NavbarMenu__Wrapper",
1516
+ componentId: "SD__sc-1c8icpt-2"
1517
+ })(["width:100%;padding:8px 16px;cursor:pointer;background:", ";border-left:4px solid ", ";&:hover{border-left-color:", ";background:", ";}"], Color.Dark400, _ref => {
1518
+ var {
1519
+ active
1520
+ } = _ref;
1521
+ return active ? Color.Blue300 : 'transparent';
1522
+ }, Color.Blue300, Color.Dark400);
1523
+ function NavbarMenu(_ref2) {
1524
+ var {
1525
+ items,
1526
+ children
1527
+ } = _ref2;
1528
+ var {
1529
+ setDrawerOpen
1530
+ } = useNavbarContext();
1531
+ var [anchor, setAnchor] = useState(null);
1532
+
1533
+ function showProfileMenu(event) {
1534
+ setAnchor(event.currentTarget);
1535
+ }
1536
+
1537
+ function hideProfileMenu() {
1538
+ setAnchor(null);
1539
+ setDrawerOpen(false);
1540
+ }
1541
+
1542
+ return /*#__PURE__*/jsxs(Fragment, {
1543
+ children: [/*#__PURE__*/jsx(Wrapper$1, {
1544
+ onClick: showProfileMenu,
1545
+ active: !!anchor,
1546
+ children: children
1547
+ }), /*#__PURE__*/jsx(Menu$1, {
1548
+ open: !!anchor,
1549
+ anchorEl: anchor,
1550
+ onClose: hideProfileMenu,
1551
+ onClick: hideProfileMenu,
1552
+ anchorOrigin: {
1553
+ vertical: 'top',
1554
+ horizontal: 'center'
1555
+ },
1556
+ transformOrigin: {
1557
+ vertical: 'bottom',
1558
+ horizontal: 'center'
1559
+ },
1560
+ children: items.filter(item => item.visible !== false).flatMap((item, index, arr) => {
1561
+ return [/*#__PURE__*/jsx(StyledMenuItem, {
1562
+ onClick: item.onClick,
1563
+ children: /*#__PURE__*/jsxs(Inline, {
1564
+ space: "small",
1565
+ verticalAlign: "center",
1566
+ children: [item.icon, /*#__PURE__*/jsx(Typography, {
1567
+ style: {
1568
+ color: Color.Dark500
1569
+ },
1570
+ children: item.label
1571
+ })]
1572
+ })
1573
+ }, item.key), index !== arr.length - 1 && /*#__PURE__*/jsx(Divider, {}, "".concat(item.key, "-divider"))];
1574
+ })
1575
+ })]
1576
+ });
1577
+ }
1578
+
968
1579
  var SidebarRoot = /*#__PURE__*/styled.aside.withConfig({
969
1580
  displayName: "Sidebar__SidebarRoot",
970
1581
  componentId: "SD__sc-b77o22-0"
@@ -1049,7 +1660,7 @@ var SidebarDividerRoot = /*#__PURE__*/styled.div.withConfig({
1049
1660
  var SidebarDivider = /*#__PURE__*/forwardRef((_, ref) => {
1050
1661
  return /*#__PURE__*/jsx(SidebarDividerRoot, {
1051
1662
  ref: ref,
1052
- children: /*#__PURE__*/jsx(Divider, {})
1663
+ children: /*#__PURE__*/jsx(Divider$1, {})
1053
1664
  });
1054
1665
  });
1055
1666
  if (process.env.NODE_ENV !== "production") SidebarDivider.displayName = "SidebarDivider";
@@ -1287,5 +1898,5 @@ var SidebarSubheader = /*#__PURE__*/forwardRef((_ref, ref) => {
1287
1898
  });
1288
1899
  if (process.env.NODE_ENV !== "production") SidebarSubheader.displayName = "SidebarSubheader";
1289
1900
 
1290
- export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, DescriptionItem, FileDropZone, FileListItem, Sidebar, SidebarContainer, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes };
1901
+ export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, Container, DescriptionItem, FileDropZone, FileListItem, LinkedText, MultilineText, Navbar, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarItem, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, Sidebar, SidebarContainer, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes, useNavbarContext };
1291
1902
  //# sourceMappingURL=index.js.map