orc-shared 5.99.0-dev.1 → 5.99.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppFrame/About.js +13 -13
- package/dist/components/AppFrame/Anchor.js +7 -7
- package/dist/components/AppFrame/AppFrame.js +3 -3
- package/dist/components/AppFrame/Help.js +4 -4
- package/dist/components/AppFrame/MenuItem.js +14 -14
- package/dist/components/AppFrame/Preferences.js +14 -14
- package/dist/components/AppFrame/Sidebar.js +6 -6
- package/dist/components/AppFrame/Topbar.js +6 -6
- package/dist/components/DropMenu/Menu.js +9 -9
- package/dist/components/Form/Field.js +4 -4
- package/dist/components/Form/Inputs/Button.js +2 -2
- package/dist/components/Form/Inputs/MultiSelector.js +67 -12
- package/dist/components/Form/Inputs/Selector.js +13 -10
- package/dist/components/InternetExplorerWarningMessage.js +15 -15
- package/dist/components/MaterialUI/DataDisplay/Modal.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +4 -4
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +1 -1
- package/dist/components/MaterialUI/Inputs/InputBase.js +209 -24
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
- package/dist/components/MaterialUI/Inputs/Select.js +170 -114
- package/dist/components/MaterialUI/Inputs/SelectProps.js +10 -2
- package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
- package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +27 -42
- package/dist/components/MaterialUI/Surfaces/Paper.js +1 -1
- package/dist/components/MaterialUI/muiThemes.js +1 -1
- package/dist/components/Routing/SegmentPage.js +9 -7
- package/dist/components/Scope/ScopeNode.js +7 -9
- package/dist/components/Sidepanel.js +29 -27
- package/dist/components/Spritesheet.js +17 -15
- package/dist/components/ToastList.js +11 -11
- package/dist/components/Treeview/Branch.js +9 -9
- package/dist/components/Treeview/Label.js +8 -8
- package/dist/components/Treeview/Leaf.js +2 -2
- package/dist/components/Treeview/settings.js +10 -1
- package/dist/hocs/withScrollBox.js +3 -8
- package/dist/hooks/useWindowSize.js +88 -0
- package/dist/sharedMessages.js +8 -0
- package/package.json +1 -1
- package/src/components/AppFrame/About.js +13 -13
- package/src/components/AppFrame/Anchor.js +7 -7
- package/src/components/AppFrame/AppFrame.js +3 -3
- package/src/components/AppFrame/Help.js +4 -4
- package/src/components/AppFrame/MenuItem.js +14 -14
- package/src/components/AppFrame/Preferences.js +14 -14
- package/src/components/AppFrame/Sidebar.js +6 -6
- package/src/components/AppFrame/Topbar.js +6 -6
- package/src/components/DropMenu/Menu.js +9 -9
- package/src/components/Form/Field.js +4 -4
- package/src/components/Form/Inputs/Button.js +2 -2
- package/src/components/Form/Inputs/MultiSelector.js +55 -5
- package/src/components/Form/Inputs/MultiSelector.test.js +259 -39
- package/src/components/Form/Inputs/Selector.js +12 -4
- package/src/components/Form/Inputs/Selector.test.js +27 -12
- package/src/components/InternetExplorerWarningMessage.js +15 -15
- package/src/components/MaterialUI/DataDisplay/Modal.js +3 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +74 -0
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/src/components/MaterialUI/DataDisplay/TransferList.js +1 -1
- package/src/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +1 -1
- package/src/components/MaterialUI/Inputs/InputBase.js +209 -8
- package/src/components/MaterialUI/Inputs/InputBase.test.js +481 -3
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
- package/src/components/MaterialUI/Inputs/Select.js +140 -87
- package/src/components/MaterialUI/Inputs/Select.test.js +170 -30
- package/src/components/MaterialUI/Inputs/SelectProps.js +9 -1
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +8 -0
- package/src/components/MaterialUI/Inputs/Switch.js +1 -1
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -2
- package/src/components/MaterialUI/ScopeSelector/TreeItem.js +8 -31
- package/src/components/MaterialUI/Surfaces/Paper.js +1 -1
- package/src/components/MaterialUI/muiThemes.js +1 -1
- package/src/components/Routing/SegmentPage.js +7 -7
- package/src/components/Scope/ScopeNode.js +7 -8
- package/src/components/Sidepanel.js +7 -7
- package/src/components/Sidepanel.test.js +9 -4
- package/src/components/Spritesheet.js +5 -5
- package/src/components/ToastList.js +11 -11
- package/src/components/Treeview/Branch.js +10 -10
- package/src/components/Treeview/Branch.test.js +2 -40
- package/src/components/Treeview/Label.js +9 -9
- package/src/components/Treeview/Label.test.js +13 -3
- package/src/components/Treeview/Leaf.js +3 -3
- package/src/components/Treeview/Leaf.test.js +1 -20
- package/src/components/Treeview/settings.js +3 -0
- package/src/hocs/withScrollBox.js +2 -8
- package/src/hooks/useMultipleFieldEditState.test.js +0 -1
- package/src/hooks/useWindowSize.js +39 -0
- package/src/hooks/useWindowSize.test.js +68 -0
- package/src/sharedMessages.js +8 -0
- package/src/translations/en-US.json +2 -0
- package/src/translations/fr-CA.json +2 -0
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import sinon from "sinon";
|
|
3
|
-
import MultiSelector
|
|
4
|
-
import { TestWrapper, createMuiTheme } from "../../../utils/testUtils";
|
|
3
|
+
import MultiSelector from "./MultiSelector";
|
|
4
|
+
import { TestWrapper, createMuiTheme, extractMessages } from "../../../utils/testUtils";
|
|
5
5
|
import Immutable from "immutable";
|
|
6
6
|
import SelectMUI from "@material-ui/core/Select";
|
|
7
7
|
import MenuItem from "@material-ui/core/MenuItem";
|
|
8
8
|
import TooltippedTypography from "../../MaterialUI/DataDisplay/TooltippedElements/TooltippedTypography";
|
|
9
9
|
import Icon from "../../MaterialUI/DataDisplay/Icon";
|
|
10
|
+
import FormControl from "@material-ui/core/FormControl";
|
|
11
|
+
import { render, screen, fireEvent } from "@testing-library/react";
|
|
12
|
+
import sharedMessages from "../../../sharedMessages";
|
|
13
|
+
|
|
14
|
+
const messages = extractMessages(sharedMessages);
|
|
10
15
|
|
|
11
16
|
describe("MultiSelector", () => {
|
|
12
|
-
let update, state, store, chevronDown;
|
|
17
|
+
let update, state, store, chevronDown, multipleRenderValue;
|
|
13
18
|
beforeEach(() => {
|
|
14
19
|
update = sinon.spy().named("update");
|
|
20
|
+
multipleRenderValue = sinon.fake.returns("En, It");
|
|
15
21
|
|
|
16
22
|
state = Immutable.fromJS({
|
|
17
23
|
locale: {
|
|
@@ -34,7 +40,7 @@ describe("MultiSelector", () => {
|
|
|
34
40
|
|
|
35
41
|
it("renders a multi selector with multiple options", () =>
|
|
36
42
|
expect(
|
|
37
|
-
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
43
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
38
44
|
<MultiSelector
|
|
39
45
|
update={update}
|
|
40
46
|
value={["English"]}
|
|
@@ -46,32 +52,34 @@ describe("MultiSelector", () => {
|
|
|
46
52
|
</TestWrapper>,
|
|
47
53
|
"when mounted",
|
|
48
54
|
"to satisfy",
|
|
49
|
-
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
56
|
+
<FormControl>
|
|
57
|
+
<SelectMUI
|
|
58
|
+
value={["English"]}
|
|
59
|
+
disableUnderline={true}
|
|
60
|
+
IconComponent={chevronDown}
|
|
61
|
+
error={false}
|
|
62
|
+
multiple={true}
|
|
63
|
+
renderValue={selected => selected.join(", ")}
|
|
64
|
+
>
|
|
65
|
+
<MenuItem key="English" value="English">
|
|
66
|
+
<TooltippedTypography children="English" titleValue="English" />
|
|
67
|
+
</MenuItem>
|
|
68
|
+
<MenuItem key="Francais" value="Francais">
|
|
69
|
+
<TooltippedTypography noWrap children="Francais" titleValue="Francais" />
|
|
70
|
+
</MenuItem>
|
|
71
|
+
</SelectMUI>
|
|
72
|
+
</FormControl>
|
|
65
73
|
</TestWrapper>,
|
|
66
74
|
));
|
|
67
75
|
|
|
68
|
-
it("renders a multi selector with
|
|
76
|
+
it("renders a multi selector with select all and clear options without errors", () =>
|
|
69
77
|
expect(
|
|
70
|
-
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
78
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
71
79
|
<MultiSelector
|
|
72
80
|
update={update}
|
|
73
|
-
|
|
74
|
-
value={[]}
|
|
81
|
+
addClearSelectAll={true}
|
|
82
|
+
value={["English"]}
|
|
75
83
|
options={[
|
|
76
84
|
{ value: "English", label: "English" },
|
|
77
85
|
{ value: "Francais", label: "Francais" },
|
|
@@ -80,9 +88,16 @@ describe("MultiSelector", () => {
|
|
|
80
88
|
</TestWrapper>,
|
|
81
89
|
"when mounted",
|
|
82
90
|
"to satisfy",
|
|
83
|
-
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
84
|
-
<
|
|
85
|
-
<SelectMUI
|
|
91
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
92
|
+
<FormControl>
|
|
93
|
+
<SelectMUI
|
|
94
|
+
value={["English"]}
|
|
95
|
+
disableUnderline={true}
|
|
96
|
+
IconComponent={chevronDown}
|
|
97
|
+
error={false}
|
|
98
|
+
multiple={false}
|
|
99
|
+
renderValue={selected => selected.join(", ")}
|
|
100
|
+
>
|
|
86
101
|
<MenuItem key="English" value="English">
|
|
87
102
|
<TooltippedTypography children="English" titleValue="English" />
|
|
88
103
|
</MenuItem>
|
|
@@ -90,23 +105,228 @@ describe("MultiSelector", () => {
|
|
|
90
105
|
<TooltippedTypography noWrap children="Francais" titleValue="Francais" />
|
|
91
106
|
</MenuItem>
|
|
92
107
|
</SelectMUI>
|
|
93
|
-
|
|
94
|
-
</div>
|
|
108
|
+
</FormControl>
|
|
95
109
|
</TestWrapper>,
|
|
110
|
+
));
|
|
111
|
+
|
|
112
|
+
it("Expect multipleRenderValue to be called and selection to be rendered correctly", () => {
|
|
113
|
+
const allOptions = [
|
|
114
|
+
{ value: "English", label: "English" },
|
|
115
|
+
{ value: "Francais", label: "Francais" },
|
|
116
|
+
{ value: "Italiano", label: "Italiano" },
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
const multiSelector = (
|
|
120
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
121
|
+
<MultiSelector
|
|
122
|
+
update={update}
|
|
123
|
+
multipleRenderValue={multipleRenderValue}
|
|
124
|
+
value={["English", "Italiano"]}
|
|
125
|
+
options={allOptions}
|
|
126
|
+
/>
|
|
127
|
+
</TestWrapper>
|
|
96
128
|
);
|
|
129
|
+
|
|
130
|
+
render(multiSelector);
|
|
131
|
+
|
|
132
|
+
const selectionText = screen.queryByText("En, It");
|
|
133
|
+
|
|
134
|
+
expect(selectionText, "not to be null");
|
|
135
|
+
expect(multipleRenderValue, "to have a call satisfying", { args: [["English", "Italiano"], allOptions] });
|
|
97
136
|
});
|
|
98
|
-
});
|
|
99
137
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
138
|
+
it("Expect to have both 'Select All' and 'Clear' options to be available with partial selection", () => {
|
|
139
|
+
const multiSelector = (
|
|
140
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
141
|
+
<MultiSelector
|
|
142
|
+
update={update}
|
|
143
|
+
addClearSelectAll={true}
|
|
144
|
+
value={["English"]}
|
|
145
|
+
options={[
|
|
146
|
+
{ value: "English", label: "English" },
|
|
147
|
+
{ value: "Francais", label: "Francais" },
|
|
148
|
+
]}
|
|
149
|
+
/>
|
|
150
|
+
</TestWrapper>
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
render(multiSelector);
|
|
154
|
+
|
|
155
|
+
const selectButton = screen.getByRole("button");
|
|
156
|
+
fireEvent.mouseDown(selectButton);
|
|
157
|
+
|
|
158
|
+
const selectAllOption = screen.queryByText("Select All");
|
|
159
|
+
const clearOption = screen.queryByText("Clear");
|
|
160
|
+
|
|
161
|
+
expect(selectAllOption, "not to be null");
|
|
162
|
+
expect(clearOption, "not to be null");
|
|
104
163
|
});
|
|
105
164
|
|
|
106
|
-
it("
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
165
|
+
it("Expect to have only 'Clear' option to be available with all options being selected", () => {
|
|
166
|
+
const multiSelector = (
|
|
167
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
168
|
+
<MultiSelector
|
|
169
|
+
update={update}
|
|
170
|
+
addClearSelectAll={true}
|
|
171
|
+
value={["English", "Francais"]}
|
|
172
|
+
options={[
|
|
173
|
+
{ value: "English", label: "English" },
|
|
174
|
+
{ value: "Francais", label: "Francais" },
|
|
175
|
+
]}
|
|
176
|
+
/>
|
|
177
|
+
</TestWrapper>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
render(multiSelector);
|
|
181
|
+
|
|
182
|
+
const selectButton = screen.getByRole("button");
|
|
183
|
+
fireEvent.mouseDown(selectButton);
|
|
184
|
+
|
|
185
|
+
const selectAllOption = screen.queryByText("Select All");
|
|
186
|
+
const clearOption = screen.queryByText("Clear");
|
|
187
|
+
|
|
188
|
+
expect(selectAllOption, "to be null");
|
|
189
|
+
expect(clearOption, "not to be null");
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("Expect to have only 'Select All' option to be available with an empty selection", () => {
|
|
193
|
+
const multiSelector = (
|
|
194
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
195
|
+
<MultiSelector
|
|
196
|
+
update={update}
|
|
197
|
+
addClearSelectAll={true}
|
|
198
|
+
value={[]}
|
|
199
|
+
options={[
|
|
200
|
+
{ value: "English", label: "English" },
|
|
201
|
+
{ value: "Francais", label: "Francais" },
|
|
202
|
+
]}
|
|
203
|
+
/>
|
|
204
|
+
</TestWrapper>
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
render(multiSelector);
|
|
208
|
+
|
|
209
|
+
const selectButton = screen.getByRole("button");
|
|
210
|
+
fireEvent.mouseDown(selectButton);
|
|
211
|
+
|
|
212
|
+
const selectAllOption = screen.queryByText("Select All");
|
|
213
|
+
const clearOption = screen.queryByText("Clear");
|
|
110
214
|
|
|
111
|
-
|
|
215
|
+
expect(selectAllOption, "not to be null");
|
|
216
|
+
expect(clearOption, "to be null");
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("Picking one selection should update with it along with existing ones", () => {
|
|
220
|
+
const multiSelector = (
|
|
221
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
222
|
+
<MultiSelector
|
|
223
|
+
update={update}
|
|
224
|
+
addClearSelectAll={true}
|
|
225
|
+
value={["English"]}
|
|
226
|
+
options={[
|
|
227
|
+
{ value: "English", label: "English" },
|
|
228
|
+
{ value: "Francais", label: "Francais" },
|
|
229
|
+
{ value: "Italiano", label: "Italiano" },
|
|
230
|
+
]}
|
|
231
|
+
/>
|
|
232
|
+
</TestWrapper>
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
render(multiSelector);
|
|
236
|
+
|
|
237
|
+
const selectButton = screen.getByRole("button");
|
|
238
|
+
fireEvent.mouseDown(selectButton);
|
|
239
|
+
|
|
240
|
+
const optionToSelect = screen.getByText("Italiano");
|
|
241
|
+
fireEvent.click(optionToSelect);
|
|
242
|
+
|
|
243
|
+
expect(update, "to have calls satisfying", [{ args: [["English", "Italiano"]] }]);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it("The 'Select All' option should update with all values", () => {
|
|
247
|
+
const multiSelector = (
|
|
248
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
249
|
+
<MultiSelector
|
|
250
|
+
update={update}
|
|
251
|
+
addClearSelectAll={true}
|
|
252
|
+
value={["English"]}
|
|
253
|
+
options={[
|
|
254
|
+
{ value: "English", label: "English" },
|
|
255
|
+
{ value: "Francais", label: "Francais" },
|
|
256
|
+
{ value: "Italiano", label: "Italiano" },
|
|
257
|
+
]}
|
|
258
|
+
/>
|
|
259
|
+
</TestWrapper>
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
render(multiSelector);
|
|
263
|
+
|
|
264
|
+
const selectButton = screen.getByRole("button");
|
|
265
|
+
fireEvent.mouseDown(selectButton);
|
|
266
|
+
|
|
267
|
+
const optionToSelect = screen.getByText("Select All");
|
|
268
|
+
fireEvent.click(optionToSelect);
|
|
269
|
+
|
|
270
|
+
expect(update, "to have calls satisfying", [{ args: [["English", "Francais", "Italiano"]] }]);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("The 'Clear' option should update with an empty list", () => {
|
|
274
|
+
const multiSelector = (
|
|
275
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
276
|
+
<MultiSelector
|
|
277
|
+
update={update}
|
|
278
|
+
addClearSelectAll={true}
|
|
279
|
+
value={["English"]}
|
|
280
|
+
options={[
|
|
281
|
+
{ value: "English", label: "English" },
|
|
282
|
+
{ value: "Francais", label: "Francais" },
|
|
283
|
+
{ value: "Italiano", label: "Italiano" },
|
|
284
|
+
]}
|
|
285
|
+
/>
|
|
286
|
+
</TestWrapper>
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
render(multiSelector);
|
|
290
|
+
|
|
291
|
+
const selectButton = screen.getByRole("button");
|
|
292
|
+
fireEvent.mouseDown(selectButton);
|
|
293
|
+
|
|
294
|
+
const optionToSelect = screen.getByText("Clear");
|
|
295
|
+
fireEvent.click(optionToSelect);
|
|
296
|
+
|
|
297
|
+
expect(update, "to have calls satisfying", [{ args: [[]] }]);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("renders a multi selector with an error", () => {
|
|
301
|
+
expect(
|
|
302
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
303
|
+
<MultiSelector
|
|
304
|
+
update={update}
|
|
305
|
+
required={true}
|
|
306
|
+
value={[]}
|
|
307
|
+
options={[
|
|
308
|
+
{ value: "English", label: "English" },
|
|
309
|
+
{ value: "Francais", label: "Francais" },
|
|
310
|
+
]}
|
|
311
|
+
/>
|
|
312
|
+
</TestWrapper>,
|
|
313
|
+
"when mounted",
|
|
314
|
+
"to satisfy",
|
|
315
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
|
|
316
|
+
<FormControl>
|
|
317
|
+
<div>
|
|
318
|
+
<SelectMUI value={[""]} disableUnderline={true} IconComponent={chevronDown} error={true} multiple={true}>
|
|
319
|
+
<MenuItem key="English" value="English">
|
|
320
|
+
<TooltippedTypography children="English" titleValue="English" />
|
|
321
|
+
</MenuItem>
|
|
322
|
+
<MenuItem key="Francais" value="Francais">
|
|
323
|
+
<TooltippedTypography noWrap children="Francais" titleValue="Francais" />
|
|
324
|
+
</MenuItem>
|
|
325
|
+
</SelectMUI>
|
|
326
|
+
<div></div>
|
|
327
|
+
</div>
|
|
328
|
+
</FormControl>
|
|
329
|
+
</TestWrapper>,
|
|
330
|
+
);
|
|
331
|
+
});
|
|
112
332
|
});
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Select from "../../MaterialUI/Inputs/Select";
|
|
3
|
-
import { memoize } from "../../../utils";
|
|
4
3
|
import SelectProps from "../../MaterialUI/Inputs/SelectProps";
|
|
5
4
|
|
|
6
|
-
export const selectEventUpdater = memoize(update => value => update(value));
|
|
7
|
-
|
|
8
5
|
const Selector = ({ value, options, update, ...props }) => {
|
|
9
6
|
const selectProps = new SelectProps();
|
|
10
7
|
|
|
11
8
|
selectProps.set(SelectProps.propNames.value, value);
|
|
12
9
|
selectProps.set(SelectProps.propNames.onClose, props.onBlur);
|
|
13
10
|
selectProps.set(SelectProps.propNames.disabled, props.disabled);
|
|
14
|
-
selectProps.set(SelectProps.propNames.update,
|
|
11
|
+
selectProps.set(SelectProps.propNames.update, update);
|
|
12
|
+
selectProps.set(SelectProps.propNames.autoWidth, false);
|
|
13
|
+
selectProps.set(SelectProps.propNames.positionOverride, {
|
|
14
|
+
anchorOrigin: {
|
|
15
|
+
vertical: "bottom",
|
|
16
|
+
horizontal: "left",
|
|
17
|
+
},
|
|
18
|
+
transformOrigin: {
|
|
19
|
+
vertical: "top",
|
|
20
|
+
horizontal: "left",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
15
23
|
|
|
16
24
|
const hasError = props.required && !value ? true : false;
|
|
17
25
|
selectProps.set(SelectProps.propNames.error, hasError);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import sinon from "sinon";
|
|
3
|
-
import Selector
|
|
3
|
+
import Selector from "./Selector";
|
|
4
4
|
import { TestWrapper, createMuiTheme } from "./../../../utils/testUtils";
|
|
5
5
|
import Immutable from "immutable";
|
|
6
6
|
import SelectMUI from "@material-ui/core/Select";
|
|
7
7
|
import MenuItem from "@material-ui/core/MenuItem";
|
|
8
8
|
import TooltippedTypography from "../../MaterialUI/DataDisplay/TooltippedElements/TooltippedTypography";
|
|
9
9
|
import Icon from "../../MaterialUI/DataDisplay/Icon";
|
|
10
|
+
import { mount } from "enzyme";
|
|
10
11
|
|
|
11
12
|
describe("Selector", () => {
|
|
12
13
|
let update, state, store, chevronDown;
|
|
@@ -88,18 +89,32 @@ describe("Selector", () => {
|
|
|
88
89
|
</TestWrapper>,
|
|
89
90
|
);
|
|
90
91
|
});
|
|
91
|
-
});
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
it("Update is invoked when selection has changed", () => {
|
|
94
|
+
const mountedComponent = mount(
|
|
95
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider intlProvider>
|
|
96
|
+
<Selector
|
|
97
|
+
update={update}
|
|
98
|
+
required={true}
|
|
99
|
+
value={null}
|
|
100
|
+
options={[
|
|
101
|
+
{ value: "English", label: "English" },
|
|
102
|
+
{ value: "Francais", label: "Francais" },
|
|
103
|
+
]}
|
|
104
|
+
/>
|
|
105
|
+
</TestWrapper>,
|
|
106
|
+
);
|
|
98
107
|
|
|
99
|
-
|
|
100
|
-
expect(selectEventUpdater, "called with", [update], "called with", ["foo"]).then(() =>
|
|
101
|
-
expect(update, "to have calls satisfying", [{ args: ["foo"] }]),
|
|
102
|
-
));
|
|
108
|
+
const selectMui = mountedComponent.find(SelectMUI);
|
|
103
109
|
|
|
104
|
-
|
|
110
|
+
const event = {
|
|
111
|
+
target: {
|
|
112
|
+
value: "Francais",
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
selectMui.invoke("onChange")(event);
|
|
117
|
+
|
|
118
|
+
expect(update, "to have calls satisfying", [{ args: ["Francais"] }]);
|
|
119
|
+
});
|
|
105
120
|
});
|
|
@@ -8,29 +8,29 @@ import sharedMessages from "../sharedMessages";
|
|
|
8
8
|
const useStyles = makeStyles(theme => ({
|
|
9
9
|
container: {
|
|
10
10
|
fontFamily: "'Open Sans', sans-serif",
|
|
11
|
-
fontSize:
|
|
11
|
+
fontSize: theme.spacing(1.4),
|
|
12
12
|
background: "rgba(255,255,255,0.85)",
|
|
13
|
-
maxWidth:
|
|
14
|
-
width:
|
|
13
|
+
maxWidth: theme.spacing(70),
|
|
14
|
+
width: `calc(100% - ${theme.spacing(4)})`,
|
|
15
15
|
display: "block",
|
|
16
16
|
top: "50%",
|
|
17
17
|
left: "50%",
|
|
18
18
|
position: "absolute",
|
|
19
|
-
boxShadow:
|
|
19
|
+
boxShadow: `${theme.spacing(0, 0.4, 0.8, 0)} rgba(0, 0, 0, 0.2), ${theme.spacing(0, 0.6, 2, 0)} rgba(0, 0, 0, 0.19)`,
|
|
20
20
|
transform: "translateY(-50%) translateX(-50%)",
|
|
21
|
-
padding:
|
|
22
|
-
borderRadius:
|
|
21
|
+
padding: theme.spacing(8),
|
|
22
|
+
borderRadius: theme.spacing(0.3),
|
|
23
23
|
"& header": {
|
|
24
|
-
paddingBottom:
|
|
25
|
-
marginBottom:
|
|
24
|
+
paddingBottom: theme.spacing(2),
|
|
25
|
+
marginBottom: theme.spacing(2),
|
|
26
26
|
borderBottom: "1px solid #999",
|
|
27
27
|
"& h1": {
|
|
28
28
|
fontWeight: 400,
|
|
29
|
-
fontWize:
|
|
29
|
+
fontWize: theme.spacing(3),
|
|
30
30
|
marginTop: 0,
|
|
31
|
-
marginBottom:
|
|
31
|
+
marginBottom: theme.spacing(0.5),
|
|
32
32
|
"& p": {
|
|
33
|
-
fontSize:
|
|
33
|
+
fontSize: theme.spacing(1.6),
|
|
34
34
|
margin: 0,
|
|
35
35
|
color: "#999",
|
|
36
36
|
fontWeight: 400,
|
|
@@ -43,7 +43,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
43
43
|
flexWrap: "wrap",
|
|
44
44
|
width: "100%",
|
|
45
45
|
boxSizing: "border-box",
|
|
46
|
-
marginTop:
|
|
46
|
+
marginTop: theme.spacing(4),
|
|
47
47
|
},
|
|
48
48
|
gridItem: {
|
|
49
49
|
display: "flex",
|
|
@@ -52,16 +52,16 @@ const useStyles = makeStyles(theme => ({
|
|
|
52
52
|
flexDirection: "column",
|
|
53
53
|
},
|
|
54
54
|
browserIconContainer: {
|
|
55
|
-
width:
|
|
55
|
+
width: theme.spacing(4.8),
|
|
56
56
|
textAlign: "center",
|
|
57
57
|
},
|
|
58
58
|
browserIconCaption: {
|
|
59
|
-
fontSize:
|
|
59
|
+
fontSize: theme.spacing(1.1),
|
|
60
60
|
color: "#999",
|
|
61
61
|
},
|
|
62
62
|
browserIcon: {
|
|
63
63
|
stroke: "none",
|
|
64
|
-
fontSize:
|
|
64
|
+
fontSize: theme.spacing(4.8),
|
|
65
65
|
},
|
|
66
66
|
}));
|
|
67
67
|
|
|
@@ -24,12 +24,12 @@ const useStyles = makeStyles(theme => ({
|
|
|
24
24
|
},
|
|
25
25
|
containerWide: {
|
|
26
26
|
width: theme.spacing(106.4),
|
|
27
|
-
height: `calc(100% -
|
|
27
|
+
height: `calc(100% - ${theme.spacing(8)})`,
|
|
28
28
|
maxHeight: theme.spacing(73),
|
|
29
29
|
},
|
|
30
30
|
containerFullwidth: {
|
|
31
|
-
width: `calc(100% -
|
|
32
|
-
height: `calc(100% -
|
|
31
|
+
width: `calc(100% - ${theme.spacing(8)})`,
|
|
32
|
+
height: `calc(100% - ${theme.spacing(8)})`,
|
|
33
33
|
},
|
|
34
34
|
title: {
|
|
35
35
|
height: theme.spacing(4),
|
|
@@ -44,18 +44,18 @@ const useStyles = makeStyles(theme => ({
|
|
|
44
44
|
},
|
|
45
45
|
textSkeleton: {
|
|
46
46
|
width: "100%",
|
|
47
|
-
height: 6,
|
|
47
|
+
height: theme.spacing(0.6),
|
|
48
48
|
animation: false,
|
|
49
49
|
},
|
|
50
50
|
chipSkeleton: {
|
|
51
|
-
width:
|
|
52
|
-
height:
|
|
51
|
+
width: theme.spacing(6),
|
|
52
|
+
height: theme.spacing(2.5),
|
|
53
53
|
animation: false,
|
|
54
|
-
borderRadius:
|
|
54
|
+
borderRadius: theme.spacing(1.5),
|
|
55
55
|
},
|
|
56
56
|
radioSkeleton: {
|
|
57
|
-
width:
|
|
58
|
-
height:
|
|
57
|
+
width: theme.spacing(1.7),
|
|
58
|
+
height: theme.spacing(1.7),
|
|
59
59
|
animation: false,
|
|
60
60
|
},
|
|
61
61
|
root: {
|
|
@@ -73,7 +73,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
73
73
|
},
|
|
74
74
|
active: {
|
|
75
75
|
backgroundColor: `${theme.palette.primary.dark} !important`,
|
|
76
|
-
boxShadow:
|
|
76
|
+
boxShadow: `inset ${theme.spacing(1, 0, 1, 0.1)} rgba(0,0,0,0.18)`,
|
|
77
77
|
|
|
78
78
|
"&:after": {
|
|
79
79
|
borderLeftColor: `${theme.palette.primary.dark} !important`,
|
|
@@ -165,7 +165,7 @@ const StepperModal = ({
|
|
|
165
165
|
<FormattedMessage {...sharedMessages.cancel} />
|
|
166
166
|
</Button>
|
|
167
167
|
|
|
168
|
-
{currentStep < steps.length - 1 &&
|
|
168
|
+
{(currentStep < steps.length - 1 || steps[currentStep]?.isIntermediate) &&
|
|
169
169
|
(steps[currentStep]?.actions?.length > 0 ? (
|
|
170
170
|
steps[currentStep].actions.map(action => (
|
|
171
171
|
<Button
|
|
@@ -191,7 +191,7 @@ const StepperModal = ({
|
|
|
191
191
|
</Button>
|
|
192
192
|
))}
|
|
193
193
|
|
|
194
|
-
{currentStep === steps.length - 1 && (
|
|
194
|
+
{currentStep === steps.length - 1 && !steps[currentStep]?.isIntermediate && (
|
|
195
195
|
<Button
|
|
196
196
|
variant="contained"
|
|
197
197
|
color="primary"
|
|
@@ -335,6 +335,80 @@ describe("StepperModal", () => {
|
|
|
335
335
|
expect(okCallback, "was called");
|
|
336
336
|
});
|
|
337
337
|
|
|
338
|
+
it("Renders StepperModal correctly without confirm button for an intermediate step", () => {
|
|
339
|
+
const open = true;
|
|
340
|
+
const title = "title";
|
|
341
|
+
const backdropClickCallback = jest.fn();
|
|
342
|
+
const okCallback = jest.fn();
|
|
343
|
+
const cancelCallback = jest.fn();
|
|
344
|
+
const modalProps = new ModalProps();
|
|
345
|
+
const actions = [
|
|
346
|
+
{
|
|
347
|
+
value: "first value",
|
|
348
|
+
label: "first action",
|
|
349
|
+
Handler: () => {},
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
value: "second value",
|
|
353
|
+
label: "second action",
|
|
354
|
+
Handler: () => {},
|
|
355
|
+
},
|
|
356
|
+
];
|
|
357
|
+
const steps = [{ title: "step1", content: <div>content</div>, actions, isIntermediate: true }];
|
|
358
|
+
|
|
359
|
+
const titleComponent = (
|
|
360
|
+
<div>
|
|
361
|
+
<div>{title}</div>
|
|
362
|
+
<div>step1</div>
|
|
363
|
+
</div>
|
|
364
|
+
);
|
|
365
|
+
const messageComponent = <div>{steps[0].content}</div>;
|
|
366
|
+
|
|
367
|
+
modalProps.set(ModalProps.propNames.title, titleComponent);
|
|
368
|
+
modalProps.set(ModalProps.propNames.open, open);
|
|
369
|
+
modalProps.set(ModalProps.propNames.backdropClickCallback, backdropClickCallback);
|
|
370
|
+
modalProps.set(ModalProps.propNames.type, "wide");
|
|
371
|
+
|
|
372
|
+
const actionPanel = (
|
|
373
|
+
<div>
|
|
374
|
+
<div></div>
|
|
375
|
+
<div>
|
|
376
|
+
<Button variant="outlined" disabled={false} onClick={() => cancelCallback()}>
|
|
377
|
+
{sharedMessages.cancel.defaultMessage}
|
|
378
|
+
</Button>
|
|
379
|
+
<Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
|
|
380
|
+
first action
|
|
381
|
+
</Button>
|
|
382
|
+
<Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
|
|
383
|
+
second action
|
|
384
|
+
</Button>
|
|
385
|
+
</div>
|
|
386
|
+
</div>
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
modalProps.set(ModalProps.propNames.actionPanel, actionPanel);
|
|
390
|
+
|
|
391
|
+
const component = (
|
|
392
|
+
<IntlProvider locale="en-US" messages={messages}>
|
|
393
|
+
<StepperModal
|
|
394
|
+
steps={steps}
|
|
395
|
+
title={title}
|
|
396
|
+
open={open}
|
|
397
|
+
confirmCallback={okCallback}
|
|
398
|
+
closeCallback={cancelCallback}
|
|
399
|
+
/>
|
|
400
|
+
</IntlProvider>
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
const expected = (
|
|
404
|
+
<IntlProvider locale="en-US" messages={messages}>
|
|
405
|
+
<Modal message={messageComponent} modalProps={modalProps} />
|
|
406
|
+
</IntlProvider>
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
410
|
+
});
|
|
411
|
+
|
|
338
412
|
it("Render closed modal", () => {
|
|
339
413
|
const open = false;
|
|
340
414
|
|
|
@@ -29,7 +29,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
29
29
|
},
|
|
30
30
|
"&::-webkit-scrollbar-thumb": {
|
|
31
31
|
background: theme.palette.grey.borders,
|
|
32
|
-
border:
|
|
32
|
+
border: `${theme.spacing(0.5)} white solid`,
|
|
33
33
|
backgroundClip: "padding-box",
|
|
34
34
|
borderRadius: theme.spacing(1.5),
|
|
35
35
|
},
|