orc-shared 5.10.2 → 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 +17 -26
- 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/ApplicationModuleLoader.js +3 -2
- package/dist/components/Authenticate.js +29 -22
- package/dist/components/DropMenu/Menu.js +9 -9
- package/dist/components/ErrorPlaceholder.js +8 -24
- package/dist/components/Form/Field.js +4 -4
- package/dist/components/Form/Inputs/Button.js +2 -2
- package/dist/components/Form/Inputs/MultiSelector.js +137 -0
- package/dist/components/Form/Inputs/Selector.js +13 -10
- package/dist/components/Form/Inputs/index.js +1 -1
- package/dist/components/InternetExplorerWarningMessage.js +15 -15
- package/dist/components/LoadingIcon.js +38 -17
- 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 +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -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/PredefinedElements/SearchControl.js +1 -1
- package/dist/components/MaterialUI/Inputs/Select.js +175 -109
- package/dist/components/MaterialUI/Inputs/SelectProps.js +11 -1
- package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
- package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
- 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/Surfaces/SectionExpansionPanel.js +3 -2
- package/dist/components/MaterialUI/muiThemes.js +3 -1
- package/dist/components/Provision.js +30 -13
- package/dist/components/Routing/SegmentPage.js +117 -56
- package/dist/components/Scope/ScopeNode.js +62 -57
- package/dist/components/Sidepanel.js +59 -23
- package/dist/components/Spritesheet.js +35 -17
- package/dist/components/Text.js +1 -60
- package/dist/components/ToastList.js +95 -64
- 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 +17 -6
- package/dist/{components/Modal/index.js → hooks/useWindowSize.js} +38 -36
- package/dist/sharedMessages.js +8 -0
- package/dist/utils/index.js +0 -4
- package/dist/utils/testUtils.js +1 -12
- package/dist/{components/Modal/Background.js → utils/toastHelper.js} +11 -14
- package/package.json +2 -2
- 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 +15 -23
- 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/ApplicationModuleLoader.js +2 -2
- package/src/components/ApplicationModuleLoader.test.js +15 -28
- package/src/components/Authenticate.js +21 -23
- package/src/components/Authenticate.test.js +19 -27
- package/src/components/DropMenu/Menu.js +9 -9
- package/src/components/ErrorPlaceholder.js +4 -21
- package/src/components/ErrorPlaceholder.test.js +7 -14
- package/src/components/Form/Field.js +4 -4
- package/src/components/Form/InputField.test.js +2 -1
- package/src/components/Form/Inputs/Button.js +2 -2
- package/src/components/Form/Inputs/MultiSelector.js +73 -0
- package/src/components/Form/Inputs/MultiSelector.test.js +332 -0
- package/src/components/Form/Inputs/Selector.js +12 -4
- package/src/components/Form/Inputs/Selector.test.js +27 -12
- package/src/components/Form/Inputs/index.js +1 -1
- package/src/components/InternetExplorerWarningMessage.js +15 -15
- package/src/components/Loader.test.js +50 -59
- package/src/components/LoadingIcon.js +27 -14
- package/src/components/LoadingIcon.test.js +11 -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 +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
- package/src/components/MaterialUI/DataDisplay/Table.test.js +21 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
- 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/PredefinedElements/SearchControl.js +1 -1
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
- package/src/components/MaterialUI/Inputs/Select.js +143 -83
- package/src/components/MaterialUI/Inputs/Select.test.js +199 -14
- package/src/components/MaterialUI/Inputs/SelectProps.js +10 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +10 -0
- package/src/components/MaterialUI/Inputs/Switch.js +1 -1
- package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
- package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
- 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/Surfaces/SectionExpansionPanel.js +2 -1
- package/src/components/MaterialUI/muiThemes.js +4 -1
- 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 +44 -55
- package/src/components/Scope/ScopeNode.test.js +84 -163
- package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
- package/src/components/Sidepanel.js +38 -32
- package/src/components/Sidepanel.test.js +54 -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/ToastList.js +79 -90
- package/src/components/ToastList.test.js +29 -103
- package/src/components/Treeview/Branch.js +65 -47
- package/src/components/Treeview/Branch.test.js +2 -43
- package/src/components/Treeview/Label.js +68 -54
- package/src/components/Treeview/Label.test.js +55 -63
- package/src/components/Treeview/Leaf.js +41 -22
- package/src/components/Treeview/Leaf.test.js +1 -15
- 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 +10 -6
- 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
- package/src/utils/index.js +0 -4
- package/src/utils/testUtils.js +0 -10
- package/src/utils/testUtils.test.js +0 -68
- package/src/utils/toastHelper.js +8 -0
- package/src/utils/toastHelper.test.js +41 -0
- package/dist/components/Button.js +0 -70
- package/dist/components/CategoryList.js +0 -197
- package/dist/components/Checkbox.js +0 -103
- package/dist/components/Icon.js +0 -69
- package/dist/components/IconButton.js +0 -80
- package/dist/components/Input.js +0 -101
- package/dist/components/List/DataCell.js +0 -129
- package/dist/components/List/HeadCell.js +0 -125
- package/dist/components/List/HeadRow.js +0 -73
- package/dist/components/List/List.js +0 -274
- package/dist/components/List/Row.js +0 -109
- package/dist/components/List/enhanceColumnDefs.js +0 -111
- package/dist/components/List/index.js +0 -59
- package/dist/components/Modal/Dialog.js +0 -75
- package/dist/components/Modal/Wrapper.js +0 -69
- 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 -158
- 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/CategoryList.js +0 -140
- package/src/components/CategoryList.test.js +0 -667
- 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/List/DataCell.js +0 -77
- package/src/components/List/DataCell.test.js +0 -357
- package/src/components/List/HeadCell.js +0 -105
- package/src/components/List/HeadCell.test.js +0 -331
- package/src/components/List/HeadRow.js +0 -21
- package/src/components/List/HeadRow.test.js +0 -27
- package/src/components/List/List.js +0 -162
- package/src/components/List/List.test.js +0 -705
- package/src/components/List/Row.js +0 -72
- package/src/components/List/Row.test.js +0 -194
- package/src/components/List/enhanceColumnDefs.js +0 -54
- package/src/components/List/enhanceColumnDefs.test.js +0 -179
- package/src/components/List/index.js +0 -6
- 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 -103
- 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,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,77 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
import { FormattedNumber, FormattedDate, FormattedTime } from "react-intl";
|
|
4
|
-
import { safeGet, getThemeProp } from "../../utils";
|
|
5
|
-
import Switch from "../Switch";
|
|
6
|
-
import Checkbox from "../Checkbox";
|
|
7
|
-
import Text from "../Text";
|
|
8
|
-
|
|
9
|
-
const arrify = thing => (Array.isArray(thing) ? thing : [thing]);
|
|
10
|
-
|
|
11
|
-
const renderByType = (value, def, rowId, selected, row) => {
|
|
12
|
-
const transformedValue = def.transform ? def.transform(value) : value;
|
|
13
|
-
switch (def.type) {
|
|
14
|
-
case "custom": {
|
|
15
|
-
const Comp = def.component;
|
|
16
|
-
return <Comp {...row} {...def.funcs} />;
|
|
17
|
-
}
|
|
18
|
-
case "currency": {
|
|
19
|
-
let currency = def.currency;
|
|
20
|
-
if (Array.isArray(currency)) {
|
|
21
|
-
currency = safeGet(row, ...currency);
|
|
22
|
-
}
|
|
23
|
-
return (
|
|
24
|
-
<FormattedNumber
|
|
25
|
-
style="currency" // eslint-disable-line react/style-prop-object
|
|
26
|
-
currency={currency}
|
|
27
|
-
value={transformedValue || "0"}
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
case "date":
|
|
32
|
-
return <FormattedDate value={transformedValue} />;
|
|
33
|
-
case "datetime":
|
|
34
|
-
return (
|
|
35
|
-
<React.Fragment>
|
|
36
|
-
<FormattedDate value={transformedValue} /> <FormattedTime value={transformedValue} />
|
|
37
|
-
</React.Fragment>
|
|
38
|
-
);
|
|
39
|
-
case "select":
|
|
40
|
-
return <Checkbox id={"select_" + rowId} value={selected} data-row-id={rowId} onChange={def.onChange} />;
|
|
41
|
-
case "switch":
|
|
42
|
-
return <Switch value={!!transformedValue} {...def.switch} data-row-id={rowId} onChange={def.onChange} />;
|
|
43
|
-
default:
|
|
44
|
-
return transformedValue ? <Text message={transformedValue} /> : null;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const TableData = styled.td`
|
|
49
|
-
border: 0 solid ${getThemeProp(["colors", "borderLight"], "#cccccc")};
|
|
50
|
-
border-top-width: 1px;
|
|
51
|
-
tr:first-child & {
|
|
52
|
-
border-top-width: 0;
|
|
53
|
-
}
|
|
54
|
-
tr:last-child & {
|
|
55
|
-
border-bottom-width: 1px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
height: 20px;
|
|
59
|
-
padding: 15px 20px;
|
|
60
|
-
white-space: nowrap;
|
|
61
|
-
overflow-x: hidden;
|
|
62
|
-
text-overflow: ellipsis;
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
const DataCell = ({ columnDef, row, rowId, selected }) => (
|
|
66
|
-
<TableData>
|
|
67
|
-
{renderByType(
|
|
68
|
-
safeGet(row, ...arrify(columnDef.fieldName)) || columnDef.defaultValue,
|
|
69
|
-
columnDef,
|
|
70
|
-
rowId,
|
|
71
|
-
selected,
|
|
72
|
-
row,
|
|
73
|
-
)}
|
|
74
|
-
</TableData>
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
export default DataCell;
|