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.
Files changed (186) hide show
  1. package/dist/actions/metadata.js +30 -11
  2. package/dist/actions/requestsApi.js +10 -1
  3. package/dist/components/AppFrame/About.js +136 -100
  4. package/dist/components/AppFrame/Anchor.js +45 -21
  5. package/dist/components/AppFrame/AppFrame.js +53 -31
  6. package/dist/components/AppFrame/Help.js +35 -15
  7. package/dist/components/AppFrame/MenuItem.js +148 -114
  8. package/dist/components/AppFrame/Preferences.js +136 -97
  9. package/dist/components/AppFrame/Sidebar.js +51 -28
  10. package/dist/components/AppFrame/Topbar.js +61 -36
  11. package/dist/components/ColumnWrapper.js +28 -5
  12. package/dist/components/Culture.js +33 -14
  13. package/dist/components/DropMenu/Menu.js +79 -45
  14. package/dist/components/DropMenu/index.js +34 -29
  15. package/dist/components/Form/Combination.js +45 -16
  16. package/dist/components/Form/Field.js +57 -38
  17. package/dist/components/Form/FieldElements.js +0 -11
  18. package/dist/components/Form/Fieldset.js +47 -19
  19. package/dist/components/Form/Form.js +22 -9
  20. package/dist/components/Form/FormElement.js +40 -7
  21. package/dist/components/Form/Inputs/Button.js +63 -18
  22. package/dist/components/Form/Inputs/ReadOnly.js +50 -27
  23. package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
  24. package/dist/components/Form/Inputs/Text.js +20 -37
  25. package/dist/components/Form/Inputs/Toggles.js +39 -40
  26. package/dist/components/Form/Inputs/index.js +2 -13
  27. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
  28. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
  29. package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
  30. package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
  31. package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
  32. package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
  33. package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
  34. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
  35. package/dist/components/MaterialUI/Inputs/Select.js +2 -0
  36. package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
  37. package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
  38. package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
  39. package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
  40. package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
  41. package/dist/components/MaterialUI/muiThemes.js +2 -1
  42. package/dist/components/Provision.js +1 -1
  43. package/dist/constants.js +2 -1
  44. package/dist/content/iconsSheet.svg +740 -116
  45. package/dist/hocs/withScrollBox.js +27 -12
  46. package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
  47. package/dist/hooks/useInMemoryPaging.js +135 -0
  48. package/dist/hooks/useMultipleFieldEditState.js +12 -3
  49. package/dist/reducers/metadata.js +6 -0
  50. package/dist/schemas/metadata.js +9 -1
  51. package/dist/selectors/locale.js +1 -0
  52. package/dist/selectors/metadata.js +14 -11
  53. package/dist/sharedMessages.js +184 -0
  54. package/dist/utils/ListHelper.js +271 -0
  55. package/dist/utils/comparisonHelper.js +185 -0
  56. package/dist/utils/propertyBagHelper.js +3 -1
  57. package/dist/utils/timezoneHelper.js +18 -31
  58. package/package.json +4 -3
  59. package/src/actions/metadata.js +11 -0
  60. package/src/actions/metadata.test.js +27 -0
  61. package/src/actions/requestsApi.js +6 -0
  62. package/src/components/AppFrame/About.js +97 -117
  63. package/src/components/AppFrame/About.test.js +128 -90
  64. package/src/components/AppFrame/Anchor.js +34 -36
  65. package/src/components/AppFrame/Anchor.test.js +5 -68
  66. package/src/components/AppFrame/AppFrame.js +31 -40
  67. package/src/components/AppFrame/AppFrame.test.js +424 -445
  68. package/src/components/AppFrame/Help.js +23 -20
  69. package/src/components/AppFrame/Help.test.js +3 -3
  70. package/src/components/AppFrame/MenuItem.js +106 -126
  71. package/src/components/AppFrame/MenuItem.test.js +78 -169
  72. package/src/components/AppFrame/Preferences.js +110 -98
  73. package/src/components/AppFrame/Preferences.test.js +115 -219
  74. package/src/components/AppFrame/Sidebar.js +39 -41
  75. package/src/components/AppFrame/Sidebar.test.js +88 -168
  76. package/src/components/AppFrame/Topbar.js +59 -52
  77. package/src/components/AppFrame/Topbar.test.js +31 -39
  78. package/src/components/ColumnWrapper.js +18 -9
  79. package/src/components/Culture.js +20 -10
  80. package/src/components/Culture.test.js +27 -16
  81. package/src/components/DropMenu/DropMenu.test.js +185 -224
  82. package/src/components/DropMenu/Menu.js +73 -80
  83. package/src/components/DropMenu/Menu.test.js +35 -86
  84. package/src/components/DropMenu/index.js +19 -15
  85. package/src/components/Form/Combination.js +35 -28
  86. package/src/components/Form/Combination.test.js +6 -19
  87. package/src/components/Form/Field.js +53 -66
  88. package/src/components/Form/Field.test.js +29 -51
  89. package/src/components/Form/FieldElements.js +0 -14
  90. package/src/components/Form/FieldElements.test.js +104 -111
  91. package/src/components/Form/Fieldset.js +42 -37
  92. package/src/components/Form/Fieldset.test.js +14 -7
  93. package/src/components/Form/Form.js +11 -7
  94. package/src/components/Form/Form.test.js +75 -56
  95. package/src/components/Form/FormElement.js +24 -16
  96. package/src/components/Form/InputField.test.js +24 -30
  97. package/src/components/Form/Inputs/Button.js +58 -14
  98. package/src/components/Form/Inputs/Button.test.js +32 -7
  99. package/src/components/Form/Inputs/Inputs.test.js +0 -7
  100. package/src/components/Form/Inputs/ReadOnly.js +34 -28
  101. package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
  102. package/src/components/Form/Inputs/Selector.js +22 -0
  103. package/src/components/Form/Inputs/Selector.test.js +105 -0
  104. package/src/components/Form/Inputs/Text.js +15 -44
  105. package/src/components/Form/Inputs/Text.test.js +20 -29
  106. package/src/components/Form/Inputs/Toggles.js +27 -26
  107. package/src/components/Form/Inputs/Toggles.test.js +22 -28
  108. package/src/components/Form/Inputs/index.js +4 -15
  109. package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
  110. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
  111. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
  112. package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
  113. package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
  114. package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
  115. package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
  116. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
  117. package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
  118. package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
  119. package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
  120. package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
  121. package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
  122. package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
  123. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
  124. package/src/components/MaterialUI/Inputs/Select.js +2 -0
  125. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  126. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  127. package/src/components/MaterialUI/Inputs/Switch.js +22 -1
  128. package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
  129. package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
  130. package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
  131. package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
  132. package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
  133. package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
  134. package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
  135. package/src/components/MaterialUI/muiThemes.js +1 -0
  136. package/src/components/Navigation/Bar.test.js +92 -87
  137. package/src/components/Provision.js +1 -1
  138. package/src/components/TaskDetailsModal.test.js +1 -3
  139. package/src/constants.js +1 -0
  140. package/src/content/iconsSheet.svg +740 -116
  141. package/src/hocs/withScrollBox.js +32 -19
  142. package/src/hocs/withScrollBox.test.js +15 -3
  143. package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
  144. package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
  145. package/src/hooks/useInMemoryPaging.js +78 -0
  146. package/src/hooks/useInMemoryPaging.test.js +515 -0
  147. package/src/hooks/useMultipleFieldEditState.js +11 -4
  148. package/src/hooks/useMultipleFieldEditState.test.js +49 -1
  149. package/src/reducers/metadata.js +6 -1
  150. package/src/reducers/metadata.test.js +31 -0
  151. package/src/requests +1 -0
  152. package/src/schemas/metadata.js +3 -0
  153. package/src/selectors/locale.js +1 -1
  154. package/src/selectors/metadata.js +12 -9
  155. package/src/selectors/metadata.test.js +92 -11
  156. package/src/sharedMessages.js +184 -0
  157. package/src/timezones.json +883 -0
  158. package/src/translations/en-US.json +46 -0
  159. package/src/translations/fr-CA.json +46 -0
  160. package/src/utils/ListHelper.js +203 -0
  161. package/src/utils/ListHelper.test.js +710 -0
  162. package/src/utils/comparisonHelper.js +135 -0
  163. package/src/utils/comparisonHelper.test.js +334 -0
  164. package/src/utils/propertyBagHelper.js +2 -0
  165. package/src/utils/propertyBagHelper.test.js +6 -0
  166. package/src/utils/timezoneHelper.js +10 -135
  167. package/src/utils/timezoneHelper.test.js +7 -7
  168. package/dist/components/Form/FieldList.js +0 -270
  169. package/dist/components/Form/Inputs/FieldButtons.js +0 -66
  170. package/dist/components/Form/Inputs/Number.js +0 -117
  171. package/dist/components/Form/Inputs/SmallButton.js +0 -91
  172. package/dist/components/Form/Inputs/Time.js +0 -86
  173. package/dist/components/Form/Inputs/Translation.js +0 -169
  174. package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
  175. package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
  176. package/src/components/Form/FieldList.js +0 -210
  177. package/src/components/Form/FieldList.test.js +0 -558
  178. package/src/components/Form/Inputs/FieldButtons.js +0 -90
  179. package/src/components/Form/Inputs/Number.js +0 -60
  180. package/src/components/Form/Inputs/Number.test.js +0 -435
  181. package/src/components/Form/Inputs/SmallButton.js +0 -37
  182. package/src/components/Form/Inputs/SmallButton.test.js +0 -65
  183. package/src/components/Form/Inputs/Time.js +0 -32
  184. package/src/components/Form/Inputs/Time.test.js +0 -41
  185. package/src/components/Form/Inputs/Translation.js +0 -93
  186. 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 { CenterWrapper, ReadOnlyBlock, ReadOnly, Label, LineLabel } from "./ReadOnly";
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
- <CenterWrapper>
23
- <ReadOnlyBlock>Read Only</ReadOnlyBlock>
24
- </CenterWrapper>,
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
- <CenterWrapper>
43
- <Label>A text value</Label>
44
- </CenterWrapper>,
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 styled from "styled-components";
3
- import Input from "../../Input";
4
- import { memoize, getThemeProp } from "../../../utils";
2
+ import InputBase from "../../MaterialUI/Inputs/InputBase";
3
+ import { memoize } from "../../../utils";
4
+ import InputBaseProps from "../../MaterialUI/Inputs/InputBaseProps";
5
5
 
