@superdispatch/ui-lab 0.19.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 +171 -13
- package/dist-node/index.js.map +1 -1
- package/dist-src/index.js +2 -0
- 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 +21 -2
- package/dist-web/index.js +175 -20
- package/dist-web/index.js.map +1 -1
- package/package.json +3 -3
package/dist-src/index.js
CHANGED
|
@@ -17,7 +17,9 @@ export * from "./navbar/NavbarItem.js";
|
|
|
17
17
|
export * from "./navbar/NavbarList.js";
|
|
18
18
|
export * from "./navbar/NavbarMenu.js";
|
|
19
19
|
export * from "./sidebar/Sidebar.js";
|
|
20
|
+
export * from "./sidebar/SidebarBackButton.js";
|
|
20
21
|
export * from "./sidebar/SidebarContainer.js";
|
|
22
|
+
export * from "./sidebar/SidebarContent.js";
|
|
21
23
|
export * from "./sidebar/SidebarDivider.js";
|
|
22
24
|
export * from "./sidebar/SidebarMenuItem.js";
|
|
23
25
|
export * from "./sidebar/SidebarMenuItemAction.js";
|
|
@@ -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) => {
|
package/dist-types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CSSTransition } from 'react-transition-group';
|
|
|
4
4
|
import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
5
5
|
import { SpaceProp, NegativeSpaceProp, ResponsiveProp, ColorProp } from '@superdispatch/ui';
|
|
6
6
|
import { Property } from 'csstype';
|
|
7
|
-
import { ButtonBaseProps, AvatarProps, TooltipProps } from '@material-ui/core';
|
|
7
|
+
import { ButtonBaseProps, AvatarProps, IconButtonProps, TooltipProps } from '@material-ui/core';
|
|
8
8
|
import { FileRejection } from 'react-dropzone';
|
|
9
9
|
import { StyledComponent, DefaultTheme } from 'styled-components';
|
|
10
10
|
|
|
@@ -289,12 +289,30 @@ interface SidebarProps {
|
|
|
289
289
|
}
|
|
290
290
|
declare const Sidebar: ForwardRefExoticComponent<SidebarProps & RefAttributes<HTMLDivElement>>;
|
|
291
291
|
|
|
292
|
+
declare function SidebarBackButton({ onClick, children, ...props }: IconButtonProps): ReactElement | null;
|
|
293
|
+
|
|
294
|
+
interface SidebarContext {
|
|
295
|
+
openSidebar: () => void;
|
|
296
|
+
openSidebarContent: () => void;
|
|
297
|
+
}
|
|
298
|
+
declare function useSidebarContext(): SidebarContext;
|
|
292
299
|
interface SidebarContainerProps {
|
|
293
300
|
sidebar: ReactChild;
|
|
294
301
|
children?: ReactNode;
|
|
295
302
|
}
|
|
296
303
|
declare const SidebarContainer: ForwardRefExoticComponent<SidebarContainerProps & RefAttributes<HTMLDivElement>>;
|
|
297
304
|
|
|
305
|
+
interface SidebarContentProps {
|
|
306
|
+
dense?: boolean;
|
|
307
|
+
title: ReactNode;
|
|
308
|
+
children: ReactNode;
|
|
309
|
+
action?: ReactNode;
|
|
310
|
+
openOnMount?: boolean;
|
|
311
|
+
closeOnUnmount?: boolean;
|
|
312
|
+
onBack?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
313
|
+
}
|
|
314
|
+
declare function SidebarContent({ dense, action, title, children, onBack, openOnMount, closeOnUnmount, }: SidebarContentProps): ReactElement;
|
|
315
|
+
|
|
298
316
|
|
|
299
317
|
declare const SidebarDivider: ForwardRefExoticComponent<RefAttributes<HTMLDivElement>>;
|
|
300
318
|
|
|
@@ -307,6 +325,7 @@ interface SidebarMenuItemProps {
|
|
|
307
325
|
action?: ReactNode;
|
|
308
326
|
avatar?: ReactNode;
|
|
309
327
|
children?: ReactNode;
|
|
328
|
+
openContentOnClick?: boolean;
|
|
310
329
|
secondaryActions?: ReactNode;
|
|
311
330
|
}
|
|
312
331
|
declare const SidebarMenuItem: ForwardRefExoticComponent<SidebarMenuItemProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -351,4 +370,4 @@ interface TextBoxProps {
|
|
|
351
370
|
}
|
|
352
371
|
declare const TextBox: ForwardRefExoticComponent<TextBoxProps & RefAttributes<HTMLElement>>;
|
|
353
372
|
|
|
354
|
-
export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, Container, ContainerProps, DescriptionItem, DescriptionItemProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, LinkComponentProps, LinkedText, LinkedTextProps, MarginProp, MultilineText, MultilineTextProps, Navbar, NavbarAccordionOptions, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarBottomBarItem, NavbarItem, NavbarItemOptions, NavbarItemProps, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, NavbarMenuItemOption, Sidebar, SidebarContainer, SidebarContainerProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes, useNavbarContext };
|
|
373
|
+
export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, Container, ContainerProps, DescriptionItem, DescriptionItemProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, LinkComponentProps, LinkedText, LinkedTextProps, MarginProp, MultilineText, MultilineTextProps, Navbar, NavbarAccordionOptions, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarBottomBarItem, NavbarItem, NavbarItemOptions, NavbarItemProps, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, NavbarMenuItemOption, Sidebar, SidebarBackButton, SidebarContainer, SidebarContainerProps, SidebarContent, SidebarContentProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes, useNavbarContext, useSidebarContext };
|
package/dist-web/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CheckCircle, Info, Error, Image, Refresh, Delete, Menu, ExpandMore, 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, AccordionSummary, Accordion, 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
13
|
import { Anchorme } from 'react-anchorme';
|
|
@@ -29,7 +29,7 @@ function toMaterialSeverity(severity) {
|
|
|
29
29
|
var iconMapping = {
|
|
30
30
|
success: /*#__PURE__*/jsx(CheckCircle, {}),
|
|
31
31
|
info: /*#__PURE__*/jsx(Info, {}),
|
|
32
|
-
error: /*#__PURE__*/jsx(Error, {})
|
|
32
|
+
error: /*#__PURE__*/jsx(Error$1, {})
|
|
33
33
|
};
|
|
34
34
|
var Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
35
35
|
var {
|
|
@@ -807,7 +807,7 @@ function UploadRejection(_ref2) {
|
|
|
807
807
|
align: "center",
|
|
808
808
|
children: [/*#__PURE__*/jsx(Column, {
|
|
809
809
|
width: "content",
|
|
810
|
-
children: /*#__PURE__*/jsx(Error, {})
|
|
810
|
+
children: /*#__PURE__*/jsx(Error$1, {})
|
|
811
811
|
}), /*#__PURE__*/jsx(Column, {
|
|
812
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
|
|
813
813
|
})]
|
|
@@ -942,7 +942,7 @@ var FileListItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
942
942
|
space: "xsmall",
|
|
943
943
|
children: [/*#__PURE__*/jsx(Column, {
|
|
944
944
|
width: "content",
|
|
945
|
-
children: status === 'error' ? /*#__PURE__*/jsx(Error, {
|
|
945
|
+
children: status === 'error' ? /*#__PURE__*/jsx(Error$1, {
|
|
946
946
|
color: "error",
|
|
947
947
|
fontSize: "small"
|
|
948
948
|
}) : fileType === 'pdf' ? /*#__PURE__*/jsx(PdfIcon, {
|
|
@@ -1579,7 +1579,7 @@ function NavbarMenu(_ref2) {
|
|
|
1579
1579
|
var SidebarRoot = /*#__PURE__*/styled.aside.withConfig({
|
|
1580
1580
|
displayName: "Sidebar__SidebarRoot",
|
|
1581
1581
|
componentId: "SD__sc-b77o22-0"
|
|
1582
|
-
})(["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);
|
|
1583
1583
|
var SidebarHeader = /*#__PURE__*/styled.div.withConfig({
|
|
1584
1584
|
displayName: "Sidebar__SidebarHeader",
|
|
1585
1585
|
componentId: "SD__sc-b77o22-1"
|
|
@@ -1631,28 +1631,172 @@ var Sidebar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
1631
1631
|
});
|
|
1632
1632
|
if (process.env.NODE_ENV !== "production") Sidebar.displayName = "Sidebar";
|
|
1633
1633
|
|
|
1634
|
-
var
|
|
1635
|
-
|
|
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",
|
|
1636
1646
|
componentId: "SD__sc-uibj1m-0"
|
|
1637
|
-
})(["
|
|
1647
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;width:240px;"]);
|
|
1638
1648
|
var SidebarContainerContent = /*#__PURE__*/styled.div.withConfig({
|
|
1639
1649
|
displayName: "SidebarContainer__SidebarContainerContent",
|
|
1640
1650
|
componentId: "SD__sc-uibj1m-1"
|
|
1641
|
-
})(["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);
|
|
1642
1656
|
var SidebarContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
1643
1657
|
var {
|
|
1644
1658
|
sidebar,
|
|
1645
1659
|
children
|
|
1646
1660
|
} = _ref;
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
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
|
+
})
|
|
1652
1685
|
});
|
|
1653
1686
|
});
|
|
1654
1687
|
if (process.env.NODE_ENV !== "production") SidebarContainer.displayName = "SidebarContainer";
|
|
1655
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' : 'medium',
|
|
1795
|
+
children: children
|
|
1796
|
+
})]
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1656
1800
|
var SidebarDividerRoot = /*#__PURE__*/styled.div.withConfig({
|
|
1657
1801
|
displayName: "SidebarDivider__SidebarDividerRoot",
|
|
1658
1802
|
componentId: "SD__sc-5lwi2i-0"
|
|
@@ -1707,17 +1851,21 @@ var SidebarMenuItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
1707
1851
|
var {
|
|
1708
1852
|
action,
|
|
1709
1853
|
avatar,
|
|
1710
|
-
onClick,
|
|
1854
|
+
onClick: _onClick,
|
|
1711
1855
|
external,
|
|
1712
1856
|
children,
|
|
1713
1857
|
disabled,
|
|
1714
1858
|
selected,
|
|
1715
1859
|
secondaryActions,
|
|
1716
|
-
badge: badgeProp
|
|
1860
|
+
badge: badgeProp,
|
|
1861
|
+
openContentOnClick
|
|
1717
1862
|
} = _ref2;
|
|
1718
1863
|
var [hovered, setHovered] = useState(false);
|
|
1719
1864
|
var actionsRef = useRef(null);
|
|
1720
1865
|
var actionsPlaceholderRef = useRef(null);
|
|
1866
|
+
var {
|
|
1867
|
+
openSidebarContent
|
|
1868
|
+
} = useSidebarContext();
|
|
1721
1869
|
useLayoutEffect(() => {
|
|
1722
1870
|
if (actionsRef.current && actionsPlaceholderRef.current) {
|
|
1723
1871
|
actionsPlaceholderRef.current.style.width = "".concat(Math.max(0, actionsRef.current.offsetWidth - 8), "px");
|
|
@@ -1734,9 +1882,15 @@ var SidebarMenuItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
1734
1882
|
setHovered(false);
|
|
1735
1883
|
},
|
|
1736
1884
|
children: [/*#__PURE__*/jsx(ButtonBase, {
|
|
1737
|
-
onClick: onClick,
|
|
1738
1885
|
disabled: disabled,
|
|
1739
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
|
+
},
|
|
1740
1894
|
children: /*#__PURE__*/jsxs(Columns, {
|
|
1741
1895
|
align: "center",
|
|
1742
1896
|
space: "xsmall",
|
|
@@ -1849,6 +2003,7 @@ var SidebarMenuItemAvatar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
1849
2003
|
color: "primary",
|
|
1850
2004
|
checked: value,
|
|
1851
2005
|
disabled: disabled,
|
|
2006
|
+
onClick: stopPropagation,
|
|
1852
2007
|
onMouseDown: stopPropagation,
|
|
1853
2008
|
onTouchStart: stopPropagation,
|
|
1854
2009
|
onChange: (_, checked) => {
|
|
@@ -1898,5 +2053,5 @@ var SidebarSubheader = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
1898
2053
|
});
|
|
1899
2054
|
if (process.env.NODE_ENV !== "production") SidebarSubheader.displayName = "SidebarSubheader";
|
|
1900
2055
|
|
|
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 };
|
|
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 };
|
|
1902
2057
|
//# sourceMappingURL=index.js.map
|