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,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.switchEnum = exports.ifFlag = exports.getThemeProp = void 0;
|
|
5
|
-
var _safeGet = _interopRequireDefault(require("./safeGet"));
|
|
6
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
(function () {
|
|
8
|
-
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
9
|
-
enterModule && enterModule(module);
|
|
10
|
-
})();
|
|
11
|
-
(function () {
|
|
12
|
-
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
13
|
-
enterModule && enterModule(module);
|
|
14
|
-
})();
|
|
15
|
-
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
16
|
-
return a;
|
|
17
|
-
};
|
|
18
|
-
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var feedPropFunc = function feedPropFunc(props) {
|
|
22
|
-
return function (value) {
|
|
23
|
-
return typeof value === "function" ? value(props) : value;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/* Safely gets a (potentially nested) theme property, can run a function on the resulting value */
|
|
28
|
-
var getThemeProp = exports.getThemeProp = function getThemeProp(path, defaultValue, func) {
|
|
29
|
-
if (func === void 0) {
|
|
30
|
-
func = function func(x) {
|
|
31
|
-
return x;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return function (props) {
|
|
35
|
-
return func(_safeGet.default.apply(void 0, [props, "theme"].concat(path.map(feedPropFunc(props)))) || feedPropFunc(props)(defaultValue));
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/* Use in styled components to check if a prop has a truthy value and
|
|
40
|
-
return values based on that. */
|
|
41
|
-
var ifFlag = exports.ifFlag = function ifFlag(name, thenVal, elseVal) {
|
|
42
|
-
if (elseVal === void 0) {
|
|
43
|
-
elseVal = "";
|
|
44
|
-
}
|
|
45
|
-
return function (props) {
|
|
46
|
-
return props[name] ? feedPropFunc(props)(thenVal) : feedPropFunc(props)(elseVal);
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/* Creates a prop function that checks a field against a list of cases,
|
|
51
|
-
and gives back a found case, or a default */
|
|
52
|
-
var switchEnum = exports.switchEnum = function switchEnum(enumField, cases) {
|
|
53
|
-
return function (props) {
|
|
54
|
-
return cases[props[enumField]] || cases["default"];
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
;
|
|
58
|
-
(function () {
|
|
59
|
-
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
60
|
-
if (!reactHotLoader) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
reactHotLoader.register(feedPropFunc, "feedPropFunc", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
64
|
-
reactHotLoader.register(getThemeProp, "getThemeProp", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
65
|
-
reactHotLoader.register(ifFlag, "ifFlag", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
66
|
-
reactHotLoader.register(switchEnum, "switchEnum", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
67
|
-
})();
|
|
68
|
-
;
|
|
69
|
-
(function () {
|
|
70
|
-
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
71
|
-
leaveModule && leaveModule(module);
|
|
72
|
-
})();
|
|
73
|
-
;
|
|
74
|
-
(function () {
|
|
75
|
-
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
76
|
-
if (!reactHotLoader) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
reactHotLoader.register(feedPropFunc, "feedPropFunc", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
80
|
-
reactHotLoader.register(getThemeProp, "getThemeProp", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
81
|
-
reactHotLoader.register(ifFlag, "ifFlag", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
82
|
-
reactHotLoader.register(switchEnum, "switchEnum", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
|
|
83
|
-
})();
|
|
84
|
-
;
|
|
85
|
-
(function () {
|
|
86
|
-
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
87
|
-
leaveModule && leaveModule(module);
|
|
88
|
-
})();
|
package/src/components/Button.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import styled, { css } from "styled-components";
|
|
2
|
-
import { getThemeProp, ifFlag } from "../utils";
|
|
3
|
-
import { tint } from "polished";
|
|
4
|
-
|
|
5
|
-
const borderColor = base => ifFlag("primary", getThemeProp(["colors", "application", "base"], base), base);
|
|
6
|
-
|
|
7
|
-
const background = ifFlag(
|
|
8
|
-
"primary",
|
|
9
|
-
ifFlag(
|
|
10
|
-
"active",
|
|
11
|
-
css`
|
|
12
|
-
color: #fff;
|
|
13
|
-
background-image: linear-gradient(
|
|
14
|
-
${getThemeProp(["colors", "application", "base"], "#333", color => tint(0.05, color))},
|
|
15
|
-
${getThemeProp(["colors", "application", "base"], "#333")}
|
|
16
|
-
);
|
|
17
|
-
&:enabled:active {
|
|
18
|
-
background-image: none;
|
|
19
|
-
background-color: #fff;
|
|
20
|
-
color: ${getThemeProp(["colors", "application", "base"], "#333")};
|
|
21
|
-
}
|
|
22
|
-
`,
|
|
23
|
-
css`
|
|
24
|
-
color: ${getThemeProp(["colors", "application", "base"], "#333")};
|
|
25
|
-
background-image: none;
|
|
26
|
-
background-color: #fff;
|
|
27
|
-
&:enabled:active {
|
|
28
|
-
color: #fff;
|
|
29
|
-
background-image: linear-gradient(
|
|
30
|
-
${getThemeProp(["colors", "application", "base"], "#333", color => tint(0.05, color))},
|
|
31
|
-
${getThemeProp(["colors", "application", "base"], "#333")}
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
`,
|
|
35
|
-
),
|
|
36
|
-
ifFlag(
|
|
37
|
-
"active",
|
|
38
|
-
css`
|
|
39
|
-
background-image: none;
|
|
40
|
-
background-color: ${getThemeProp(["colors", "bgLight"], "#efefef")};
|
|
41
|
-
&:enabled:active {
|
|
42
|
-
background-color: #f7f7f7;
|
|
43
|
-
}
|
|
44
|
-
`,
|
|
45
|
-
css`
|
|
46
|
-
background-image: none;
|
|
47
|
-
background-color: #f7f7f7;
|
|
48
|
-
&:enabled:active {
|
|
49
|
-
background-color: ${getThemeProp(["colors", "bgLight"], "#efefef")};
|
|
50
|
-
}
|
|
51
|
-
`,
|
|
52
|
-
),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const Button = styled.button`
|
|
56
|
-
display: inline-block;
|
|
57
|
-
margin: 0;
|
|
58
|
-
font-weight: 400;
|
|
59
|
-
text-align: center;
|
|
60
|
-
vertical-align: middle;
|
|
61
|
-
cursor: pointer;
|
|
62
|
-
white-space: nowrap;
|
|
63
|
-
padding: 6px 10px;
|
|
64
|
-
font-size: 13px;
|
|
65
|
-
line-height: 1.42857;
|
|
66
|
-
border-radius: 4px;
|
|
67
|
-
user-select: none;
|
|
68
|
-
height: 30px;
|
|
69
|
-
border: 1px solid ${borderColor(getThemeProp(["colors", "borderLight"], "#cccccc"))};
|
|
70
|
-
outline: none;
|
|
71
|
-
font-family: ${getThemeProp(["fonts", "header"], "sans-serif")};
|
|
72
|
-
text-transform: uppercase;
|
|
73
|
-
min-width: 50px;
|
|
74
|
-
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
|
75
|
-
${background};
|
|
76
|
-
|
|
77
|
-
&:enabled:active,
|
|
78
|
-
&:enabled:focus,
|
|
79
|
-
&:enabled:hover {
|
|
80
|
-
border-color: ${borderColor("#4fa1f0")};
|
|
81
|
-
box-shadow: 0 0 4px #4fa1f0;
|
|
82
|
-
outline: none;
|
|
83
|
-
}
|
|
84
|
-
&:disabled {
|
|
85
|
-
opacity: 0.6;
|
|
86
|
-
cursor: default;
|
|
87
|
-
}
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
|
-
export default Button;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Button from "./Button";
|
|
3
|
-
|
|
4
|
-
describe("Button", () => {
|
|
5
|
-
let onClick;
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
onClick = () => {};
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("renders a button", () =>
|
|
11
|
-
expect(
|
|
12
|
-
<Button onClick={onClick}>Label</Button>,
|
|
13
|
-
"when mounted",
|
|
14
|
-
"to satisfy",
|
|
15
|
-
<button onClick={onClick}>Label</button>,
|
|
16
|
-
));
|
|
17
|
-
|
|
18
|
-
it("sets an inactive background-color", () =>
|
|
19
|
-
expect(<Button />, "when mounted", "to have style rules satisfying", "to contain", "background-color: #f7f7f7;"));
|
|
20
|
-
|
|
21
|
-
it("sets an active background-color", () =>
|
|
22
|
-
expect(
|
|
23
|
-
<Button active />,
|
|
24
|
-
"when mounted",
|
|
25
|
-
"to have style rules satisfying",
|
|
26
|
-
"to contain",
|
|
27
|
-
"background-color: #efefef;",
|
|
28
|
-
));
|
|
29
|
-
|
|
30
|
-
describe("primary", () => {
|
|
31
|
-
it("sets an inactive background gradient", () =>
|
|
32
|
-
expect(
|
|
33
|
-
<Button primary />,
|
|
34
|
-
"when mounted",
|
|
35
|
-
"to have style rules satisfying",
|
|
36
|
-
"to contain",
|
|
37
|
-
"background-color: #fff;",
|
|
38
|
-
));
|
|
39
|
-
|
|
40
|
-
it("sets an active background-color", () =>
|
|
41
|
-
expect(
|
|
42
|
-
<Button primary active />,
|
|
43
|
-
"when mounted",
|
|
44
|
-
"to have style rules satisfying",
|
|
45
|
-
"to contain",
|
|
46
|
-
"background-image: linear-gradient( #3d3d3d,#333 )",
|
|
47
|
-
));
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled, { css } from "styled-components";
|
|
3
|
-
import { getThemeProp, ifFlag } from "../utils";
|
|
4
|
-
import { tint } from "polished";
|
|
5
|
-
import withId from "../hocs/withId";
|
|
6
|
-
|
|
7
|
-
export const Wrapper = styled.label`
|
|
8
|
-
padding: 10px 15px;
|
|
9
|
-
margin: -10px -15px;
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
export const ContainedInput = styled.input.attrs(() => ({ type: "checkbox" }))`
|
|
13
|
-
position: absolute;
|
|
14
|
-
opacity: 0;
|
|
15
|
-
z-index: 10;
|
|
16
|
-
margin: 0;
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
export const Cover = styled.label`
|
|
20
|
-
display: inline-block;
|
|
21
|
-
position: relative;
|
|
22
|
-
height: 14px;
|
|
23
|
-
width: 14px;
|
|
24
|
-
border: 1px solid ${getThemeProp(["colors", "borderLight"], "#cccccc")};
|
|
25
|
-
border-radius: 3px;
|
|
26
|
-
|
|
27
|
-
${ContainedInput}:active + &,
|
|
28
|
-
${ContainedInput}:focus + & {
|
|
29
|
-
box-shadow: 0px 0px 1px 0px ${getThemeProp(["colors", "application", "base"], "#777", color => tint(0.05, color))};
|
|
30
|
-
border-color: ${getThemeProp(["colors", "application", "base"], "#777")};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
${ifFlag(
|
|
34
|
-
"value",
|
|
35
|
-
css`
|
|
36
|
-
background-color: ${getThemeProp(["colors", "application", "base"], "#777", color => tint(0.05, color))};
|
|
37
|
-
&::after {
|
|
38
|
-
content: "✔";
|
|
39
|
-
font-size: 12px;
|
|
40
|
-
line-height: 1;
|
|
41
|
-
position: absolute;
|
|
42
|
-
top: 1px;
|
|
43
|
-
left: 0;
|
|
44
|
-
right: 0;
|
|
45
|
-
bottom: 0;
|
|
46
|
-
color: white;
|
|
47
|
-
text-align: center;
|
|
48
|
-
}
|
|
49
|
-
`,
|
|
50
|
-
css`
|
|
51
|
-
background-color: white;
|
|
52
|
-
`,
|
|
53
|
-
)};
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
export const Checkbox = ({ value, className, id, ...otherProps }) => (
|
|
57
|
-
<Wrapper className={className} htmlFor={id}>
|
|
58
|
-
<ContainedInput value={value} id={id} {...otherProps} />
|
|
59
|
-
<Cover value={value} htmlFor={id} />
|
|
60
|
-
</Wrapper>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
export default withId("checkbox")(Checkbox);
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { mount } from "unexpected-reaction";
|
|
3
|
-
import { getClassSelector, getStyledClassSelector } from "../utils/testUtils";
|
|
4
|
-
import { Checkbox, Wrapper, ContainedInput, Cover } from "./Checkbox";
|
|
5
|
-
|
|
6
|
-
describe("Checkbox", () => {
|
|
7
|
-
it("renders an input and a label", () =>
|
|
8
|
-
expect(
|
|
9
|
-
<Checkbox id="foo" value={true} random="stuff" />,
|
|
10
|
-
"when mounted",
|
|
11
|
-
"to satisfy",
|
|
12
|
-
<Wrapper htmlFor="foo">
|
|
13
|
-
<ContainedInput id="foo" value={true} random="stuff" />
|
|
14
|
-
<Cover htmlFor="foo" value={true} />
|
|
15
|
-
</Wrapper>,
|
|
16
|
-
));
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe("ContainedInput", () => {
|
|
20
|
-
it("renders an input of type checkbox", () =>
|
|
21
|
-
expect(<ContainedInput />, "when mounted", "to satisfy", <input type="checkbox" />));
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe("Cover", () => {
|
|
25
|
-
it("sets a highlight when input is focused or active", () => {
|
|
26
|
-
const inputSelector = getStyledClassSelector(ContainedInput);
|
|
27
|
-
const coverSelector = getClassSelector(<Cover />, 1); // Get the generated class name
|
|
28
|
-
mount(<Cover />);
|
|
29
|
-
return expect(
|
|
30
|
-
coverSelector,
|
|
31
|
-
"as a selector to have style rules",
|
|
32
|
-
expect.it(
|
|
33
|
-
"to contain",
|
|
34
|
-
`${inputSelector}:active + ${coverSelector},` +
|
|
35
|
-
`${inputSelector}:focus + ${coverSelector}` +
|
|
36
|
-
" {box-shadow: 0px 0px 1px 0px #7d7d7d; border-color: #777;}",
|
|
37
|
-
),
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("sets a highlight when input is focused or active, when checked", () => {
|
|
42
|
-
const inputSelector = getStyledClassSelector(ContainedInput);
|
|
43
|
-
const coverSelector = getClassSelector(<Cover value={true} />, 1); // Get the generated class name
|
|
44
|
-
mount(<Cover value={true} />);
|
|
45
|
-
return expect(
|
|
46
|
-
coverSelector,
|
|
47
|
-
"as a selector to have style rules",
|
|
48
|
-
expect.it(
|
|
49
|
-
"to contain",
|
|
50
|
-
`${inputSelector}:active + ${coverSelector},` +
|
|
51
|
-
`${inputSelector}:focus + ${coverSelector}` +
|
|
52
|
-
" {box-shadow: 0px 0px 1px 0px #7d7d7d; border-color: #777;}",
|
|
53
|
-
),
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("sets a clear background when not checked", () =>
|
|
58
|
-
expect(<Cover />, "when mounted", "to have style rules satisfying", "to contain", "background-color: white;"));
|
|
59
|
-
|
|
60
|
-
it("sets a colored background and a checkmark when checked", () =>
|
|
61
|
-
expect(
|
|
62
|
-
<Cover value />,
|
|
63
|
-
"when mounted",
|
|
64
|
-
"to have style rules satisfying",
|
|
65
|
-
expect.it("to contain", "background-color: #7d7d7d;").and("to contain", '::after {content: "✔";'),
|
|
66
|
-
));
|
|
67
|
-
|
|
68
|
-
describe("with highlight color from theme", () => {
|
|
69
|
-
let theme;
|
|
70
|
-
beforeEach(() => {
|
|
71
|
-
theme = { colors: { application: { base: "#cc0000" } } };
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("sets a highlight when input is focused or active", () => {
|
|
75
|
-
const inputSelector = getStyledClassSelector(ContainedInput);
|
|
76
|
-
const coverSelector = getClassSelector(<Cover theme={theme} />, 1); // Get the generated class name
|
|
77
|
-
mount(<Cover theme={theme} />);
|
|
78
|
-
return expect(
|
|
79
|
-
coverSelector,
|
|
80
|
-
"as a selector to have style rules",
|
|
81
|
-
expect.it(
|
|
82
|
-
"to contain",
|
|
83
|
-
`${inputSelector}:active + ${coverSelector},` +
|
|
84
|
-
`${inputSelector}:focus + ${coverSelector}` +
|
|
85
|
-
" {box-shadow: 0px 0px 1px 0px #ce0c0c; border-color: #cc0000;}",
|
|
86
|
-
),
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("sets a highlight when input is focused or active, when checked", () => {
|
|
91
|
-
const inputSelector = getStyledClassSelector(ContainedInput);
|
|
92
|
-
const coverSelector = getClassSelector(<Cover theme={theme} value={true} />, 1); // Get the generated class name
|
|
93
|
-
mount(<Cover theme={theme} value={true} />);
|
|
94
|
-
return expect(
|
|
95
|
-
coverSelector,
|
|
96
|
-
"as a selector to have style rules",
|
|
97
|
-
expect.it(
|
|
98
|
-
"to contain",
|
|
99
|
-
`${inputSelector}:active + ${coverSelector},` +
|
|
100
|
-
`${inputSelector}:focus + ${coverSelector}` +
|
|
101
|
-
" {box-shadow: 0px 0px 1px 0px #ce0c0c; border-color: #cc0000;}",
|
|
102
|
-
),
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("sets a clear background when not checked", () =>
|
|
107
|
-
expect(
|
|
108
|
-
<Cover theme={theme} />,
|
|
109
|
-
"when mounted",
|
|
110
|
-
"to have style rules satisfying",
|
|
111
|
-
expect.it("to contain", "background-color: white;").and("not to contain", "::after"),
|
|
112
|
-
));
|
|
113
|
-
|
|
114
|
-
it("sets a colored background and a checkmark when checked", () =>
|
|
115
|
-
expect(
|
|
116
|
-
<Cover theme={theme} value />,
|
|
117
|
-
"when mounted",
|
|
118
|
-
"to have style rules satisfying",
|
|
119
|
-
expect.it("to contain", "background-color: #ce0c0c;").and("to contain", '::after {content: "✔";'),
|
|
120
|
-
));
|
|
121
|
-
});
|
|
122
|
-
});
|
package/src/components/Icon.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
|
|
4
|
-
const IconSVG = styled.svg`
|
|
5
|
-
height: 1em;
|
|
6
|
-
width: 1em;
|
|
7
|
-
fill: currentColor;
|
|
8
|
-
stroke: currentColor;
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
console.warn("Icon has been deprecated. Use Icon from MaterialUI.");
|
|
12
|
-
const Icon = ({ id, ...props }) => (
|
|
13
|
-
<IconSVG {...props}>
|
|
14
|
-
<use href={`#icon-${id}`} />
|
|
15
|
-
</IconSVG>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export default Icon;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
import Button from "./Button";
|
|
4
|
-
import Icon from "./Icon";
|
|
5
|
-
import Text from "./Text";
|
|
6
|
-
|
|
7
|
-
export const ButtonIcon = styled(Icon)`
|
|
8
|
-
font-size: 1.23em;
|
|
9
|
-
margin: -3px -2px;
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
export const ButtonText = styled.span`
|
|
13
|
-
${ButtonIcon} + & {
|
|
14
|
-
margin-left: 12px;
|
|
15
|
-
vertical-align: top;
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
const IconButton = ({ icon, label, ...props }) => (
|
|
20
|
-
<Button {...props}>
|
|
21
|
-
{icon ? <ButtonIcon id={icon} /> : null}
|
|
22
|
-
{label ? (
|
|
23
|
-
<ButtonText>
|
|
24
|
-
<Text message={label} />
|
|
25
|
-
</ButtonText>
|
|
26
|
-
) : null}
|
|
27
|
-
</Button>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export default IconButton;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Provider } from "react-redux";
|
|
3
|
-
import Button from "./Button";
|
|
4
|
-
import IconButton, { ButtonIcon, ButtonText } from "./IconButton";
|
|
5
|
-
|
|
6
|
-
describe("IconButton", () => {
|
|
7
|
-
it("renders a button with an icon", () =>
|
|
8
|
-
expect(
|
|
9
|
-
<Provider
|
|
10
|
-
store={{
|
|
11
|
-
subscribe: () => {},
|
|
12
|
-
dispatch: () => {},
|
|
13
|
-
getState: () => ({}),
|
|
14
|
-
}}
|
|
15
|
-
>
|
|
16
|
-
<IconButton icon="test" otherProp />
|
|
17
|
-
</Provider>,
|
|
18
|
-
"when mounted",
|
|
19
|
-
"to satisfy",
|
|
20
|
-
<Button otherProp>
|
|
21
|
-
<ButtonIcon id="test" />
|
|
22
|
-
</Button>,
|
|
23
|
-
));
|
|
24
|
-
|
|
25
|
-
it("renders a button with a label", () =>
|
|
26
|
-
expect(
|
|
27
|
-
<Provider
|
|
28
|
-
store={{
|
|
29
|
-
subscribe: () => {},
|
|
30
|
-
dispatch: () => {},
|
|
31
|
-
getState: () => ({}),
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
<IconButton label="Message" random="foo" />
|
|
35
|
-
</Provider>,
|
|
36
|
-
"when mounted",
|
|
37
|
-
"to satisfy",
|
|
38
|
-
<Button random="foo">
|
|
39
|
-
<ButtonText>Message</ButtonText>
|
|
40
|
-
</Button>,
|
|
41
|
-
));
|
|
42
|
-
|
|
43
|
-
it("renders a button with both an icon and a label", () =>
|
|
44
|
-
expect(
|
|
45
|
-
<Provider
|
|
46
|
-
store={{
|
|
47
|
-
subscribe: () => {},
|
|
48
|
-
dispatch: () => {},
|
|
49
|
-
getState: () => ({}),
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
<IconButton icon="test" label="Message" passThru={[1, 2, 3]} />
|
|
53
|
-
</Provider>,
|
|
54
|
-
"when mounted",
|
|
55
|
-
"to satisfy",
|
|
56
|
-
<Button passThru={[1, 2, 3]}>
|
|
57
|
-
<ButtonIcon id="test" />
|
|
58
|
-
<ButtonText>Message</ButtonText>
|
|
59
|
-
</Button>,
|
|
60
|
-
));
|
|
61
|
-
});
|
package/src/components/Input.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
import { IntlContext } from "react-intl";
|
|
4
|
-
import { getThemeProp } from "../utils";
|
|
5
|
-
|
|
6
|
-
const defaultFormatMessage = message => {
|
|
7
|
-
throw new Error("Attempting to translate message " + message.id + " outside of Intl context");
|
|
8
|
-
};
|
|
9
|
-
const maybeTranslate = (formatMessage = defaultFormatMessage, message) =>
|
|
10
|
-
message && message.id ? formatMessage(message) : message;
|
|
11
|
-
|
|
12
|
-
const useIntlSoft = () => useContext(IntlContext) || {};
|
|
13
|
-
|
|
14
|
-
export const InputComponent = styled.input`
|
|
15
|
-
font-family: ${getThemeProp(["fonts", "base"], "sans-serif")};
|
|
16
|
-
box-sizing: border-box;
|
|
17
|
-
flex: 0 0 auto;
|
|
18
|
-
height: 30px;
|
|
19
|
-
padding: 5px 10px;
|
|
20
|
-
border: 1px solid ${getThemeProp(["colors", "borderLight"], "#cccccc")};
|
|
21
|
-
border-radius: 5px;
|
|
22
|
-
|
|
23
|
-
&:focus {
|
|
24
|
-
border-color: #4fa1f0;
|
|
25
|
-
box-shadow: 0 0 4px #4fa1f0;
|
|
26
|
-
outline: none;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
const Input = ({ placeholder, ...props }) => {
|
|
31
|
-
const { formatMessage } = useIntlSoft();
|
|
32
|
-
return <InputComponent {...props} placeholder={maybeTranslate(formatMessage, placeholder)} />;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default Input;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { IntlProvider } from "react-intl";
|
|
3
|
-
import { mount } from "unexpected-reaction";
|
|
4
|
-
import { spyOnConsole } from "../utils/testUtils";
|
|
5
|
-
import Input, { InputComponent } from "./Input";
|
|
6
|
-
|
|
7
|
-
describe("Input", () => {
|
|
8
|
-
spyOnConsole(["error"]);
|
|
9
|
-
|
|
10
|
-
it("renders a styled input field with a plain text placeholder", () =>
|
|
11
|
-
expect(
|
|
12
|
-
<Input placeholder="A placeholder" />,
|
|
13
|
-
"when mounted",
|
|
14
|
-
"to satisfy",
|
|
15
|
-
<InputComponent placeholder="A placeholder" />,
|
|
16
|
-
));
|
|
17
|
-
|
|
18
|
-
it("renders a styled input field with a translated placeholder", () =>
|
|
19
|
-
expect(
|
|
20
|
-
<IntlProvider locale="en">
|
|
21
|
-
<Input placeholder={{ id: "placeholder", defaultMessage: "A placeholder" }} />
|
|
22
|
-
</IntlProvider>,
|
|
23
|
-
"when mounted",
|
|
24
|
-
"to satisfy",
|
|
25
|
-
<InputComponent placeholder="A placeholder" />,
|
|
26
|
-
));
|
|
27
|
-
|
|
28
|
-
it("fails on attempt to translate intl message outside an IntlProvider", () =>
|
|
29
|
-
expect(
|
|
30
|
-
() => mount(<Input placeholder={{ id: "placeholder", defaultMessage: "A placeholder" }} />),
|
|
31
|
-
"to throw",
|
|
32
|
-
"Attempting to translate message placeholder outside of Intl context",
|
|
33
|
-
));
|
|
34
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import styled, { css } from "styled-components";
|
|
2
|
-
import { getThemeProp } from "../../utils";
|
|
3
|
-
import withClickOutside from "../../hocs/withClickOutside";
|
|
4
|
-
|
|
5
|
-
const darkDialogStyle = css`
|
|
6
|
-
background-color: ${getThemeProp(["colors", "bgDark"], "#333333")};
|
|
7
|
-
border-radius: 15px;
|
|
8
|
-
`;
|
|
9
|
-
|
|
10
|
-
const dialogLook = {
|
|
11
|
-
default: css`
|
|
12
|
-
background-color: white;
|
|
13
|
-
`,
|
|
14
|
-
dark: darkDialogStyle,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// TODO: Add light dialog style for other dialogs, switching mechanism
|
|
18
|
-
export const Dialog = styled.div`
|
|
19
|
-
flex: 0 0 auto;
|
|
20
|
-
margin: auto;
|
|
21
|
-
align-self: center;
|
|
22
|
-
z-index: 10000;
|
|
23
|
-
${props => dialogLook[props.look]};
|
|
24
|
-
`;
|
|
25
|
-
Dialog.defaultProps = { look: "default" };
|
|
26
|
-
|
|
27
|
-
export default withClickOutside(Dialog);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Dialog } from "./Dialog";
|
|
3
|
-
|
|
4
|
-
describe("Dialog", () => {
|
|
5
|
-
it("renders a dialog with a default look", () =>
|
|
6
|
-
expect(
|
|
7
|
-
<Dialog />,
|
|
8
|
-
"when mounted",
|
|
9
|
-
"to have style rules satisfying",
|
|
10
|
-
expect.it("to contain", "background-color: white;"),
|
|
11
|
-
));
|
|
12
|
-
|
|
13
|
-
it("renders a dialog with dark look", () =>
|
|
14
|
-
expect(
|
|
15
|
-
<Dialog look="dark" />,
|
|
16
|
-
"when mounted",
|
|
17
|
-
"to have style rules satisfying",
|
|
18
|
-
expect.it("to contain", "background-color: #333333;").and("to contain", "border-radius: 15px;"),
|
|
19
|
-
));
|
|
20
|
-
});
|