orc-shared 5.10.0-dev.2 → 5.10.0-dev.21
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/actions/metadata.js +30 -11
- package/dist/actions/requestsApi.js +10 -1
- package/dist/components/AppFrame/About.js +136 -100
- package/dist/components/AppFrame/Anchor.js +45 -21
- package/dist/components/AppFrame/AppFrame.js +53 -31
- package/dist/components/AppFrame/Help.js +35 -15
- package/dist/components/AppFrame/MenuItem.js +148 -114
- package/dist/components/AppFrame/Preferences.js +136 -97
- package/dist/components/AppFrame/Sidebar.js +51 -28
- package/dist/components/AppFrame/Topbar.js +61 -36
- package/dist/components/ColumnWrapper.js +28 -5
- package/dist/components/Culture.js +33 -14
- package/dist/components/DropMenu/Menu.js +79 -45
- package/dist/components/DropMenu/index.js +34 -29
- package/dist/components/Form/Combination.js +45 -16
- package/dist/components/Form/Field.js +57 -38
- package/dist/components/Form/FieldElements.js +0 -11
- package/dist/components/Form/Fieldset.js +47 -19
- package/dist/components/Form/Form.js +22 -9
- package/dist/components/Form/FormElement.js +40 -7
- package/dist/components/Form/Inputs/Button.js +63 -18
- package/dist/components/Form/Inputs/ReadOnly.js +50 -27
- package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
- package/dist/components/Form/Inputs/Text.js +20 -37
- package/dist/components/Form/Inputs/Toggles.js +39 -40
- package/dist/components/Form/Inputs/index.js +2 -13
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
- package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/dist/components/MaterialUI/Inputs/Select.js +2 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
- package/dist/components/MaterialUI/muiThemes.js +2 -1
- package/dist/components/Provision.js +1 -1
- package/dist/constants.js +2 -1
- package/dist/content/iconsSheet.svg +740 -116
- package/dist/hocs/withScrollBox.js +27 -12
- package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
- package/dist/hooks/useInMemoryPaging.js +135 -0
- package/dist/hooks/useMultipleFieldEditState.js +12 -3
- package/dist/reducers/metadata.js +6 -0
- package/dist/schemas/metadata.js +9 -1
- package/dist/selectors/locale.js +1 -0
- package/dist/selectors/metadata.js +14 -11
- package/dist/sharedMessages.js +184 -0
- package/dist/utils/ListHelper.js +271 -0
- package/dist/utils/comparisonHelper.js +185 -0
- package/dist/utils/propertyBagHelper.js +3 -1
- package/dist/utils/timezoneHelper.js +18 -31
- package/package.json +4 -3
- package/src/actions/metadata.js +11 -0
- package/src/actions/metadata.test.js +27 -0
- package/src/actions/requestsApi.js +6 -0
- package/src/components/AppFrame/About.js +97 -117
- package/src/components/AppFrame/About.test.js +128 -90
- package/src/components/AppFrame/Anchor.js +34 -36
- package/src/components/AppFrame/Anchor.test.js +5 -68
- package/src/components/AppFrame/AppFrame.js +31 -40
- package/src/components/AppFrame/AppFrame.test.js +424 -445
- package/src/components/AppFrame/Help.js +23 -20
- package/src/components/AppFrame/Help.test.js +3 -3
- package/src/components/AppFrame/MenuItem.js +106 -126
- package/src/components/AppFrame/MenuItem.test.js +78 -169
- package/src/components/AppFrame/Preferences.js +110 -98
- package/src/components/AppFrame/Preferences.test.js +115 -219
- package/src/components/AppFrame/Sidebar.js +39 -41
- package/src/components/AppFrame/Sidebar.test.js +88 -168
- package/src/components/AppFrame/Topbar.js +59 -52
- package/src/components/AppFrame/Topbar.test.js +31 -39
- package/src/components/ColumnWrapper.js +18 -9
- package/src/components/Culture.js +20 -10
- package/src/components/Culture.test.js +27 -16
- package/src/components/DropMenu/DropMenu.test.js +185 -224
- package/src/components/DropMenu/Menu.js +73 -80
- package/src/components/DropMenu/Menu.test.js +35 -86
- package/src/components/DropMenu/index.js +19 -15
- package/src/components/Form/Combination.js +35 -28
- package/src/components/Form/Combination.test.js +6 -19
- package/src/components/Form/Field.js +53 -66
- package/src/components/Form/Field.test.js +29 -51
- package/src/components/Form/FieldElements.js +0 -14
- package/src/components/Form/FieldElements.test.js +104 -111
- package/src/components/Form/Fieldset.js +42 -37
- package/src/components/Form/Fieldset.test.js +14 -7
- package/src/components/Form/Form.js +11 -7
- package/src/components/Form/Form.test.js +75 -56
- package/src/components/Form/FormElement.js +24 -16
- package/src/components/Form/InputField.test.js +24 -30
- package/src/components/Form/Inputs/Button.js +58 -14
- package/src/components/Form/Inputs/Button.test.js +32 -7
- package/src/components/Form/Inputs/Inputs.test.js +0 -7
- package/src/components/Form/Inputs/ReadOnly.js +34 -28
- package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
- package/src/components/Form/Inputs/Selector.js +22 -0
- package/src/components/Form/Inputs/Selector.test.js +105 -0
- package/src/components/Form/Inputs/Text.js +15 -44
- package/src/components/Form/Inputs/Text.test.js +20 -29
- package/src/components/Form/Inputs/Toggles.js +27 -26
- package/src/components/Form/Inputs/Toggles.test.js +22 -28
- package/src/components/Form/Inputs/index.js +4 -15
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
- package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/src/components/MaterialUI/Inputs/Select.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/Switch.js +22 -1
- package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
- package/src/components/MaterialUI/muiThemes.js +1 -0
- package/src/components/Navigation/Bar.test.js +92 -87
- package/src/components/Provision.js +1 -1
- package/src/components/TaskDetailsModal.test.js +1 -3
- package/src/constants.js +1 -0
- package/src/content/iconsSheet.svg +740 -116
- package/src/hocs/withScrollBox.js +32 -19
- package/src/hocs/withScrollBox.test.js +15 -3
- package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
- package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
- package/src/hooks/useInMemoryPaging.js +78 -0
- package/src/hooks/useInMemoryPaging.test.js +515 -0
- package/src/hooks/useMultipleFieldEditState.js +11 -4
- package/src/hooks/useMultipleFieldEditState.test.js +49 -1
- package/src/reducers/metadata.js +6 -1
- package/src/reducers/metadata.test.js +31 -0
- package/src/requests +1 -0
- package/src/schemas/metadata.js +3 -0
- package/src/selectors/locale.js +1 -1
- package/src/selectors/metadata.js +12 -9
- package/src/selectors/metadata.test.js +92 -11
- package/src/sharedMessages.js +184 -0
- package/src/timezones.json +883 -0
- package/src/translations/en-US.json +46 -0
- package/src/translations/fr-CA.json +46 -0
- package/src/utils/ListHelper.js +203 -0
- package/src/utils/ListHelper.test.js +710 -0
- package/src/utils/comparisonHelper.js +135 -0
- package/src/utils/comparisonHelper.test.js +334 -0
- package/src/utils/propertyBagHelper.js +2 -0
- package/src/utils/propertyBagHelper.test.js +6 -0
- package/src/utils/timezoneHelper.js +10 -135
- package/src/utils/timezoneHelper.test.js +7 -7
- package/dist/components/Form/FieldList.js +0 -270
- package/dist/components/Form/Inputs/FieldButtons.js +0 -66
- package/dist/components/Form/Inputs/Number.js +0 -117
- package/dist/components/Form/Inputs/SmallButton.js +0 -91
- package/dist/components/Form/Inputs/Time.js +0 -86
- package/dist/components/Form/Inputs/Translation.js +0 -169
- package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
- package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
- package/src/components/Form/FieldList.js +0 -210
- package/src/components/Form/FieldList.test.js +0 -558
- package/src/components/Form/Inputs/FieldButtons.js +0 -90
- package/src/components/Form/Inputs/Number.js +0 -60
- package/src/components/Form/Inputs/Number.test.js +0 -435
- package/src/components/Form/Inputs/SmallButton.js +0 -37
- package/src/components/Form/Inputs/SmallButton.test.js +0 -65
- package/src/components/Form/Inputs/Time.js +0 -32
- package/src/components/Form/Inputs/Time.test.js +0 -41
- package/src/components/Form/Inputs/Translation.js +0 -93
- package/src/components/Form/Inputs/Translation.test.js +0 -204
|
@@ -1,87 +1,80 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import Icon from "../Icon";
|
|
6
|
-
import Text from "../Text";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const useStyles = makeStyles(theme => ({
|
|
7
|
+
drawer: {
|
|
8
|
+
position: "absolute",
|
|
9
|
+
zIndex: 19999,
|
|
10
|
+
margin: "4px 0 0",
|
|
11
|
+
left: props => (props.alignRight ? "auto" : "0"),
|
|
12
|
+
right: props => (props.alignRight ? "0" : "auto"),
|
|
13
|
+
transition: "opacity 100ms ease-out",
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
"&.enter-active": {
|
|
16
|
+
opacity: 1,
|
|
17
|
+
visibility: "visible",
|
|
18
|
+
},
|
|
19
|
+
"&.exit-active": {
|
|
20
|
+
opacity: 0,
|
|
21
|
+
visibility: "hidden",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
list: {
|
|
25
|
+
color: theme.palette.text.primary,
|
|
26
|
+
backgroundColor: "white",
|
|
27
|
+
border: `1px solid ${theme.palette.text.hint}`,
|
|
28
|
+
borderRadius: "5px",
|
|
29
|
+
listStyleType: "none",
|
|
30
|
+
padding: "5px 0",
|
|
31
|
+
margin: "0",
|
|
32
|
+
fontFamily: "Open Sans, sans-serif",
|
|
33
|
+
fontSize: "12px",
|
|
34
|
+
width: "max-content",
|
|
35
|
+
},
|
|
36
|
+
item: {
|
|
37
|
+
boxSizing: "border-box",
|
|
38
|
+
height: "30px",
|
|
39
|
+
minWidth: "178px",
|
|
40
|
+
padding: "9px 12px",
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
cursor: "pointer",
|
|
44
|
+
"&:hover": {
|
|
45
|
+
backgroundColor: theme.palette.primary.main,
|
|
46
|
+
color: "white",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
itemIcon: {
|
|
50
|
+
paddingRight: "11px",
|
|
51
|
+
fontSize: "17px",
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
15
54
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
&:enter-active {
|
|
20
|
-
opacity: 1;
|
|
21
|
-
}
|
|
22
|
-
&:exit {
|
|
23
|
-
opacity: 1;
|
|
24
|
-
}
|
|
25
|
-
&:exit-active {
|
|
26
|
-
opacity: 0.01;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
Drawer.defaultProps = {
|
|
30
|
-
unmountOnExit: true,
|
|
31
|
-
timeout: 100,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const List = styled.ul`
|
|
35
|
-
color: ${getThemeProp(["colors", "text"], "#333333")};
|
|
36
|
-
background-color: white;
|
|
37
|
-
border: 1px solid ${getThemeProp(["colors", "border"], "#999999")};
|
|
38
|
-
border-radius: 5px;
|
|
39
|
-
list-style-type: none;
|
|
40
|
-
padding: 5px 0;
|
|
41
|
-
margin: 0;
|
|
42
|
-
font-family: Open Sans, sans-serif;
|
|
43
|
-
font-size: 12px;
|
|
44
|
-
width: max-content;
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
export const Item = styled.li`
|
|
48
|
-
box-sizing: border-box;
|
|
49
|
-
height: 30px;
|
|
50
|
-
min-width: 178px;
|
|
51
|
-
padding: 9px 12px;
|
|
52
|
-
display: flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
cursor: pointer;
|
|
55
|
+
const Menu = ({ id, open, menuItems, reset, alignRight }) => {
|
|
56
|
+
const classes = useStyles({ alignRight });
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
79
|
-
{item.icon ? <ItemIcon id={item.icon} /> : null}
|
|
80
|
-
<Text message={item.label} />
|
|
81
|
-
</Item>
|
|
82
|
-
))}
|
|
83
|
-
</List>
|
|
84
|
-
</Drawer>
|
|
85
|
-
);
|
|
58
|
+
return (
|
|
59
|
+
<div className={`${classes.drawer} ${open ? "enter-active" : "exit-active"}`}>
|
|
60
|
+
<ul id={id} className={classes.list}>
|
|
61
|
+
{menuItems.map(item => (
|
|
62
|
+
<li
|
|
63
|
+
id={item.id}
|
|
64
|
+
key={item.id || item.label?.id + (item.icon || "")}
|
|
65
|
+
className={classes.item}
|
|
66
|
+
onClick={event => {
|
|
67
|
+
reset();
|
|
68
|
+
item.handler(event);
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{item.icon ? <Icon id={item.icon} className={classes.itemIcon} /> : null}
|
|
72
|
+
{typeof item.label === "string" ? item.label : <FormattedMessage {...item.label} />}
|
|
73
|
+
</li>
|
|
74
|
+
))}
|
|
75
|
+
</ul>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
86
79
|
|
|
87
80
|
export default Menu;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
3
|
import sinon from "sinon";
|
|
4
|
-
import {
|
|
5
|
-
import Menu
|
|
4
|
+
import { IntlProvider } from "react-intl";
|
|
5
|
+
import Menu from "./Menu";
|
|
6
|
+
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
6
7
|
|
|
7
8
|
describe("Menu", () => {
|
|
8
9
|
it("renders a closed menu", () =>
|
|
9
10
|
expect(
|
|
10
11
|
<Menu menuItems={[{ label: "First", icon: "one", handler: () => {} }]} />,
|
|
11
12
|
"when mounted",
|
|
12
|
-
"to
|
|
13
|
-
|
|
13
|
+
"to have style rules satisfying",
|
|
14
|
+
"to match",
|
|
15
|
+
/visibility:\s*hidden;/,
|
|
14
16
|
));
|
|
15
17
|
|
|
16
18
|
it("renders an open menu", () =>
|
|
@@ -28,18 +30,18 @@ describe("Menu", () => {
|
|
|
28
30
|
</Provider>,
|
|
29
31
|
"when mounted",
|
|
30
32
|
"to satisfy",
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
<
|
|
33
|
+
<div>
|
|
34
|
+
<ul id="testMenu">
|
|
35
|
+
<li id="first">
|
|
36
|
+
<Icon id="one" />
|
|
35
37
|
First
|
|
36
|
-
</
|
|
37
|
-
<
|
|
38
|
-
<
|
|
38
|
+
</li>
|
|
39
|
+
<li id="second">
|
|
40
|
+
<Icon id="two" />
|
|
39
41
|
Second
|
|
40
|
-
</
|
|
41
|
-
</
|
|
42
|
-
</
|
|
42
|
+
</li>
|
|
43
|
+
</ul>
|
|
44
|
+
</div>,
|
|
43
45
|
));
|
|
44
46
|
|
|
45
47
|
it("renders an open right-aligned menu", () =>
|
|
@@ -53,23 +55,22 @@ describe("Menu", () => {
|
|
|
53
55
|
{ id: "second", label: "Second", icon: "two", handler: () => {} },
|
|
54
56
|
]}
|
|
55
57
|
toggle={() => {}}
|
|
56
|
-
alignRight
|
|
57
58
|
/>
|
|
58
59
|
</Provider>,
|
|
59
60
|
"when mounted",
|
|
60
61
|
"to satisfy",
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
62
|
+
<div>
|
|
63
|
+
<ul id="testMenu">
|
|
64
|
+
<li id="first">
|
|
65
|
+
<Icon id="one" />
|
|
65
66
|
First
|
|
66
|
-
</
|
|
67
|
-
<
|
|
68
|
-
<
|
|
67
|
+
</li>
|
|
68
|
+
<li id="second">
|
|
69
|
+
<Icon id="two" />
|
|
69
70
|
Second
|
|
70
|
-
</
|
|
71
|
-
</
|
|
72
|
-
</
|
|
71
|
+
</li>
|
|
72
|
+
</ul>
|
|
73
|
+
</div>,
|
|
73
74
|
));
|
|
74
75
|
|
|
75
76
|
it("closes on click on item", () => {
|
|
@@ -77,71 +78,19 @@ describe("Menu", () => {
|
|
|
77
78
|
const handler = sinon.spy().named("handler");
|
|
78
79
|
return expect(
|
|
79
80
|
<Provider store={{ getState: () => ({}), subscribe: () => {}, dispatch: () => {} }}>
|
|
80
|
-
<
|
|
81
|
+
<IntlProvider locale="en-US">
|
|
82
|
+
<Menu open menuItems={[{ label: { id: "foo", defaultMessage: "Foo" }, handler }]} reset={reset} />
|
|
83
|
+
</IntlProvider>
|
|
81
84
|
</Provider>,
|
|
82
85
|
"when mounted",
|
|
83
86
|
"with event",
|
|
84
|
-
{ type: "click", target:
|
|
87
|
+
{ type: "click", target: "li" },
|
|
85
88
|
"to satisfy",
|
|
86
|
-
<
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
</
|
|
90
|
-
</
|
|
89
|
+
<div>
|
|
90
|
+
<ul>
|
|
91
|
+
<li>Foo</li>
|
|
92
|
+
</ul>
|
|
93
|
+
</div>,
|
|
91
94
|
).then(() => Promise.all([expect(reset, "was called"), expect(handler, "was called")]));
|
|
92
95
|
});
|
|
93
|
-
|
|
94
|
-
describe("Drawer", () => {
|
|
95
|
-
it("sets transition time according to its timeout", () =>
|
|
96
|
-
expect(
|
|
97
|
-
<Drawer in timeout={500} />,
|
|
98
|
-
"when mounted",
|
|
99
|
-
"to have style rules satisfying",
|
|
100
|
-
"to contain",
|
|
101
|
-
"transition: opacity 500ms ease-out;",
|
|
102
|
-
));
|
|
103
|
-
|
|
104
|
-
it("defaults to left aligned position", () =>
|
|
105
|
-
expect(
|
|
106
|
-
<Drawer in timeout={500} />,
|
|
107
|
-
"when mounted",
|
|
108
|
-
"to have style rules satisfying",
|
|
109
|
-
expect.it("to contain", "left: 0;").and("not to contain", "right: 0"),
|
|
110
|
-
));
|
|
111
|
-
|
|
112
|
-
it("can align right", () =>
|
|
113
|
-
expect(
|
|
114
|
-
<Drawer in timeout={500} alignRight />,
|
|
115
|
-
"when mounted",
|
|
116
|
-
"to have style rules satisfying",
|
|
117
|
-
expect.it("to contain", "right: 0;").and("not to contain", "left: 0"),
|
|
118
|
-
));
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe("Item", () => {
|
|
122
|
-
let theme;
|
|
123
|
-
beforeEach(() => {
|
|
124
|
-
theme = {
|
|
125
|
-
colors: { application: { base: "#ff00ff" } },
|
|
126
|
-
};
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("shows a background with the highlight color when hovering", () =>
|
|
130
|
-
expect(
|
|
131
|
-
<Item theme={theme} />,
|
|
132
|
-
"when mounted",
|
|
133
|
-
"to have style rules satisfying",
|
|
134
|
-
"to match",
|
|
135
|
-
/:hover\s*\{[^}]*\bbackground-color: #ff00ff;[^}]*\}/,
|
|
136
|
-
));
|
|
137
|
-
|
|
138
|
-
it("has a default highlight color", () =>
|
|
139
|
-
expect(
|
|
140
|
-
<Item />,
|
|
141
|
-
"when mounted",
|
|
142
|
-
"to have style rules satisfying",
|
|
143
|
-
"to match",
|
|
144
|
-
/:hover\s*\{[^}]*\bbackground-color: #ffffff;[^}]*\}/,
|
|
145
|
-
));
|
|
146
|
-
});
|
|
147
96
|
});
|
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
3
|
import Menu from "./Menu";
|
|
4
4
|
import useToggle from "../../hooks/useToggle";
|
|
5
5
|
import withClickOutside from "../../hocs/withClickOutside";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const useStyles = makeStyles(() => ({
|
|
8
|
+
wrapper: {
|
|
9
|
+
position: "relative",
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
10
12
|
|
|
11
|
-
export const
|
|
13
|
+
export const Wrapper = withClickOutside(
|
|
14
|
+
React.forwardRef(({ children, className }, ref) => {
|
|
15
|
+
const classes = useStyles();
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`;
|
|
17
|
+
return (
|
|
18
|
+
<div ref={ref} className={`${classes.wrapper} ${className ? className : ""}`}>
|
|
19
|
+
{children}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
21
24
|
|
|
22
25
|
const DropMenu = ({ id, initOpen, menuItems, alignRight, className = "", children }) => {
|
|
23
26
|
const [open, toggle, reset] = useToggle(initOpen);
|
|
27
|
+
|
|
24
28
|
return (
|
|
25
29
|
<Wrapper className={className} onClickOutside={reset}>
|
|
26
|
-
<
|
|
30
|
+
<div id={id + "Anchor"} onClick={toggle}>
|
|
27
31
|
{React.Children.map(children, child =>
|
|
28
32
|
typeof child === "object" ? React.cloneElement(child, { open }) : child,
|
|
29
33
|
)}
|
|
30
|
-
</
|
|
34
|
+
</div>
|
|
31
35
|
<Menu id={id + "Dropdown"} {...{ open, menuItems, reset }} alignRight={alignRight} />
|
|
32
36
|
</Wrapper>
|
|
33
37
|
);
|
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import Field
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import Field from "./Field";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const useStyles = makeStyles(() => ({
|
|
6
|
+
combiningRow: props => {
|
|
7
|
+
const flexStyles = props.proportions.reduce((styles, width, index) => {
|
|
8
|
+
if (width) {
|
|
9
|
+
styles[`& > *:nth-child(${index + 1})`] = {
|
|
10
|
+
flex: typeof width === "string" ? `0 0 ${width}` : `0 1 ${width}%`,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return styles;
|
|
14
|
+
}, {});
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`
|
|
24
|
-
: "",
|
|
25
|
-
)};
|
|
26
|
-
`;
|
|
16
|
+
return {
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexDirection: "row",
|
|
19
|
+
"& > *": {
|
|
20
|
+
marginTop: 0,
|
|
21
|
+
marginRight: 15,
|
|
22
|
+
},
|
|
23
|
+
"& > :last-child": {
|
|
24
|
+
marginRight: 0,
|
|
25
|
+
},
|
|
26
|
+
...flexStyles,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
27
30
|
|
|
28
|
-
const CombinationField = ({ label, children, proportions = [] }) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const CombinationField = ({ label, children, proportions = [] }) => {
|
|
32
|
+
const classes = useStyles({ proportions });
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Field label={label}>
|
|
36
|
+
<div className={classes.combiningRow}>{children}</div>
|
|
37
|
+
</Field>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
33
40
|
|
|
34
41
|
export default CombinationField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
3
|
import Field from "./Field";
|
|
4
|
-
import Combination
|
|
4
|
+
import Combination from "./Combination";
|
|
5
5
|
|
|
6
6
|
describe("Combination", () => {
|
|
7
7
|
it("renders a combining box around a list of fields", () =>
|
|
@@ -13,7 +13,7 @@ describe("Combination", () => {
|
|
|
13
13
|
getState: () => ({}),
|
|
14
14
|
}}
|
|
15
15
|
>
|
|
16
|
-
<Combination label="A combination" proportions={[30, 70]}>
|
|
16
|
+
<Combination label="A combination" proportions={[30, 70, undefined]}>
|
|
17
17
|
<div id="child1" />
|
|
18
18
|
<div id="child2" />
|
|
19
19
|
</Combination>
|
|
@@ -28,10 +28,10 @@ describe("Combination", () => {
|
|
|
28
28
|
}}
|
|
29
29
|
>
|
|
30
30
|
<Field label="A combination">
|
|
31
|
-
<
|
|
31
|
+
<div>
|
|
32
32
|
<div id="child1" />
|
|
33
33
|
<div id="child2" />
|
|
34
|
-
</
|
|
34
|
+
</div>
|
|
35
35
|
</Field>
|
|
36
36
|
</Provider>,
|
|
37
37
|
));
|
|
@@ -45,23 +45,10 @@ describe("Combination", () => {
|
|
|
45
45
|
"when mounted",
|
|
46
46
|
"to satisfy",
|
|
47
47
|
<Field label={undefined}>
|
|
48
|
-
<
|
|
48
|
+
<div>
|
|
49
49
|
<div id="child1" />
|
|
50
50
|
<div id="child2" />
|
|
51
|
-
</
|
|
51
|
+
</div>
|
|
52
52
|
</Field>,
|
|
53
53
|
));
|
|
54
54
|
});
|
|
55
|
-
|
|
56
|
-
describe("CombiningRow", () => {
|
|
57
|
-
it("sets flex rules on its children to control their proportions", () =>
|
|
58
|
-
expect(
|
|
59
|
-
<CombiningRow proportions={[50, undefined, "70px"]} />,
|
|
60
|
-
"when mounted",
|
|
61
|
-
"to have style rules satisfying",
|
|
62
|
-
expect
|
|
63
|
-
.it("to match", /:nth-child\(1\) \{[^{]*flex: 0 1 50%;/)
|
|
64
|
-
.and("not to match", /:nth-child\(2\)/)
|
|
65
|
-
.and("to match", /:nth-child\(3\) \{[^{]*flex: 0 0 70px;/),
|
|
66
|
-
));
|
|
67
|
-
});
|
|
@@ -1,81 +1,68 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import Text from "../Text";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
5
4
|
|
|
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
|
-
&::after {
|
|
42
|
-
content: " *";
|
|
43
|
-
color: #666;
|
|
44
|
-
}
|
|
45
|
-
`,
|
|
46
|
-
)}
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
export const RequiredNotice = styled.div`
|
|
50
|
-
position: absolute;
|
|
51
|
-
bottom: -1.6em;
|
|
52
|
-
right: 0;
|
|
53
|
-
color: ${getThemeProp(["colors", "error"], "#ce4844")};
|
|
54
|
-
`;
|
|
5
|
+
const useStyles = makeStyles(theme => ({
|
|
6
|
+
fieldBox: {
|
|
7
|
+
flex: "0 1 auto",
|
|
8
|
+
display: "flex",
|
|
9
|
+
flexDirection: "column",
|
|
10
|
+
marginTop: 20,
|
|
11
|
+
position: "relative",
|
|
12
|
+
},
|
|
13
|
+
label: {
|
|
14
|
+
minHeight: 17,
|
|
15
|
+
color: theme.palette.text.hint,
|
|
16
|
+
marginBottom: "10px",
|
|
17
|
+
},
|
|
18
|
+
invalidLabel: {
|
|
19
|
+
color: theme.palette.error.main,
|
|
20
|
+
},
|
|
21
|
+
centerLabel: {
|
|
22
|
+
textAlign: "center",
|
|
23
|
+
},
|
|
24
|
+
labelOnly: {
|
|
25
|
+
marginBottom: "0px",
|
|
26
|
+
},
|
|
27
|
+
requiredLabel: {
|
|
28
|
+
"&::after": {
|
|
29
|
+
content: '" *"',
|
|
30
|
+
color: "#666",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
requiredNotice: {
|
|
34
|
+
position: "absolute",
|
|
35
|
+
bottom: "-1.6em",
|
|
36
|
+
right: 0,
|
|
37
|
+
color: theme.palette.error.main,
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
55
40
|
|
|
56
41
|
const Field = ({ id, label, center, labelOnly, required, invalid, children }) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
42
|
+
const classes = useStyles();
|
|
43
|
+
|
|
59
44
|
return (
|
|
60
|
-
<
|
|
45
|
+
<div className={classes.fieldBox}>
|
|
61
46
|
{label !== undefined ? (
|
|
62
|
-
<
|
|
47
|
+
<label
|
|
63
48
|
htmlFor={labelOnly ? undefined : id}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
id={`${id}_label`}
|
|
50
|
+
className={`${classes.label}
|
|
51
|
+
${invalid ? classes.invalidLabel : ""}
|
|
52
|
+
${center ? classes.centerLabel : ""}
|
|
53
|
+
${labelOnly ? classes.labelOnly : ""}
|
|
54
|
+
${required ? classes.requiredLabel : ""}`}
|
|
68
55
|
>
|
|
69
|
-
<
|
|
70
|
-
</
|
|
56
|
+
{typeof label === "string" ? label : <FormattedMessage {...label} />}
|
|
57
|
+
</label>
|
|
71
58
|
) : null}
|
|
72
59
|
{labelOnly ? null : children}
|
|
73
60
|
{!labelOnly && required && invalid ? (
|
|
74
|
-
<
|
|
75
|
-
<
|
|
76
|
-
</
|
|
61
|
+
<div className={classes.requiredNotice}>
|
|
62
|
+
{typeof required === "string" ? required : <FormattedMessage {...required} />}
|
|
63
|
+
</div>
|
|
77
64
|
) : null}
|
|
78
|
-
</
|
|
65
|
+
</div>
|
|
79
66
|
);
|
|
80
67
|
};
|
|
81
68
|
|