6
- export const FormInput = styled(Input)`
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
- &:active,
14
- &:focus {
15
- z-index: 1;
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
- &:invalid {
19
- border-color: ${getThemeProp(["colors", "error"], "#ce4844")};
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
- ${"" /* These are hacks, work only in Chrome, best not used */}
24
- &[type="date"],
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 { FormInput, getEventUpdater, TextInput, EmailInput } from "./Text";
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
- describe("TextInput", () => {
7
- let update;
8
- beforeEach(() => {
9
- update = sinon.spy().named("update");
10
- });
10
+ const messages = extractMessages(sharedMessages);
11
11
 
12
- it("renders a text input with change handler", () =>
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
- <IntlProvider locale="en">
34
- <EmailInput update={update} otherProp />
35
- </IntlProvider>,
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
- <IntlProvider locale="en">
39
- <FormInput type="email" onChange={getEventUpdater(update)} otherProp />
40
- </IntlProvider>,
27
+ <StylesProvider generateClassName={generateClassName}>
28
+ <IntlProvider locale="en" messages={messages}>
29
+ <InputBase />
30
+ </IntlProvider>
31
+ </StylesProvider>,
41
32
  ));
42
33
  });
43
34
 
44
- describe("getEventUpdater", () => {
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(getEventUpdater, "called with", [update], "called with", [{ target: { value: "foo" } }]).then(() =>
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(getEventUpdater, "called with", [update], "to be", getEventUpdater(update)));
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 styled from "styled-components";
2
+ import { makeStyles } from "@material-ui/core/styles";
3
3
  import { memoize } from "../../../utils";
4
- import Checkbox from "../../Checkbox";
5
- import Switch from "../../Switch";
4
+ import Switch from "../../MaterialUI/Inputs/Switch";
5
+ import SwitchProps from "../../MaterialUI/Inputs/SwitchProps";
6
6
 
7
- export const FormCheckbox = styled(Checkbox)`
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
- export const getCheckUpdater = memoize(update => e => update(e.target.checked));
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 CenterMiddleWrapper = styled.div`
17
- min-height: 30px;
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
- export const CheckboxInput = ({ update, value, ...props }) => (
24
- <CenterMiddleWrapper>
25
- <FormCheckbox onChange={getCheckUpdater(update)} value={value} {...props} />
26
- </CenterMiddleWrapper>
27
- );
21
+ const switchProps = new SwitchProps();
28
22
 
29
- export const SwitchInput = ({ update, value, ...props }) => (
30
- <CenterMiddleWrapper>
31
- <Switch onChange={getCheckUpdater(update)} value={value} {...props} />
32
- </CenterMiddleWrapper>
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 Switch from "../../Switch";
4
- import { FormCheckbox, getCheckUpdater, CenterMiddleWrapper, CheckboxInput, SwitchInput } from "./Toggles";
5
-
6
- describe("CheckboxInput", () => {
7
- let update;
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
- <SwitchInput id="test-item" update={update} value={true} otherProp />,
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
- <CenterMiddleWrapper>
35
- <Switch id="test-item" onChange={getCheckUpdater(update)} value={true} otherProp />
36
- </CenterMiddleWrapper>,
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("getCheckUpdater", () => {
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 'checked' attribute of the target", () =>
47
- expect(getCheckUpdater, "called with", [update], "called with", [{ target: { checked: true } }]).then(() =>
48
- expect(update, "to have calls satisfying", [{ args: [true] }]),
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(getCheckUpdater, "called with", [update], "to be", getCheckUpdater(update)));
45
+ it("is memoized", () => expect(switchEventUpdater, "called with", [update], "to be", switchEventUpdater(update)));
52
46
  });
@@ -1,30 +1,19 @@
1
- import Selector from "../../Selector";
1
+ import Selector from "./Selector";
2
2
  import MultiSelector from "../../MultiSelector";
3
3
  import Button from "./Button";
4
- import SmallButton from "./SmallButton";
5
- import { ReadOnly, LineLabel } from "./ReadOnly";
6
- import { CheckboxInput, SwitchInput } from "./Toggles";
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 textProps={multipleLinesTextProps}>{value}</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 container direction="column" alignItems="center" className={classes.placeholder}>
94
- {icon ? <Icon className={classes.placeholderImage} id={icon} /> : null}
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 = <Placeholder icon={icon} title={title} subtitle={subtitle} cellList={cellList} />;
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;