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,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
3
|
import { IntlProvider } from "react-intl";
|
|
4
|
-
import {
|
|
4
|
+
import { ReadOnly, LineLabel } from "./ReadOnly";
|
|
5
5
|
|
|
6
6
|
describe("ReadOnly", () => {
|
|
7
7
|
it("renders a read-only value in a form", () =>
|
|
@@ -19,13 +19,51 @@ describe("ReadOnly", () => {
|
|
|
19
19
|
</Provider>,
|
|
20
20
|
"when mounted",
|
|
21
21
|
"to satisfy",
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
</
|
|
22
|
+
<div>
|
|
23
|
+
<p>Read Only</p>
|
|
24
|
+
</div>,
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
it("renders a read-only text in a form", () =>
|
|
28
|
+
expect(
|
|
29
|
+
<Provider
|
|
30
|
+
store={{
|
|
31
|
+
subscribe: () => {},
|
|
32
|
+
dispatch: () => {},
|
|
33
|
+
getState: () => ({}),
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<ReadOnly value="Read Only" />
|
|
37
|
+
</Provider>,
|
|
38
|
+
"when mounted",
|
|
39
|
+
"to satisfy",
|
|
40
|
+
<div>
|
|
41
|
+
<p>Read Only</p>
|
|
42
|
+
</div>,
|
|
25
43
|
));
|
|
26
44
|
});
|
|
27
45
|
|
|
28
46
|
describe("LineLabel", () => {
|
|
47
|
+
it("renders a formatted text in large font", () =>
|
|
48
|
+
expect(
|
|
49
|
+
<Provider
|
|
50
|
+
store={{
|
|
51
|
+
subscribe: () => {},
|
|
52
|
+
dispatch: () => {},
|
|
53
|
+
getState: () => ({}),
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<IntlProvider locale="en">
|
|
57
|
+
<LineLabel value={{ id: "test.textValue", defaultMessage: "A text value" }} />
|
|
58
|
+
</IntlProvider>
|
|
59
|
+
</Provider>,
|
|
60
|
+
"when mounted",
|
|
61
|
+
"to satisfy",
|
|
62
|
+
<div>
|
|
63
|
+
<p>A text value</p>
|
|
64
|
+
</div>,
|
|
65
|
+
));
|
|
66
|
+
|
|
29
67
|
it("renders a text in large font", () =>
|
|
30
68
|
expect(
|
|
31
69
|
<Provider
|
|
@@ -39,8 +77,8 @@ describe("LineLabel", () => {
|
|
|
39
77
|
</Provider>,
|
|
40
78
|
"when mounted",
|
|
41
79
|
"to satisfy",
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
</
|
|
80
|
+
<div>
|
|
81
|
+
<p>A text value</p>
|
|
82
|
+
</div>,
|
|
45
83
|
));
|
|
46
84
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Select from "../../MaterialUI/Inputs/Select";
|
|
3
|
+
import { memoize } from "../../../utils";
|
|
4
|
+
import SelectProps from "../../MaterialUI/Inputs/SelectProps";
|
|
5
|
+
|
|
6
|
+
export const selectEventUpdater = memoize(update => value => update(value));
|
|
7
|
+
|
|
8
|
+
const Selector = ({ value, options, update, ...props }) => {
|
|
9
|
+
const selectProps = new SelectProps();
|
|
10
|
+
|
|
11
|
+
selectProps.set(SelectProps.propNames.value, value);
|
|
12
|
+
selectProps.set(SelectProps.propNames.onClose, props.onBlur);
|
|
13
|
+
selectProps.set(SelectProps.propNames.disabled, props.disabled);
|
|
14
|
+
selectProps.set(SelectProps.propNames.update, selectEventUpdater(update));
|
|
15
|
+
|
|
16
|
+
const hasError = props.required && !value ? true : false;
|
|
17
|
+
selectProps.set(SelectProps.propNames.error, hasError);
|
|
18
|
+
|
|
19
|
+
return <Select options={options} selectProps={selectProps} />;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default Selector;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import sinon from "sinon";
|
|
3
|
+
import Selector, { selectEventUpdater } from "./Selector";
|
|
4
|
+
import { TestWrapper, createMuiTheme } from "./../../../utils/testUtils";
|
|
5
|
+
import Immutable from "immutable";
|
|
6
|
+
import SelectMUI from "@material-ui/core/Select";
|
|
7
|
+
import MenuItem from "@material-ui/core/MenuItem";
|
|
8
|
+
import TooltippedTypography from "../../MaterialUI/DataDisplay/TooltippedElements/TooltippedTypography";
|
|
9
|
+
import Icon from "../../MaterialUI/DataDisplay/Icon";
|
|
10
|
+
|
|
11
|
+
describe("Selector", () => {
|
|
12
|
+
let update, state, store, chevronDown;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
update = sinon.spy().named("update");
|
|
15
|
+
|
|
16
|
+
state = Immutable.fromJS({
|
|
17
|
+
locale: {
|
|
18
|
+
locale: "en-CA",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
store = {
|
|
23
|
+
subscribe: () => {},
|
|
24
|
+
dispatch: () => {},
|
|
25
|
+
getState: () => state,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
chevronDown = props => {
|
|
29
|
+
return <Icon id="dropdown-chevron-down" {...props} />;
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const theme = createMuiTheme();
|
|
34
|
+
|
|
35
|
+
it("renders a selector with multiple options", () =>
|
|
36
|
+
expect(
|
|
37
|
+
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
38
|
+
<Selector
|
|
39
|
+
update={update}
|
|
40
|
+
value="English"
|
|
41
|
+
options={[
|
|
42
|
+
{ value: "English", label: "English" },
|
|
43
|
+
{ value: "Francais", label: "Francais" },
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
</TestWrapper>,
|
|
47
|
+
"when mounted",
|
|
48
|
+
"to satisfy",
|
|
49
|
+
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
50
|
+
<SelectMUI value="English" disableUnderline={true} IconComponent={chevronDown} error={false}>
|
|
51
|
+
<MenuItem key="English" value="English">
|
|
52
|
+
<TooltippedTypography children="English" titleValue="English" />
|
|
53
|
+
</MenuItem>
|
|
54
|
+
<MenuItem key="Francais" value="Francais">
|
|
55
|
+
<TooltippedTypography noWrap children="Francais" titleValue="Francais" />
|
|
56
|
+
</MenuItem>
|
|
57
|
+
</SelectMUI>
|
|
58
|
+
</TestWrapper>,
|
|
59
|
+
));
|
|
60
|
+
|
|
61
|
+
it("renders a selector with an error", () => {
|
|
62
|
+
expect(
|
|
63
|
+
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
64
|
+
<Selector
|
|
65
|
+
update={update}
|
|
66
|
+
required={true}
|
|
67
|
+
value={null}
|
|
68
|
+
options={[
|
|
69
|
+
{ value: "English", label: "English" },
|
|
70
|
+
{ value: "Francais", label: "Francais" },
|
|
71
|
+
]}
|
|
72
|
+
/>
|
|
73
|
+
</TestWrapper>,
|
|
74
|
+
"when mounted",
|
|
75
|
+
"to satisfy",
|
|
76
|
+
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
77
|
+
<div>
|
|
78
|
+
<SelectMUI value="" disableUnderline={true} IconComponent={chevronDown} error={true}>
|
|
79
|
+
<MenuItem key="English" value="English">
|
|
80
|
+
<TooltippedTypography children="English" titleValue="English" />
|
|
81
|
+
</MenuItem>
|
|
82
|
+
<MenuItem key="Francais" value="Francais">
|
|
83
|
+
<TooltippedTypography noWrap children="Francais" titleValue="Francais" />
|
|
84
|
+
</MenuItem>
|
|
85
|
+
</SelectMUI>
|
|
86
|
+
<div></div>
|
|
87
|
+
</div>
|
|
88
|
+
</TestWrapper>,
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe("selectEventUpdater", () => {
|
|
94
|
+
let update;
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
update = sinon.spy().named("update");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("creates a handler for an event and calls update with the value of the target", () =>
|
|
100
|
+
expect(selectEventUpdater, "called with", [update], "called with", ["foo"]).then(() =>
|
|
101
|
+
expect(update, "to have calls satisfying", [{ args: ["foo"] }]),
|
|
102
|
+
));
|
|
103
|
+
|
|
104
|
+
it("is memoized", () => expect(selectEventUpdater, "called with", [update], "to be", selectEventUpdater(update)));
|
|
105
|
+
});
|
|
@@ -1,49 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import InputBase from "../../MaterialUI/Inputs/InputBase";
|
|
3
|
+
import { memoize } from "../../../utils";
|
|
4
|
+
import InputBaseProps from "../../MaterialUI/Inputs/InputBaseProps";
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
flex: 0 0 auto;
|
|
9
|
-
border-radius: 4px;
|
|
10
|
-
min-width: 40px;
|
|
11
|
-
width: 100%;
|
|
6
|
+
export const inputEventUpdater = memoize(update => input => update(input));
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export const TextInput = ({ update, value = "", ...props }) => {
|
|
9
|
+
const inputBaseProps = new InputBaseProps();
|
|
10
|
+
inputBaseProps.set(InputBaseProps.propNames.value, value);
|
|
11
|
+
inputBaseProps.set(InputBaseProps.propNames.disabled, props.disabled);
|
|
12
|
+
inputBaseProps.set(InputBaseProps.propNames.placeholder, props.placeholder);
|
|
13
|
+
inputBaseProps.set(InputBaseProps.propNames.onBlur, props.onBlur);
|
|
14
|
+
inputBaseProps.set(InputBaseProps.propNames.update, inputEventUpdater(update));
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
box-shadow: 0 0 4px ${getThemeProp(["colors", "error"], "#ce4844")};
|
|
21
|
-
}
|
|
16
|
+
const hasError = props.required && !value ? true : false;
|
|
17
|
+
inputBaseProps.set(InputBaseProps.propNames.error, hasError);
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
&[type="number"],
|
|
26
|
-
&[type="time"] {
|
|
27
|
-
-webkit-appearance: none;
|
|
28
|
-
-moz-appearance: textfield;
|
|
29
|
-
}
|
|
30
|
-
&::-webkit-clear-button,
|
|
31
|
-
&::-webkit-calendar-picker-indicator {
|
|
32
|
-
display: none;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&::-webkit-outer-spin-button,
|
|
36
|
-
&::-webkit-inner-spin-button {
|
|
37
|
-
-webkit-appearance: none;
|
|
38
|
-
margin: 0;
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
export const getEventUpdater = memoize(update => e => update(e.target.value));
|
|
43
|
-
|
|
44
|
-
export const TextInput = ({ update, value = "", ...props }) => (
|
|
45
|
-
<FormInput type="text" onChange={getEventUpdater(update)} {...props} value={value} />
|
|
46
|
-
);
|
|
47
|
-
export const EmailInput = ({ update, value = "", ...props }) => (
|
|
48
|
-
<FormInput type="email" onChange={getEventUpdater(update)} {...props} value={value} />
|
|
49
|
-
);
|
|
19
|
+
return <InputBase inputProps={inputBaseProps} />;
|
|
20
|
+
};
|
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { IntlProvider } from "react-intl";
|
|
3
3
|
import sinon from "sinon";
|
|
4
|
-
import
|
|
4
|
+
import InputBase from "../../MaterialUI/Inputs/InputBase";
|
|
5
|
+
import { inputEventUpdater, TextInput } from "./Text";
|
|
6
|
+
import { extractMessages, generateClassName } from "../../../utils/testUtils";
|
|
7
|
+
import sharedMessages from "../../../sharedMessages";
|
|
8
|
+
import { StylesProvider } from "@material-ui/core";
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
let update;
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
update = sinon.spy().named("update");
|
|
10
|
-
});
|
|
10
|
+
const messages = extractMessages(sharedMessages);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
expect(
|
|
14
|
-
<IntlProvider locale="en">
|
|
15
|
-
<TextInput update={update} otherProp />
|
|
16
|
-
</IntlProvider>,
|
|
17
|
-
"when mounted",
|
|
18
|
-
"to satisfy",
|
|
19
|
-
<IntlProvider locale="en">
|
|
20
|
-
<FormInput type="text" onChange={getEventUpdater(update)} otherProp />
|
|
21
|
-
</IntlProvider>,
|
|
22
|
-
));
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe("EmailInput", () => {
|
|
12
|
+
describe("TextInput", () => {
|
|
26
13
|
let update;
|
|
27
14
|
beforeEach(() => {
|
|
28
15
|
update = sinon.spy().named("update");
|
|
@@ -30,27 +17,31 @@ describe("EmailInput", () => {
|
|
|
30
17
|
|
|
31
18
|
it("renders a text input with change handler", () =>
|
|
32
19
|
expect(
|
|
33
|
-
<
|
|
34
|
-
<
|
|
35
|
-
|
|
20
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
21
|
+
<IntlProvider locale="en" messages={messages}>
|
|
22
|
+
<TextInput update={update} otherProp />
|
|
23
|
+
</IntlProvider>
|
|
24
|
+
</StylesProvider>,
|
|
36
25
|
"when mounted",
|
|
37
26
|
"to satisfy",
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
|
|
27
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
28
|
+
<IntlProvider locale="en" messages={messages}>
|
|
29
|
+
<InputBase />
|
|
30
|
+
</IntlProvider>
|
|
31
|
+
</StylesProvider>,
|
|
41
32
|
));
|
|
42
33
|
});
|
|
43
34
|
|
|
44
|
-
describe("
|
|
35
|
+
describe("inputEventUpdater", () => {
|
|
45
36
|
let update;
|
|
46
37
|
beforeEach(() => {
|
|
47
38
|
update = sinon.spy().named("update");
|
|
48
39
|
});
|
|
49
40
|
|
|
50
41
|
it("creates a handler for an event and calls update with the value of the target", () =>
|
|
51
|
-
expect(
|
|
42
|
+
expect(inputEventUpdater, "called with", [update], "called with", ["foo"]).then(() =>
|
|
52
43
|
expect(update, "to have calls satisfying", [{ args: ["foo"] }]),
|
|
53
44
|
));
|
|
54
45
|
|
|
55
|
-
it("is memoized", () => expect(
|
|
46
|
+
it("is memoized", () => expect(inputEventUpdater, "called with", [update], "to be", inputEventUpdater(update)));
|
|
56
47
|
});
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
3
|
import { memoize } from "../../../utils";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import Switch from "../../MaterialUI/Inputs/Switch";
|
|
5
|
+
import SwitchProps from "../../MaterialUI/Inputs/SwitchProps";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
height: 30px;
|
|
9
|
-
display: flex;
|
|
10
|
-
align-self: flex-start;
|
|
11
|
-
align-items: center;
|
|
12
|
-
`;
|
|
7
|
+
export const switchEventUpdater = memoize(update => value => update(value));
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
const useStyles = makeStyles({
|
|
10
|
+
centerMiddleWrapper: {
|
|
11
|
+
minHeight: 30,
|
|
12
|
+
display: "flex",
|
|
13
|
+
justifyContent: "center",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
},
|
|
16
|
+
});
|
|
15
17
|
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
display: flex;
|
|
19
|
-
justify-content: center;
|
|
20
|
-
align-items: center;
|
|
21
|
-
`;
|
|
18
|
+
export const SwitchInput = ({ update, value, ...props }) => {
|
|
19
|
+
const classes = useStyles();
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
<CenterMiddleWrapper>
|
|
25
|
-
<FormCheckbox onChange={getCheckUpdater(update)} value={value} {...props} />
|
|
26
|
-
</CenterMiddleWrapper>
|
|
27
|
-
);
|
|
21
|
+
const switchProps = new SwitchProps();
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
23
|
+
switchProps.set(SwitchProps.propNames.value, value);
|
|
24
|
+
switchProps.set(SwitchProps.propNames.onCaption, props.onCaption);
|
|
25
|
+
switchProps.set(SwitchProps.propNames.offCaption, props.offCaption);
|
|
26
|
+
switchProps.set(SwitchProps.propNames.disabled, props.disabled);
|
|
27
|
+
switchProps.set(SwitchProps.propNames.update, switchEventUpdater(update));
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className={classes.centerMiddleWrapper}>
|
|
31
|
+
<Switch switchProps={switchProps} />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import sinon from "sinon";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
update = sinon.spy().named("update");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("renders a checkbox input with change handler", () =>
|
|
13
|
-
expect(
|
|
14
|
-
<CheckboxInput id="test-item" update={update} value={false} otherProp />,
|
|
15
|
-
"when mounted",
|
|
16
|
-
"to satisfy",
|
|
17
|
-
<CenterMiddleWrapper>
|
|
18
|
-
<FormCheckbox id="test-item" onChange={getCheckUpdater(update)} value={false} otherProp />
|
|
19
|
-
</CenterMiddleWrapper>,
|
|
20
|
-
));
|
|
21
|
-
});
|
|
3
|
+
import { IntlProvider } from "react-intl";
|
|
4
|
+
import Switch from "../../MaterialUI/Inputs/Switch";
|
|
5
|
+
import { generateClassName } from "../../../utils/testUtils";
|
|
6
|
+
import { switchEventUpdater, SwitchInput } from "./Toggles";
|
|
7
|
+
import { StylesProvider } from "@material-ui/core";
|
|
22
8
|
|
|
23
9
|
describe("SwitchInput", () => {
|
|
24
10
|
let update;
|
|
@@ -28,25 +14,33 @@ describe("SwitchInput", () => {
|
|
|
28
14
|
|
|
29
15
|
it("renders a switch input with change handler", () =>
|
|
30
16
|
expect(
|
|
31
|
-
<
|
|
17
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
18
|
+
<IntlProvider locale="en">
|
|
19
|
+
<SwitchInput id="test-item" update={update} value={true} otherProp />
|
|
20
|
+
</IntlProvider>
|
|
21
|
+
</StylesProvider>,
|
|
32
22
|
"when mounted",
|
|
33
23
|
"to satisfy",
|
|
34
|
-
<
|
|
35
|
-
<
|
|
36
|
-
|
|
24
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
25
|
+
<IntlProvider locale="en">
|
|
26
|
+
<div>
|
|
27
|
+
<Switch />
|
|
28
|
+
</div>
|
|
29
|
+
</IntlProvider>
|
|
30
|
+
</StylesProvider>,
|
|
37
31
|
));
|
|
38
32
|
});
|
|
39
33
|
|
|
40
|
-
describe("
|
|
34
|
+
describe("switchEventUpdater", () => {
|
|
41
35
|
let update;
|
|
42
36
|
beforeEach(() => {
|
|
43
37
|
update = sinon.spy().named("update");
|
|
44
38
|
});
|
|
45
39
|
|
|
46
|
-
it("creates a handler for an event and calls update with the
|
|
47
|
-
expect(
|
|
48
|
-
expect(update, "to have calls satisfying", [{ args: [
|
|
40
|
+
it("creates a handler for an event and calls update with the value of the target", () =>
|
|
41
|
+
expect(switchEventUpdater, "called with", [update], "called with", ["foo"]).then(() =>
|
|
42
|
+
expect(update, "to have calls satisfying", [{ args: ["foo"] }]),
|
|
49
43
|
));
|
|
50
44
|
|
|
51
|
-
it("is memoized", () => expect(
|
|
45
|
+
it("is memoized", () => expect(switchEventUpdater, "called with", [update], "to be", switchEventUpdater(update)));
|
|
52
46
|
});
|
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
import Selector from "
|
|
1
|
+
import Selector from "./Selector";
|
|
2
2
|
import MultiSelector from "../../MultiSelector";
|
|
3
3
|
import Button from "./Button";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { TextInput, EmailInput } from "./Text";
|
|
8
|
-
import { NumberInput } from "./Number";
|
|
4
|
+
import { ReadOnly } from "./ReadOnly";
|
|
5
|
+
import { SwitchInput } from "./Toggles";
|
|
6
|
+
import { TextInput } from "./Text";
|
|
9
7
|
import { DateInput } from "./Date";
|
|
10
|
-
import { TimeInput } from "./Time";
|
|
11
|
-
import TranslationInput from "./Translation";
|
|
12
8
|
|
|
13
9
|
const inputs = {
|
|
14
10
|
Button,
|
|
15
|
-
CheckboxInput,
|
|
16
11
|
DateInput,
|
|
17
|
-
EmailInput,
|
|
18
|
-
LineLabel,
|
|
19
12
|
MultiSelector,
|
|
20
|
-
NumberInput,
|
|
21
13
|
ReadOnly,
|
|
22
14
|
Selector,
|
|
23
|
-
SmallButton,
|
|
24
15
|
SwitchInput,
|
|
25
16
|
TextInput,
|
|
26
|
-
TimeInput,
|
|
27
|
-
TranslationInput,
|
|
28
17
|
};
|
|
29
18
|
|
|
30
19
|
export default inputs;
|
|
@@ -126,9 +126,6 @@ describe("Information Item", () => {
|
|
|
126
126
|
const label = "label";
|
|
127
127
|
const value = "value";
|
|
128
128
|
|
|
129
|
-
const multipleLinesTextProps = new TextProps();
|
|
130
|
-
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
131
|
-
|
|
132
129
|
const component = (
|
|
133
130
|
<IntlProvider locale="en-US">
|
|
134
131
|
<InformationItem label={label} isMaxLineCountEnabled={null}>
|
|
@@ -140,7 +137,7 @@ describe("Information Item", () => {
|
|
|
140
137
|
const expected = (
|
|
141
138
|
<div>
|
|
142
139
|
<Typography children={label} />
|
|
143
|
-
<MultipleLinesText
|
|
140
|
+
<MultipleLinesText>{value}</MultipleLinesText>
|
|
144
141
|
</div>
|
|
145
142
|
);
|
|
146
143
|
|
|
@@ -8,20 +8,25 @@ import Skeleton from "@material-ui/lab/Skeleton";
|
|
|
8
8
|
const useStyles = makeStyles(theme => ({
|
|
9
9
|
placeholder: {
|
|
10
10
|
margin: `${theme.spacing(10)} auto`,
|
|
11
|
+
"& > *": {
|
|
12
|
+
color: theme.palette.grey.icon,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
placeholderError: {
|
|
16
|
+
"& > *": {
|
|
17
|
+
color: theme.palette.error.main,
|
|
18
|
+
},
|
|
11
19
|
},
|
|
12
20
|
placeholderImage: {
|
|
13
21
|
fontSize: theme.spacing(14),
|
|
14
|
-
color: theme.palette.grey.icon,
|
|
15
22
|
},
|
|
16
23
|
placeholderTitle: {
|
|
17
24
|
marginTop: theme.spacing(1),
|
|
18
25
|
fontSize: theme.typography.h1Size,
|
|
19
|
-
color: theme.palette.grey.icon,
|
|
20
26
|
},
|
|
21
27
|
placeholderSubtitle: {
|
|
22
28
|
marginTop: theme.spacing(1),
|
|
23
29
|
fontSize: theme.typography.h3Size,
|
|
24
|
-
color: theme.palette.grey.icon,
|
|
25
30
|
},
|
|
26
31
|
placeholderRow: {
|
|
27
32
|
alignSelf: "flex-start",
|
|
@@ -55,10 +60,21 @@ const useStyles = makeStyles(theme => ({
|
|
|
55
60
|
},
|
|
56
61
|
root: {
|
|
57
62
|
flexGrow: 1,
|
|
63
|
+
display: "flex",
|
|
64
|
+
flexDirection: "column",
|
|
65
|
+
},
|
|
66
|
+
animatePlaceholderImage: {
|
|
67
|
+
animation: "$rotate 4s linear infinite",
|
|
68
|
+
margin: "auto",
|
|
69
|
+
},
|
|
70
|
+
"@keyframes rotate": {
|
|
71
|
+
to: {
|
|
72
|
+
transform: "rotate(1turn)",
|
|
73
|
+
},
|
|
58
74
|
},
|
|
59
75
|
}));
|
|
60
76
|
|
|
61
|
-
const Placeholder = ({ icon, title, subtitle, cellList = [] }) => {
|
|
77
|
+
const Placeholder = ({ icon, title, subtitle, cellList = [], error = false, animateIcon = false }) => {
|
|
62
78
|
const classes = useStyles();
|
|
63
79
|
return (
|
|
64
80
|
<>
|
|
@@ -90,8 +106,18 @@ const Placeholder = ({ icon, title, subtitle, cellList = [] }) => {
|
|
|
90
106
|
</div>
|
|
91
107
|
) : null}
|
|
92
108
|
{(icon || title || subtitle) && (
|
|
93
|
-
<Grid
|
|
94
|
-
|
|
109
|
+
<Grid
|
|
110
|
+
container
|
|
111
|
+
direction="column"
|
|
112
|
+
alignItems="center"
|
|
113
|
+
className={`${classes.placeholder} ${error ? classes.placeholderError : ""}`}
|
|
114
|
+
>
|
|
115
|
+
{icon ? (
|
|
116
|
+
<Icon
|
|
117
|
+
className={`${classes.placeholderImage} ${animateIcon ? classes.animatePlaceholderImage : ""}`}
|
|
118
|
+
id={icon}
|
|
119
|
+
/>
|
|
120
|
+
) : null}
|
|
95
121
|
{title ? <Typography className={classes.placeholderTitle}>{title}</Typography> : null}
|
|
96
122
|
{subtitle ? <Typography className={classes.placeholderSubtitle}>{subtitle}</Typography> : null}
|
|
97
123
|
</Grid>
|
|
@@ -151,7 +151,9 @@ describe("Placeholder", () => {
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
it("Renders placeholder with all parametres", () => {
|
|
154
|
-
const component =
|
|
154
|
+
const component = (
|
|
155
|
+
<Placeholder icon={icon} animateIcon title={title} subtitle={subtitle} cellList={cellList} error={true} />
|
|
156
|
+
);
|
|
155
157
|
|
|
156
158
|
const mountedComponent = mount(component);
|
|
157
159
|
const expected = (
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
|
|
4
|
+
const useStyles = makeStyles(theme => ({
|
|
5
|
+
container: {
|
|
6
|
+
display: "flex",
|
|
7
|
+
padding: `${theme.spacing(1)} ${theme.spacing(2)}`,
|
|
8
|
+
minHeight: theme.spacing(4),
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
borderBottom: `${theme.spacing(0.1)} solid ${theme.palette.grey.borders}`,
|
|
11
|
+
},
|
|
12
|
+
rightContent: {
|
|
13
|
+
justifyContent: "flex-end",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
display: "flex",
|
|
16
|
+
flex: 1,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const SectionToolbar = ({ children, rightContent }) => {
|
|
21
|
+
const classes = useStyles();
|
|
22
|
+
|
|
23
|
+
const container = (
|
|
24
|
+
<div className={classes.container}>
|
|
25
|
+
{children}
|
|
26
|
+
{[
|
|
27
|
+
rightContent && (
|
|
28
|
+
<div key={"rightContent"} className={classes.rightContent}>
|
|
29
|
+
{rightContent}
|
|
30
|
+
</div>
|
|
31
|
+
),
|
|
32
|
+
]}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return container;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default SectionToolbar;
|