orc-shared 5.10.1-dev.8 → 5.10.1-dev.9
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/Authenticate.js +41 -17
- package/dist/components/ErrorPlaceholder.js +8 -24
- package/dist/components/{Icon.js → Form/Inputs/MultiSelector.js} +33 -20
- package/dist/components/Form/Inputs/index.js +1 -1
- package/dist/components/LoadingIcon.js +6 -16
- package/dist/components/MaterialUI/Inputs/Select.js +10 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
- package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
- package/dist/components/Provision.js +30 -13
- package/dist/components/Routing/SegmentPage.js +115 -56
- package/dist/components/Scope/ScopeNode.js +68 -45
- package/dist/components/Sidepanel.js +57 -23
- package/dist/components/Spritesheet.js +33 -17
- package/dist/components/Text.js +1 -60
- package/dist/components/Treeview/Branch.js +82 -20
- package/dist/components/Treeview/Label.js +108 -31
- package/dist/components/Treeview/Leaf.js +56 -12
- package/dist/components/Treeview/Node.js +22 -9
- package/dist/components/Treeview/index.js +7 -1
- package/dist/components/Treeview/settings.js +7 -5
- package/dist/utils/index.js +0 -4
- package/dist/utils/testUtils.js +1 -12
- package/package.json +1 -1
- package/src/components/ApplicationModuleLoader.test.js +14 -27
- package/src/components/Authenticate.js +29 -21
- package/src/components/Authenticate.test.js +18 -27
- package/src/components/ErrorPlaceholder.js +4 -21
- package/src/components/ErrorPlaceholder.test.js +7 -14
- package/src/components/Form/InputField.test.js +2 -1
- package/src/components/Form/Inputs/MultiSelector.js +23 -0
- package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
- package/src/components/Form/Inputs/index.js +1 -1
- package/src/components/Loader.test.js +21 -33
- package/src/components/LoadingIcon.js +2 -15
- package/src/components/LoadingIcon.test.js +2 -20
- package/src/components/MaterialUI/DataDisplay/Table.test.js +1 -1
- package/src/components/MaterialUI/Inputs/Select.js +7 -0
- package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
- package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
- package/src/components/Navigation/Navigation.test.js +0 -5
- package/src/components/Navigation/useNavigationState.test.js +79 -222
- package/src/components/Provision.js +36 -42
- package/src/components/Provision.test.js +10 -26
- package/src/components/Routing/SegmentPage.js +68 -52
- package/src/components/Routing/SegmentPage.test.js +4 -12
- package/src/components/Scope/ScopeNode.js +61 -54
- package/src/components/Scope/ScopeNode.test.js +61 -154
- package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
- package/src/components/Sidepanel.js +38 -32
- package/src/components/Sidepanel.test.js +49 -27
- package/src/components/Spritesheet.js +23 -21
- package/src/components/Spritesheet.test.js +10 -10
- package/src/components/Text.js +0 -49
- package/src/components/Treeview/Branch.js +63 -45
- package/src/components/Treeview/Branch.test.js +21 -24
- package/src/components/Treeview/Label.js +66 -52
- package/src/components/Treeview/Label.test.js +42 -60
- package/src/components/Treeview/Leaf.js +41 -22
- package/src/components/Treeview/Leaf.test.js +15 -10
- package/src/components/Treeview/Node.js +16 -9
- package/src/components/Treeview/Node.test.js +269 -200
- package/src/components/Treeview/Treeview.test.js +248 -248
- package/src/components/Treeview/index.js +6 -0
- package/src/components/Treeview/settings.js +7 -6
- package/src/utils/index.js +0 -4
- package/src/utils/testUtils.js +0 -10
- package/src/utils/testUtils.test.js +0 -68
- package/dist/components/Button.js +0 -70
- package/dist/components/Checkbox.js +0 -103
- package/dist/components/IconButton.js +0 -80
- package/dist/components/Input.js +0 -101
- package/dist/components/Modal/Background.js +0 -55
- package/dist/components/Modal/Dialog.js +0 -75
- package/dist/components/Modal/Wrapper.js +0 -69
- package/dist/components/Modal/index.js +0 -86
- package/dist/components/MultiSelector.js +0 -187
- package/dist/components/Navigation/Bar.js +0 -293
- package/dist/components/Navigation/Tab.js +0 -182
- package/dist/components/Placeholder.js +0 -114
- package/dist/components/Scope/Selector.js +0 -123
- package/dist/components/Selector.js +0 -185
- package/dist/components/Switch.js +0 -128
- package/dist/components/Toolbar.js +0 -227
- package/dist/components/Tooltip.js +0 -66
- package/dist/getTheme.js +0 -153
- package/dist/getThemeOverrides.js +0 -93
- package/dist/hocs/withAuthentication.js +0 -72
- package/dist/utils/styledPropFuncs.js +0 -88
- package/src/components/Button.js +0 -90
- package/src/components/Button.test.js +0 -49
- package/src/components/Checkbox.js +0 -63
- package/src/components/Checkbox.test.js +0 -122
- package/src/components/Icon.js +0 -18
- package/src/components/IconButton.js +0 -30
- package/src/components/IconButton.test.js +0 -61
- package/src/components/Input.js +0 -35
- package/src/components/Input.test.js +0 -34
- package/src/components/Modal/Background.js +0 -10
- package/src/components/Modal/Dialog.js +0 -27
- package/src/components/Modal/Dialog.test.js +0 -20
- package/src/components/Modal/Modal.test.js +0 -52
- package/src/components/Modal/Wrapper.js +0 -32
- package/src/components/Modal/Wrapper.test.js +0 -55
- package/src/components/Modal/index.js +0 -22
- package/src/components/MultiSelector.js +0 -104
- package/src/components/MultiSelector.test.js +0 -348
- package/src/components/Navigation/Bar.js +0 -212
- package/src/components/Navigation/Bar.test.js +0 -552
- package/src/components/Navigation/Tab.js +0 -156
- package/src/components/Navigation/Tab.test.js +0 -404
- package/src/components/Placeholder.js +0 -61
- package/src/components/Placeholder.test.js +0 -106
- package/src/components/Scope/Selector.js +0 -70
- package/src/components/Scope/Selector.test.js +0 -138
- package/src/components/Selector.js +0 -191
- package/src/components/Selector.test.js +0 -157
- package/src/components/Switch.js +0 -112
- package/src/components/Switch.test.js +0 -130
- package/src/components/Text.test.js +0 -132
- package/src/components/Toolbar.js +0 -178
- package/src/components/Toolbar.test.js +0 -478
- package/src/components/Tooltip.js +0 -51
- package/src/components/Tooltip.test.js +0 -21
- package/src/getTheme.js +0 -98
- package/src/getTheme.test.js +0 -92
- package/src/getThemeOverrides.js +0 -27
- package/src/hocs/withAuthentication.js +0 -18
- package/src/hocs/withAuthentication.test.js +0 -120
- package/src/utils/styledPropFuncs.js +0 -20
- package/src/utils/styledPropFuncs.test.js +0 -166
|
@@ -1,47 +1,65 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
3
|
import { branchIndent, branchLength, branchHeight } from "./settings";
|
|
4
|
+
import classNames from "classnames";
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
6
|
+
const useStyles = makeStyles(theme => {
|
|
7
|
+
const base = {
|
|
8
|
+
margin: 0,
|
|
9
|
+
fontSize: "13px",
|
|
10
|
+
listStyleType: "none",
|
|
11
|
+
borderWidth: 0,
|
|
12
|
+
borderStyle: "solid",
|
|
13
|
+
borderColor: "#666",
|
|
14
|
+
position: "relative",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
branch: props => ({
|
|
19
|
+
...base,
|
|
20
|
+
marginLeft: `${branchIndent}px`,
|
|
21
|
+
padding: "0",
|
|
22
|
+
paddingLeft: `${branchLength}px`,
|
|
23
|
+
borderLeftWidth: "1px",
|
|
24
|
+
|
|
25
|
+
"&:last-child::after": {
|
|
26
|
+
/* blocker - hides lowest part of vertical branch */
|
|
27
|
+
content: '""',
|
|
28
|
+
backgroundColor: props.dark ? theme.palette.grey.dark : "#fff",
|
|
29
|
+
position: "absolute",
|
|
30
|
+
left: `-${branchIndent + branchLength + 2}px`,
|
|
31
|
+
bottom: 0,
|
|
32
|
+
top: `-${branchHeight}px`,
|
|
33
|
+
width: "1px",
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
wrapper: {
|
|
37
|
+
...base,
|
|
38
|
+
overflowY: "auto",
|
|
39
|
+
overflowX: "hidden",
|
|
40
|
+
marginLeft: 0,
|
|
41
|
+
padding: `${branchLength - 5}px`,
|
|
42
|
+
|
|
43
|
+
"& > $branch": {
|
|
44
|
+
/* First Branch immediately under Wrapper needs margin adjusted to look right */
|
|
45
|
+
marginLeft: `${1.5 * branchIndent}px`,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const Branch = ({ dark, branchClassName, children }) => {
|
|
52
|
+
const classes = useStyles({ dark });
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ul className={classNames(classes.branch, branchClassName)} data-qa="branch">
|
|
56
|
+
{children}
|
|
57
|
+
</ul>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Wrapper = ({ children }) => {
|
|
62
|
+
const classes = useStyles();
|
|
63
|
+
|
|
64
|
+
return <ul className={classes.wrapper}>{children}</ul>;
|
|
65
|
+
};
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { createMuiTheme, TestWrapper } from "../../utils/testUtils";
|
|
2
3
|
import { Branch, Wrapper } from "./Branch";
|
|
3
4
|
|
|
4
5
|
describe("Branch", () => {
|
|
6
|
+
const theme = createMuiTheme();
|
|
7
|
+
|
|
5
8
|
it("renders a <ul>", () => expect(<Branch />, "when mounted", "to satisfy", <ul />));
|
|
6
9
|
|
|
7
10
|
it("sets styling for showing a branch structure", () =>
|
|
8
11
|
expect(
|
|
9
|
-
<Branch
|
|
10
|
-
theme={{
|
|
11
|
-
treeSettings: {
|
|
12
|
-
branchIndent: 10,
|
|
13
|
-
branchLength: 12,
|
|
14
|
-
branchHeight: 14,
|
|
15
|
-
},
|
|
16
|
-
}}
|
|
17
|
-
/>,
|
|
12
|
+
<Branch />,
|
|
18
13
|
"when mounted",
|
|
19
14
|
"to have style rules satisfying",
|
|
20
15
|
expect
|
|
21
|
-
.it("to contain", "margin-left:
|
|
22
|
-
.and("to contain", "padding-left:
|
|
23
|
-
.and("to match", /:last-child::after {[^}]*left: -
|
|
24
|
-
.and("to match", /:last-child::after {[^}]*top: -
|
|
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;[^}]*}/),
|
|
25
30
|
));
|
|
26
31
|
});
|
|
27
32
|
|
|
@@ -30,20 +35,12 @@ describe("Wrapper", () => {
|
|
|
30
35
|
|
|
31
36
|
it("sets styling for showing the root of a tree structure", () =>
|
|
32
37
|
expect(
|
|
33
|
-
<Wrapper
|
|
34
|
-
theme={{
|
|
35
|
-
treeSettings: {
|
|
36
|
-
branchIndent: 10,
|
|
37
|
-
branchLength: 12,
|
|
38
|
-
branchHeight: 14,
|
|
39
|
-
},
|
|
40
|
-
}}
|
|
41
|
-
/>,
|
|
38
|
+
<Wrapper />,
|
|
42
39
|
"when mounted",
|
|
43
40
|
"to have style rules satisfying",
|
|
44
41
|
expect
|
|
45
42
|
.it("to contain", "margin-left: 0;")
|
|
46
|
-
.and("to contain", "padding:
|
|
47
|
-
.and("to contain", "
|
|
43
|
+
.and("to contain", "padding: 10px;")
|
|
44
|
+
.and("to contain", "{margin-left: 21px;}"),
|
|
48
45
|
));
|
|
49
46
|
});
|
|
@@ -1,54 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
4
4
|
import { branchLength } from "./settings";
|
|
5
|
+
import classNames from "classnames";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
7
|
+
const useStyles = makeStyles(theme => ({
|
|
8
|
+
beforeIndicator: {
|
|
9
|
+
backgroundColor: "#666",
|
|
10
|
+
marginLeft: `-${branchLength + 1}px`,
|
|
11
|
+
width: `${branchLength + 1}px`,
|
|
12
|
+
height: "1px",
|
|
13
|
+
zIndex: 99,
|
|
14
|
+
position: "absolute",
|
|
15
|
+
},
|
|
16
|
+
nonIndicator: {
|
|
17
|
+
height: "1px",
|
|
18
|
+
width: `${branchLength + 21}px`,
|
|
19
|
+
margin: `auto 0 auto -${branchLength + 1}px`,
|
|
20
|
+
backgroundColor: "#666",
|
|
21
|
+
alignSelf: "stretch",
|
|
22
|
+
flex: "0 0 auto",
|
|
23
|
+
zIndex: 99,
|
|
24
|
+
},
|
|
25
|
+
label: props => ({
|
|
26
|
+
cursor: "pointer",
|
|
27
|
+
flexGrow: 1,
|
|
28
|
+
width: "100%",
|
|
29
|
+
backgroundColor: props.isSelectedNode ? "#222" : undefined,
|
|
30
|
+
border: props.isSelectedNode ? `1px solid ${theme.palette.grey.borders}` : undefined,
|
|
31
|
+
}),
|
|
32
|
+
indicator: props => ({
|
|
33
|
+
fontSize: "10px",
|
|
34
|
+
padding: "10px 0 10px 10px",
|
|
35
|
+
cursor: "pointer",
|
|
36
|
+
flex: "0 0 auto",
|
|
37
|
+
color: props.open
|
|
38
|
+
? props.dark
|
|
39
|
+
? theme.palette.primary.light
|
|
40
|
+
: theme.palette.text.primary
|
|
41
|
+
: theme.palette.primary.main,
|
|
42
|
+
}),
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
export const BeforeIndicator = ({ children }) => {
|
|
46
|
+
const classes = useStyles();
|
|
47
|
+
|
|
48
|
+
return <div className={classes.beforeIndicator}>{children}</div>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const NonIndicator = ({ children }) => {
|
|
52
|
+
const classes = useStyles();
|
|
53
|
+
|
|
54
|
+
return <div className={classes.nonIndicator}>{children}</div>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Label = ({ isSelectedNode, labelClassName, children }) => {
|
|
58
|
+
const classes = useStyles({ isSelectedNode });
|
|
59
|
+
|
|
60
|
+
return <div className={classNames(classes.label, labelClassName)}>{children}</div>;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const Indicator = ({ open, dark, onClick }) => {
|
|
64
|
+
const classes = useStyles({ open, dark });
|
|
65
|
+
const iconId = open ? "dropdown-chevron-down" : "dropdown-chevron-right";
|
|
66
|
+
|
|
67
|
+
return <Icon id={iconId} className={classes.indicator} onClick={onClick} data-qa="indicator" />;
|
|
68
|
+
};
|
|
@@ -1,72 +1,50 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { MuiThemeProvider } from "@material-ui/core";
|
|
2
3
|
import { Label, Indicator, BeforeIndicator, NonIndicator } from "./Label";
|
|
3
|
-
import Icon from "../Icon";
|
|
4
|
+
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
5
|
+
import { createMuiTheme } from "../../utils/testUtils";
|
|
6
|
+
|
|
7
|
+
const theme = createMuiTheme();
|
|
4
8
|
|
|
5
9
|
describe("Indicator", () => {
|
|
6
10
|
it("renders a closed arrow icon", () =>
|
|
7
|
-
expect(<Indicator />, "when mounted", "to satisfy", <Icon id="chevron-right" />));
|
|
11
|
+
expect(<Indicator />, "when mounted", "to satisfy", <Icon id="dropdown-chevron-right" />));
|
|
8
12
|
|
|
9
13
|
it("renders an open arrow icon", () =>
|
|
10
|
-
expect(<Indicator open />, "when mounted", "to satisfy", <Icon id="chevron-down" />));
|
|
14
|
+
expect(<Indicator open />, "when mounted", "to satisfy", <Icon id="dropdown-chevron-down" />));
|
|
11
15
|
|
|
12
16
|
it("renders closed arrows in highlight color", () =>
|
|
13
|
-
expect(
|
|
17
|
+
expect(
|
|
18
|
+
<MuiThemeProvider theme={theme}>
|
|
19
|
+
<Indicator />
|
|
20
|
+
</MuiThemeProvider>,
|
|
21
|
+
"when mounted",
|
|
22
|
+
"to have style rules satisfying",
|
|
23
|
+
"to contain",
|
|
24
|
+
"color: #333;",
|
|
25
|
+
));
|
|
14
26
|
|
|
15
27
|
it("renders open arrows in dark grey", () =>
|
|
16
|
-
expect(
|
|
28
|
+
expect(
|
|
29
|
+
<MuiThemeProvider theme={theme}>
|
|
30
|
+
<Indicator open />
|
|
31
|
+
</MuiThemeProvider>,
|
|
32
|
+
"when mounted",
|
|
33
|
+
"to have style rules satisfying",
|
|
34
|
+
"to contain",
|
|
35
|
+
"color: #333;",
|
|
36
|
+
));
|
|
17
37
|
|
|
18
38
|
it("renders open arrows in light grey when dark", () =>
|
|
19
|
-
expect(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
up: "arrow-up",
|
|
29
|
-
down: "arrow-down",
|
|
30
|
-
right: "arrow-right",
|
|
31
|
-
left: "arrow-left",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("renders a closed arrow icon", () =>
|
|
38
|
-
expect(<Indicator theme={theme} />, "when mounted", "to satisfy", <Icon id="arrow-right" />));
|
|
39
|
-
|
|
40
|
-
it("renders an open arrow icon", () =>
|
|
41
|
-
expect(<Indicator theme={theme} open />, "when mounted", "to satisfy", <Icon id="arrow-down" />));
|
|
42
|
-
|
|
43
|
-
it("renders closed arrows in highlight color", () =>
|
|
44
|
-
expect(
|
|
45
|
-
<Indicator theme={theme} />,
|
|
46
|
-
"when mounted",
|
|
47
|
-
"to have style rules satisfying",
|
|
48
|
-
"to contain",
|
|
49
|
-
"color: red;",
|
|
50
|
-
));
|
|
51
|
-
|
|
52
|
-
it("renders open arrows in dark grey", () =>
|
|
53
|
-
expect(
|
|
54
|
-
<Indicator theme={theme} open />,
|
|
55
|
-
"when mounted",
|
|
56
|
-
"to have style rules satisfying",
|
|
57
|
-
"to contain",
|
|
58
|
-
"color: #333333;",
|
|
59
|
-
));
|
|
60
|
-
|
|
61
|
-
it("renders open arrows in light grey when dark", () =>
|
|
62
|
-
expect(
|
|
63
|
-
<Indicator theme={theme} open dark />,
|
|
64
|
-
"when mounted",
|
|
65
|
-
"to have style rules satisfying",
|
|
66
|
-
"to contain",
|
|
67
|
-
"color: #cccccc;",
|
|
68
|
-
));
|
|
69
|
-
});
|
|
39
|
+
expect(
|
|
40
|
+
<MuiThemeProvider theme={theme}>
|
|
41
|
+
<Indicator open dark />
|
|
42
|
+
</MuiThemeProvider>,
|
|
43
|
+
"when mounted",
|
|
44
|
+
"to have style rules satisfying",
|
|
45
|
+
"to contain",
|
|
46
|
+
"color: #CCC;",
|
|
47
|
+
));
|
|
70
48
|
});
|
|
71
49
|
|
|
72
50
|
describe("BeforeIndicator", () => {
|
|
@@ -90,17 +68,21 @@ describe("Label", () => {
|
|
|
90
68
|
|
|
91
69
|
it("renders a label without border", () =>
|
|
92
70
|
expect(
|
|
93
|
-
<
|
|
71
|
+
<MuiThemeProvider theme={theme}>
|
|
72
|
+
<Label />
|
|
73
|
+
</MuiThemeProvider>,
|
|
94
74
|
"when mounted",
|
|
95
75
|
"to have style rules satisfying",
|
|
96
|
-
expect.it("not to contain", "background-color: #222;").and("not to contain", "border: 1px solid #
|
|
76
|
+
expect.it("not to contain", "background-color: #222;").and("not to contain", "border: 1px solid #CCC"),
|
|
97
77
|
));
|
|
98
78
|
|
|
99
79
|
it("renders a label with border", () =>
|
|
100
80
|
expect(
|
|
101
|
-
<
|
|
81
|
+
<MuiThemeProvider theme={theme}>
|
|
82
|
+
<Label isSelectedNode={true} />
|
|
83
|
+
</MuiThemeProvider>,
|
|
102
84
|
"when mounted",
|
|
103
85
|
"to have style rules satisfying",
|
|
104
|
-
expect.it("to contain", "background-color: #222;").and("to contain", "border: 1px solid #
|
|
86
|
+
expect.it("to contain", "background-color: #222;").and("to contain", "border: 1px solid #CCC"),
|
|
105
87
|
));
|
|
106
88
|
});
|
|
@@ -1,24 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { branchLength
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import { branchLength } from "./settings";
|
|
4
|
+
import classNames from "classnames";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const useStyles = makeStyles(theme => ({
|
|
7
|
+
root: {
|
|
8
|
+
position: "relative",
|
|
9
|
+
display: "flex",
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
},
|
|
12
|
+
leaf: props => ({
|
|
13
|
+
"&:last-child::after": {
|
|
14
|
+
/* blocker - hides lowest part of vertical branch */
|
|
15
|
+
content: '""',
|
|
16
|
+
backgroundColor: props.dark ? theme.palette.grey.dark : "#fff",
|
|
17
|
+
position: "absolute",
|
|
18
|
+
top: "calc(50%)",
|
|
19
|
+
left: `-${branchLength + 1}px`,
|
|
20
|
+
bottom: 0,
|
|
21
|
+
width: "1px",
|
|
22
|
+
height: "50%",
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
}));
|
|
10
26
|
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
export const Root = ({ dark, leafClassName, children }) => {
|
|
28
|
+
const classes = useStyles({ dark });
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<li className={classNames(classes.root, classes.leaf, leafClassName)} data-qa="leaf">
|
|
32
|
+
{children}
|
|
33
|
+
</li>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Leaf = ({ dark, leafClassName, children }) => {
|
|
38
|
+
return (
|
|
39
|
+
<Root leafClassName={leafClassName} dark={dark}>
|
|
40
|
+
{children}
|
|
41
|
+
</Root>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { createMuiTheme, TestWrapper } from "../../utils/testUtils";
|
|
2
3
|
import { Root, Leaf } from "./Leaf";
|
|
3
4
|
|
|
4
5
|
describe("Root", () => {
|
|
@@ -6,21 +7,25 @@ describe("Root", () => {
|
|
|
6
7
|
});
|
|
7
8
|
|
|
8
9
|
describe("Leaf", () => {
|
|
10
|
+
const theme = createMuiTheme();
|
|
11
|
+
|
|
9
12
|
it("renders a <li>", () => expect(<Leaf />, "when mounted", "to satisfy", <li />));
|
|
10
13
|
|
|
11
14
|
it("sets styling for a branch structure", () =>
|
|
12
15
|
expect(
|
|
13
|
-
<Leaf
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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>,
|
|
22
27
|
"when mounted",
|
|
23
28
|
"to have style rules satisfying",
|
|
24
|
-
expect.it("to match", /:last-child::after {[^}]*
|
|
29
|
+
expect.it("to match", /:last-child::after {[^}]*background-color: #333;[^}]*}/),
|
|
25
30
|
));
|
|
26
31
|
});
|
|
@@ -6,8 +6,8 @@ import { safeGet, stripKey } from "../../utils";
|
|
|
6
6
|
|
|
7
7
|
export const TreeContext = React.createContext();
|
|
8
8
|
|
|
9
|
-
export const LeafNode = ({ dark, isSelectedNode, ...nodeData }) => (
|
|
10
|
-
<Leaf dark={dark}>
|
|
9
|
+
export const LeafNode = ({ dark, isSelectedNode, labelClassName, leafClassName, ...nodeData }) => (
|
|
10
|
+
<Leaf dark={dark} leafClassName={leafClassName}>
|
|
11
11
|
<TreeContext.Consumer>
|
|
12
12
|
{({ Content, nodeState, updateNodeState, dark, otherProps }) => {
|
|
13
13
|
const toggle = () => updateNodeState({ ...nodeState, [nodeData.id]: !nodeData.open });
|
|
@@ -18,7 +18,7 @@ export const LeafNode = ({ dark, isSelectedNode, ...nodeData }) => (
|
|
|
18
18
|
) : (
|
|
19
19
|
<NonIndicator />
|
|
20
20
|
)}
|
|
21
|
-
<Label isSelectedNode={isSelectedNode}>
|
|
21
|
+
<Label isSelectedNode={isSelectedNode} labelClassName={labelClassName}>
|
|
22
22
|
<Content {...stripKey("children", nodeData)} {...otherProps} />
|
|
23
23
|
</Label>
|
|
24
24
|
</React.Fragment>
|
|
@@ -29,9 +29,9 @@ export const LeafNode = ({ dark, isSelectedNode, ...nodeData }) => (
|
|
|
29
29
|
);
|
|
30
30
|
LeafNode.displayName = "LeafNode";
|
|
31
31
|
|
|
32
|
-
export const RootNode = ({ isSelectedNode, ...nodeData }) => (
|
|
32
|
+
export const RootNode = ({ isSelectedNode, labelClassName, ...nodeData }) => (
|
|
33
33
|
<Root>
|
|
34
|
-
<Label isSelectedNode={isSelectedNode}>
|
|
34
|
+
<Label isSelectedNode={isSelectedNode} labelClassName={labelClassName}>
|
|
35
35
|
<TreeContext.Consumer>
|
|
36
36
|
{({ Content, otherProps }) => <Content {...stripKey("children", nodeData)} {...otherProps} />}
|
|
37
37
|
</TreeContext.Consumer>
|
|
@@ -42,7 +42,7 @@ RootNode.displayName = "RootNode";
|
|
|
42
42
|
|
|
43
43
|
export const Node = ({ root, id }) => (
|
|
44
44
|
<TreeContext.Consumer>
|
|
45
|
-
{({ openAll, getNode, selectedNodeId, nodeState, dark }) => {
|
|
45
|
+
{({ openAll, getNode, selectedNodeId, nodeState, dark, labelClassName, leafClassName, branchClassName }) => {
|
|
46
46
|
const nodeData = getNode(id);
|
|
47
47
|
if (!nodeData) return null;
|
|
48
48
|
const isSelectedNode = selectedNodeId === id;
|
|
@@ -51,12 +51,19 @@ export const Node = ({ root, id }) => (
|
|
|
51
51
|
return (
|
|
52
52
|
<React.Fragment>
|
|
53
53
|
{root ? (
|
|
54
|
-
<RootNode {...nodeData} isSelectedNode={isSelectedNode} />
|
|
54
|
+
<RootNode {...nodeData} isSelectedNode={isSelectedNode} labelClassName={labelClassName} />
|
|
55
55
|
) : (
|
|
56
|
-
<LeafNode
|
|
56
|
+
<LeafNode
|
|
57
|
+
{...nodeData}
|
|
58
|
+
open={open}
|
|
59
|
+
dark={dark}
|
|
60
|
+
isSelectedNode={isSelectedNode}
|
|
61
|
+
labelClassName={labelClassName}
|
|
62
|
+
leafClassName={leafClassName}
|
|
63
|
+
/>
|
|
57
64
|
)}
|
|
58
65
|
{open && safeGet(nodeData, "children", "length") ? (
|
|
59
|
-
<Branch dark={dark}>
|
|
66
|
+
<Branch dark={dark} branchClassName={branchClassName}>
|
|
60
67
|
{nodeData.children.map(id => (
|
|
61
68
|
<Node key={id} id={id} />
|
|
62
69
|
))}
|