@dxc-technology/halstack-react 0.0.0-1e19032 → 0.0.0-1e57e26
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/ThemeContext.d.ts +4 -9
- package/ThemeContext.js +25 -17
- package/accordion/Accordion.test.js +57 -0
- package/accordion-group/AccordionGroup.test.js +133 -0
- package/alert/Alert.test.js +92 -0
- package/box/Box.test.js +18 -0
- package/button/Button.test.js +35 -0
- package/card/Card.test.js +50 -0
- package/checkbox/Checkbox.test.js +65 -0
- package/chip/Chip.test.js +56 -0
- package/common/variables.js +0 -5
- package/date-input/DateInput.test.js +469 -0
- package/dialog/Dialog.test.js +40 -0
- package/dropdown/Dropdown.test.js +189 -0
- package/file-input/FileInput.test.js +457 -0
- package/footer/Footer.test.js +109 -0
- package/header/Header.test.js +63 -0
- package/heading/Heading.test.js +186 -0
- package/link/Link.test.js +91 -0
- package/number-input/NumberInput.test.js +508 -0
- package/package.json +1 -1
- package/paginator/Paginator.test.js +266 -0
- package/password-input/PasswordInput.test.js +183 -0
- package/progress-bar/ProgressBar.test.js +65 -0
- package/radio/Radio.test.js +71 -0
- package/radio-group/RadioGroup.js +2 -1
- package/radio-group/RadioGroup.stories.tsx +4 -0
- package/radio-group/RadioGroup.test.js +84 -83
- package/radio-group/types.d.ts +77 -0
- package/resultsetTable/ResultsetTable.test.js +306 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.js +75 -204
- package/select/Select.stories.tsx +19 -19
- package/select/Select.test.js +2016 -0
- package/select/types.d.ts +22 -1
- package/sidenav/Sidenav.test.js +56 -0
- package/slider/Slider.test.js +129 -0
- package/spinner/Spinner.test.js +64 -0
- package/stack/types.d.ts +15 -0
- package/switch/Switch.test.js +73 -0
- package/table/Table.test.js +26 -0
- package/tabs/Tabs.test.js +123 -0
- package/tag/Tag.js +12 -14
- package/tag/Tag.stories.tsx +12 -8
- package/tag/Tag.test.js +60 -0
- package/text-input/TextInput.js +3 -1
- package/text-input/TextInput.stories.tsx +10 -10
- package/text-input/TextInput.test.js +1725 -0
- package/text-input/types.d.ts +4 -0
- package/textarea/Textarea.js +3 -1
- package/textarea/Textarea.stories.jsx +5 -5
- package/textarea/Textarea.test.js +447 -0
- package/textarea/types.d.ts +4 -0
- package/toggle-group/ToggleGroup.test.js +125 -0
- package/wizard/Wizard.test.js +128 -0
|
@@ -53,18 +53,24 @@ describe("Radio Group component tests", function () {
|
|
|
53
53
|
test("Initial render has correct aria attributes and tabIndex", function () {
|
|
54
54
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
55
55
|
label: "test-radioGroup-label",
|
|
56
|
-
options: options
|
|
56
|
+
options: options,
|
|
57
|
+
error: ""
|
|
57
58
|
})),
|
|
58
59
|
getByRole = _render.getByRole,
|
|
59
60
|
getAllByRole = _render.getAllByRole,
|
|
60
|
-
getByText = _render.getByText
|
|
61
|
+
getByText = _render.getByText,
|
|
62
|
+
container = _render.container;
|
|
61
63
|
|
|
62
64
|
var radioGroup = getByRole("radiogroup");
|
|
63
65
|
var radios = getAllByRole("radio");
|
|
66
|
+
var errorId = "error-".concat(getByText("test-radioGroup-label").id.replace("label-", ""));
|
|
67
|
+
var error = container.querySelector("#".concat(errorId));
|
|
64
68
|
expect(radioGroup.getAttribute("aria-disabled")).toBe("false");
|
|
65
69
|
expect(radioGroup.getAttribute("aria-labelledby")).toBe(getByText("test-radioGroup-label").id);
|
|
66
70
|
expect(radioGroup.getAttribute("aria-invalid")).toBe("false");
|
|
67
71
|
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
72
|
+
expect(radioGroup.getAttribute("aria-orientation")).toBe("vertical");
|
|
73
|
+
expect(error.getAttribute("aria-live")).toBe("off");
|
|
68
74
|
radios.forEach(function (radio, index) {
|
|
69
75
|
// if no option was previously selected, first option is the focusable one
|
|
70
76
|
index === 0 ? expect(radio.tabIndex).toBe(0) : expect(radio.tabIndex).toBe(-1);
|
|
@@ -73,14 +79,25 @@ describe("Radio Group component tests", function () {
|
|
|
73
79
|
expect(radio.getAttribute("aria-labelledby")).toBe(getByText("Option 0".concat(index + 1)).id);
|
|
74
80
|
});
|
|
75
81
|
});
|
|
76
|
-
test("
|
|
82
|
+
test("aria-orientation attribute changes depending on stacking prop value", function () {
|
|
77
83
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
84
|
+
label: "test-radioGroup-label",
|
|
85
|
+
options: options,
|
|
86
|
+
stacking: "row"
|
|
87
|
+
})),
|
|
88
|
+
getByRole = _render2.getByRole;
|
|
89
|
+
|
|
90
|
+
var radioGroup = getByRole("radiogroup");
|
|
91
|
+
expect(radioGroup.getAttribute("aria-orientation")).toBe("horizontal");
|
|
92
|
+
});
|
|
93
|
+
test("Disabled state renders with correct aria attribute, correct tabIndex values and it is not focusable by keyboard", function () {
|
|
94
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
78
95
|
label: "test-radioGroup-label",
|
|
79
96
|
options: options,
|
|
80
97
|
disabled: true
|
|
81
98
|
})),
|
|
82
|
-
getByRole =
|
|
83
|
-
getAllByRole =
|
|
99
|
+
getByRole = _render3.getByRole,
|
|
100
|
+
getAllByRole = _render3.getAllByRole;
|
|
84
101
|
|
|
85
102
|
var radioGroup = getByRole("radiogroup");
|
|
86
103
|
var radios = getAllByRole("radio");
|
|
@@ -115,14 +132,13 @@ describe("Radio Group component tests", function () {
|
|
|
115
132
|
});
|
|
116
133
|
});
|
|
117
134
|
test("Disabled option renders with correct aria attribute, correct tabIndex value and it is not focusable by keyboard (focus 'jumps' the disabled option)", function () {
|
|
118
|
-
var
|
|
135
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
119
136
|
name: "test",
|
|
120
137
|
label: "test-radioGroup-label",
|
|
121
138
|
options: single_disabled_options
|
|
122
139
|
})),
|
|
123
|
-
getByRole =
|
|
124
|
-
getAllByRole =
|
|
125
|
-
container = _render3.container;
|
|
140
|
+
getByRole = _render4.getByRole,
|
|
141
|
+
getAllByRole = _render4.getAllByRole;
|
|
126
142
|
|
|
127
143
|
var radioGroup = getByRole("radiogroup");
|
|
128
144
|
var radios = getAllByRole("radio");
|
|
@@ -150,13 +166,13 @@ describe("Radio Group component tests", function () {
|
|
|
150
166
|
expect(radios[2].tabIndex).toBe(-1);
|
|
151
167
|
});
|
|
152
168
|
test("Error state renders with correct aria attributes", function () {
|
|
153
|
-
var
|
|
169
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
154
170
|
label: "test-radioGroup-label",
|
|
155
171
|
options: options,
|
|
156
172
|
error: "Error message"
|
|
157
173
|
})),
|
|
158
|
-
getByRole =
|
|
159
|
-
getByText =
|
|
174
|
+
getByRole = _render5.getByRole,
|
|
175
|
+
getByText = _render5.getByText;
|
|
160
176
|
|
|
161
177
|
var radioGroup = getByRole("radiogroup");
|
|
162
178
|
var errorMessage = getByText("Error message");
|
|
@@ -168,21 +184,20 @@ describe("Radio Group component tests", function () {
|
|
|
168
184
|
var onChange = jest.fn();
|
|
169
185
|
var onBlur = jest.fn();
|
|
170
186
|
|
|
171
|
-
var
|
|
187
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
172
188
|
label: "test-radioGroup-label",
|
|
173
189
|
options: options,
|
|
174
190
|
onChange: onChange,
|
|
175
191
|
onBlur: onBlur
|
|
176
192
|
})),
|
|
177
|
-
getByRole =
|
|
178
|
-
getAllByRole =
|
|
193
|
+
getByRole = _render6.getByRole,
|
|
194
|
+
getAllByRole = _render6.getAllByRole;
|
|
179
195
|
|
|
180
196
|
var radioGroup = getByRole("radiogroup");
|
|
181
197
|
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
182
198
|
|
|
183
199
|
_react2.fireEvent.blur(radioGroup);
|
|
184
200
|
|
|
185
|
-
expect(onBlur).toHaveBeenCalled();
|
|
186
201
|
expect(onBlur).toHaveBeenCalledWith({
|
|
187
202
|
error: "This field is required. Please, choose an option."
|
|
188
203
|
});
|
|
@@ -191,12 +206,10 @@ describe("Radio Group component tests", function () {
|
|
|
191
206
|
|
|
192
207
|
_userEvent["default"].click(getAllByRole("radio")[0]);
|
|
193
208
|
|
|
194
|
-
expect(onChange).toHaveBeenCalled();
|
|
195
209
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
196
210
|
|
|
197
211
|
_react2.fireEvent.blur(radioGroup);
|
|
198
212
|
|
|
199
|
-
expect(onBlur).toHaveBeenCalled();
|
|
200
213
|
expect(onBlur).toHaveBeenCalledWith({
|
|
201
214
|
value: "1"
|
|
202
215
|
});
|
|
@@ -205,22 +218,21 @@ describe("Radio Group component tests", function () {
|
|
|
205
218
|
var onChange = jest.fn();
|
|
206
219
|
var onBlur = jest.fn();
|
|
207
220
|
|
|
208
|
-
var
|
|
221
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
209
222
|
label: "test-radioGroup-label",
|
|
210
223
|
value: "",
|
|
211
224
|
options: options,
|
|
212
225
|
onChange: onChange,
|
|
213
226
|
onBlur: onBlur
|
|
214
227
|
})),
|
|
215
|
-
getByRole =
|
|
216
|
-
getAllByRole =
|
|
228
|
+
getByRole = _render7.getByRole,
|
|
229
|
+
getAllByRole = _render7.getAllByRole;
|
|
217
230
|
|
|
218
231
|
var radioGroup = getByRole("radiogroup");
|
|
219
232
|
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
220
233
|
|
|
221
234
|
_react2.fireEvent.blur(radioGroup);
|
|
222
235
|
|
|
223
|
-
expect(onBlur).toHaveBeenCalled();
|
|
224
236
|
expect(onBlur).toHaveBeenCalledWith({
|
|
225
237
|
value: "",
|
|
226
238
|
error: "This field is required. Please, choose an option."
|
|
@@ -228,13 +240,12 @@ describe("Radio Group component tests", function () {
|
|
|
228
240
|
|
|
229
241
|
_userEvent["default"].click(getAllByRole("radio")[0]);
|
|
230
242
|
|
|
231
|
-
expect(onChange).toHaveBeenCalled();
|
|
232
243
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
233
244
|
});
|
|
234
245
|
test("The 'defaultValue' gives the radio group an initial value when it is uncontrolled", function () {
|
|
235
246
|
var onChange = jest.fn();
|
|
236
247
|
|
|
237
|
-
var
|
|
248
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
238
249
|
defaultValue: "2",
|
|
239
250
|
name: "test",
|
|
240
251
|
label: "test-radio-group-label",
|
|
@@ -242,8 +253,8 @@ describe("Radio Group component tests", function () {
|
|
|
242
253
|
options: options,
|
|
243
254
|
onChange: onChange
|
|
244
255
|
})),
|
|
245
|
-
getAllByRole =
|
|
246
|
-
container =
|
|
256
|
+
getAllByRole = _render8.getAllByRole,
|
|
257
|
+
container = _render8.container;
|
|
247
258
|
|
|
248
259
|
var radio = getAllByRole("radio")[1];
|
|
249
260
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
@@ -255,7 +266,7 @@ describe("Radio Group component tests", function () {
|
|
|
255
266
|
var onChange = jest.fn();
|
|
256
267
|
var onBlur = jest.fn();
|
|
257
268
|
|
|
258
|
-
var
|
|
269
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
259
270
|
name: "test",
|
|
260
271
|
label: "test-radio-group-label",
|
|
261
272
|
helperText: "test-radio-group-helper-text",
|
|
@@ -265,16 +276,15 @@ describe("Radio Group component tests", function () {
|
|
|
265
276
|
optional: true,
|
|
266
277
|
optionalItemLabel: "No selection"
|
|
267
278
|
})),
|
|
268
|
-
getByRole =
|
|
269
|
-
getByText =
|
|
270
|
-
container =
|
|
279
|
+
getByRole = _render9.getByRole,
|
|
280
|
+
getByText = _render9.getByText,
|
|
281
|
+
container = _render9.container;
|
|
271
282
|
|
|
272
283
|
var radioGroup = getByRole("radiogroup");
|
|
273
284
|
expect(radioGroup.getAttribute("aria-required")).toBe("false");
|
|
274
285
|
|
|
275
286
|
_react2.fireEvent.blur(radioGroup);
|
|
276
287
|
|
|
277
|
-
expect(onBlur).toHaveBeenCalled();
|
|
278
288
|
expect(onBlur).toHaveBeenCalledWith({});
|
|
279
289
|
expect(radioGroup.getAttribute("aria-invalid")).toBe("false");
|
|
280
290
|
var optionalLabel = getByText("No selection");
|
|
@@ -282,7 +292,6 @@ describe("Radio Group component tests", function () {
|
|
|
282
292
|
|
|
283
293
|
_userEvent["default"].click(optionalLabel);
|
|
284
294
|
|
|
285
|
-
expect(onChange).toHaveBeenCalled();
|
|
286
295
|
expect(onChange).toHaveBeenCalledWith("");
|
|
287
296
|
expect(submitInput.value).toBe("");
|
|
288
297
|
});
|
|
@@ -290,7 +299,7 @@ describe("Radio Group component tests", function () {
|
|
|
290
299
|
var onChange = jest.fn();
|
|
291
300
|
var onBlur = jest.fn();
|
|
292
301
|
|
|
293
|
-
var
|
|
302
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
294
303
|
name: "test",
|
|
295
304
|
value: "2",
|
|
296
305
|
label: "test-radio-group-label",
|
|
@@ -299,9 +308,9 @@ describe("Radio Group component tests", function () {
|
|
|
299
308
|
onChange: onChange,
|
|
300
309
|
onBlur: onBlur
|
|
301
310
|
})),
|
|
302
|
-
getByRole =
|
|
303
|
-
getAllByRole =
|
|
304
|
-
container =
|
|
311
|
+
getByRole = _render10.getByRole,
|
|
312
|
+
getAllByRole = _render10.getAllByRole,
|
|
313
|
+
container = _render10.container;
|
|
305
314
|
|
|
306
315
|
var radioGroup = getByRole("radiogroup");
|
|
307
316
|
var radios = getAllByRole("radio");
|
|
@@ -312,12 +321,10 @@ describe("Radio Group component tests", function () {
|
|
|
312
321
|
|
|
313
322
|
_userEvent["default"].click(radios[6]);
|
|
314
323
|
|
|
315
|
-
expect(onChange).toHaveBeenCalled();
|
|
316
324
|
expect(onChange).toHaveBeenCalledWith("7");
|
|
317
325
|
|
|
318
326
|
_react2.fireEvent.blur(radioGroup);
|
|
319
327
|
|
|
320
|
-
expect(onBlur).toHaveBeenCalled();
|
|
321
328
|
expect(onBlur).toHaveBeenCalledWith({
|
|
322
329
|
value: "2"
|
|
323
330
|
});
|
|
@@ -325,16 +332,16 @@ describe("Radio Group component tests", function () {
|
|
|
325
332
|
test("Select an option by clicking on its label", function () {
|
|
326
333
|
var onChange = jest.fn();
|
|
327
334
|
|
|
328
|
-
var
|
|
335
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
329
336
|
name: "test",
|
|
330
337
|
label: "test-radio-group-label",
|
|
331
338
|
helperText: "test-radio-group-helper-text",
|
|
332
339
|
options: options,
|
|
333
340
|
onChange: onChange
|
|
334
341
|
})),
|
|
335
|
-
getByText =
|
|
336
|
-
getAllByRole =
|
|
337
|
-
container =
|
|
342
|
+
getByText = _render11.getByText,
|
|
343
|
+
getAllByRole = _render11.getAllByRole,
|
|
344
|
+
container = _render11.container;
|
|
338
345
|
|
|
339
346
|
var radioLabel = getByText("Option 09");
|
|
340
347
|
var checkedRadio = getAllByRole("radio")[8];
|
|
@@ -343,7 +350,6 @@ describe("Radio Group component tests", function () {
|
|
|
343
350
|
|
|
344
351
|
_userEvent["default"].click(radioLabel);
|
|
345
352
|
|
|
346
|
-
expect(onChange).toHaveBeenCalled();
|
|
347
353
|
expect(onChange).toHaveBeenCalledWith("9");
|
|
348
354
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
349
355
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -353,15 +359,15 @@ describe("Radio Group component tests", function () {
|
|
|
353
359
|
test("Select an option by clicking on its radio input", function () {
|
|
354
360
|
var onChange = jest.fn();
|
|
355
361
|
|
|
356
|
-
var
|
|
362
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
357
363
|
name: "test",
|
|
358
364
|
label: "test-radio-group-label",
|
|
359
365
|
helperText: "test-radio-group-helper-text",
|
|
360
366
|
options: options,
|
|
361
367
|
onChange: onChange
|
|
362
368
|
})),
|
|
363
|
-
getAllByRole =
|
|
364
|
-
container =
|
|
369
|
+
getAllByRole = _render12.getAllByRole,
|
|
370
|
+
container = _render12.container;
|
|
365
371
|
|
|
366
372
|
var checkedRadio = getAllByRole("radio")[6];
|
|
367
373
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
@@ -369,7 +375,6 @@ describe("Radio Group component tests", function () {
|
|
|
369
375
|
|
|
370
376
|
_userEvent["default"].click(checkedRadio);
|
|
371
377
|
|
|
372
|
-
expect(onChange).toHaveBeenCalled();
|
|
373
378
|
expect(onChange).toHaveBeenCalledWith("7");
|
|
374
379
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
375
380
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -379,7 +384,7 @@ describe("Radio Group component tests", function () {
|
|
|
379
384
|
test("Select an option that is already checked does not call onChange event but gives the focus", function () {
|
|
380
385
|
var onChange = jest.fn();
|
|
381
386
|
|
|
382
|
-
var
|
|
387
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
383
388
|
defaultValue: "2",
|
|
384
389
|
name: "test",
|
|
385
390
|
label: "test-radio-group-label",
|
|
@@ -387,7 +392,7 @@ describe("Radio Group component tests", function () {
|
|
|
387
392
|
options: options,
|
|
388
393
|
onChange: onChange
|
|
389
394
|
})),
|
|
390
|
-
getAllByRole =
|
|
395
|
+
getAllByRole = _render13.getAllByRole;
|
|
391
396
|
|
|
392
397
|
var checkedRadio = getAllByRole("radio")[1];
|
|
393
398
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -401,16 +406,16 @@ describe("Radio Group component tests", function () {
|
|
|
401
406
|
test("The 'enter' key checks the current focused option if anyone is checked", function () {
|
|
402
407
|
var onChange = jest.fn();
|
|
403
408
|
|
|
404
|
-
var
|
|
409
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
405
410
|
name: "test",
|
|
406
411
|
label: "test-radio-group-label",
|
|
407
412
|
helperText: "test-radio-group-helper-text",
|
|
408
413
|
options: options,
|
|
409
414
|
onChange: onChange
|
|
410
415
|
})),
|
|
411
|
-
getByRole =
|
|
412
|
-
getAllByRole =
|
|
413
|
-
container =
|
|
416
|
+
getByRole = _render14.getByRole,
|
|
417
|
+
getAllByRole = _render14.getAllByRole,
|
|
418
|
+
container = _render14.container;
|
|
414
419
|
|
|
415
420
|
var radioGroup = getByRole("radiogroup");
|
|
416
421
|
var checkedRadio = getAllByRole("radio")[0];
|
|
@@ -423,7 +428,6 @@ describe("Radio Group component tests", function () {
|
|
|
423
428
|
charCode: 13
|
|
424
429
|
});
|
|
425
430
|
|
|
426
|
-
expect(onChange).toHaveBeenCalled();
|
|
427
431
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
428
432
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
429
433
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -432,16 +436,16 @@ describe("Radio Group component tests", function () {
|
|
|
432
436
|
test("The 'space' key checks the current focused option if anyone is checked", function () {
|
|
433
437
|
var onChange = jest.fn();
|
|
434
438
|
|
|
435
|
-
var
|
|
439
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
436
440
|
name: "test",
|
|
437
441
|
label: "test-radio-group-label",
|
|
438
442
|
helperText: "test-radio-group-helper-text",
|
|
439
443
|
options: options,
|
|
440
444
|
onChange: onChange
|
|
441
445
|
})),
|
|
442
|
-
getByRole =
|
|
443
|
-
getAllByRole =
|
|
444
|
-
container =
|
|
446
|
+
getByRole = _render15.getByRole,
|
|
447
|
+
getAllByRole = _render15.getAllByRole,
|
|
448
|
+
container = _render15.container;
|
|
445
449
|
|
|
446
450
|
var radioGroup = getByRole("radiogroup");
|
|
447
451
|
var checkedRadio = getAllByRole("radio")[0];
|
|
@@ -454,7 +458,6 @@ describe("Radio Group component tests", function () {
|
|
|
454
458
|
charCode: 32
|
|
455
459
|
});
|
|
456
460
|
|
|
457
|
-
expect(onChange).toHaveBeenCalled();
|
|
458
461
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
459
462
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
460
463
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -464,7 +467,7 @@ describe("Radio Group component tests", function () {
|
|
|
464
467
|
var onChange = jest.fn();
|
|
465
468
|
var onBlur = jest.fn();
|
|
466
469
|
|
|
467
|
-
var
|
|
470
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
468
471
|
name: "test",
|
|
469
472
|
label: "test-radio-group-label",
|
|
470
473
|
helperText: "test-radio-group-helper-text",
|
|
@@ -472,9 +475,9 @@ describe("Radio Group component tests", function () {
|
|
|
472
475
|
onChange: onChange,
|
|
473
476
|
onBlur: onBlur
|
|
474
477
|
})),
|
|
475
|
-
getByRole =
|
|
476
|
-
getAllByRole =
|
|
477
|
-
container =
|
|
478
|
+
getByRole = _render16.getByRole,
|
|
479
|
+
getAllByRole = _render16.getAllByRole,
|
|
480
|
+
container = _render16.container;
|
|
478
481
|
|
|
479
482
|
var radioGroup = getByRole("radiogroup");
|
|
480
483
|
var radios = getAllByRole("radio");
|
|
@@ -503,11 +506,11 @@ describe("Radio Group component tests", function () {
|
|
|
503
506
|
expect(radios[1].tabIndex).toBe(0);
|
|
504
507
|
expect(submitInput.value).toBe("2");
|
|
505
508
|
});
|
|
506
|
-
test("The 'arrowDown' and 'arrowRight' keys move the selection to the next radio", function () {
|
|
509
|
+
test("The 'arrowDown' and 'arrowRight' keys move the selection to the next radio. When the last radio is reached, moves the selection to the first one", function () {
|
|
507
510
|
var onChange = jest.fn();
|
|
508
511
|
var onBlur = jest.fn();
|
|
509
512
|
|
|
510
|
-
var
|
|
513
|
+
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
511
514
|
defaultValue: "8",
|
|
512
515
|
name: "test",
|
|
513
516
|
label: "test-radio-group-label",
|
|
@@ -516,9 +519,9 @@ describe("Radio Group component tests", function () {
|
|
|
516
519
|
onChange: onChange,
|
|
517
520
|
onBlur: onBlur
|
|
518
521
|
})),
|
|
519
|
-
getByRole =
|
|
520
|
-
getAllByRole =
|
|
521
|
-
container =
|
|
522
|
+
getByRole = _render17.getByRole,
|
|
523
|
+
getAllByRole = _render17.getAllByRole,
|
|
524
|
+
container = _render17.container;
|
|
522
525
|
|
|
523
526
|
var radioGroup = getByRole("radiogroup");
|
|
524
527
|
var radios = getAllByRole("radio");
|
|
@@ -552,11 +555,11 @@ describe("Radio Group component tests", function () {
|
|
|
552
555
|
expect(radios[0].tabIndex).toBe(0);
|
|
553
556
|
expect(submitInput.value).toBe("1");
|
|
554
557
|
});
|
|
555
|
-
test("The 'arrowUp' and 'arrowLeft' keys move the selection to the previous radio", function () {
|
|
558
|
+
test("The 'arrowUp' and 'arrowLeft' keys move the selection to the previous radio. When the first radio is reached, moves the selection to the last one", function () {
|
|
556
559
|
var onChange = jest.fn();
|
|
557
560
|
var onBlur = jest.fn();
|
|
558
561
|
|
|
559
|
-
var
|
|
562
|
+
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
560
563
|
defaultValue: "2",
|
|
561
564
|
name: "test",
|
|
562
565
|
label: "test-radio-group-label",
|
|
@@ -565,9 +568,9 @@ describe("Radio Group component tests", function () {
|
|
|
565
568
|
onChange: onChange,
|
|
566
569
|
onBlur: onBlur
|
|
567
570
|
})),
|
|
568
|
-
getByRole =
|
|
569
|
-
getAllByRole =
|
|
570
|
-
container =
|
|
571
|
+
getByRole = _render18.getByRole,
|
|
572
|
+
getAllByRole = _render18.getAllByRole,
|
|
573
|
+
container = _render18.container;
|
|
571
574
|
|
|
572
575
|
var radioGroup = getByRole("radiogroup");
|
|
573
576
|
var radios = getAllByRole("radio");
|
|
@@ -604,16 +607,16 @@ describe("Radio Group component tests", function () {
|
|
|
604
607
|
test("Keyboard focus movement continues from the last radio input clicked", function () {
|
|
605
608
|
var onChange = jest.fn();
|
|
606
609
|
|
|
607
|
-
var
|
|
610
|
+
var _render19 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
608
611
|
name: "test",
|
|
609
612
|
label: "test-radio-group-label",
|
|
610
613
|
helperText: "test-radio-group-helper-text",
|
|
611
614
|
options: options,
|
|
612
615
|
onChange: onChange
|
|
613
616
|
})),
|
|
614
|
-
getByRole =
|
|
615
|
-
getAllByRole =
|
|
616
|
-
container =
|
|
617
|
+
getByRole = _render19.getByRole,
|
|
618
|
+
getAllByRole = _render19.getAllByRole,
|
|
619
|
+
container = _render19.container;
|
|
617
620
|
|
|
618
621
|
var radioGroup = getByRole("radiogroup");
|
|
619
622
|
var radios = getAllByRole("radio");
|
|
@@ -628,7 +631,6 @@ describe("Radio Group component tests", function () {
|
|
|
628
631
|
charCode: 40
|
|
629
632
|
});
|
|
630
633
|
|
|
631
|
-
expect(onChange).toHaveBeenCalled();
|
|
632
634
|
expect(onChange).toHaveBeenCalledWith("5");
|
|
633
635
|
expect(radios[4].getAttribute("aria-checked")).toBe("true");
|
|
634
636
|
expect(document.activeElement).toEqual(radios[4]);
|
|
@@ -644,7 +646,6 @@ describe("Radio Group component tests", function () {
|
|
|
644
646
|
charCode: 37
|
|
645
647
|
});
|
|
646
648
|
|
|
647
|
-
expect(onChange).toHaveBeenCalled();
|
|
648
649
|
expect(onChange).toHaveBeenCalledWith("8");
|
|
649
650
|
expect(radios[7].getAttribute("aria-checked")).toBe("true");
|
|
650
651
|
expect(document.activeElement).toEqual(radios[7]);
|
|
@@ -654,7 +655,7 @@ describe("Radio Group component tests", function () {
|
|
|
654
655
|
test("Readonly radio group lets the user move the focus, but neither click nor keyboard press changes the value", function () {
|
|
655
656
|
var onChange = jest.fn();
|
|
656
657
|
|
|
657
|
-
var
|
|
658
|
+
var _render20 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
658
659
|
name: "test",
|
|
659
660
|
label: "test-radio-group-label",
|
|
660
661
|
helperText: "test-radio-group-helper-text",
|
|
@@ -662,9 +663,9 @@ describe("Radio Group component tests", function () {
|
|
|
662
663
|
onChange: onChange,
|
|
663
664
|
readonly: true
|
|
664
665
|
})),
|
|
665
|
-
getByRole =
|
|
666
|
-
getAllByRole =
|
|
667
|
-
container =
|
|
666
|
+
getByRole = _render20.getByRole,
|
|
667
|
+
getAllByRole = _render20.getAllByRole,
|
|
668
|
+
container = _render20.container;
|
|
668
669
|
|
|
669
670
|
var radioGroup = getByRole("radiogroup");
|
|
670
671
|
var radios = getAllByRole("radio");
|
package/radio-group/types.d.ts
CHANGED
|
@@ -1,29 +1,106 @@
|
|
|
1
1
|
export declare type Option = {
|
|
2
|
+
/**
|
|
3
|
+
* Label of the option placed next to the radio input.
|
|
4
|
+
*/
|
|
2
5
|
value: string;
|
|
6
|
+
/**
|
|
7
|
+
* Value of the option. It should be unique and
|
|
8
|
+
* not an empty string, which is reserved to the optional item added
|
|
9
|
+
* by 'optional' prop.
|
|
10
|
+
*/
|
|
3
11
|
label: string;
|
|
12
|
+
/**
|
|
13
|
+
* If true, disables the option.
|
|
14
|
+
*/
|
|
4
15
|
disabled?: boolean;
|
|
5
16
|
};
|
|
6
17
|
declare type RadioGroupProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Text to be placed above the radio group.
|
|
20
|
+
*/
|
|
7
21
|
label: string;
|
|
22
|
+
/**
|
|
23
|
+
* Name attribute of the input element. This attribute will allow users
|
|
24
|
+
* to find the component's value during the submit event.
|
|
25
|
+
*/
|
|
8
26
|
name?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Helper text to be placed above the radio group.
|
|
29
|
+
*/
|
|
9
30
|
helperText?: string;
|
|
31
|
+
/**
|
|
32
|
+
* An array of objects representing the selectable options.
|
|
33
|
+
*/
|
|
10
34
|
options: Option[];
|
|
35
|
+
/**
|
|
36
|
+
* If true, the component will be disabled.
|
|
37
|
+
*/
|
|
11
38
|
disabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If true, the radio group will be optional, showing
|
|
41
|
+
* (Optional) next to the label and adding a default last
|
|
42
|
+
* option with an empty string as value. Otherwise, the field will be
|
|
43
|
+
* considered required and an error will be passed as a parameter to the
|
|
44
|
+
* OnBlur functions if an option wasn't selected.
|
|
45
|
+
*/
|
|
12
46
|
optional?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Label of the optional radio input.
|
|
49
|
+
*/
|
|
13
50
|
optionalItemLabel?: string;
|
|
51
|
+
/**
|
|
52
|
+
* If true, the component will be marked as readonly.
|
|
53
|
+
*/
|
|
14
54
|
readonly?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the orientation of the options within the radio group.
|
|
57
|
+
*/
|
|
15
58
|
stacking?: "row" | "column";
|
|
59
|
+
/**
|
|
60
|
+
* Initial value of the radio group, only when it is uncontrolled.
|
|
61
|
+
*/
|
|
16
62
|
defaultValue?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Value of the radio group. If undefined, the component will be
|
|
65
|
+
* uncontrolled and the value will be managed internally by the
|
|
66
|
+
* component.
|
|
67
|
+
*/
|
|
17
68
|
value?: string;
|
|
69
|
+
/**
|
|
70
|
+
* This function will be called when the user chooses an option. The new
|
|
71
|
+
* value will be passed to this function.
|
|
72
|
+
*/
|
|
18
73
|
onChange?: (value: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* This function will be called when the radio group loses the focus. An
|
|
76
|
+
* object including the value and the error will be passed to this
|
|
77
|
+
* function. If there is no error, error will not be defined.
|
|
78
|
+
*/
|
|
19
79
|
onBlur?: (val: {
|
|
20
80
|
value?: string;
|
|
21
81
|
error?: string;
|
|
22
82
|
}) => void;
|
|
83
|
+
/**
|
|
84
|
+
* If it is a defined value and also a truthy string, the component will
|
|
85
|
+
* change its appearance, showing the error below the radio group. If the
|
|
86
|
+
* defined value is an empty string, it will reserve a space below the
|
|
87
|
+
* component for a future error, but it would not change its look. In
|
|
88
|
+
* case of being undefined or null, both the appearance and the space for
|
|
89
|
+
* the error message would not be modified.
|
|
90
|
+
*/
|
|
23
91
|
error?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Value of the tabindex attribute.
|
|
94
|
+
*/
|
|
24
95
|
tabIndex?: number;
|
|
25
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Reference to the component.
|
|
99
|
+
*/
|
|
26
100
|
export declare type RefType = HTMLDivElement;
|
|
101
|
+
/**
|
|
102
|
+
* Single radio prop types.
|
|
103
|
+
*/
|
|
27
104
|
export declare type RadioProps = {
|
|
28
105
|
option: Option;
|
|
29
106
|
currentValue?: string;
|