@dxc-technology/halstack-react 0.0.0-f54247d → 0.0.0-f6d6be5
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 +1337 -5
- package/HalstackContext.js +113 -72
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +14 -37
- package/accordion/Accordion.stories.tsx +104 -113
- package/accordion/Accordion.test.js +1 -1
- package/accordion/types.d.ts +2 -14
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +23 -44
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +7 -17
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +2 -14
- package/alert/Alert.js +4 -8
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +7 -26
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +0 -12
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +48 -60
- package/button/Button.stories.tsx +151 -9
- package/button/Button.test.js +12 -1
- package/button/types.d.ts +7 -3
- package/card/Card.d.ts +1 -1
- package/card/Card.js +27 -45
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +1 -1
- package/card/types.d.ts +1 -7
- 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 +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1490 -0
- package/common/variables.js +984 -1127
- package/date-input/Calendar.d.ts +1 -1
- package/date-input/Calendar.js +45 -45
- 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.d.ts +1 -1
- package/dialog/Dialog.js +55 -86
- package/dialog/Dialog.stories.tsx +145 -217
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +0 -13
- package/dropdown/Dropdown.js +5 -8
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +3 -2
- package/dropdown/DropdownMenu.js +12 -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 +3 -2
- package/file-input/types.d.ts +1 -1
- package/flex/Flex.js +4 -2
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +70 -5
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +44 -64
- package/footer/Footer.stories.tsx +36 -21
- package/footer/Footer.test.js +16 -26
- package/footer/types.d.ts +10 -12
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +20 -49
- package/header/Header.stories.tsx +115 -36
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +1 -15
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/image/Image.d.ts +4 -0
- package/image/Image.js +85 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +5 -5
- package/layout/ApplicationLayout.js +15 -12
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +7 -4
- package/layout/Icons.js +52 -56
- package/layout/types.d.ts +2 -3
- package/link/Link.js +3 -3
- 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 +4 -2
- package/main.js +17 -1
- package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
- package/{tabs-nav → nav-tabs}/NavTabs.js +8 -11
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +110 -6
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +48 -32
- package/{tabs-nav → nav-tabs}/types.d.ts +8 -9
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +6 -4
- package/number-input/NumberInput.test.js +279 -96
- package/package.json +3 -3
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +7 -15
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +57 -47
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +39 -0
- package/password-input/PasswordInput.js +35 -82
- package/password-input/PasswordInput.stories.tsx +1 -0
- package/password-input/PasswordInput.test.js +28 -35
- 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/Radio.js +10 -10
- package/radio-group/RadioGroup.js +8 -10
- 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 +495 -148
- package/select/Select.test.js +80 -85
- package/select/types.d.ts +2 -2
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +66 -96
- package/sidenav/Sidenav.stories.tsx +165 -63
- package/sidenav/types.d.ts +21 -18
- 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 -15
- package/tabs/Tabs.js +11 -17
- 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 +71 -91
- package/text-input/TextInput.stories.tsx +93 -5
- package/text-input/TextInput.test.js +125 -26
- package/textarea/Textarea.js +3 -4
- package/textarea/Textarea.stories.jsx +60 -1
- package/textarea/Textarea.test.js +2 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +85 -59
- package/toggle-group/ToggleGroup.stories.tsx +48 -3
- package/toggle-group/ToggleGroup.test.js +38 -24
- package/toggle-group/types.d.ts +22 -13
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1242 -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 +138 -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/card/ice-cream.jpg +0 -0
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +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
|
|
|
@@ -171,7 +171,6 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
171
171
|
backgroundType: backgroundType,
|
|
172
172
|
ref: textareaRef,
|
|
173
173
|
tabIndex: tabIndex,
|
|
174
|
-
"aria-disabled": disabled,
|
|
175
174
|
"aria-invalid": error ? "true" : "false",
|
|
176
175
|
"aria-errormessage": error ? errorId : undefined,
|
|
177
176
|
"aria-required": optional ? "false" : "true"
|
|
@@ -193,7 +192,7 @@ var calculateWidth = function calculateWidth(margin, size) {
|
|
|
193
192
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
194
193
|
};
|
|
195
194
|
|
|
196
|
-
var TextareaContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n
|
|
195
|
+
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
196
|
return calculateWidth(props.margin, props.size);
|
|
198
197
|
}, function (props) {
|
|
199
198
|
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 () {
|
|
@@ -85,7 +85,6 @@ describe("Textarea component tests", function () {
|
|
|
85
85
|
getByLabelText = _render7.getByLabelText;
|
|
86
86
|
|
|
87
87
|
var textarea = getByLabelText("Example label");
|
|
88
|
-
expect(textarea.getAttribute("aria-disabled")).toBe("false");
|
|
89
88
|
expect(textarea.getAttribute("aria-invalid")).toBe("false");
|
|
90
89
|
expect(textarea.getAttribute("aria-describedBy")).toBeNull();
|
|
91
90
|
expect(textarea.getAttribute("aria-required")).toBe("true");
|
|
@@ -101,7 +100,7 @@ describe("Textarea component tests", function () {
|
|
|
101
100
|
var textarea = getByLabelText("Example label");
|
|
102
101
|
expect(textarea.value).toBe("Example text");
|
|
103
102
|
});
|
|
104
|
-
test("Disabled textarea
|
|
103
|
+
test("Disabled textarea can not be modified", function () {
|
|
105
104
|
var onChange = jest.fn();
|
|
106
105
|
|
|
107
106
|
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
@@ -112,7 +111,6 @@ describe("Textarea component tests", function () {
|
|
|
112
111
|
getByLabelText = _render9.getByLabelText;
|
|
113
112
|
|
|
114
113
|
var textarea = getByLabelText("Example label");
|
|
115
|
-
expect(textarea.getAttribute("aria-disabled")).toBe("true");
|
|
116
114
|
|
|
117
115
|
_userEvent["default"].type(textarea, "Test");
|
|
118
116
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
declare const DxcToggleGroup: ({ label, helperText, defaultValue, value, onChange, disabled, options, margin, multiple, tabIndex, }:
|
|
2
|
+
import ToggleGroupPropsType from "./types";
|
|
3
|
+
declare const DxcToggleGroup: ({ label, helperText, defaultValue, value, onChange, disabled, options, margin, multiple, tabIndex, }: ToggleGroupPropsType) => JSX.Element;
|
|
4
4
|
export default DxcToggleGroup;
|