orc-shared 5.99.0-dev.1 → 5.99.0-dev.10
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/components/AppFrame/About.js +13 -13
- package/dist/components/AppFrame/Anchor.js +7 -7
- package/dist/components/AppFrame/AppFrame.js +3 -3
- package/dist/components/AppFrame/Help.js +4 -4
- package/dist/components/AppFrame/MenuItem.js +14 -14
- package/dist/components/AppFrame/Preferences.js +14 -14
- package/dist/components/AppFrame/Sidebar.js +6 -6
- package/dist/components/AppFrame/Topbar.js +6 -6
- package/dist/components/DropMenu/Menu.js +9 -9
- package/dist/components/Form/Field.js +4 -4
- package/dist/components/Form/Inputs/Button.js +2 -2
- package/dist/components/Form/Inputs/MultiSelector.js +67 -12
- package/dist/components/Form/Inputs/Selector.js +13 -10
- package/dist/components/InternetExplorerWarningMessage.js +15 -15
- package/dist/components/MaterialUI/DataDisplay/Modal.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +4 -4
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +1 -1
- package/dist/components/MaterialUI/Inputs/InputBase.js +209 -24
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
- package/dist/components/MaterialUI/Inputs/Select.js +170 -114
- package/dist/components/MaterialUI/Inputs/SelectProps.js +10 -2
- package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
- package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +27 -42
- package/dist/components/MaterialUI/Surfaces/Paper.js +1 -1
- package/dist/components/MaterialUI/muiThemes.js +1 -1
- package/dist/components/Routing/SegmentPage.js +9 -7
- package/dist/components/Scope/ScopeNode.js +7 -9
- package/dist/components/Sidepanel.js +29 -27
- package/dist/components/Spritesheet.js +17 -15
- package/dist/components/ToastList.js +11 -11
- package/dist/components/Treeview/Branch.js +9 -9
- package/dist/components/Treeview/Label.js +8 -8
- package/dist/components/Treeview/Leaf.js +2 -2
- package/dist/components/Treeview/settings.js +10 -1
- package/dist/hocs/withScrollBox.js +3 -8
- package/dist/hooks/useWindowSize.js +88 -0
- package/dist/sharedMessages.js +8 -0
- package/package.json +1 -1
- package/src/components/AppFrame/About.js +13 -13
- package/src/components/AppFrame/Anchor.js +7 -7
- package/src/components/AppFrame/AppFrame.js +3 -3
- package/src/components/AppFrame/Help.js +4 -4
- package/src/components/AppFrame/MenuItem.js +14 -14
- package/src/components/AppFrame/Preferences.js +14 -14
- package/src/components/AppFrame/Sidebar.js +6 -6
- package/src/components/AppFrame/Topbar.js +6 -6
- package/src/components/DropMenu/Menu.js +9 -9
- package/src/components/Form/Field.js +4 -4
- package/src/components/Form/Inputs/Button.js +2 -2
- package/src/components/Form/Inputs/MultiSelector.js +55 -5
- package/src/components/Form/Inputs/MultiSelector.test.js +259 -39
- package/src/components/Form/Inputs/Selector.js +12 -4
- package/src/components/Form/Inputs/Selector.test.js +27 -12
- package/src/components/InternetExplorerWarningMessage.js +15 -15
- package/src/components/MaterialUI/DataDisplay/Modal.js +3 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +74 -0
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/src/components/MaterialUI/DataDisplay/TransferList.js +1 -1
- package/src/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +1 -1
- package/src/components/MaterialUI/Inputs/InputBase.js +209 -8
- package/src/components/MaterialUI/Inputs/InputBase.test.js +481 -3
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
- package/src/components/MaterialUI/Inputs/Select.js +140 -87
- package/src/components/MaterialUI/Inputs/Select.test.js +170 -30
- package/src/components/MaterialUI/Inputs/SelectProps.js +9 -1
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +8 -0
- package/src/components/MaterialUI/Inputs/Switch.js +1 -1
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -2
- package/src/components/MaterialUI/ScopeSelector/TreeItem.js +8 -31
- package/src/components/MaterialUI/Surfaces/Paper.js +1 -1
- package/src/components/MaterialUI/muiThemes.js +1 -1
- package/src/components/Routing/SegmentPage.js +7 -7
- package/src/components/Scope/ScopeNode.js +7 -8
- package/src/components/Sidepanel.js +7 -7
- package/src/components/Sidepanel.test.js +9 -4
- package/src/components/Spritesheet.js +5 -5
- package/src/components/ToastList.js +11 -11
- package/src/components/Treeview/Branch.js +10 -10
- package/src/components/Treeview/Branch.test.js +2 -40
- package/src/components/Treeview/Label.js +9 -9
- package/src/components/Treeview/Label.test.js +13 -3
- package/src/components/Treeview/Leaf.js +3 -3
- package/src/components/Treeview/Leaf.test.js +1 -20
- package/src/components/Treeview/settings.js +3 -0
- package/src/hocs/withScrollBox.js +2 -8
- package/src/hooks/useMultipleFieldEditState.test.js +0 -1
- package/src/hooks/useWindowSize.js +39 -0
- package/src/hooks/useWindowSize.test.js +68 -0
- package/src/sharedMessages.js +8 -0
- package/src/translations/en-US.json +2 -0
- package/src/translations/fr-CA.json +2 -0
|
@@ -15,7 +15,6 @@ const useStyles = makeStyles(theme => ({
|
|
|
15
15
|
backgroundColor: theme.palette.grey.light,
|
|
16
16
|
border: `1px solid ${theme.palette.grey.borders}`,
|
|
17
17
|
boxShadow: "0 2px 4px rgba(0,0,0,0.5)",
|
|
18
|
-
width: theme.spacing(50),
|
|
19
18
|
display: "flex",
|
|
20
19
|
},
|
|
21
20
|
scopeContainer: {
|
|
@@ -65,7 +64,7 @@ const ScopeSelector = ({ show, getScope, selectedScope, closeSelector, filter, u
|
|
|
65
64
|
);
|
|
66
65
|
|
|
67
66
|
const scopeSelector = (
|
|
68
|
-
<Sidepanel className={classes.container} in={show} timeout={300}>
|
|
67
|
+
<Sidepanel className={classes.container} widthSpacing={50} in={show} timeout={300}>
|
|
69
68
|
<ClickAwayListener onClickAway={e => closeSelector(e)}>
|
|
70
69
|
{/* this div is required since ClickAwayListener child element should be able to hold ref */}
|
|
71
70
|
<div className={classes.scopeContainer}>{show ? scopeSelectorContent : null}</div>
|
|
@@ -11,19 +11,6 @@ import { scopeTypes } from "./../../../constants";
|
|
|
11
11
|
const useStyles = makeStyles(theme => ({
|
|
12
12
|
group: {
|
|
13
13
|
marginLeft: props => (props.isRootScope ? theme.spacing(1.2) : theme.spacing(3.2)),
|
|
14
|
-
// to hide unnecessary border part
|
|
15
|
-
// "& > div > div > :last-child": {
|
|
16
|
-
// "&:after": {
|
|
17
|
-
// content: "''",
|
|
18
|
-
// backgroundColor: theme.palette.grey.light,
|
|
19
|
-
// position: "absolute",
|
|
20
|
-
// top: theme.spacing(1.2),
|
|
21
|
-
// left: theme.spacing(-2.1),
|
|
22
|
-
// height: "100%",
|
|
23
|
-
// bottom: 0,
|
|
24
|
-
// width: "1px",
|
|
25
|
-
// },
|
|
26
|
-
// }
|
|
27
14
|
},
|
|
28
15
|
rootIconContainer: {
|
|
29
16
|
marginRight: 0,
|
|
@@ -73,33 +60,23 @@ const useStyles = makeStyles(theme => ({
|
|
|
73
60
|
},
|
|
74
61
|
}));
|
|
75
62
|
|
|
76
|
-
export const ScopeIcon = ({ type }) => {
|
|
63
|
+
export const ScopeIcon = ({ type, scopeIconClass }) => {
|
|
77
64
|
const classes = useStyles();
|
|
78
65
|
const theme = useTheme();
|
|
79
66
|
|
|
80
|
-
const
|
|
81
|
-
const virtualIcon = (
|
|
82
|
-
<Icon className={classes.scopeIcon} themeColor={theme.palette.grey.dark} fontSize="medium" id="virtual-scope" />
|
|
83
|
-
);
|
|
84
|
-
const salesIcon = <Icon className={classes.scopeIcon} color="primary" fontSize="medium" id="sales-scope" />;
|
|
85
|
-
const dependentIcon = (
|
|
86
|
-
<Icon
|
|
87
|
-
className={classes.scopeIcon}
|
|
88
|
-
themeColor={theme.palette.success.main}
|
|
89
|
-
fontSize="medium"
|
|
90
|
-
id="dependent-scope"
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
67
|
+
const iconClass = classNames(classes.scopeIcon, scopeIconClass);
|
|
93
68
|
|
|
94
69
|
switch (type) {
|
|
95
70
|
case scopeTypes.global:
|
|
96
|
-
return
|
|
71
|
+
return <Icon className={iconClass} color="primary" fontSize="medium" id="global-scope" />;
|
|
97
72
|
case scopeTypes.virtual:
|
|
98
|
-
return
|
|
73
|
+
return <Icon className={iconClass} themeColor={theme.palette.grey.dark} fontSize="medium" id="virtual-scope" />;
|
|
99
74
|
case scopeTypes.sale:
|
|
100
|
-
return
|
|
75
|
+
return <Icon className={iconClass} color="primary" fontSize="medium" id="sales-scope" />;
|
|
101
76
|
case scopeTypes.dependant:
|
|
102
|
-
return
|
|
77
|
+
return (
|
|
78
|
+
<Icon className={iconClass} themeColor={theme.palette.success.main} fontSize="medium" id="dependent-scope" />
|
|
79
|
+
);
|
|
103
80
|
default:
|
|
104
81
|
return null;
|
|
105
82
|
}
|
|
@@ -13,7 +13,7 @@ const useStyle = makeStyles(theme => ({
|
|
|
13
13
|
},
|
|
14
14
|
"&::-webkit-scrollbar-thumb": {
|
|
15
15
|
background: theme.palette.grey.borders,
|
|
16
|
-
border:
|
|
16
|
+
border: `${theme.spacing(0.5)} transparent solid`,
|
|
17
17
|
backgroundClip: "padding-box",
|
|
18
18
|
borderRadius: theme.spacing(1.5),
|
|
19
19
|
},
|
|
@@ -46,7 +46,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
46
46
|
display: "flex",
|
|
47
47
|
borderTop: `1px solid ${theme.palette.grey.borders}`,
|
|
48
48
|
flex: "0 1 100%",
|
|
49
|
-
height:
|
|
49
|
+
height: `calc(100% - ${theme.spacing(9)})`,
|
|
50
50
|
minHeight: 0,
|
|
51
51
|
|
|
52
52
|
"div[class^='AppFrame__ViewPort'] > div&:nth-child(3)": {
|
|
@@ -64,9 +64,9 @@ const useStyles = makeStyles(theme => ({
|
|
|
64
64
|
display: "block",
|
|
65
65
|
whiteSpace: "nowrap",
|
|
66
66
|
minWidth: "max-content",
|
|
67
|
-
padding:
|
|
67
|
+
padding: theme.spacing(1.5, 2),
|
|
68
68
|
fontWeight: "bold",
|
|
69
|
-
fontSize:
|
|
69
|
+
fontSize: theme.spacing(1.3),
|
|
70
70
|
textDecoration: "none",
|
|
71
71
|
cursor: "pointer",
|
|
72
72
|
color: theme.palette.text.primary,
|
|
@@ -150,20 +150,20 @@ export const SegmentItem = ({ isModified, isError, isActive, segpath, config, ba
|
|
|
150
150
|
);
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
export const Wrapper = ({ children }) => {
|
|
153
|
+
export const Wrapper = ({ className, children }) => {
|
|
154
154
|
const classes = useStyles();
|
|
155
155
|
|
|
156
156
|
return (
|
|
157
|
-
<div className={classes.wrapper} key="Segments">
|
|
157
|
+
<div className={classNames(classes.wrapper, className ?? null)} key="Segments">
|
|
158
158
|
{children}
|
|
159
159
|
</div>
|
|
160
160
|
);
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
export const List = ({ children }) => {
|
|
163
|
+
export const List = ({ className, children }) => {
|
|
164
164
|
const classes = useStyles();
|
|
165
165
|
|
|
166
|
-
return <div className={classes.list}>{children}</div>;
|
|
166
|
+
return <div className={classNames(classes.list, className ?? null)}>{children}</div>;
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
export const Item = ({ active, to, children, onClick }) => {
|
|
@@ -5,10 +5,10 @@ import classNames from "classnames";
|
|
|
5
5
|
|
|
6
6
|
const useStyles = makeStyles(theme => ({
|
|
7
7
|
scopeIcon: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
paddingRight: theme.spacing(0.8),
|
|
9
|
+
marginRight: theme.spacing(0),
|
|
10
|
+
height: theme.spacing(2),
|
|
11
|
+
width: theme.spacing(2),
|
|
12
12
|
},
|
|
13
13
|
scopeText: {
|
|
14
14
|
overflowWrap: "break-word",
|
|
@@ -17,9 +17,8 @@ const useStyles = makeStyles(theme => ({
|
|
|
17
17
|
boxSizing: "border-box",
|
|
18
18
|
display: "flex",
|
|
19
19
|
alignItems: "center",
|
|
20
|
-
padding:
|
|
20
|
+
padding: theme.spacing(1),
|
|
21
21
|
width: "100%",
|
|
22
|
-
textTransform: props.isGlobal ? "uppercase" : "none",
|
|
23
22
|
...(props.isClickable
|
|
24
23
|
? {
|
|
25
24
|
"&:hover": {
|
|
@@ -33,7 +32,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
33
32
|
}),
|
|
34
33
|
}));
|
|
35
34
|
|
|
36
|
-
export const ScopeNode = ({ type, scopeId, name, contentLabelClassName,
|
|
35
|
+
export const ScopeNode = ({ type, scopeId, name, contentLabelClassName, onClick, children }) => {
|
|
37
36
|
const classes = useStyles({ isGlobal: type === "Global", isClickable: onClick !== undefined });
|
|
38
37
|
|
|
39
38
|
const displayValue = (name || scopeId) ?? null;
|
|
@@ -45,7 +44,7 @@ export const ScopeNode = ({ type, scopeId, name, contentLabelClassName, iconClas
|
|
|
45
44
|
onClick={onClick}
|
|
46
45
|
data-qa="content-label"
|
|
47
46
|
>
|
|
48
|
-
<ScopeIcon type={type}
|
|
47
|
+
<ScopeIcon type={type} scopeIconClass={classes.scopeIcon} />
|
|
49
48
|
{displayValue && <div className={classes.scopeText}>{displayValue}</div>}
|
|
50
49
|
{children}
|
|
51
50
|
</div>
|
|
@@ -6,16 +6,16 @@ import classNames from "classnames";
|
|
|
6
6
|
|
|
7
7
|
const getModalRoot = () => document.getElementById("modal");
|
|
8
8
|
|
|
9
|
-
const useStyles = makeStyles({
|
|
9
|
+
const useStyles = makeStyles(theme => ({
|
|
10
10
|
panel: props => ({
|
|
11
11
|
position: "absolute",
|
|
12
12
|
top: 0,
|
|
13
13
|
bottom: 0,
|
|
14
14
|
right: 0,
|
|
15
|
-
width: props.
|
|
15
|
+
width: theme.spacing(props.widthSpacing),
|
|
16
16
|
|
|
17
17
|
"&.enter": {
|
|
18
|
-
transform: `translateX(${props.
|
|
18
|
+
transform: `translateX(${theme.spacing(props.widthSpacing)})`,
|
|
19
19
|
},
|
|
20
20
|
"&.enter-active": {
|
|
21
21
|
transform: "translateX(0)",
|
|
@@ -25,14 +25,14 @@ const useStyles = makeStyles({
|
|
|
25
25
|
transform: "translateX(0)",
|
|
26
26
|
},
|
|
27
27
|
"&.exit-active": {
|
|
28
|
-
transform: `translateX(${props.
|
|
28
|
+
transform: `translateX(${theme.spacing(props.widthSpacing)})`,
|
|
29
29
|
transition: `transform ${props.timeout}ms ease-out`,
|
|
30
30
|
},
|
|
31
31
|
}),
|
|
32
|
-
});
|
|
32
|
+
}));
|
|
33
33
|
|
|
34
|
-
const Sidepanel = ({ in: inProp,
|
|
35
|
-
const classes = useStyles({
|
|
34
|
+
const Sidepanel = ({ in: inProp, widthSpacing = 30, timeout = 1000, children, className }) => {
|
|
35
|
+
const classes = useStyles({ widthSpacing, timeout });
|
|
36
36
|
|
|
37
37
|
const panel = (
|
|
38
38
|
<CSSTransition in={inProp} timeout={timeout} unmountOnExit>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
import Sidepanel from "./Sidepanel";
|
|
4
|
+
import { createMuiTheme, TestWrapper } from "../utils/testUtils";
|
|
5
|
+
|
|
6
|
+
const theme = createMuiTheme();
|
|
4
7
|
|
|
5
8
|
class RenderSidepanel extends React.Component {
|
|
6
9
|
render() {
|
|
@@ -44,9 +47,11 @@ describe("Sidepanel", () => {
|
|
|
44
47
|
|
|
45
48
|
it("sets the width it is given", () => {
|
|
46
49
|
ReactDOM.render(
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
+
<TestWrapper muiThemeProvider={{ theme }}>
|
|
51
|
+
<Sidepanel in widthSpacing={25}>
|
|
52
|
+
<div id="inner">Foo</div>
|
|
53
|
+
</Sidepanel>
|
|
54
|
+
</TestWrapper>,
|
|
50
55
|
appRoot,
|
|
51
56
|
);
|
|
52
57
|
return expect(
|
|
@@ -55,7 +60,7 @@ describe("Sidepanel", () => {
|
|
|
55
60
|
"div#modal > div",
|
|
56
61
|
"to have style rules satisfying",
|
|
57
62
|
"to contain",
|
|
58
|
-
"width:
|
|
63
|
+
"width: 15.625rem",
|
|
59
64
|
);
|
|
60
65
|
});
|
|
61
66
|
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { makeStyles } from "@material-ui/core";
|
|
3
3
|
import Icon from "./MaterialUI/DataDisplay/Icon";
|
|
4
4
|
|
|
5
|
-
const useStyles = makeStyles({
|
|
5
|
+
const useStyles = makeStyles(theme => ({
|
|
6
6
|
wrapper: {
|
|
7
7
|
display: "flex",
|
|
8
8
|
flexWrap: "wrap",
|
|
@@ -13,11 +13,11 @@ const useStyles = makeStyles({
|
|
|
13
13
|
iconBlock: {
|
|
14
14
|
flex: "0 0 30%",
|
|
15
15
|
border: "1px solid #999",
|
|
16
|
-
margin:
|
|
17
|
-
padding:
|
|
18
|
-
fontSize:
|
|
16
|
+
margin: theme.spacing(0.5),
|
|
17
|
+
padding: theme.spacing(0.5, 1),
|
|
18
|
+
fontSize: theme.spacing(2.4),
|
|
19
19
|
},
|
|
20
|
-
});
|
|
20
|
+
}));
|
|
21
21
|
|
|
22
22
|
const arrify = thing => [].slice.call(thing);
|
|
23
23
|
|
|
@@ -19,11 +19,11 @@ const useStyles = makeStyles(theme => ({
|
|
|
19
19
|
|
|
20
20
|
return {
|
|
21
21
|
display: "flex",
|
|
22
|
-
width:
|
|
23
|
-
marginTop:
|
|
24
|
-
padding:
|
|
25
|
-
borderRadius:
|
|
26
|
-
fontSize:
|
|
22
|
+
width: theme.spacing(39),
|
|
23
|
+
marginTop: theme.spacing(1),
|
|
24
|
+
padding: theme.spacing(1.7),
|
|
25
|
+
borderRadius: theme.spacing(0.5),
|
|
26
|
+
fontSize: theme.spacing(1.4),
|
|
27
27
|
color: "white",
|
|
28
28
|
backgroundColor: toastColor,
|
|
29
29
|
zIndex: 10000,
|
|
@@ -59,18 +59,18 @@ const useStyles = makeStyles(theme => ({
|
|
|
59
59
|
},
|
|
60
60
|
listWrapper: {
|
|
61
61
|
position: "absolute",
|
|
62
|
-
top:
|
|
63
|
-
right:
|
|
62
|
+
top: theme.spacing(4),
|
|
63
|
+
right: theme.spacing(1.6),
|
|
64
64
|
display: "flex",
|
|
65
65
|
flexDirection: "column",
|
|
66
66
|
},
|
|
67
67
|
closeIcon: {
|
|
68
|
-
padding:
|
|
69
|
-
borderRadius:
|
|
70
|
-
strokeWidth:
|
|
68
|
+
padding: theme.spacing(0.2),
|
|
69
|
+
borderRadius: theme.spacing(0.2),
|
|
70
|
+
strokeWidth: theme.spacing(0.2),
|
|
71
71
|
cursor: "pointer",
|
|
72
72
|
marginLeft: "auto",
|
|
73
|
-
fontSize:
|
|
73
|
+
fontSize: theme.spacing(2),
|
|
74
74
|
},
|
|
75
75
|
}));
|
|
76
76
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
-
import {
|
|
3
|
+
import { branchIndentSpacing, branchLengthSpacing, branchHeightSpacing } from "./settings";
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
|
|
6
6
|
const useStyles = makeStyles(theme => {
|
|
7
7
|
const base = {
|
|
8
8
|
margin: 0,
|
|
9
|
-
fontSize:
|
|
9
|
+
fontSize: theme.spacing(1.3),
|
|
10
10
|
listStyleType: "none",
|
|
11
11
|
borderWidth: 0,
|
|
12
12
|
borderStyle: "solid",
|
|
@@ -17,20 +17,20 @@ const useStyles = makeStyles(theme => {
|
|
|
17
17
|
return {
|
|
18
18
|
branch: props => ({
|
|
19
19
|
...base,
|
|
20
|
-
marginLeft: `${
|
|
20
|
+
marginLeft: `${theme.spacing(branchIndentSpacing)}`,
|
|
21
21
|
padding: "0",
|
|
22
|
-
paddingLeft: `${
|
|
23
|
-
borderLeftWidth:
|
|
22
|
+
paddingLeft: `${theme.spacing(branchLengthSpacing)}`,
|
|
23
|
+
borderLeftWidth: theme.spacing(0.1),
|
|
24
24
|
|
|
25
25
|
"&:last-child::after": {
|
|
26
26
|
/* blocker - hides lowest part of vertical branch */
|
|
27
27
|
content: '""',
|
|
28
28
|
backgroundColor: props.dark ? theme.palette.grey.dark : "#fff",
|
|
29
29
|
position: "absolute",
|
|
30
|
-
left: `-${
|
|
30
|
+
left: `-${theme.spacing(branchIndentSpacing + branchLengthSpacing + 0.2)}`,
|
|
31
31
|
bottom: 0,
|
|
32
|
-
top: `-${
|
|
33
|
-
width:
|
|
32
|
+
top: `-${theme.spacing(branchHeightSpacing)}`,
|
|
33
|
+
width: theme.spacing(0.1),
|
|
34
34
|
},
|
|
35
35
|
}),
|
|
36
36
|
wrapper: {
|
|
@@ -38,11 +38,11 @@ const useStyles = makeStyles(theme => {
|
|
|
38
38
|
overflowY: "auto",
|
|
39
39
|
overflowX: "hidden",
|
|
40
40
|
marginLeft: 0,
|
|
41
|
-
padding: `${
|
|
41
|
+
padding: `${theme.spacing(branchLengthSpacing - 0.5)}`,
|
|
42
42
|
|
|
43
43
|
"& > $branch": {
|
|
44
44
|
/* First Branch immediately under Wrapper needs margin adjusted to look right */
|
|
45
|
-
marginLeft: `${
|
|
45
|
+
marginLeft: `${theme.spacing(branchIndentSpacing * 1.5)}`,
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
};
|
|
@@ -1,46 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { Branch, Wrapper } from "./Branch";
|
|
2
|
+
import { Branch } from "./Branch";
|
|
4
3
|
|
|
5
4
|
describe("Branch", () => {
|
|
6
|
-
const theme = createMuiTheme();
|
|
7
|
-
|
|
8
5
|
it("renders a <ul>", () => expect(<Branch />, "when mounted", "to satisfy", <ul />));
|
|
9
6
|
|
|
10
|
-
it("
|
|
11
|
-
expect(
|
|
12
|
-
<Branch />,
|
|
13
|
-
"when mounted",
|
|
14
|
-
"to have style rules satisfying",
|
|
15
|
-
expect
|
|
16
|
-
.it("to contain", "margin-left: 14px;")
|
|
17
|
-
.and("to contain", "padding-left: 15px;")
|
|
18
|
-
.and("to match", /:last-child::after {[^}]*left: -31px;[^}]*}/)
|
|
19
|
-
.and("to match", /:last-child::after {[^}]*top: -20px;[^}]*}/),
|
|
20
|
-
));
|
|
21
|
-
|
|
22
|
-
it("sets styling for a dark theme", () =>
|
|
23
|
-
expect(
|
|
24
|
-
<TestWrapper muiThemeProvider={{ theme }}>
|
|
25
|
-
<Branch dark />
|
|
26
|
-
</TestWrapper>,
|
|
27
|
-
"when mounted",
|
|
28
|
-
"to have style rules satisfying",
|
|
29
|
-
expect.it("to match", /:last-child::after {[^}]*background-color: #333;[^}]*}/),
|
|
30
|
-
));
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe("Wrapper", () => {
|
|
34
|
-
it("renders a <ul>", () => expect(<Wrapper />, "when mounted", "to satisfy", <ul />));
|
|
35
|
-
|
|
36
|
-
it("sets styling for showing the root of a tree structure", () =>
|
|
37
|
-
expect(
|
|
38
|
-
<Wrapper />,
|
|
39
|
-
"when mounted",
|
|
40
|
-
"to have style rules satisfying",
|
|
41
|
-
expect
|
|
42
|
-
.it("to contain", "margin-left: 0;")
|
|
43
|
-
.and("to contain", "padding: 10px;")
|
|
44
|
-
.and("to contain", "{margin-left: 21px;}"),
|
|
45
|
-
));
|
|
7
|
+
it("renders a dark <ul>", () => expect(<Branch dark />, "when mounted", "to satisfy", <ul />));
|
|
46
8
|
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { makeStyles } from "@material-ui/core/styles";
|
|
3
3
|
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
4
|
-
import {
|
|
4
|
+
import { branchLengthSpacing } from "./settings";
|
|
5
5
|
import classNames from "classnames";
|
|
6
6
|
|
|
7
7
|
const useStyles = makeStyles(theme => ({
|
|
8
8
|
beforeIndicator: {
|
|
9
9
|
backgroundColor: "#666",
|
|
10
|
-
marginLeft: `-${
|
|
11
|
-
width: `${
|
|
12
|
-
height:
|
|
10
|
+
marginLeft: `-${theme.spacing(branchLengthSpacing + 0.1)}`,
|
|
11
|
+
width: `${theme.spacing(branchLengthSpacing + 0.1)}`,
|
|
12
|
+
height: theme.spacing(0.1),
|
|
13
13
|
zIndex: 99,
|
|
14
14
|
position: "absolute",
|
|
15
15
|
},
|
|
16
16
|
nonIndicator: {
|
|
17
|
-
height:
|
|
18
|
-
width: `${
|
|
19
|
-
margin: `auto 0 auto -${
|
|
17
|
+
height: theme.spacing(0.1),
|
|
18
|
+
width: `${theme.spacing(branchLengthSpacing + 2.1)}`,
|
|
19
|
+
margin: `auto 0 auto -${theme.spacing(branchLengthSpacing + 0.1)}`,
|
|
20
20
|
backgroundColor: "#666",
|
|
21
21
|
alignSelf: "stretch",
|
|
22
22
|
flex: "0 0 auto",
|
|
@@ -30,8 +30,8 @@ const useStyles = makeStyles(theme => ({
|
|
|
30
30
|
border: props.isSelectedNode ? `1px solid ${theme.palette.grey.borders}` : undefined,
|
|
31
31
|
}),
|
|
32
32
|
indicator: props => ({
|
|
33
|
-
fontSize:
|
|
34
|
-
padding:
|
|
33
|
+
fontSize: theme.spacing(1),
|
|
34
|
+
padding: theme.spacing(1, 0, 1, 1),
|
|
35
35
|
cursor: "pointer",
|
|
36
36
|
flex: "0 0 auto",
|
|
37
37
|
color: props.open
|
|
@@ -49,17 +49,27 @@ describe("Indicator", () => {
|
|
|
49
49
|
|
|
50
50
|
describe("BeforeIndicator", () => {
|
|
51
51
|
it("renders a branch continuation before indicator", () =>
|
|
52
|
-
expect(
|
|
52
|
+
expect(
|
|
53
|
+
<MuiThemeProvider theme={theme}>
|
|
54
|
+
<BeforeIndicator />
|
|
55
|
+
</MuiThemeProvider>,
|
|
56
|
+
"when mounted",
|
|
57
|
+
"to have style rules satisfying",
|
|
58
|
+
"to contain",
|
|
59
|
+
"margin-left: -1rem;",
|
|
60
|
+
));
|
|
53
61
|
});
|
|
54
62
|
|
|
55
63
|
describe("NonIndicator", () => {
|
|
56
64
|
it("renders a branch continuation", () =>
|
|
57
65
|
expect(
|
|
58
|
-
<
|
|
66
|
+
<MuiThemeProvider theme={theme}>
|
|
67
|
+
<NonIndicator />
|
|
68
|
+
</MuiThemeProvider>,
|
|
59
69
|
"when mounted",
|
|
60
70
|
"to have style rules satisfying",
|
|
61
71
|
"to contain",
|
|
62
|
-
"margin: auto 0 auto -
|
|
72
|
+
"margin: auto 0 auto -1rem;",
|
|
63
73
|
));
|
|
64
74
|
});
|
|
65
75
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
-
import {
|
|
3
|
+
import { branchLengthSpacing } from "./settings";
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
|
|
6
6
|
const useStyles = makeStyles(theme => ({
|
|
@@ -16,9 +16,9 @@ const useStyles = makeStyles(theme => ({
|
|
|
16
16
|
backgroundColor: props.dark ? theme.palette.grey.dark : "#fff",
|
|
17
17
|
position: "absolute",
|
|
18
18
|
top: "calc(50%)",
|
|
19
|
-
left: `-${
|
|
19
|
+
left: `-${theme.spacing(branchLengthSpacing + 0.1)}`,
|
|
20
20
|
bottom: 0,
|
|
21
|
-
width:
|
|
21
|
+
width: theme.spacing(0.1),
|
|
22
22
|
height: "50%",
|
|
23
23
|
},
|
|
24
24
|
}),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { createMuiTheme, TestWrapper } from "../../utils/testUtils";
|
|
3
2
|
import { Root, Leaf } from "./Leaf";
|
|
4
3
|
|
|
5
4
|
describe("Root", () => {
|
|
@@ -7,25 +6,7 @@ describe("Root", () => {
|
|
|
7
6
|
});
|
|
8
7
|
|
|
9
8
|
describe("Leaf", () => {
|
|
10
|
-
const theme = createMuiTheme();
|
|
11
|
-
|
|
12
9
|
it("renders a <li>", () => expect(<Leaf />, "when mounted", "to satisfy", <li />));
|
|
13
10
|
|
|
14
|
-
it("
|
|
15
|
-
expect(
|
|
16
|
-
<Leaf />,
|
|
17
|
-
"when mounted",
|
|
18
|
-
"to have style rules satisfying",
|
|
19
|
-
expect.it("to match", /:last-child::after {[^}]*left: -16px;[^}]*}/),
|
|
20
|
-
));
|
|
21
|
-
|
|
22
|
-
it("sets styling for a dark theme", () =>
|
|
23
|
-
expect(
|
|
24
|
-
<TestWrapper muiThemeProvider={{ theme }}>
|
|
25
|
-
<Leaf dark />
|
|
26
|
-
</TestWrapper>,
|
|
27
|
-
"when mounted",
|
|
28
|
-
"to have style rules satisfying",
|
|
29
|
-
expect.it("to match", /:last-child::after {[^}]*background-color: #333;[^}]*}/),
|
|
30
|
-
));
|
|
11
|
+
it("renders a dark <li>", () => expect(<Leaf dark />, "when mounted", "to satisfy", <li />));
|
|
31
12
|
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// in px
|
|
2
2
|
// How far from parent left edge to vertical branch under it
|
|
3
3
|
export const branchIndent = 14;
|
|
4
|
+
export const branchIndentSpacing = 1.4;
|
|
4
5
|
// How far from vertical branch to children's left edge
|
|
5
6
|
export const branchLength = 15;
|
|
7
|
+
export const branchLengthSpacing = 1.5;
|
|
6
8
|
// How far up from bottom edge of node should horizontal branch sit
|
|
7
9
|
export const branchHeight = 20;
|
|
10
|
+
export const branchHeightSpacing = 2;
|
|
@@ -15,16 +15,10 @@ const withScrollBox = WrappedComp =>
|
|
|
15
15
|
React.forwardRef(({ onScroll, ...otherProps }, externalRef) => {
|
|
16
16
|
const classes = useStyles();
|
|
17
17
|
|
|
18
|
-
const mergeRef = (node, measureRef) => {
|
|
19
|
-
measureRef(node);
|
|
20
|
-
|
|
21
|
-
if (externalRef) externalRef.current = node;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
18
|
return (
|
|
25
|
-
<Measure bounds>
|
|
19
|
+
<Measure bounds innerRef={externalRef}>
|
|
26
20
|
{({ measureRef, contentRect }) => (
|
|
27
|
-
<div className={classes.scrollbox} onScroll={onScroll} ref={
|
|
21
|
+
<div className={classes.scrollbox} onScroll={onScroll} ref={measureRef}>
|
|
28
22
|
<WrappedComp
|
|
29
23
|
{...otherProps}
|
|
30
24
|
height={safeGet(contentRect, "bounds", "height")}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export const useWindowSize = () => {
|
|
4
|
+
const [windowSize, setWindowSize] = useState({
|
|
5
|
+
innerWidth: window.innerWidth,
|
|
6
|
+
innerHeight: window.innerHeight,
|
|
7
|
+
outerWidth: window.outerWidth,
|
|
8
|
+
outerHeight: window.outerHeight,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const handleResize = () => {
|
|
13
|
+
const haveChanged =
|
|
14
|
+
windowSize.innerWidth !== window.innerWidth ||
|
|
15
|
+
windowSize.innerHeight !== window.innerHeight ||
|
|
16
|
+
windowSize.outerWidth !== window.outerWidth ||
|
|
17
|
+
windowSize.outerHeight !== window.outerHeight;
|
|
18
|
+
|
|
19
|
+
if (haveChanged) {
|
|
20
|
+
setWindowSize({
|
|
21
|
+
innerWidth: window.innerWidth,
|
|
22
|
+
innerHeight: window.innerHeight,
|
|
23
|
+
outerWidth: window.outerWidth,
|
|
24
|
+
outerHeight: window.outerHeight,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
handleResize();
|
|
30
|
+
|
|
31
|
+
window.addEventListener("resize", handleResize);
|
|
32
|
+
|
|
33
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
34
|
+
}, [windowSize]);
|
|
35
|
+
|
|
36
|
+
return windowSize;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default useWindowSize;
|