@superdispatch/ui-lab 0.13.0 → 0.16.0-alpha.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 +1564 -149
- package/dist-node/index.js.map +1 -1
- package/dist-src/banner/Banner.js +61 -0
- package/dist-src/index.js +4 -1
- package/dist-src/sidebar/SidebarSubheader.js +2 -1
- package/dist-src/text-box/TextBox.js +1 -0
- package/dist-src/v5/alert/Alert.js +43 -0
- package/dist-src/v5/banner/Banner.js +61 -0
- package/dist-src/v5/box/Box.js +153 -0
- package/dist-src/v5/button/Button.js +227 -0
- package/dist-src/v5/button-area/ButtonArea.js +48 -0
- package/dist-src/v5/description-item/DescriptionItem.js +75 -0
- package/dist-src/v5/file-drop-zone/FileDropZone.js +132 -0
- package/dist-src/v5/file-list-item/FileListItem.js +136 -0
- package/dist-src/v5/index.js +16 -0
- package/dist-src/v5/sidebar/Sidebar.js +66 -0
- package/dist-src/v5/sidebar/SidebarContainer.js +25 -0
- package/dist-src/v5/sidebar/SidebarDivider.js +15 -0
- package/dist-src/v5/sidebar/SidebarMenuItem.js +124 -0
- package/dist-src/v5/sidebar/SidebarMenuItemAction.js +26 -0
- package/dist-src/v5/sidebar/SidebarMenuItemAvatar.js +53 -0
- package/dist-src/v5/sidebar/SidebarMenuItemContext.js +21 -0
- package/dist-src/v5/sidebar/SidebarSubheader.js +41 -0
- package/dist-src/v5/text-box/TextBox.js +133 -0
- package/dist-src/v5/utils/RuleNormalizer.js +17 -0
- package/dist-src/v5/utils/mergeStyles.js +24 -0
- package/dist-types/index.d.ts +340 -10
- package/dist-web/index.js +1553 -139
- package/dist-web/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { v5 } from '@superdispatch/ui';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { TextBox } from "../text-box/TextBox.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
var {
|
|
8
|
+
Color,
|
|
9
|
+
Column,
|
|
10
|
+
Columns,
|
|
11
|
+
Inline,
|
|
12
|
+
isEmptyReactNode,
|
|
13
|
+
useUID
|
|
14
|
+
} = v5;
|
|
15
|
+
|
|
16
|
+
function descriptionItemIconMixin(size) {
|
|
17
|
+
return css(["width:", "px;height:", "px;& > .MuiSvgIcon-root{font-size:", "px;}"], size, size + 4, size);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var DescriptionItemIcon = /*#__PURE__*/styled.div.withConfig({
|
|
21
|
+
displayName: "DescriptionItem__DescriptionItemIcon",
|
|
22
|
+
componentId: "SD__sc-l1c918-0"
|
|
23
|
+
})(_ref => {
|
|
24
|
+
var {
|
|
25
|
+
theme
|
|
26
|
+
} = _ref;
|
|
27
|
+
return css(["display:flex;align-items:center;& > .MuiSvgIcon-root{color:", ";}", ";", "{", ";}"], Color.Dark100, descriptionItemIconMixin(20), theme.breakpoints.up('sm'), descriptionItemIconMixin(16));
|
|
28
|
+
});
|
|
29
|
+
export var DescriptionItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
30
|
+
var {
|
|
31
|
+
icon,
|
|
32
|
+
wrap,
|
|
33
|
+
inset,
|
|
34
|
+
label,
|
|
35
|
+
children,
|
|
36
|
+
fallback,
|
|
37
|
+
id: idProp,
|
|
38
|
+
'aria-label': ariaLabel
|
|
39
|
+
} = _ref2;
|
|
40
|
+
var id = useUID(idProp);
|
|
41
|
+
var labelID = "".concat(id, "-label");
|
|
42
|
+
var isEmptyChildren = isEmptyReactNode(children);
|
|
43
|
+
return /*#__PURE__*/_jsxs(Columns, {
|
|
44
|
+
id: id,
|
|
45
|
+
ref: ref,
|
|
46
|
+
space: "xsmall",
|
|
47
|
+
"aria-label": ariaLabel,
|
|
48
|
+
children: [!!(icon || inset) && /*#__PURE__*/_jsx(Column, {
|
|
49
|
+
width: "content",
|
|
50
|
+
children: /*#__PURE__*/_jsx(DescriptionItemIcon, {
|
|
51
|
+
children: icon
|
|
52
|
+
})
|
|
53
|
+
}), /*#__PURE__*/_jsx(Column, {
|
|
54
|
+
width: "adaptive",
|
|
55
|
+
children: /*#__PURE__*/_jsxs(Inline, {
|
|
56
|
+
space: "xxsmall",
|
|
57
|
+
noWrap: !wrap,
|
|
58
|
+
children: [!!label && /*#__PURE__*/_jsx(TextBox, {
|
|
59
|
+
as: "label",
|
|
60
|
+
id: labelID,
|
|
61
|
+
color: "secondary",
|
|
62
|
+
children: label
|
|
63
|
+
}), /*#__PURE__*/_jsx(TextBox, {
|
|
64
|
+
as: "div",
|
|
65
|
+
noWrap: !wrap,
|
|
66
|
+
wrapOverflow: !!wrap,
|
|
67
|
+
"aria-labelledby": label == null ? undefined : labelID,
|
|
68
|
+
color: isEmptyChildren && label == null ? 'secondary' : 'primary',
|
|
69
|
+
children: isEmptyChildren ? fallback : children
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
if (process.env.NODE_ENV !== "production") DescriptionItem.displayName = "DescriptionItem";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["disabled", "children", "hintText", "startIcon", "fallback", "accept", "maxSize", "maxFiles", "onDropRejected", "onDropAccepted"];
|
|
4
|
+
import { mdiUpload } from '@mdi/js';
|
|
5
|
+
import { Error } from '@mui/icons-material';
|
|
6
|
+
import { CircularProgress, SvgIcon } from '@mui/material';
|
|
7
|
+
import { v5 } from '@superdispatch/ui';
|
|
8
|
+
import { forwardRef, Suspense } from 'react';
|
|
9
|
+
import Dropzone from 'react-dropzone';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
var {
|
|
15
|
+
CardButton,
|
|
16
|
+
Color,
|
|
17
|
+
Column,
|
|
18
|
+
Columns
|
|
19
|
+
} = v5;
|
|
20
|
+
export function toBytes(input, unit) {
|
|
21
|
+
if (unit === 'gb') return input * (1 << 30);
|
|
22
|
+
if (unit === 'mb') return input * (1 << 20);
|
|
23
|
+
return input * (1 << 10);
|
|
24
|
+
}
|
|
25
|
+
var KILOBYTE = 1024;
|
|
26
|
+
var BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
27
|
+
export function formatBytes(bytes) {
|
|
28
|
+
if (bytes === 0) return '0 Bytes';
|
|
29
|
+
var unitIndex = Math.floor(Math.log(bytes) / Math.log(KILOBYTE));
|
|
30
|
+
var unit = BYTE_UNITS[unitIndex];
|
|
31
|
+
return "".concat((bytes / Math.pow(KILOBYTE, unitIndex)).toFixed(2), " ").concat(unit);
|
|
32
|
+
}
|
|
33
|
+
var StyledCardButton = /*#__PURE__*/styled(CardButton).withConfig({
|
|
34
|
+
displayName: "FileDropZone__StyledCardButton",
|
|
35
|
+
componentId: "SD__sc-neqvyq-0"
|
|
36
|
+
})(_ref => {
|
|
37
|
+
var {
|
|
38
|
+
status
|
|
39
|
+
} = _ref;
|
|
40
|
+
return {
|
|
41
|
+
backgroundColor: status === 'active' ? Color.Blue50 : undefined
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function UploadRejection(_ref2) {
|
|
46
|
+
var {
|
|
47
|
+
maxSize,
|
|
48
|
+
rejection
|
|
49
|
+
} = _ref2;
|
|
50
|
+
var [error] = rejection.errors;
|
|
51
|
+
if (!error) return null;
|
|
52
|
+
return /*#__PURE__*/_jsxs(Columns, {
|
|
53
|
+
align: "center",
|
|
54
|
+
children: [/*#__PURE__*/_jsx(Column, {
|
|
55
|
+
width: "content",
|
|
56
|
+
children: /*#__PURE__*/_jsx(Error, {})
|
|
57
|
+
}), /*#__PURE__*/_jsx(Column, {
|
|
58
|
+
children: error.code === 'file-too-large' ? maxSize == null ? 'Attachment size is too large' : "Attachment size should be less than ".concat(formatBytes(maxSize)) : error.message
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export var FileDropZone = /*#__PURE__*/forwardRef((props, ref) => {
|
|
64
|
+
var {
|
|
65
|
+
// CardButton
|
|
66
|
+
disabled = false,
|
|
67
|
+
children: _children = 'Upload Attachments',
|
|
68
|
+
hintText = 'or Drag & Drop files',
|
|
69
|
+
startIcon = /*#__PURE__*/_jsx(SvgIcon, {
|
|
70
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
71
|
+
d: mdiUpload
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
fallback = /*#__PURE__*/_jsx(CardButton, {
|
|
75
|
+
ref: ref,
|
|
76
|
+
disabled: true,
|
|
77
|
+
startIcon: /*#__PURE__*/_jsx(CircularProgress, {
|
|
78
|
+
size: "1em",
|
|
79
|
+
color: "inherit"
|
|
80
|
+
}),
|
|
81
|
+
children: "Loading dependencies\u2026"
|
|
82
|
+
}),
|
|
83
|
+
// Dropzone
|
|
84
|
+
accept,
|
|
85
|
+
maxSize = Infinity,
|
|
86
|
+
maxFiles = Infinity,
|
|
87
|
+
onDropRejected: _onDropRejected,
|
|
88
|
+
onDropAccepted: _onDropAccepted
|
|
89
|
+
} = props,
|
|
90
|
+
dropzoneProps = _objectWithoutProperties(props, _excluded);
|
|
91
|
+
|
|
92
|
+
return /*#__PURE__*/_jsx(Suspense, {
|
|
93
|
+
fallback: fallback,
|
|
94
|
+
children: /*#__PURE__*/_jsx(Dropzone, _objectSpread(_objectSpread({}, dropzoneProps), {}, {
|
|
95
|
+
accept: accept,
|
|
96
|
+
maxSize: maxSize,
|
|
97
|
+
maxFiles: maxFiles,
|
|
98
|
+
disabled: disabled,
|
|
99
|
+
onDropAccepted: files => {
|
|
100
|
+
_onDropAccepted === null || _onDropAccepted === void 0 ? void 0 : _onDropAccepted(files);
|
|
101
|
+
},
|
|
102
|
+
onDropRejected: fileRejections => {
|
|
103
|
+
_onDropRejected === null || _onDropRejected === void 0 ? void 0 : _onDropRejected(fileRejections);
|
|
104
|
+
},
|
|
105
|
+
children: _ref3 => {
|
|
106
|
+
var {
|
|
107
|
+
isDragActive,
|
|
108
|
+
isDragReject,
|
|
109
|
+
getRootProps,
|
|
110
|
+
getInputProps,
|
|
111
|
+
fileRejections: [fileRejection]
|
|
112
|
+
} = _ref3;
|
|
113
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
114
|
+
children: [/*#__PURE__*/_jsx("input", _objectSpread({}, getInputProps())), /*#__PURE__*/_jsx(StyledCardButton, _objectSpread(_objectSpread({}, getRootProps()), {}, {
|
|
115
|
+
ref: ref,
|
|
116
|
+
hint: hintText,
|
|
117
|
+
disabled: disabled,
|
|
118
|
+
startIcon: startIcon,
|
|
119
|
+
status: isDragActive ? 'active' : isDragReject ? 'error' : 'idle',
|
|
120
|
+
error: !!fileRejection && /*#__PURE__*/_jsx(UploadRejection, {
|
|
121
|
+
accept: accept,
|
|
122
|
+
maxSize: maxSize,
|
|
123
|
+
rejection: fileRejection
|
|
124
|
+
}),
|
|
125
|
+
children: _children
|
|
126
|
+
}))]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}))
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
if (process.env.NODE_ENV !== "production") FileDropZone.displayName = "FileDropZone";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import { mdiFilePdfBox, mdiTextBox } from '@mdi/js';
|
|
3
|
+
import { CheckCircle, Delete, Error, Image, Refresh } from '@mui/icons-material';
|
|
4
|
+
import { CircularProgress, IconButton, Link, SvgIcon, Tooltip } from '@mui/material';
|
|
5
|
+
import { v5 } from '@superdispatch/ui';
|
|
6
|
+
import { forwardRef, memo, useState } from 'react';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
var {
|
|
11
|
+
Color,
|
|
12
|
+
Column,
|
|
13
|
+
Columns,
|
|
14
|
+
useResponsiveValue,
|
|
15
|
+
useUID
|
|
16
|
+
} = v5;
|
|
17
|
+
var FileListItemName = /*#__PURE__*/styled.div.withConfig({
|
|
18
|
+
displayName: "FileListItem__FileListItemName",
|
|
19
|
+
componentId: "SD__sc-1pro30e-0"
|
|
20
|
+
})(["overflow:hidden;line-height:22px;white-space:nowrap;text-overflow:ellipsis;"]);
|
|
21
|
+
var FileListItemProgress = /*#__PURE__*/styled(CircularProgress).withConfig({
|
|
22
|
+
displayName: "FileListItem__FileListItemProgress",
|
|
23
|
+
componentId: "SD__sc-1pro30e-1"
|
|
24
|
+
})(["font-size:24px;", "{font-size:14px;}"], _ref => {
|
|
25
|
+
var {
|
|
26
|
+
theme
|
|
27
|
+
} = _ref;
|
|
28
|
+
return theme.breakpoints.up('sm');
|
|
29
|
+
});
|
|
30
|
+
var PdfIcon = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SvgIcon, _objectSpread(_objectSpread({}, props), {}, {
|
|
31
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
32
|
+
d: mdiFilePdfBox
|
|
33
|
+
})
|
|
34
|
+
})));
|
|
35
|
+
var TextBoxIcon = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SvgIcon, _objectSpread(_objectSpread({}, props), {}, {
|
|
36
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
37
|
+
d: mdiTextBox
|
|
38
|
+
})
|
|
39
|
+
})));
|
|
40
|
+
var PDF_FILE_PATTERN = /\.pdf$/;
|
|
41
|
+
var IMAGE_FILE_PATTERN = /\.(gif|png|jpg|jpeg)$/;
|
|
42
|
+
|
|
43
|
+
function getFileType(name) {
|
|
44
|
+
if (PDF_FILE_PATTERN.exec(name)) return 'pdf';
|
|
45
|
+
if (IMAGE_FILE_PATTERN.exec(name)) return 'image';
|
|
46
|
+
return 'unknown';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export var FileListItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
50
|
+
var {
|
|
51
|
+
url,
|
|
52
|
+
name,
|
|
53
|
+
status,
|
|
54
|
+
onRetry,
|
|
55
|
+
onDelete
|
|
56
|
+
} = _ref2;
|
|
57
|
+
var uid = useUID();
|
|
58
|
+
var fileType = getFileType(name);
|
|
59
|
+
var [isHoveredState, setIsHovered] = useState(false);
|
|
60
|
+
var isHovered = useResponsiveValue(true, isHoveredState);
|
|
61
|
+
return /*#__PURE__*/_jsx("div", {
|
|
62
|
+
ref: ref,
|
|
63
|
+
onMouseOver: () => {
|
|
64
|
+
setIsHovered(true);
|
|
65
|
+
},
|
|
66
|
+
onMouseLeave: () => {
|
|
67
|
+
setIsHovered(false);
|
|
68
|
+
},
|
|
69
|
+
children: /*#__PURE__*/_jsxs(Columns, {
|
|
70
|
+
align: "center",
|
|
71
|
+
space: "xsmall",
|
|
72
|
+
children: [/*#__PURE__*/_jsx(Column, {
|
|
73
|
+
width: "content",
|
|
74
|
+
children: status === 'error' ? /*#__PURE__*/_jsx(Error, {
|
|
75
|
+
color: "error",
|
|
76
|
+
fontSize: "small"
|
|
77
|
+
}) : fileType === 'pdf' ? /*#__PURE__*/_jsx(PdfIcon, {
|
|
78
|
+
color: "action",
|
|
79
|
+
fontSize: "small"
|
|
80
|
+
}) : fileType === 'image' ? /*#__PURE__*/_jsx(Image, {
|
|
81
|
+
color: "action",
|
|
82
|
+
fontSize: "small"
|
|
83
|
+
}) : /*#__PURE__*/_jsx(TextBoxIcon, {
|
|
84
|
+
color: "action",
|
|
85
|
+
fontSize: "small"
|
|
86
|
+
})
|
|
87
|
+
}), /*#__PURE__*/_jsx(Column, {
|
|
88
|
+
width: "fluid",
|
|
89
|
+
children: /*#__PURE__*/_jsx(FileListItemName, {
|
|
90
|
+
id: uid,
|
|
91
|
+
children: !url ? name : /*#__PURE__*/_jsx(Link, {
|
|
92
|
+
href: url,
|
|
93
|
+
noWrap: true,
|
|
94
|
+
target: "_blank",
|
|
95
|
+
rel: "noopener noreferrer",
|
|
96
|
+
children: name
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
}), status === 'error' && /*#__PURE__*/_jsx(Column, {
|
|
100
|
+
width: "content",
|
|
101
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
102
|
+
title: "Retry",
|
|
103
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
104
|
+
size: "small",
|
|
105
|
+
onClick: onRetry,
|
|
106
|
+
children: /*#__PURE__*/_jsx(Refresh, {
|
|
107
|
+
fontSize: "small"
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
}), /*#__PURE__*/_jsx(Column, {
|
|
112
|
+
width: "content",
|
|
113
|
+
children: status === 'loading' ? /*#__PURE__*/_jsx(IconButton, {
|
|
114
|
+
size: "small",
|
|
115
|
+
disabled: true,
|
|
116
|
+
children: /*#__PURE__*/_jsx(FileListItemProgress, {
|
|
117
|
+
size: "1em"
|
|
118
|
+
})
|
|
119
|
+
}) : /*#__PURE__*/_jsx(Tooltip, {
|
|
120
|
+
title: "Delete",
|
|
121
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
122
|
+
size: "small",
|
|
123
|
+
onClick: onDelete,
|
|
124
|
+
children: !isHovered && status === 'success' ? /*#__PURE__*/_jsx(CheckCircle, {
|
|
125
|
+
fontSize: "small",
|
|
126
|
+
htmlColor: Color.Green300
|
|
127
|
+
}) : /*#__PURE__*/_jsx(Delete, {
|
|
128
|
+
fontSize: "small"
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
})]
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
if (process.env.NODE_ENV !== "production") FileListItem.displayName = "FileListItem";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./alert/Alert.js";
|
|
2
|
+
export * from "./banner/Banner.js";
|
|
3
|
+
export * from "./box/Box.js";
|
|
4
|
+
export * from "./button-area/ButtonArea.js";
|
|
5
|
+
export * from "./button/Button.js";
|
|
6
|
+
export * from "./description-item/DescriptionItem.js";
|
|
7
|
+
export * from "./file-drop-zone/FileDropZone.js";
|
|
8
|
+
export * from "./file-list-item/FileListItem.js";
|
|
9
|
+
export * from "./sidebar/Sidebar.js";
|
|
10
|
+
export * from "./sidebar/SidebarContainer.js";
|
|
11
|
+
export * from "./sidebar/SidebarDivider.js";
|
|
12
|
+
export * from "./sidebar/SidebarMenuItem.js";
|
|
13
|
+
export * from "./sidebar/SidebarMenuItemAction.js";
|
|
14
|
+
export * from "./sidebar/SidebarMenuItemAvatar.js";
|
|
15
|
+
export * from "./sidebar/SidebarSubheader.js";
|
|
16
|
+
export * from "./text-box/TextBox.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { v5 } from '@superdispatch/ui';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { TextBox } from "../text-box/TextBox.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
var {
|
|
8
|
+
Color,
|
|
9
|
+
Column,
|
|
10
|
+
Columns,
|
|
11
|
+
useUID
|
|
12
|
+
} = v5;
|
|
13
|
+
var SidebarRoot = /*#__PURE__*/styled.aside.withConfig({
|
|
14
|
+
displayName: "Sidebar__SidebarRoot",
|
|
15
|
+
componentId: "SD__sc-14hfb05-0"
|
|
16
|
+
})(["top:0;position:sticky;overflow-y:auto;overflow-x:hidden;width:240px;height:100vh;background-color:", ";border-right:1px solid ", ";"], Color.White, Color.Silver400);
|
|
17
|
+
var SidebarHeader = /*#__PURE__*/styled.div.withConfig({
|
|
18
|
+
displayName: "Sidebar__SidebarHeader",
|
|
19
|
+
componentId: "SD__sc-14hfb05-1"
|
|
20
|
+
})(["top:0;z-index:1;position:sticky;padding-left:24px;padding-right:24px;padding-bottom:8px;background-color:", ";"], Color.White);
|
|
21
|
+
var SidebarTitle = /*#__PURE__*/styled.div.withConfig({
|
|
22
|
+
displayName: "Sidebar__SidebarTitle",
|
|
23
|
+
componentId: "SD__sc-14hfb05-2"
|
|
24
|
+
})(["height:64px;max-height:64px;display:flex;align-items:center;"]);
|
|
25
|
+
export var Sidebar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
26
|
+
var {
|
|
27
|
+
title,
|
|
28
|
+
count,
|
|
29
|
+
header,
|
|
30
|
+
children,
|
|
31
|
+
id: idProp
|
|
32
|
+
} = _ref;
|
|
33
|
+
var id = useUID(idProp);
|
|
34
|
+
var titleID = "".concat(id, "-title");
|
|
35
|
+
return /*#__PURE__*/_jsxs(SidebarRoot, {
|
|
36
|
+
id: id,
|
|
37
|
+
ref: ref,
|
|
38
|
+
children: [/*#__PURE__*/_jsxs(SidebarHeader, {
|
|
39
|
+
children: [/*#__PURE__*/_jsx(SidebarTitle, {
|
|
40
|
+
children: /*#__PURE__*/_jsxs(Columns, {
|
|
41
|
+
space: "xsmall",
|
|
42
|
+
align: "center",
|
|
43
|
+
children: [/*#__PURE__*/_jsx(Column, {
|
|
44
|
+
width: "fluid",
|
|
45
|
+
children: /*#__PURE__*/_jsx(TextBox, {
|
|
46
|
+
variant: "heading-2",
|
|
47
|
+
noWrap: true,
|
|
48
|
+
id: titleID,
|
|
49
|
+
children: title
|
|
50
|
+
})
|
|
51
|
+
}), !!count && /*#__PURE__*/_jsx(Column, {
|
|
52
|
+
width: "content",
|
|
53
|
+
children: /*#__PURE__*/_jsx(TextBox, {
|
|
54
|
+
color: "secondary",
|
|
55
|
+
children: count
|
|
56
|
+
})
|
|
57
|
+
})]
|
|
58
|
+
})
|
|
59
|
+
}), header]
|
|
60
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
61
|
+
"aria-labelledby": titleID,
|
|
62
|
+
children: children
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
if (process.env.NODE_ENV !== "production") Sidebar.displayName = "Sidebar";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
var SidebarContainerRoot = /*#__PURE__*/styled.div.withConfig({
|
|
6
|
+
displayName: "SidebarContainer__SidebarContainerRoot",
|
|
7
|
+
componentId: "SD__sc-6u6mqe-0"
|
|
8
|
+
})(["display:flex;height:inherit;max-height:inherit;min-height:inherit;"]);
|
|
9
|
+
var SidebarContainerContent = /*#__PURE__*/styled.div.withConfig({
|
|
10
|
+
displayName: "SidebarContainer__SidebarContainerContent",
|
|
11
|
+
componentId: "SD__sc-6u6mqe-1"
|
|
12
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;width:calc(100% - 240px);min-width:calc(100% - 240px);max-width:calc(100% - 240px);"]);
|
|
13
|
+
export var SidebarContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
|
+
var {
|
|
15
|
+
sidebar,
|
|
16
|
+
children
|
|
17
|
+
} = _ref;
|
|
18
|
+
return /*#__PURE__*/_jsxs(SidebarContainerRoot, {
|
|
19
|
+
ref: ref,
|
|
20
|
+
children: [sidebar, /*#__PURE__*/_jsx(SidebarContainerContent, {
|
|
21
|
+
children: children
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
if (process.env.NODE_ENV !== "production") SidebarContainer.displayName = "SidebarContainer";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Divider } from '@mui/material';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
var SidebarDividerRoot = /*#__PURE__*/styled.div.withConfig({
|
|
6
|
+
displayName: "SidebarDivider__SidebarDividerRoot",
|
|
7
|
+
componentId: "SD__sc-182lunj-0"
|
|
8
|
+
})(["padding:20px 24px;"]);
|
|
9
|
+
export var SidebarDivider = /*#__PURE__*/forwardRef((_, ref) => {
|
|
10
|
+
return /*#__PURE__*/_jsx(SidebarDividerRoot, {
|
|
11
|
+
ref: ref,
|
|
12
|
+
children: /*#__PURE__*/_jsx(Divider, {})
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
if (process.env.NODE_ENV !== "production") SidebarDivider.displayName = "SidebarDivider";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { OpenInNew } from '@mui/icons-material';
|
|
2
|
+
import { ButtonBase } from '@mui/material';
|
|
3
|
+
import { v5 } from '@superdispatch/ui';
|
|
4
|
+
import { forwardRef, useLayoutEffect, useRef, useState } from 'react';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
|
+
import { TextBox } from "../text-box/TextBox.js";
|
|
7
|
+
import { SidebarMenuItemContextProvider } from "./SidebarMenuItemContext.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
var {
|
|
11
|
+
Color,
|
|
12
|
+
Column,
|
|
13
|
+
Columns,
|
|
14
|
+
Inline
|
|
15
|
+
} = v5;
|
|
16
|
+
var SidebarMenuItemRoot = /*#__PURE__*/styled.div.withConfig({
|
|
17
|
+
displayName: "SidebarMenuItem__SidebarMenuItemRoot",
|
|
18
|
+
componentId: "SD__sc-1srwx2n-0"
|
|
19
|
+
})(_ref => {
|
|
20
|
+
var {
|
|
21
|
+
hasAvatar
|
|
22
|
+
} = _ref;
|
|
23
|
+
var height = hasAvatar ? 48 : 40;
|
|
24
|
+
return css(["position:relative;& > .MuiButtonBase-root{width:100%;display:flex;justify-content:flex-start;padding-left:24px;padding-right:24px;height:", "px;max-height:", "px;&[aria-current='true']{background-color:", ";box-shadow:inset 4px 0 0 ", ";}}"], height, height, Color.Silver200, Color.Blue300);
|
|
25
|
+
});
|
|
26
|
+
var SidebarMenuItemBadge = /*#__PURE__*/styled.div.withConfig({
|
|
27
|
+
displayName: "SidebarMenuItem__SidebarMenuItemBadge",
|
|
28
|
+
componentId: "SD__sc-1srwx2n-1"
|
|
29
|
+
})(["font-size:12px;line-height:16px;padding-left:4px;padding-right:4px;border-radius:100px;color:", ";background-color:", ";.MuiButtonBase-root[aria-current='true'] &{color:", ";background-color:", ";}"], Color.Dark500, Color.Silver300, Color.White, Color.Dark450);
|
|
30
|
+
var SidebarMenuItemSecondaryAction = /*#__PURE__*/styled.div.withConfig({
|
|
31
|
+
displayName: "SidebarMenuItem__SidebarMenuItemSecondaryAction",
|
|
32
|
+
componentId: "SD__sc-1srwx2n-2"
|
|
33
|
+
})(["top:50%;right:24px;position:absolute;transform:translate3d(0,-50%,0);"]);
|
|
34
|
+
export var SidebarMenuItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
35
|
+
var {
|
|
36
|
+
action,
|
|
37
|
+
avatar,
|
|
38
|
+
onClick,
|
|
39
|
+
external,
|
|
40
|
+
children,
|
|
41
|
+
disabled,
|
|
42
|
+
selected,
|
|
43
|
+
secondaryActions,
|
|
44
|
+
badge: badgeProp
|
|
45
|
+
} = _ref2;
|
|
46
|
+
var [hovered, setHovered] = useState(false);
|
|
47
|
+
var actionsRef = useRef(null);
|
|
48
|
+
var actionsPlaceholderRef = useRef(null);
|
|
49
|
+
useLayoutEffect(() => {
|
|
50
|
+
if (actionsRef.current && actionsPlaceholderRef.current) {
|
|
51
|
+
actionsPlaceholderRef.current.style.width = "".concat(Math.max(0, actionsRef.current.offsetWidth - 8), "px");
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
var badge = !badgeProp || !Number.isFinite(badgeProp) ? null : badgeProp > 999 ? '999+' : badgeProp;
|
|
55
|
+
return /*#__PURE__*/_jsxs(SidebarMenuItemRoot, {
|
|
56
|
+
ref: ref,
|
|
57
|
+
hasAvatar: !!avatar,
|
|
58
|
+
onMouseEnter: () => {
|
|
59
|
+
setHovered(true);
|
|
60
|
+
},
|
|
61
|
+
onMouseLeave: () => {
|
|
62
|
+
setHovered(false);
|
|
63
|
+
},
|
|
64
|
+
children: [/*#__PURE__*/_jsx(ButtonBase, {
|
|
65
|
+
onClick: onClick,
|
|
66
|
+
disabled: disabled,
|
|
67
|
+
"aria-current": selected,
|
|
68
|
+
children: /*#__PURE__*/_jsxs(Columns, {
|
|
69
|
+
align: "center",
|
|
70
|
+
space: "xsmall",
|
|
71
|
+
children: [/*#__PURE__*/_jsx(Column, {
|
|
72
|
+
children: /*#__PURE__*/_jsx(Columns, {
|
|
73
|
+
align: "center",
|
|
74
|
+
space: "xsmall",
|
|
75
|
+
children: /*#__PURE__*/_jsx(Column, {
|
|
76
|
+
width: "fluid",
|
|
77
|
+
children: /*#__PURE__*/_jsxs(Columns, {
|
|
78
|
+
align: "center",
|
|
79
|
+
space: "xsmall",
|
|
80
|
+
children: [!!avatar && /*#__PURE__*/_jsx(SidebarMenuItemContextProvider, {
|
|
81
|
+
hovered: hovered,
|
|
82
|
+
disabled: disabled,
|
|
83
|
+
children: /*#__PURE__*/_jsx(Column, {
|
|
84
|
+
width: "content",
|
|
85
|
+
children: avatar
|
|
86
|
+
})
|
|
87
|
+
}), /*#__PURE__*/_jsx(Column, {
|
|
88
|
+
width: "adaptive",
|
|
89
|
+
children: /*#__PURE__*/_jsx(TextBox, {
|
|
90
|
+
variant: selected ? 'body-semibold' : 'body',
|
|
91
|
+
noWrap: true,
|
|
92
|
+
children: children
|
|
93
|
+
})
|
|
94
|
+
}), external && /*#__PURE__*/_jsx(Column, {
|
|
95
|
+
width: "content",
|
|
96
|
+
children: /*#__PURE__*/_jsx(OpenInNew, {
|
|
97
|
+
color: "action",
|
|
98
|
+
fontSize: "small"
|
|
99
|
+
})
|
|
100
|
+
})]
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
}), !!badge && /*#__PURE__*/_jsx(Column, {
|
|
105
|
+
width: "content",
|
|
106
|
+
children: /*#__PURE__*/_jsx(SidebarMenuItemBadge, {
|
|
107
|
+
children: badge
|
|
108
|
+
})
|
|
109
|
+
}), (!!action || !!secondaryActions) && /*#__PURE__*/_jsx(Column, {
|
|
110
|
+
width: "content",
|
|
111
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
112
|
+
ref: actionsPlaceholderRef
|
|
113
|
+
})
|
|
114
|
+
})]
|
|
115
|
+
})
|
|
116
|
+
}), (!!action || !!secondaryActions) && /*#__PURE__*/_jsx(SidebarMenuItemSecondaryAction, {
|
|
117
|
+
ref: actionsRef,
|
|
118
|
+
children: /*#__PURE__*/_jsxs(Inline, {
|
|
119
|
+
children: [hovered && secondaryActions, action]
|
|
120
|
+
})
|
|
121
|
+
})]
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
if (process.env.NODE_ENV !== "production") SidebarMenuItem.displayName = "SidebarMenuItem";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
var SidebarMenuItemActionRoot = /*#__PURE__*/styled(IconButton).withConfig({
|
|
6
|
+
displayName: "SidebarMenuItemAction__SidebarMenuItemActionRoot",
|
|
7
|
+
componentId: "SD__sc-4la7tu-0"
|
|
8
|
+
})(["& .MuiSvgIcon-root{font-size:16px;}"]);
|
|
9
|
+
export var SidebarMenuItemAction = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
10
|
+
var {
|
|
11
|
+
title,
|
|
12
|
+
placement,
|
|
13
|
+
children
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
16
|
+
title: title,
|
|
17
|
+
placement: placement,
|
|
18
|
+
children: /*#__PURE__*/_jsx(SidebarMenuItemActionRoot, {
|
|
19
|
+
ref: ref,
|
|
20
|
+
size: "small",
|
|
21
|
+
edge: "end",
|
|
22
|
+
children: children
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
if (process.env.NODE_ENV !== "production") SidebarMenuItemAction.displayName = "SidebarMenuItemAction";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Avatar, Checkbox } from '@mui/material';
|
|
2
|
+
import { forwardRef, useMemo } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { useSidebarMenuItemContext } from "./SidebarMenuItemContext.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
function stopPropagation(event) {
|
|
8
|
+
event.stopPropagation();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var SidebarMenuItemAvatarCheckbox = /*#__PURE__*/styled.div.withConfig({
|
|
12
|
+
displayName: "SidebarMenuItemAvatar__SidebarMenuItemAvatarCheckbox",
|
|
13
|
+
componentId: "SD__sc-bfi0pv-0"
|
|
14
|
+
})(["margin:-5px;"]);
|
|
15
|
+
export var SidebarMenuItemAvatar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
16
|
+
var {
|
|
17
|
+
children,
|
|
18
|
+
value,
|
|
19
|
+
onChange: _onChange
|
|
20
|
+
} = _ref;
|
|
21
|
+
var {
|
|
22
|
+
hovered,
|
|
23
|
+
disabled
|
|
24
|
+
} = useSidebarMenuItemContext();
|
|
25
|
+
var initials = useMemo(() => {
|
|
26
|
+
var matches = children.match(/\b\w/g) || [];
|
|
27
|
+
var first = matches.shift() || '';
|
|
28
|
+
var last = matches.pop() || '';
|
|
29
|
+
return (first + last).toUpperCase();
|
|
30
|
+
}, [children]);
|
|
31
|
+
|
|
32
|
+
if (value === true || hovered && value != null) {
|
|
33
|
+
return /*#__PURE__*/_jsx(SidebarMenuItemAvatarCheckbox, {
|
|
34
|
+
children: /*#__PURE__*/_jsx(Checkbox, {
|
|
35
|
+
color: "primary",
|
|
36
|
+
checked: value,
|
|
37
|
+
disabled: disabled,
|
|
38
|
+
onMouseDown: stopPropagation,
|
|
39
|
+
onTouchStart: stopPropagation,
|
|
40
|
+
onChange: (_, checked) => {
|
|
41
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(checked);
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/_jsx(Avatar, {
|
|
48
|
+
ref: ref,
|
|
49
|
+
"aria-hidden": true,
|
|
50
|
+
children: initials
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
if (process.env.NODE_ENV !== "production") SidebarMenuItemAvatar.displayName = "SidebarMenuItemAvatar";
|