@dxc-technology/halstack-react 8.0.0 → 9.0.1
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/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1329 -5
- package/HalstackContext.js +114 -73
- package/accordion/Accordion.js +13 -24
- package/accordion/Accordion.stories.tsx +102 -13
- package/accordion/Accordion.test.js +1 -1
- package/accordion/types.d.ts +3 -3
- package/accordion-group/AccordionGroup.js +2 -2
- package/accordion-group/AccordionGroup.test.js +1 -1
- package/accordion-group/types.d.ts +2 -2
- package/alert/Alert.js +3 -5
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/box/Box.js +3 -5
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +1 -1
- package/button/Button.js +13 -15
- package/button/Button.stories.tsx +150 -8
- package/button/Button.test.js +1 -1
- package/button/types.d.ts +3 -3
- package/card/Card.js +12 -13
- package/card/Card.stories.tsx +12 -13
- package/card/Card.test.js +1 -1
- package/checkbox/Checkbox.js +3 -3
- package/checkbox/Checkbox.stories.tsx +52 -0
- package/checkbox/Checkbox.test.js +1 -1
- package/checkbox/types.d.ts +2 -2
- package/chip/Chip.js +18 -26
- package/chip/Chip.stories.tsx +96 -9
- package/chip/Chip.test.js +3 -5
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1625 -0
- package/common/variables.js +280 -288
- package/date-input/Calendar.d.ts +1 -1
- package/date-input/Calendar.js +43 -43
- package/date-input/DateInput.js +74 -32
- package/date-input/DateInput.stories.tsx +183 -30
- package/date-input/DateInput.test.js +120 -37
- package/date-input/DatePicker.js +38 -52
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +1 -1
- package/date-input/YearPicker.js +23 -12
- package/date-input/types.d.ts +6 -8
- package/dialog/Dialog.js +61 -74
- package/dialog/Dialog.stories.tsx +211 -159
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.js +5 -8
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +3 -2
- package/dropdown/DropdownMenu.js +8 -18
- package/dropdown/DropdownMenuItem.js +4 -17
- package/dropdown/types.d.ts +3 -3
- package/file-input/FileInput.js +4 -8
- package/file-input/FileInput.stories.tsx +85 -2
- package/file-input/FileInput.test.js +1 -42
- package/file-input/FileItem.js +1 -0
- package/footer/Footer.js +6 -8
- package/footer/Footer.stories.tsx +91 -0
- package/footer/Footer.test.js +14 -26
- package/header/Header.d.ts +3 -2
- package/header/Header.js +21 -23
- package/header/Header.stories.tsx +149 -6
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +2 -2
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +1 -1
- package/link/Link.js +2 -2
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +2 -4
- package/link/types.d.ts +2 -2
- package/main.d.ts +1 -1
- package/main.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +37 -17
- package/number-input/NumberInput.test.js +1 -1
- package/package.json +2 -2
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +6 -14
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +44 -47
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/PasswordInput.test.js +1 -1
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/progress-bar/ProgressBar.test.js +1 -1
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/radio-group/RadioGroup.test.js +1 -1
- package/resultsetTable/ResultsetTable.js +2 -2
- package/resultsetTable/ResultsetTable.test.js +18 -23
- package/resultsetTable/types.d.ts +3 -3
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +56 -35
- package/select/Select.stories.tsx +492 -145
- package/select/Select.test.js +76 -81
- package/select/types.d.ts +2 -2
- package/sidenav/Sidenav.js +9 -11
- package/sidenav/Sidenav.stories.tsx +148 -46
- package/slider/Slider.js +6 -7
- package/slider/Slider.stories.tsx +57 -0
- package/slider/Slider.test.js +1 -1
- package/slider/types.d.ts +2 -2
- package/spinner/Spinner.js +17 -23
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.js +3 -3
- package/switch/Switch.stories.tsx +33 -0
- package/switch/Switch.test.js +1 -1
- package/switch/types.d.ts +2 -2
- package/table/Table.js +2 -2
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +1 -1
- package/tabs/Tab.js +12 -14
- package/tabs/Tabs.js +4 -6
- package/tabs/Tabs.stories.tsx +45 -5
- package/tabs/Tabs.test.js +4 -5
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.js +7 -9
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/text-input/Suggestion.js +34 -7
- package/text-input/TextInput.js +10 -14
- package/text-input/TextInput.stories.tsx +92 -4
- package/text-input/TextInput.test.js +125 -26
- package/textarea/Textarea.js +3 -3
- package/textarea/Textarea.stories.jsx +60 -1
- package/textarea/Textarea.test.js +1 -1
- package/toggle-group/ToggleGroup.js +7 -4
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +1 -1
- package/useTranslatedLabels.d.ts +84 -1
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +139 -0
- package/wizard/Wizard.js +2 -2
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +5 -6
- /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.js +0 -0
|
@@ -16,7 +16,7 @@ var _react2 = require("@testing-library/react");
|
|
|
16
16
|
|
|
17
17
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
18
18
|
|
|
19
|
-
var _TextInput = _interopRequireDefault(require("./TextInput"));
|
|
19
|
+
var _TextInput = _interopRequireDefault(require("./TextInput.tsx"));
|
|
20
20
|
|
|
21
21
|
// Mocking DOMRect for Radix Primitive Popover
|
|
22
22
|
global.globalThis = global;
|
|
@@ -57,6 +57,7 @@ global.DOMRect = {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
var countries = ["Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands, The", "Central African Republic", "Chad", "Democratic Republic of the Congo", "Dominican Republic", "Dominica", "Denmark", "Djibouti"];
|
|
60
|
+
var specialCharacters = ["/", "\\", "*", "(", ")", "[", "]", "+", "?", "*{[]}|"];
|
|
60
61
|
describe("TextInput component tests", function () {
|
|
61
62
|
test("Renders with correct error aria attributes", function () {
|
|
62
63
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
@@ -1183,10 +1184,108 @@ describe("TextInput component synchronous autosuggest tests", function () {
|
|
|
1183
1184
|
expect(input.value).toBe("");
|
|
1184
1185
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
1185
1186
|
});
|
|
1187
|
+
test("Autosuggest escapes special characters", function () {
|
|
1188
|
+
var onChange = jest.fn();
|
|
1189
|
+
|
|
1190
|
+
var _render37 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1191
|
+
label: "Autocomplete Countries",
|
|
1192
|
+
suggestions: specialCharacters,
|
|
1193
|
+
onChange: onChange
|
|
1194
|
+
})),
|
|
1195
|
+
getAllByText = _render37.getAllByText,
|
|
1196
|
+
getByRole = _render37.getByRole;
|
|
1197
|
+
|
|
1198
|
+
var input = getByRole("combobox");
|
|
1199
|
+
|
|
1200
|
+
_react2.fireEvent.focus(input);
|
|
1201
|
+
|
|
1202
|
+
var list = getByRole("listbox");
|
|
1203
|
+
|
|
1204
|
+
_react2.fireEvent.change(input, {
|
|
1205
|
+
target: {
|
|
1206
|
+
value: "/"
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
expect(list).toBeTruthy();
|
|
1211
|
+
expect(getAllByText("/").length).toBe(1);
|
|
1212
|
+
|
|
1213
|
+
_react2.fireEvent.change(input, {
|
|
1214
|
+
target: {
|
|
1215
|
+
value: "\\"
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
expect(list).toBeTruthy();
|
|
1220
|
+
expect(getAllByText("\\").length).toBe(1);
|
|
1221
|
+
|
|
1222
|
+
_react2.fireEvent.change(input, {
|
|
1223
|
+
target: {
|
|
1224
|
+
value: "*"
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
expect(list).toBeTruthy();
|
|
1229
|
+
expect(getAllByText("*").length).toBe(2);
|
|
1230
|
+
|
|
1231
|
+
_react2.fireEvent.change(input, {
|
|
1232
|
+
target: {
|
|
1233
|
+
value: "("
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
expect(list).toBeTruthy();
|
|
1238
|
+
expect(getAllByText("(").length).toBe(1);
|
|
1239
|
+
|
|
1240
|
+
_react2.fireEvent.change(input, {
|
|
1241
|
+
target: {
|
|
1242
|
+
value: ")"
|
|
1243
|
+
}
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
expect(list).toBeTruthy();
|
|
1247
|
+
expect(getAllByText(")").length).toBe(1);
|
|
1248
|
+
|
|
1249
|
+
_react2.fireEvent.change(input, {
|
|
1250
|
+
target: {
|
|
1251
|
+
value: "["
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1255
|
+
expect(list).toBeTruthy();
|
|
1256
|
+
expect(getAllByText("[").length).toBe(1);
|
|
1257
|
+
|
|
1258
|
+
_react2.fireEvent.change(input, {
|
|
1259
|
+
target: {
|
|
1260
|
+
value: "]"
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
|
|
1264
|
+
expect(list).toBeTruthy();
|
|
1265
|
+
expect(getAllByText("]").length).toBe(1);
|
|
1266
|
+
|
|
1267
|
+
_react2.fireEvent.change(input, {
|
|
1268
|
+
target: {
|
|
1269
|
+
value: "+"
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
expect(list).toBeTruthy();
|
|
1274
|
+
expect(getAllByText("+").length).toBe(1);
|
|
1275
|
+
|
|
1276
|
+
_react2.fireEvent.change(input, {
|
|
1277
|
+
target: {
|
|
1278
|
+
value: "?"
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
expect(list).toBeTruthy();
|
|
1283
|
+
expect(getAllByText("?").length).toBe(1);
|
|
1284
|
+
});
|
|
1186
1285
|
});
|
|
1187
1286
|
describe("TextInput component asynchronous autosuggest tests", function () {
|
|
1188
1287
|
test("Autosuggest 'Searching...' message is shown", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
1189
|
-
var callbackFunc, onChange,
|
|
1288
|
+
var callbackFunc, onChange, _render38, getByRole, getByText, input;
|
|
1190
1289
|
|
|
1191
1290
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
1192
1291
|
while (1) {
|
|
@@ -1203,11 +1302,11 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1203
1302
|
return result;
|
|
1204
1303
|
});
|
|
1205
1304
|
onChange = jest.fn();
|
|
1206
|
-
|
|
1305
|
+
_render38 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1207
1306
|
label: "Autosuggest Countries",
|
|
1208
1307
|
suggestions: callbackFunc,
|
|
1209
1308
|
onChange: onChange
|
|
1210
|
-
})), getByRole =
|
|
1309
|
+
})), getByRole = _render38.getByRole, getByText = _render38.getByText;
|
|
1211
1310
|
input = getByRole("combobox");
|
|
1212
1311
|
|
|
1213
1312
|
_react2.fireEvent.focus(input);
|
|
@@ -1270,14 +1369,14 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1270
1369
|
});
|
|
1271
1370
|
var onChange = jest.fn();
|
|
1272
1371
|
|
|
1273
|
-
var
|
|
1372
|
+
var _render39 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1274
1373
|
label: "Autosuggest Countries",
|
|
1275
1374
|
suggestions: callbackFunc,
|
|
1276
1375
|
onChange: onChange
|
|
1277
1376
|
})),
|
|
1278
|
-
getByRole =
|
|
1279
|
-
queryByText =
|
|
1280
|
-
queryByRole =
|
|
1377
|
+
getByRole = _render39.getByRole,
|
|
1378
|
+
queryByText = _render39.queryByText,
|
|
1379
|
+
queryByRole = _render39.queryByRole;
|
|
1281
1380
|
|
|
1282
1381
|
var input = getByRole("combobox");
|
|
1283
1382
|
|
|
@@ -1299,7 +1398,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1299
1398
|
expect(input.value).toBe("");
|
|
1300
1399
|
});
|
|
1301
1400
|
test("Autosuggest Esc + arrow down working while 'Searching...' message is shown", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
1302
|
-
var callbackFunc, onChange,
|
|
1401
|
+
var callbackFunc, onChange, _render40, getByRole, getByText, queryByText, queryByRole, input, list;
|
|
1303
1402
|
|
|
1304
1403
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
1305
1404
|
while (1) {
|
|
@@ -1316,11 +1415,11 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1316
1415
|
return result;
|
|
1317
1416
|
});
|
|
1318
1417
|
onChange = jest.fn();
|
|
1319
|
-
|
|
1418
|
+
_render40 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1320
1419
|
label: "Autosuggest Countries",
|
|
1321
1420
|
suggestions: callbackFunc,
|
|
1322
1421
|
onChange: onChange
|
|
1323
|
-
})), getByRole =
|
|
1422
|
+
})), getByRole = _render40.getByRole, getByText = _render40.getByText, queryByText = _render40.queryByText, queryByRole = _render40.queryByRole;
|
|
1324
1423
|
input = getByRole("combobox");
|
|
1325
1424
|
|
|
1326
1425
|
_react2.fireEvent.focus(input);
|
|
@@ -1368,7 +1467,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1368
1467
|
}, _callee2);
|
|
1369
1468
|
})));
|
|
1370
1469
|
test("Asynchronous uncontrolled autosuggest test", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
1371
|
-
var callbackFunc, onChange,
|
|
1470
|
+
var callbackFunc, onChange, _render41, getByRole, getByText, input;
|
|
1372
1471
|
|
|
1373
1472
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
1374
1473
|
while (1) {
|
|
@@ -1385,11 +1484,11 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1385
1484
|
return result;
|
|
1386
1485
|
});
|
|
1387
1486
|
onChange = jest.fn();
|
|
1388
|
-
|
|
1487
|
+
_render41 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1389
1488
|
label: "Autosuggest Countries",
|
|
1390
1489
|
onChange: onChange,
|
|
1391
1490
|
suggestions: callbackFunc
|
|
1392
|
-
})), getByRole =
|
|
1491
|
+
})), getByRole = _render41.getByRole, getByText = _render41.getByText;
|
|
1393
1492
|
input = getByRole("combobox");
|
|
1394
1493
|
|
|
1395
1494
|
_react2.fireEvent.focus(input);
|
|
@@ -1419,7 +1518,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1419
1518
|
}, _callee3);
|
|
1420
1519
|
})));
|
|
1421
1520
|
test("Asynchronous controlled autosuggest test", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
1422
|
-
var callbackFunc, onChange,
|
|
1521
|
+
var callbackFunc, onChange, _render42, getByRole, getByText, queryByRole, input;
|
|
1423
1522
|
|
|
1424
1523
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
1425
1524
|
while (1) {
|
|
@@ -1436,12 +1535,12 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1436
1535
|
return result;
|
|
1437
1536
|
});
|
|
1438
1537
|
onChange = jest.fn();
|
|
1439
|
-
|
|
1538
|
+
_render42 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1440
1539
|
label: "Autosuggest Countries",
|
|
1441
1540
|
value: "Denm",
|
|
1442
1541
|
onChange: onChange,
|
|
1443
1542
|
suggestions: callbackFunc
|
|
1444
|
-
})), getByRole =
|
|
1543
|
+
})), getByRole = _render42.getByRole, getByText = _render42.getByText, queryByRole = _render42.queryByRole;
|
|
1445
1544
|
input = getByRole("combobox");
|
|
1446
1545
|
expect(input.value).toBe("Denm");
|
|
1447
1546
|
|
|
@@ -1472,7 +1571,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1472
1571
|
}, _callee4);
|
|
1473
1572
|
})));
|
|
1474
1573
|
test("Asynchronous autosuggest closes the listbox after finishing no matches search", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
1475
|
-
var callbackFunc, onChange,
|
|
1574
|
+
var callbackFunc, onChange, _render43, getByText, getByRole, queryByRole, input;
|
|
1476
1575
|
|
|
1477
1576
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
1478
1577
|
while (1) {
|
|
@@ -1489,11 +1588,11 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1489
1588
|
return result;
|
|
1490
1589
|
});
|
|
1491
1590
|
onChange = jest.fn();
|
|
1492
|
-
|
|
1591
|
+
_render43 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1493
1592
|
label: "Autosuggest Countries",
|
|
1494
1593
|
onChange: onChange,
|
|
1495
1594
|
suggestions: callbackFunc
|
|
1496
|
-
})), getByText =
|
|
1595
|
+
})), getByText = _render43.getByText, getByRole = _render43.getByRole, queryByRole = _render43.queryByRole;
|
|
1497
1596
|
input = getByRole("combobox");
|
|
1498
1597
|
|
|
1499
1598
|
_react2.fireEvent.focus(input);
|
|
@@ -1516,7 +1615,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1516
1615
|
}, _callee5);
|
|
1517
1616
|
})));
|
|
1518
1617
|
test("Asynchronous autosuggest with no matches founded doesn't let the listbox to be opened", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
1519
|
-
var callbackFunc, onChange,
|
|
1618
|
+
var callbackFunc, onChange, _render44, getByText, getByRole, queryByRole, input;
|
|
1520
1619
|
|
|
1521
1620
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
1522
1621
|
while (1) {
|
|
@@ -1533,11 +1632,11 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1533
1632
|
return result;
|
|
1534
1633
|
});
|
|
1535
1634
|
onChange = jest.fn();
|
|
1536
|
-
|
|
1635
|
+
_render44 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1537
1636
|
label: "Autosuggest Countries",
|
|
1538
1637
|
onChange: onChange,
|
|
1539
1638
|
suggestions: callbackFunc
|
|
1540
|
-
})), getByText =
|
|
1639
|
+
})), getByText = _render44.getByText, getByRole = _render44.getByRole, queryByRole = _render44.queryByRole;
|
|
1541
1640
|
input = getByRole("combobox");
|
|
1542
1641
|
|
|
1543
1642
|
_react2.fireEvent.focus(input);
|
|
@@ -1582,7 +1681,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1582
1681
|
}, _callee6);
|
|
1583
1682
|
})));
|
|
1584
1683
|
test("Asynchronous autosuggest request failed, shows 'Error fetching data' message", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
1585
|
-
var errorCallbackFunc, onChange,
|
|
1684
|
+
var errorCallbackFunc, onChange, _render45, getByRole, getByText, input;
|
|
1586
1685
|
|
|
1587
1686
|
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
1588
1687
|
while (1) {
|
|
@@ -1597,11 +1696,11 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1597
1696
|
return result;
|
|
1598
1697
|
});
|
|
1599
1698
|
onChange = jest.fn();
|
|
1600
|
-
|
|
1699
|
+
_render45 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1601
1700
|
label: "Autosuggest Countries",
|
|
1602
1701
|
onChange: onChange,
|
|
1603
1702
|
suggestions: errorCallbackFunc
|
|
1604
|
-
})), getByRole =
|
|
1703
|
+
})), getByRole = _render45.getByRole, getByText = _render45.getByText;
|
|
1605
1704
|
input = getByRole("combobox");
|
|
1606
1705
|
|
|
1607
1706
|
_react2.fireEvent.focus(input);
|
package/textarea/Textarea.js
CHANGED
|
@@ -19,13 +19,13 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _utils = require("../common/utils
|
|
22
|
+
var _utils = require("../common/utils");
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
26
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
27
|
|
|
28
|
-
var _variables = require("../common/variables
|
|
28
|
+
var _variables = require("../common/variables");
|
|
29
29
|
|
|
30
30
|
var _uuid = require("uuid");
|
|
31
31
|
|
|
@@ -193,7 +193,7 @@ var calculateWidth = function calculateWidth(margin, size) {
|
|
|
193
193
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
var TextareaContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n
|
|
196
|
+
var TextareaContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
197
197
|
return calculateWidth(props.margin, props.size);
|
|
198
198
|
}, function (props) {
|
|
199
199
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -4,12 +4,20 @@ import Title from "../../.storybook/components/Title";
|
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
6
6
|
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: "Textarea",
|
|
10
11
|
component: DxcTextarea,
|
|
11
12
|
};
|
|
12
13
|
|
|
14
|
+
const opinionatedTheme = {
|
|
15
|
+
textarea: {
|
|
16
|
+
fontColor: "#000000",
|
|
17
|
+
hoverBorderColor: "#a46ede",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
export const Chromatic = () => (
|
|
14
22
|
<>
|
|
15
23
|
<>
|
|
@@ -151,7 +159,58 @@ export const Chromatic = () => (
|
|
|
151
159
|
<ExampleContainer>
|
|
152
160
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
153
161
|
<DxcTextarea label="Xxlarge" margin="xxlarge" />
|
|
154
|
-
|
|
162
|
+
</ExampleContainer>
|
|
163
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
164
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
165
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
166
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
167
|
+
<DxcTextarea label="Hovered" helperText="Sample text" placeholder="Placeholder" />
|
|
168
|
+
</HalstackProvider>
|
|
169
|
+
</ExampleContainer>
|
|
170
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
171
|
+
<Title title="Focused" theme="light" level={4} />
|
|
172
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
173
|
+
<DxcTextarea label="Focused" helperText="Sample text" />
|
|
174
|
+
</HalstackProvider>
|
|
175
|
+
</ExampleContainer>
|
|
176
|
+
<ExampleContainer>
|
|
177
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
178
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
179
|
+
<DxcTextarea
|
|
180
|
+
label="Disabled"
|
|
181
|
+
optional
|
|
182
|
+
helperText="Sample text"
|
|
183
|
+
placeholder="Enter your text here..."
|
|
184
|
+
disabled
|
|
185
|
+
/>
|
|
186
|
+
</HalstackProvider>
|
|
187
|
+
</ExampleContainer>
|
|
188
|
+
<ExampleContainer>
|
|
189
|
+
<Title title="Disabled with value" theme="light" level={4} />
|
|
190
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
191
|
+
<DxcTextarea label="Disabled" helperText="Sample text" defaultValue="Example text" disabled />
|
|
192
|
+
</HalstackProvider>
|
|
193
|
+
</ExampleContainer>
|
|
194
|
+
<ExampleContainer>
|
|
195
|
+
<Title title="With error" theme="light" level={4} />
|
|
196
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
197
|
+
<DxcTextarea
|
|
198
|
+
label="Textarea with error"
|
|
199
|
+
helperText="Helper text"
|
|
200
|
+
placeholder="Enter your text here..."
|
|
201
|
+
error="Error message."
|
|
202
|
+
/>
|
|
203
|
+
</HalstackProvider>
|
|
204
|
+
</ExampleContainer>
|
|
205
|
+
<ExampleContainer>
|
|
206
|
+
<Title title="Grow manual" theme="light" level={4} />{" "}
|
|
207
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
208
|
+
<DxcTextarea
|
|
209
|
+
label="Manual vertical grow"
|
|
210
|
+
verticalGrow="manual"
|
|
211
|
+
defaultValue="Long textttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"
|
|
212
|
+
/>
|
|
213
|
+
</HalstackProvider>
|
|
155
214
|
</ExampleContainer>
|
|
156
215
|
</>
|
|
157
216
|
);
|
|
@@ -8,7 +8,7 @@ var _react2 = require("@testing-library/react");
|
|
|
8
8
|
|
|
9
9
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
10
|
|
|
11
|
-
var _Textarea = _interopRequireDefault(require("./Textarea"));
|
|
11
|
+
var _Textarea = _interopRequireDefault(require("./Textarea.tsx"));
|
|
12
12
|
|
|
13
13
|
describe("Textarea component tests", function () {
|
|
14
14
|
test("Renders with correct label", function () {
|
|
@@ -21,10 +21,12 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _uuid = require("uuid");
|
|
23
23
|
|
|
24
|
-
var _variables = require("../common/variables
|
|
24
|
+
var _variables = require("../common/variables");
|
|
25
25
|
|
|
26
26
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
27
27
|
|
|
28
|
+
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
29
|
+
|
|
28
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
29
31
|
|
|
30
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -56,6 +58,8 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
56
58
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
57
59
|
toggleGroupId = _useState4[0];
|
|
58
60
|
|
|
61
|
+
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
62
|
+
|
|
59
63
|
var handleToggleChange = function handleToggleChange(selectedOption) {
|
|
60
64
|
var newSelectedOptions;
|
|
61
65
|
|
|
@@ -97,8 +101,7 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
97
101
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
98
102
|
theme: colorsTheme.toggleGroup
|
|
99
103
|
}, /*#__PURE__*/_react["default"].createElement(ToggleGroup, {
|
|
100
|
-
margin: margin
|
|
101
|
-
disabled: disabled
|
|
104
|
+
margin: margin
|
|
102
105
|
}, /*#__PURE__*/_react["default"].createElement(Label, {
|
|
103
106
|
htmlFor: toggleGroupId,
|
|
104
107
|
disabled: disabled
|
|
@@ -111,12 +114,12 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
111
114
|
return /*#__PURE__*/_react["default"].createElement(ToggleContainer, {
|
|
112
115
|
selected: multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
|
|
113
116
|
role: multiple ? "switch" : "radio",
|
|
117
|
+
backgroundType: backgroundType,
|
|
114
118
|
"aria-checked": multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
|
|
115
119
|
tabIndex: !disabled ? tabIndex : -1,
|
|
116
120
|
onClick: function onClick() {
|
|
117
121
|
return !disabled && handleToggleChange(option.value);
|
|
118
122
|
},
|
|
119
|
-
isFirst: i === 0,
|
|
120
123
|
isLast: i === options.length - 1,
|
|
121
124
|
isIcon: option.icon,
|
|
122
125
|
optionLabel: option.label,
|
|
@@ -3,6 +3,7 @@ import { userEvent, within } from "@storybook/testing-library";
|
|
|
3
3
|
import DxcToggleGroup from "./ToggleGroup";
|
|
4
4
|
import Title from "../../.storybook/components/Title";
|
|
5
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "ToggleGroup",
|
|
@@ -89,6 +90,16 @@ const twoOptions = [
|
|
|
89
90
|
label: "Twitter",
|
|
90
91
|
},
|
|
91
92
|
];
|
|
93
|
+
|
|
94
|
+
const opinionatedTheme = {
|
|
95
|
+
toggleGroup: {
|
|
96
|
+
selectedBaseColor: "#5f249f",
|
|
97
|
+
selectedFontColor: "#ffffff",
|
|
98
|
+
unselectedBaseColor: "#e6e6e6",
|
|
99
|
+
unselectedFontColor: "#000000",
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
92
103
|
export const Chromatic = () => (
|
|
93
104
|
<>
|
|
94
105
|
<ExampleContainer>
|
|
@@ -154,6 +165,37 @@ export const Chromatic = () => (
|
|
|
154
165
|
<Title title="xxLarge" theme="light" level={4} />
|
|
155
166
|
<DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
|
|
156
167
|
</ExampleContainer>
|
|
168
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
169
|
+
<ExampleContainer>
|
|
170
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
171
|
+
<Title title="Selected" theme="light" level={4} />
|
|
172
|
+
<DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
|
|
173
|
+
</HalstackProvider>
|
|
174
|
+
</ExampleContainer>
|
|
175
|
+
<ExampleContainer>
|
|
176
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
177
|
+
<Title title="Icons & label toggle group" theme="light" level={4} />
|
|
178
|
+
<DxcToggleGroup label="Icons & label" options={optionsWithIconAndLabel} />
|
|
179
|
+
</HalstackProvider>
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
<ExampleContainer>
|
|
182
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
183
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
184
|
+
<DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
|
|
185
|
+
</HalstackProvider>
|
|
186
|
+
</ExampleContainer>
|
|
187
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
188
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
189
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
190
|
+
<DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
|
|
191
|
+
</HalstackProvider>
|
|
192
|
+
</ExampleContainer>
|
|
193
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
194
|
+
<Title title="Actived" theme="light" level={4} />
|
|
195
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
196
|
+
<DxcToggleGroup label="Actived" options={twoOptions} defaultValue={2} />
|
|
197
|
+
</HalstackProvider>
|
|
198
|
+
</ExampleContainer>
|
|
157
199
|
</>
|
|
158
200
|
);
|
|
159
201
|
const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
|
|
@@ -6,7 +6,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
6
6
|
|
|
7
7
|
var _react2 = require("@testing-library/react");
|
|
8
8
|
|
|
9
|
-
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup"));
|
|
9
|
+
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup.tsx"));
|
|
10
10
|
|
|
11
11
|
var options = [{
|
|
12
12
|
value: 1,
|
package/toggle-group/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import TypographyPropsTypes from "./types";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const DxcTypography: ({ textOverflow, whiteSpace, children, ...props }: TypographyPropsTypes) => JSX.Element;
|
|
4
|
+
export default DxcTypography;
|