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,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
|
-
import
|
|
3
|
+
import { IntlProvider } from "react-intl";
|
|
4
|
+
import Field from "./Field";
|
|
4
5
|
|
|
5
6
|
describe("Field", () => {
|
|
6
7
|
it("renders a field with a label", () =>
|
|
@@ -18,12 +19,12 @@ describe("Field", () => {
|
|
|
18
19
|
</Provider>,
|
|
19
20
|
"when mounted",
|
|
20
21
|
"to satisfy",
|
|
21
|
-
<
|
|
22
|
-
<
|
|
22
|
+
<div>
|
|
23
|
+
<label htmlFor="field" id="field_label">
|
|
23
24
|
A test
|
|
24
|
-
</
|
|
25
|
+
</label>
|
|
25
26
|
<div id="child" />
|
|
26
|
-
</
|
|
27
|
+
</div>,
|
|
27
28
|
));
|
|
28
29
|
|
|
29
30
|
it("renders a required field with a label", () =>
|
|
@@ -41,12 +42,12 @@ describe("Field", () => {
|
|
|
41
42
|
</Provider>,
|
|
42
43
|
"when mounted",
|
|
43
44
|
"to satisfy",
|
|
44
|
-
<
|
|
45
|
-
<
|
|
45
|
+
<div>
|
|
46
|
+
<label htmlFor="field" id="field_label">
|
|
46
47
|
A test
|
|
47
|
-
</
|
|
48
|
+
</label>
|
|
48
49
|
<div id="child" />
|
|
49
|
-
</
|
|
50
|
+
</div>,
|
|
50
51
|
));
|
|
51
52
|
|
|
52
53
|
it("renders a missing required field with a label", () =>
|
|
@@ -58,19 +59,21 @@ describe("Field", () => {
|
|
|
58
59
|
getState: () => ({}),
|
|
59
60
|
}}
|
|
60
61
|
>
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
|
|
62
|
+
<IntlProvider locale="en">
|
|
63
|
+
<Field id="field" label="A test" required={{ id: "required", defaultMessage: "Required" }} invalid>
|
|
64
|
+
<div id="child" />
|
|
65
|
+
</Field>
|
|
66
|
+
</IntlProvider>
|
|
64
67
|
</Provider>,
|
|
65
68
|
"when mounted",
|
|
66
69
|
"to satisfy",
|
|
67
|
-
<
|
|
68
|
-
<
|
|
70
|
+
<div>
|
|
71
|
+
<label htmlFor="field" id="field_label">
|
|
69
72
|
A test
|
|
70
|
-
</
|
|
73
|
+
</label>
|
|
71
74
|
<div id="child" />
|
|
72
|
-
<
|
|
73
|
-
</
|
|
75
|
+
<div>Required</div>
|
|
76
|
+
</div>,
|
|
74
77
|
));
|
|
75
78
|
|
|
76
79
|
it("renders a field with no label", () =>
|
|
@@ -80,9 +83,9 @@ describe("Field", () => {
|
|
|
80
83
|
</Field>,
|
|
81
84
|
"when mounted",
|
|
82
85
|
"to satisfy",
|
|
83
|
-
<
|
|
86
|
+
<div>
|
|
84
87
|
<div id="child" />
|
|
85
|
-
</
|
|
88
|
+
</div>,
|
|
86
89
|
));
|
|
87
90
|
|
|
88
91
|
it("renders only its label when flagged", () =>
|
|
@@ -100,11 +103,9 @@ describe("Field", () => {
|
|
|
100
103
|
</Provider>,
|
|
101
104
|
"when mounted",
|
|
102
105
|
"to satisfy",
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
</Label>
|
|
107
|
-
</FieldBox>,
|
|
106
|
+
<div>
|
|
107
|
+
<label id="field_label">A test</label>
|
|
108
|
+
</div>,
|
|
108
109
|
));
|
|
109
110
|
|
|
110
111
|
it("renders a field with a centered label", () =>
|
|
@@ -122,34 +123,11 @@ describe("Field", () => {
|
|
|
122
123
|
</Provider>,
|
|
123
124
|
"when mounted",
|
|
124
125
|
"to satisfy",
|
|
125
|
-
<
|
|
126
|
-
<
|
|
126
|
+
<div>
|
|
127
|
+
<label htmlFor="field" id="field_label">
|
|
127
128
|
A test
|
|
128
|
-
</
|
|
129
|
+
</label>
|
|
129
130
|
<div id="child" />
|
|
130
|
-
</
|
|
131
|
-
));
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe("Label", () => {
|
|
135
|
-
it("renders a mark on required labels", () =>
|
|
136
|
-
expect(
|
|
137
|
-
<Label required>A text</Label>,
|
|
138
|
-
"when mounted",
|
|
139
|
-
"to have style rules satisfying",
|
|
140
|
-
"to contain",
|
|
141
|
-
'::after {content: " *";',
|
|
142
|
-
));
|
|
143
|
-
|
|
144
|
-
it("when not flagged renders a label with bottom margin", () =>
|
|
145
|
-
expect(<Label>A text</Label>, "when mounted", "to have style rules satisfying", "to contain", "margin-bottom:"));
|
|
146
|
-
|
|
147
|
-
it("when flagged renders a label without margin", () =>
|
|
148
|
-
expect(
|
|
149
|
-
<Label labelOnly>A text</Label>,
|
|
150
|
-
"when mounted",
|
|
151
|
-
"to have style rules satisfying",
|
|
152
|
-
"not to contain",
|
|
153
|
-
"margin-bottom",
|
|
131
|
+
</div>,
|
|
154
132
|
));
|
|
155
133
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Fieldset from "./Fieldset";
|
|
3
3
|
import Combination from "./Combination";
|
|
4
|
-
import FieldList from "./FieldList";
|
|
5
4
|
import InputField from "./InputField";
|
|
6
5
|
|
|
7
6
|
// // Multiple column fields?
|
|
@@ -25,19 +24,6 @@ const FieldElements = ({ fields, labelOnly, getUpdater = () => {}, ...elementPro
|
|
|
25
24
|
</Combination>
|
|
26
25
|
);
|
|
27
26
|
}
|
|
28
|
-
case "List": {
|
|
29
|
-
return (
|
|
30
|
-
<FieldList
|
|
31
|
-
key={key}
|
|
32
|
-
name={name}
|
|
33
|
-
label={label}
|
|
34
|
-
getUpdater={getUpdater}
|
|
35
|
-
rowCount={props.rowCount}
|
|
36
|
-
{...elementProps}
|
|
37
|
-
{...props}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
27
|
default: {
|
|
42
28
|
return (
|
|
43
29
|
<InputField
|
|
@@ -3,10 +3,11 @@ import Immutable from "immutable";
|
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { IntlProvider } from "react-intl";
|
|
5
5
|
import { mount } from "unexpected-reaction";
|
|
6
|
+
import { StylesProvider } from "@material-ui/core";
|
|
7
|
+
import { generateClassName } from "../../utils/testUtils";
|
|
6
8
|
import { FormContext } from "./Form";
|
|
7
9
|
import Fieldset from "./Fieldset";
|
|
8
10
|
import Combination from "./Combination";
|
|
9
|
-
import FieldList from "./FieldList";
|
|
10
11
|
import InputField from "./InputField";
|
|
11
12
|
import FieldElements from "./FieldElements";
|
|
12
13
|
|
|
@@ -28,112 +29,100 @@ describe("FieldElements", () => {
|
|
|
28
29
|
};
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
it("renders a list of field elements, handling fieldsets, combination fields
|
|
32
|
+
it("renders a list of field elements, handling fieldsets, combination fields", () =>
|
|
32
33
|
expect(
|
|
33
34
|
mount(
|
|
34
35
|
<Provider store={store}>
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
fields={[
|
|
39
|
-
{
|
|
40
|
-
type: "ReadOnly",
|
|
41
|
-
name: "thing",
|
|
42
|
-
someProp: 12.5,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
type: "Fieldset",
|
|
46
|
-
label: "A field set",
|
|
47
|
-
fields: [
|
|
48
|
-
{
|
|
49
|
-
type: "NumberInput",
|
|
50
|
-
name: "stuff",
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
type: "Combination",
|
|
56
|
-
name: "combo",
|
|
57
|
-
label: "Combined fields",
|
|
58
|
-
proportions: ["300px", 100],
|
|
59
|
-
fields: [
|
|
60
|
-
{ type: "CheckboxInput", name: "item" },
|
|
61
|
-
{ type: "EmailInput", name: "otheritem" },
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: "List",
|
|
66
|
-
name: "list",
|
|
67
|
-
rowCount: 15,
|
|
68
|
-
someProp: "Is this way",
|
|
69
|
-
rowField: { name: "listStuff", type: "TextInput" },
|
|
70
|
-
},
|
|
71
|
-
]}
|
|
72
|
-
getUpdater={getUpdater}
|
|
73
|
-
/>
|
|
74
|
-
</FormContext.Provider>
|
|
75
|
-
</IntlProvider>
|
|
76
|
-
</Provider>,
|
|
77
|
-
).childNodes,
|
|
78
|
-
"to satisfy",
|
|
79
|
-
[
|
|
80
|
-
<Provider store={store}>
|
|
81
|
-
<IntlProvider locale="en">
|
|
82
|
-
<FormContext.Provider value={{ values }}>
|
|
83
|
-
<InputField
|
|
84
|
-
key="thing"
|
|
85
|
-
name="thing"
|
|
86
|
-
type="ReadOnly"
|
|
87
|
-
update={expect.it("when called", "to equal", "thing")}
|
|
88
|
-
someProp={12.5}
|
|
89
|
-
/>
|
|
90
|
-
</FormContext.Provider>
|
|
91
|
-
</IntlProvider>
|
|
92
|
-
</Provider>,
|
|
93
|
-
<Provider store={store}>
|
|
94
|
-
<IntlProvider locale="en">
|
|
95
|
-
<FormContext.Provider value={{ values }}>
|
|
96
|
-
<Fieldset label="A field set">
|
|
36
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
37
|
+
<IntlProvider locale="en">
|
|
38
|
+
<FormContext.Provider value={{ values }}>
|
|
97
39
|
<FieldElements
|
|
98
40
|
fields={[
|
|
99
41
|
{
|
|
100
|
-
type: "
|
|
101
|
-
name: "
|
|
42
|
+
type: "ReadOnly",
|
|
43
|
+
name: "thing",
|
|
44
|
+
someProp: 12.5,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "Fieldset",
|
|
48
|
+
label: {
|
|
49
|
+
id: "fieldset",
|
|
50
|
+
defaultMessage: "A field set",
|
|
51
|
+
},
|
|
52
|
+
fields: [
|
|
53
|
+
{
|
|
54
|
+
type: "NumberInput",
|
|
55
|
+
name: "stuff",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "Combination",
|
|
61
|
+
name: "combo",
|
|
62
|
+
label: {
|
|
63
|
+
id: "CombinedFields",
|
|
64
|
+
defaultMessage: "Combined fields",
|
|
65
|
+
},
|
|
66
|
+
proportions: ["300px", 100],
|
|
67
|
+
fields: [{ type: "CheckboxInput", name: "item" }],
|
|
102
68
|
},
|
|
103
69
|
]}
|
|
104
70
|
getUpdater={getUpdater}
|
|
105
71
|
/>
|
|
106
|
-
</
|
|
107
|
-
</
|
|
108
|
-
</
|
|
72
|
+
</FormContext.Provider>
|
|
73
|
+
</IntlProvider>
|
|
74
|
+
</StylesProvider>
|
|
109
75
|
</Provider>,
|
|
76
|
+
).childNodes,
|
|
77
|
+
"to satisfy",
|
|
78
|
+
[
|
|
110
79
|
<Provider store={store}>
|
|
111
|
-
<
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
80
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
81
|
+
<IntlProvider locale="en">
|
|
82
|
+
<FormContext.Provider value={{ values }}>
|
|
83
|
+
<InputField
|
|
84
|
+
key="thing"
|
|
85
|
+
name="thing"
|
|
86
|
+
type="ReadOnly"
|
|
87
|
+
update={expect.it("when called", "to equal", "thing")}
|
|
88
|
+
someProp={12.5}
|
|
120
89
|
/>
|
|
121
|
-
</
|
|
122
|
-
</
|
|
123
|
-
</
|
|
90
|
+
</FormContext.Provider>
|
|
91
|
+
</IntlProvider>
|
|
92
|
+
</StylesProvider>
|
|
124
93
|
</Provider>,
|
|
125
94
|
<Provider store={store}>
|
|
126
|
-
<
|
|
127
|
-
<
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
95
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
96
|
+
<IntlProvider locale="en">
|
|
97
|
+
<FormContext.Provider value={{ values }}>
|
|
98
|
+
<Fieldset label={{ id: "FieldSet", defaultMessage: "A field set" }}>
|
|
99
|
+
<FieldElements
|
|
100
|
+
fields={[
|
|
101
|
+
{
|
|
102
|
+
type: "NumberInput",
|
|
103
|
+
name: "stuff",
|
|
104
|
+
},
|
|
105
|
+
]}
|
|
106
|
+
getUpdater={getUpdater}
|
|
107
|
+
/>
|
|
108
|
+
</Fieldset>
|
|
109
|
+
</FormContext.Provider>
|
|
110
|
+
</IntlProvider>
|
|
111
|
+
</StylesProvider>
|
|
112
|
+
</Provider>,
|
|
113
|
+
<Provider store={store}>
|
|
114
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
115
|
+
<IntlProvider locale="en">
|
|
116
|
+
<FormContext.Provider value={{ values }}>
|
|
117
|
+
<Combination
|
|
118
|
+
label={{ id: "CombinedFields", defaultMessage: "Combined fields" }}
|
|
119
|
+
proportions={["300px", 100]}
|
|
120
|
+
>
|
|
121
|
+
<FieldElements fields={[{ type: "CheckboxInput", name: "item" }]} getUpdater={getUpdater} />
|
|
122
|
+
</Combination>
|
|
123
|
+
</FormContext.Provider>
|
|
124
|
+
</IntlProvider>
|
|
125
|
+
</StylesProvider>
|
|
137
126
|
</Provider>,
|
|
138
127
|
],
|
|
139
128
|
));
|
|
@@ -141,29 +130,33 @@ describe("FieldElements", () => {
|
|
|
141
130
|
it("handles absent update function and values", () =>
|
|
142
131
|
expect(
|
|
143
132
|
<Provider store={store}>
|
|
144
|
-
<
|
|
145
|
-
<
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
{
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
133
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
134
|
+
<IntlProvider locale="en">
|
|
135
|
+
<FormContext.Provider value={{ values }}>
|
|
136
|
+
<FieldElements
|
|
137
|
+
fields={[
|
|
138
|
+
{
|
|
139
|
+
type: "ReadOnly",
|
|
140
|
+
name: "thing",
|
|
141
|
+
},
|
|
142
|
+
]}
|
|
143
|
+
/>
|
|
144
|
+
</FormContext.Provider>
|
|
145
|
+
</IntlProvider>
|
|
146
|
+
</StylesProvider>
|
|
156
147
|
</Provider>,
|
|
157
148
|
"when mounted",
|
|
158
149
|
"to satisfy",
|
|
159
150
|
<Provider store={store}>
|
|
160
|
-
<
|
|
161
|
-
<
|
|
162
|
-
<
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
151
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
152
|
+
<IntlProvider locale="en">
|
|
153
|
+
<FormContext.Provider value={{ values }}>
|
|
154
|
+
<React.Fragment>
|
|
155
|
+
<InputField name="thing" update={undefined} value={undefined} type="ReadOnly" />
|
|
156
|
+
</React.Fragment>
|
|
157
|
+
</FormContext.Provider>
|
|
158
|
+
</IntlProvider>
|
|
159
|
+
</StylesProvider>
|
|
167
160
|
</Provider>,
|
|
168
161
|
));
|
|
169
162
|
});
|
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import Text from "../Text";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
const useStyles = makeStyles(theme => ({
|
|
6
|
+
fieldsetBox: {
|
|
7
|
+
position: "relative",
|
|
8
|
+
boxSizing: "border-box",
|
|
9
|
+
display: "flex",
|
|
10
|
+
alignSelf: "stretch",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
flexWrap: "wrap",
|
|
13
|
+
border: `1px solid ${theme.palette.grey.borders}`,
|
|
14
|
+
borderRadius: 5,
|
|
15
|
+
marginTop: 45,
|
|
16
|
+
marginLeft: 0,
|
|
17
|
+
marginBottom: 0,
|
|
18
|
+
padding: 20,
|
|
19
|
+
paddingTop: 0,
|
|
20
|
+
backgroundColor: "#fafafa",
|
|
21
|
+
},
|
|
22
|
+
legend: {
|
|
23
|
+
position: "absolute",
|
|
24
|
+
top: "-2em",
|
|
25
|
+
left: -4,
|
|
26
|
+
fontFamily: theme.typography.button.fontFamily,
|
|
27
|
+
fontStyle: "italic",
|
|
28
|
+
fontSize: 13,
|
|
29
|
+
textTransform: "uppercase",
|
|
30
|
+
color: theme.palette.primary.main,
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
32
33
|
|
|
33
|
-
const Fieldset = ({ label, children }) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const Fieldset = ({ label, children }) => {
|
|
35
|
+
const classes = useStyles();
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<fieldset className={classes.fieldsetBox}>
|
|
39
|
+
<legend className={classes.legend}>
|
|
40
|
+
<FormattedMessage {...label} />
|
|
41
|
+
</legend>
|
|
42
|
+
{children}
|
|
43
|
+
</fieldset>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
41
46
|
|
|
42
47
|
export default Fieldset;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
|
-
import
|
|
3
|
+
import { IntlProvider } from "react-intl";
|
|
4
|
+
import Fieldset from "./Fieldset";
|
|
5
|
+
import { extractMessages } from "../../utils/testUtils";
|
|
6
|
+
import sharedMessages from "../../sharedMessages";
|
|
7
|
+
|
|
8
|
+
const messages = extractMessages(sharedMessages);
|
|
4
9
|
|
|
5
10
|
describe("Fieldset", () => {
|
|
6
11
|
it("works", () =>
|
|
@@ -12,15 +17,17 @@ describe("Fieldset", () => {
|
|
|
12
17
|
getState: () => ({}),
|
|
13
18
|
}}
|
|
14
19
|
>
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
|
|
20
|
+
<IntlProvider locale="en" messages={messages}>
|
|
21
|
+
<Fieldset label={{ id: "fieldset.label", defaultMessage: "A field set" }}>
|
|
22
|
+
<div id="child" />
|
|
23
|
+
</Fieldset>
|
|
24
|
+
</IntlProvider>
|
|
18
25
|
</Provider>,
|
|
19
26
|
"when mounted",
|
|
20
27
|
"to satisfy",
|
|
21
|
-
<
|
|
22
|
-
<
|
|
28
|
+
<fieldset>
|
|
29
|
+
<legend>A field set</legend>
|
|
23
30
|
<div id="child" />
|
|
24
|
-
</
|
|
31
|
+
</fieldset>,
|
|
25
32
|
));
|
|
26
33
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React, { createContext } from "react";
|
|
2
|
-
import
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
3
|
import pt from "prop-types";
|
|
4
4
|
import withScrollBox from "../../hocs/withScrollBox";
|
|
5
5
|
import Form from "./FormElement";
|
|
6
6
|
import FieldElements from "./FieldElements";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const useStyles = makeStyles(() => ({
|
|
9
|
+
wrapper: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
marginBottom: 20,
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
12
14
|
|
|
13
15
|
const splitFields = (fields, cols) => {
|
|
14
16
|
if (cols <= 1) return [fields];
|
|
@@ -27,8 +29,10 @@ export const FormContext = createContext();
|
|
|
27
29
|
FormContext.displayName = "FormContext";
|
|
28
30
|
|
|
29
31
|
export const FormPage = ({ formName, cols = [1, 1, 1], getUpdater, fields, values, wide }) => {
|
|
32
|
+
const classes = useStyles();
|
|
30
33
|
let colSpans = wide ? [] : cols;
|
|
31
34
|
const colFields = splitFields(fields, colSpans.length);
|
|
35
|
+
|
|
32
36
|
return (
|
|
33
37
|
<FormContext.Provider
|
|
34
38
|
value={{
|
|
@@ -36,13 +40,13 @@ export const FormPage = ({ formName, cols = [1, 1, 1], getUpdater, fields, value
|
|
|
36
40
|
formName,
|
|
37
41
|
}}
|
|
38
42
|
>
|
|
39
|
-
<
|
|
43
|
+
<div className={classes.wrapper}>
|
|
40
44
|
{colFields.map((fields, index) => (
|
|
41
45
|
<Form key={index} spanWidth={colSpans[index] || 1}>
|
|
42
46
|
<FieldElements getUpdater={getUpdater} fields={fields} />
|
|
43
47
|
</Form>
|
|
44
48
|
))}
|
|
45
|
-
</
|
|
49
|
+
</div>
|
|
46
50
|
</FormContext.Provider>
|
|
47
51
|
);
|
|
48
52
|
};
|