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,11 +1,14 @@
1
1
  import React from "react";
2
2
  import Immutable from "immutable";
3
3
  import { Provider } from "react-redux";
4
+ import { generateClassName } from "../../utils/testUtils";
4
5
  import { IntlProvider } from "react-intl";
5
6
  import Form from "./FormElement";
6
7
  import FieldElements from "./FieldElements";
7
- import { FieldBox, Label } from "./Field";
8
- import { FormPage, Wrapper, FormContext } from "./Form";
8
+ import Field from "./Field";
9
+ import { FormPage, FormContext } from "./Form";
10
+ import { StylesProvider } from "@material-ui/core";
11
+ import { TextInput } from "./Inputs/Text";
9
12
 
10
13
  describe("FormPage", () => {
11
14
  let state, store, getUpdater, fields, manyFields, values;
@@ -36,94 +39,110 @@ describe("FormPage", () => {
36
39
  it("renders a form with a single field", () =>
37
40
  expect(
38
41
  <Provider store={store}>
39
- <IntlProvider locale="en">
40
- <FormPage formName="testForm" fields={fields} getUpdater={getUpdater} values={values} />
41
- </IntlProvider>
42
+ <StylesProvider generateClassName={generateClassName}>
43
+ <IntlProvider locale="en">
44
+ <FormPage formName="testForm" fields={fields} getUpdater={getUpdater} values={values} />
45
+ </IntlProvider>
46
+ </StylesProvider>
42
47
  </Provider>,
43
48
  "when mounted",
44
49
  "to satisfy",
45
50
  <Provider store={store}>
46
- <IntlProvider locale="en">
47
- <FormContext.Provider value={{ values, formName: "testForm" }}>
48
- <Wrapper>
49
- <Form spanWidth={1}>
50
- <FieldBox>
51
- <Label>A text</Label>
52
- <input value="foo" id="text1" onChange={() => {}} data-test-id="testForm_text1" />
53
- </FieldBox>
54
- </Form>
55
- </Wrapper>
56
- </FormContext.Provider>
57
- </IntlProvider>
51
+ <StylesProvider generateClassName={generateClassName}>
52
+ <IntlProvider locale="en">
53
+ <FormContext.Provider value={{ values, formName: "testForm" }}>
54
+ <div>
55
+ <Form spanWidth={1}>
56
+ <Field>
57
+ <label>A text</label>
58
+ <TextInput value="foo" />
59
+ </Field>
60
+ </Form>
61
+ </div>
62
+ </FormContext.Provider>
63
+ </IntlProvider>
64
+ </StylesProvider>
58
65
  </Provider>,
59
66
  ));
60
67
 
61
68
  it("still respects 'wide' flag", () =>
62
69
  expect(
63
70
  <Provider store={store}>
64
- <IntlProvider locale="en">
65
- <FormPage wide fields={fields} getUpdater={getUpdater} values={values} />
66
- </IntlProvider>
71
+ <StylesProvider generateClassName={generateClassName}>
72
+ <IntlProvider locale="en">
73
+ <FormPage wide fields={fields} getUpdater={getUpdater} values={values} />
74
+ </IntlProvider>
75
+ </StylesProvider>
67
76
  </Provider>,
68
77
  "when mounted",
69
78
  "to satisfy",
70
79
  <Provider store={store}>
71
- <IntlProvider locale="en">
72
- <FormContext.Provider value={{ values }}>
73
- <Wrapper>
74
- <Form spanWidth={1}>
75
- <FieldElements getUpdater={getUpdater} fields={fields} />
76
- </Form>
77
- </Wrapper>
78
- </FormContext.Provider>
79
- </IntlProvider>
80
+ <StylesProvider generateClassName={generateClassName}>
81
+ <IntlProvider locale="en">
82
+ <FormContext.Provider value={{ values }}>
83
+ <div>
84
+ <Form spanWidth={1}>
85
+ <FieldElements getUpdater={getUpdater} fields={fields} />
86
+ </Form>
87
+ </div>
88
+ </FormContext.Provider>
89
+ </IntlProvider>
90
+ </StylesProvider>
80
91
  </Provider>,
81
92
  ));
82
93
 
83
94
  it("still respects 'wide' flag with multiple fields", () =>
84
95
  expect(
85
96
  <Provider store={store}>
86
- <IntlProvider locale="en">
87
- <FormPage wide cols={[2, 1]} fields={manyFields} getUpdater={getUpdater} values={values} />
88
- </IntlProvider>
97
+ <StylesProvider generateClassName={generateClassName}>
98
+ <IntlProvider locale="en">
99
+ <FormPage wide cols={[2, 1]} fields={manyFields} getUpdater={getUpdater} values={values} />
100
+ </IntlProvider>
101
+ </StylesProvider>
89
102
  </Provider>,
90
103
  "when mounted",
91
104
  "to satisfy",
92
105
  <Provider store={store}>
93
- <IntlProvider locale="en">
94
- <FormContext.Provider value={{ values }}>
95
- <Wrapper>
96
- <Form spanWidth={1}>
97
- <FieldElements getUpdater={getUpdater} fields={manyFields} />
98
- </Form>
99
- </Wrapper>
100
- </FormContext.Provider>
101
- </IntlProvider>
106
+ <StylesProvider generateClassName={generateClassName}>
107
+ <IntlProvider locale="en">
108
+ <FormContext.Provider value={{ values }}>
109
+ <div>
110
+ <Form spanWidth={1}>
111
+ <FieldElements getUpdater={getUpdater} fields={manyFields} />
112
+ </Form>
113
+ </div>
114
+ </FormContext.Provider>
115
+ </IntlProvider>
116
+ </StylesProvider>
102
117
  </Provider>,
103
118
  ));
104
119
 
105
120
  it("renders a form with a multiple fields", () =>
106
121
  expect(
107
122
  <Provider store={store}>
108
- <IntlProvider locale="en">
109
- <FormPage cols={[2, 1]} fields={manyFields} getUpdater={getUpdater} values={values} />
110
- </IntlProvider>
123
+ <StylesProvider generateClassName={generateClassName}>
124
+ <IntlProvider locale="en">
125
+ <FormPage cols={[2, 1]} fields={manyFields} getUpdater={getUpdater} values={values} />
126
+ </IntlProvider>
127
+ </StylesProvider>
111
128
  </Provider>,
112
129
  "when mounted",
113
130
  "to satisfy",
114
131
  <Provider store={store}>
115
- <IntlProvider locale="en">
116
- <FormContext.Provider value={{ values }}>
117
- <Wrapper>
118
- <Form spanWidth={2}>
119
- <FieldElements getUpdater={getUpdater} fields={manyFields.slice(0, 5)} />
120
- </Form>
121
- <Form spanWidth={1}>
122
- <FieldElements getUpdater={getUpdater} fields={manyFields.slice(5, 10)} />
123
- </Form>
124
- </Wrapper>
125
- </FormContext.Provider>
126
- </IntlProvider>
132
+ <StylesProvider generateClassName={generateClassName}>
133
+ <IntlProvider locale="en">
134
+ <FormContext.Provider value={{ values }}>
135
+ <div>
136
+ <Form spanWidth={2}>
137
+ <FieldElements getUpdater={getUpdater} fields={manyFields.slice(0, 5)} />
138
+ </Form>
139
+ <Form spanWidth={1}>
140
+ <FieldElements getUpdater={getUpdater} fields={manyFields.slice(5, 10)} />
141
+ </Form>
142
+ </div>
143
+ </FormContext.Provider>
144
+ </IntlProvider>
145
+ </StylesProvider>
127
146
  </Provider>,
128
147
  ));
129
148
  });
@@ -1,20 +1,28 @@
1
- import styled from "styled-components";
1
+ import { makeStyles } from "@material-ui/core/styles";
2
+ import React from "react";
2
3
 
3
- const Form = styled.div`
4
- box-sizing: border-box;
5
- flex-basis: 0;
6
- flex-shrink: 0;
7
- flex-grow: ${({ spanWidth = 1 }) => spanWidth};
8
- display: flex;
9
- flex-direction: column;
10
- padding: 0;
11
- padding-right: 20px;
12
- padding-top: 0;
13
- font-size: 12px;
4
+ const useStyles = makeStyles(() => ({
5
+ form: {
6
+ boxSizing: "border-box",
7
+ flexBasis: 0,
8
+ flexShrink: 0,
9
+ display: "flex",
10
+ flexDirection: "column",
11
+ padding: 0,
12
+ paddingRight: 20,
13
+ paddingTop: 0,
14
+ fontSize: 12,
15
+ flexGrow: props => props.spanWidth,
16
+ "&:first-child": {
17
+ paddingLeft: 20,
18
+ },
19
+ },
20
+ }));
14
21
 
15
- &:first-child {
16
- padding-left: 20px;
17
- }
18
- `;
22
+ const Form = ({ spanWidth = 1, children }) => {
23
+ const classes = useStyles({ spanWidth });
24
+
25
+ return <div className={classes.form}>{children}</div>;
26
+ };
19
27
 
20
28
  export default Form;
@@ -89,7 +89,7 @@ describe("InputField", () => {
89
89
  it("gives error message if given no type", () =>
90
90
  expect(
91
91
  <SubjectWrapper store={store} values={{}}>
92
- <InputField label="A bad field" otherProp />
92
+ <InputField label={{ id: "BadField", defaultMessage: "A bad field" }} otherProp />
93
93
  </SubjectWrapper>,
94
94
  "when mounted",
95
95
  "to satisfy",
@@ -100,12 +100,7 @@ describe("InputField", () => {
100
100
 
101
101
  Object.keys(inputs).forEach(type => {
102
102
  describe("input type " + type, () => {
103
- let Input,
104
- val,
105
- emptyVal,
106
- target,
107
- options,
108
- center = false;
103
+ let Input, val, emptyVal, target, options;
109
104
  beforeEach(() => {
110
105
  Input = inputs[type];
111
106
  target = "input";
@@ -123,16 +118,12 @@ describe("InputField", () => {
123
118
  val = "thing";
124
119
  }
125
120
  target = "select";
126
- } else if (type === "CheckboxInput" || type === "SwitchInput") {
121
+ } else if (type === "SwitchInput") {
127
122
  val = true;
128
- center = true;
129
- } else if (type === "TranslationInput") {
130
- val = { "en-US": "Words", "fr-CA": "Des mots" };
131
- emptyVal = undefined;
132
123
  } else if (type === "DateInput") {
133
124
  val = "2014-05-22";
134
125
  emptyVal = "";
135
- } else if (type === "Button" || type === "SmallButton") {
126
+ } else if (type === "Button") {
136
127
  target = "button";
137
128
  }
138
129
  });
@@ -143,7 +134,7 @@ describe("InputField", () => {
143
134
  <InputField
144
135
  name="fieldName"
145
136
  type={type}
146
- label={`A ${type} field`}
137
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
147
138
  placeholder={{
148
139
  id: "foo.bar",
149
140
  defaultMessage: "Placeholder",
@@ -155,7 +146,7 @@ describe("InputField", () => {
155
146
  "when mounted",
156
147
  "to satisfy",
157
148
  <PatternWrapper store={store}>
158
- <Field wasBlurred center={center} id="fieldName" label={`A ${type} field`}>
149
+ <Field wasBlurred id="fieldName" label={{ id: "BadField", defaultMessage: "A bad field" }}>
159
150
  <Input
160
151
  id="fieldName"
161
152
  data-test-id="field_fieldName"
@@ -174,7 +165,7 @@ describe("InputField", () => {
174
165
  <InputField
175
166
  name="fieldName"
176
167
  type={type}
177
- label={`A ${type} field`}
168
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
178
169
  placeholder={{
179
170
  id: "foo.bar",
180
171
  defaultMessage: "Placeholder",
@@ -186,7 +177,7 @@ describe("InputField", () => {
186
177
  "when mounted",
187
178
  "to satisfy",
188
179
  <PatternWrapper store={store}>
189
- <Field center={center} id="fieldName" label={`A ${type} field`}>
180
+ <Field id="fieldName" label={{ id: "BadField", defaultMessage: "A bad field" }}>
190
181
  <Input
191
182
  id="fieldName"
192
183
  data-test-id="testForm_fieldName"
@@ -199,7 +190,7 @@ describe("InputField", () => {
199
190
  </PatternWrapper>,
200
191
  ));
201
192
 
202
- const cannotRequire = ["CheckboxInput", "SwitchInput", "LineLabel", "ReadOnly"];
193
+ const cannotRequire = ["SwitchInput", "LineLabel", "ReadOnly", "Selector"];
203
194
  if (!cannotRequire.includes(type)) {
204
195
  it("renders a required field", () =>
205
196
  expect(
@@ -207,12 +198,13 @@ describe("InputField", () => {
207
198
  <InputField
208
199
  name="fieldName"
209
200
  type={type}
210
- label={`A ${type} field`}
201
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
211
202
  placeholder={{
212
203
  id: "foo.bar",
213
204
  defaultMessage: "Placeholder",
214
205
  }}
215
206
  required={`A ${type} field is a required field`}
207
+ update={() => {}}
216
208
  options={options}
217
209
  otherProp
218
210
  />
@@ -224,10 +216,9 @@ describe("InputField", () => {
224
216
  <SubjectWrapper store={store} values={{ fieldName: val }}>
225
217
  <Field
226
218
  wasBlurred
227
- center={center}
228
219
  id="fieldName"
229
- label={`A ${type} field`}
230
220
  required={`A ${type} field is a required field`}
221
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
231
222
  >
232
223
  <Input id="fieldName" value={val} otherProp placeholder="Placeholder" options={options} required />
233
224
  </Field>
@@ -240,7 +231,7 @@ describe("InputField", () => {
240
231
  <InputField
241
232
  name="fieldName"
242
233
  type={type}
243
- label={`A ${type} field`}
234
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
244
235
  placeholder={{
245
236
  id: "foo.bar",
246
237
  defaultMessage: "Placeholder",
@@ -255,10 +246,9 @@ describe("InputField", () => {
255
246
  <PatternWrapper store={store}>
256
247
  <Field
257
248
  wasBlurred
258
- center={center}
259
249
  id="fieldName"
260
- label={`A ${type} field`}
261
250
  required={`A ${type} field is a required field`}
251
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
262
252
  invalid
263
253
  >
264
254
  <Input id="fieldName" value={emptyVal} otherProp placeholder="Placeholder" options={options} required />
@@ -272,7 +262,7 @@ describe("InputField", () => {
272
262
  <InputField
273
263
  name="fieldName"
274
264
  type={type}
275
- label={`A ${type} field`}
265
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
276
266
  placeholder={{
277
267
  id: "foo.bar",
278
268
  defaultMessage: "Placeholder",
@@ -287,10 +277,9 @@ describe("InputField", () => {
287
277
  <PatternWrapper store={store}>
288
278
  <Field
289
279
  wasBlurred
290
- center={center}
291
280
  id="fieldName"
292
- label={`A ${type} field`}
293
281
  required={`A ${type} field is a required field`}
282
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
294
283
  invalid
295
284
  >
296
285
  <Input
@@ -310,17 +299,22 @@ describe("InputField", () => {
310
299
  it("modifies the field name if inside a list", () =>
311
300
  expect(
312
301
  <SubjectWrapper store={store} values={{ fieldName: val }} index={12}>
313
- <InputField name="fieldName" type={type} label={`A ${type} field`} options={options} otherProp />
302
+ <InputField
303
+ name="fieldName"
304
+ type={type}
305
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
306
+ options={options}
307
+ otherProp
308
+ />
314
309
  </SubjectWrapper>,
315
310
  "when mounted",
316
311
  "to satisfy",
317
312
  <PatternWrapper store={store}>
318
313
  <Field
319
314
  wasBlurred
320
- center={center}
321
315
  id="fieldName[12]"
322
316
  data-test-id="field_fieldName[12]"
323
- label={`A ${type} field`}
317
+ label={{ id: "BadField", defaultMessage: "A bad field" }}
324
318
  >
325
319
  <Input id="fieldName[12]" value={val} otherProp options={options} />
326
320
  </Field>
@@ -1,21 +1,65 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
2
+ import { makeStyles } from "@material-ui/core/styles";
3
+ import Button from "@material-ui/core/Button";
3
4
  import withId from "../../../hocs/withId";
4
- import IconButton from "../../IconButton";
5
+ import Icon from "../../MaterialUI/DataDisplay/Icon";
6
+ import { FormattedMessage } from "react-intl";
5
7
 
6
- export const PositionedButton = styled(IconButton)`
7
- width: max-content;
8
- position: relative;
9
- `;
8
+ const useStyles = makeStyles(theme => ({
9
+ positionedButton: {
10
+ width: "max-content",
11
+ position: "relative",
12
+ padding: "6px 14px !important",
13
+ "&:hover": {
14
+ borderColor: "#4fa1f0",
15
+ boxShadow: "0 0 4px #4fa1f0",
16
+ outline: "none",
17
+ backgroundColor: "#f7f7f7 !important",
18
+ },
19
+ "&:disabled": {
20
+ opacity: 0.6,
21
+ backgroundColor: "#f7f7f7 !important",
22
+ },
23
+ },
24
+ buttonIcon: {
25
+ height: "1em",
26
+ width: "1em",
27
+ fill: "currentColor",
28
+ stroke: "currentColor",
29
+ fontSize: "1.23em !important",
30
+ },
31
+ primaryButton: {
32
+ color: `${theme.palette.primary.main} !important`,
33
+ border: `1px solid ${theme.palette.primary.main} !important`,
34
+ backgroundColor: "#fff !important",
35
+ "&:hover": {
36
+ backgroundColor: "#fff !important",
37
+ },
38
+ },
39
+ primaryIcon: {
40
+ color: `${theme.palette.primary.main} !important`,
41
+ },
42
+ }));
43
+
44
+ const FormButton = ({ id, icon, buttonText, update, primary, ...props }) => {
45
+ const classes = useStyles();
46
+
47
+ return (
48
+ <Button
49
+ id={id}
50
+ className={`${classes.positionedButton} ${primary ? classes.primaryButton : ""}`}
51
+ onClick={update}
52
+ variant="outlined"
53
+ startIcon={
54
+ icon ? <Icon id={icon} className={`${classes.buttonIcon} ${primary ? classes.primaryIcon : ""}`} /> : null
55
+ }
56
+ {...props}
57
+ >
58
+ {buttonText ? <FormattedMessage {...buttonText} /> : null}
59
+ </Button>
60
+ );
61
+ };
10
62
 
11
- export const FormButton = ({
12
- id,
13
- icon,
14
- buttonText,
15
- update,
16
- "aria-labelledby": aria, // Not meaningful for buttons
17
- ...props
18
- }) => <PositionedButton id={id} {...props} onClick={update} icon={icon} label={buttonText} />;
19
63
  FormButton.displayName = "FormButton";
20
64
 
21
65
  export default withId("formbutton")(FormButton);
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
2
  import { Provider } from "react-redux";
3
- import { FormButton, PositionedButton } from "./Button";
3
+ import { IntlProvider } from "react-intl";
4
+ import FormButton from "./Button";
5
+ import Button from "@material-ui/core/Button";
6
+ import Icon from "../../MaterialUI/DataDisplay/Icon";
4
7
 
5
8
  describe("FormButton", () => {
6
9
  let update;
@@ -17,7 +20,9 @@ describe("FormButton", () => {
17
20
  getState: () => ({}),
18
21
  }}
19
22
  >
20
- <FormButton id="testId" update={update} icon="test-icon" otherProp />
23
+ <IntlProvider locale="en">
24
+ <FormButton id="testId" update={update} icon="test-icon" otherProp />
25
+ </IntlProvider>
21
26
  </Provider>,
22
27
  "when mounted",
23
28
  "to satisfy",
@@ -28,7 +33,7 @@ describe("FormButton", () => {
28
33
  getState: () => ({}),
29
34
  }}
30
35
  >
31
- <PositionedButton id="testId" otherProp onClick={update} icon="test-icon" />
36
+ <Button id="testId" otherProp onClick={update} startIcon={<Icon id="test-icon" />} variant="outlined"></Button>
32
37
  </Provider>,
33
38
  ));
34
39
 
@@ -41,7 +46,14 @@ describe("FormButton", () => {
41
46
  getState: () => ({}),
42
47
  }}
43
48
  >
44
- <FormButton id="testId" update={update} buttonText="Push this" otherProp />
49
+ <IntlProvider locale="en">
50
+ <FormButton
51
+ id="testId"
52
+ update={update}
53
+ buttonText={{ id: "PushThis", defaultMessage: "Push this" }}
54
+ otherProp
55
+ />
56
+ </IntlProvider>
45
57
  </Provider>,
46
58
  "when mounted",
47
59
  "to satisfy",
@@ -52,7 +64,9 @@ describe("FormButton", () => {
52
64
  getState: () => ({}),
53
65
  }}
54
66
  >
55
- <PositionedButton id="testId" otherProp onClick={update} label="Push this" />
67
+ <Button id="testId" otherProp onClick={update} variant="outlined">
68
+ Push this
69
+ </Button>
56
70
  </Provider>,
57
71
  ));
58
72
 
@@ -65,7 +79,16 @@ describe("FormButton", () => {
65
79
  getState: () => ({}),
66
80
  }}
67
81
  >
68
- <FormButton id="testId" update={update} icon="test-icon" buttonText="Push this" otherProp />
82
+ <IntlProvider locale="en">
83
+ <FormButton
84
+ id="testId"
85
+ update={update}
86
+ icon="test-icon"
87
+ buttonText={{ id: "PushThis", defaultMessage: "Push this" }}
88
+ primary
89
+ otherProp
90
+ />
91
+ </IntlProvider>
69
92
  </Provider>,
70
93
  "when mounted",
71
94
  "to satisfy",
@@ -76,7 +99,9 @@ describe("FormButton", () => {
76
99
  getState: () => ({}),
77
100
  }}
78
101
  >
79
- <PositionedButton id="testId" otherProp onClick={update} icon="test-icon" label="Push this" />
102
+ <Button id="testId" otherProp onClick={update} startIcon={<Icon id="test-icon" />} variant="outlined">
103
+ Push this
104
+ </Button>
80
105
  </Provider>,
81
106
  ));
82
107
  });
@@ -4,18 +4,11 @@ describe("Input field collection", () => {
4
4
  it("contains a list of named inputs", () =>
5
5
  expect(inputs, "to exhaustively satisfy", {
6
6
  Button: expect.it("to be a function"),
7
- CheckboxInput: expect.it("to be a function"),
8
7
  DateInput: expect.it("to be a function"),
9
- EmailInput: expect.it("to be a function"),
10
- NumberInput: expect.it("to be a function"),
11
8
  MultiSelector: expect.it("to be a function"),
12
- LineLabel: expect.it("to be a function"),
13
9
  ReadOnly: expect.it("to be a function"),
14
10
  Selector: expect.it("to be a function"),
15
- SmallButton: expect.it("to be a function"),
16
11
  SwitchInput: expect.it("to be a function"),
17
12
  TextInput: expect.it("to be a function"),
18
- TimeInput: expect.it("to be a function"),
19
- TranslationInput: expect.it("to be a function"),
20
13
  }));
21
14
  });
@@ -1,34 +1,40 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import Text from "../../Text";
2
+ import { makeStyles } from "@material-ui/core/styles";
3
+ import { FormattedMessage } from "react-intl";
4
4
 
5
- export const CenterWrapper = styled.div`
6
- min-height: 30px;
7
- display: flex;
8
- align-items: center;
9
- `;
5
+ const useStyles = makeStyles(() => ({
6
+ centerWrapper: {
7
+ minHeight: 30,
8
+ display: "flex",
9
+ alignItems: "center",
10
+ },
11
+ readOnlyBlock: {
12
+ margin: 0,
13
+ },
14
+ label: {
15
+ margin: 0,
16
+ fontSize: 16,
17
+ },
18
+ }));
10
19
 
11
- export const ReadOnlyBlock = styled.p`
12
- margin: 0;
13
- `;
20
+ export const ReadOnly = ({ value }) => {
21
+ const classes = useStyles();
14
22
 
15
- export const ReadOnly = ({ value }) => (
16
- <CenterWrapper>
17
- <ReadOnlyBlock>
18
- <Text message={value} />
19
- </ReadOnlyBlock>
20
- </CenterWrapper>
21
- );
23
+ return (
24
+ <div className={classes.centerWrapper}>
25
+ <p className={classes.readOnlyBlock}>{typeof value === "string" ? value : <FormattedMessage {...value} />}</p>
26
+ </div>
27
+ );
28
+ };
22
29
 
23
- export const Label = styled.p`
24
- margin: 0;
25
- font-size: 16px;
26
- `;
30
+ export const LineLabel = ({ value }) => {
31
+ const classes = useStyles();
27
32
 
28
- export const LineLabel = ({ value }) => (
29
- <CenterWrapper>
30
- <Label>
31
- <Text message={value} />
32
- </Label>
33
- </CenterWrapper>
34
- );
33
+ return (
34
+ <div className={classes.centerWrapper}>
35
+ <p className={classes.label}>{typeof value === "string" ? value : <FormattedMessage {...value} />}</p>
36
+ </div>
37
+ );
38
+ };
39
+
40
+ export default ReadOnly;