@dxc-technology/halstack-react 0.0.0-e4ccd42 → 0.0.0-e690193
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/README.md +1 -2
- package/dist/index.d.mts +3923 -0
- package/dist/index.d.ts +3923 -0
- package/dist/index.js +14133 -0
- package/dist/index.mjs +14045 -0
- package/package.json +83 -67
- package/BackgroundColorContext.d.ts +0 -1
- package/BackgroundColorContext.js +0 -30
- package/HalstackContext.d.ts +0 -1249
- package/HalstackContext.js +0 -310
- package/accordion/Accordion.d.ts +0 -4
- package/accordion/Accordion.js +0 -182
- package/accordion/Accordion.stories.tsx +0 -283
- package/accordion/Accordion.test.js +0 -56
- package/accordion/types.d.ts +0 -57
- package/accordion/types.js +0 -5
- package/accordion-group/AccordionGroup.d.ts +0 -8
- package/accordion-group/AccordionGroup.js +0 -101
- package/accordion-group/AccordionGroup.stories.tsx +0 -252
- package/accordion-group/AccordionGroup.test.js +0 -98
- package/accordion-group/AccordionGroupAccordion.d.ts +0 -4
- package/accordion-group/AccordionGroupAccordion.js +0 -31
- package/accordion-group/types.d.ts +0 -67
- package/accordion-group/types.js +0 -5
- package/action-icon/ActionIcon.d.ts +0 -4
- package/action-icon/ActionIcon.js +0 -47
- package/action-icon/ActionIcon.stories.tsx +0 -41
- package/action-icon/ActionIcon.test.js +0 -64
- package/action-icon/types.d.ts +0 -26
- package/action-icon/types.js +0 -5
- package/alert/Alert.d.ts +0 -4
- package/alert/Alert.js +0 -254
- package/alert/Alert.stories.tsx +0 -198
- package/alert/Alert.test.js +0 -75
- package/alert/types.d.ts +0 -49
- package/alert/types.js +0 -5
- package/badge/Badge.d.ts +0 -4
- package/badge/Badge.js +0 -159
- package/badge/Badge.stories.tsx +0 -210
- package/badge/Badge.test.js +0 -30
- package/badge/types.d.ts +0 -54
- package/badge/types.js +0 -5
- package/bleed/Bleed.d.ts +0 -3
- package/bleed/Bleed.js +0 -43
- package/bleed/Bleed.stories.tsx +0 -342
- package/bleed/types.d.ts +0 -37
- package/bleed/types.js +0 -5
- package/box/Box.d.ts +0 -4
- package/box/Box.js +0 -75
- package/box/Box.stories.tsx +0 -119
- package/box/Box.test.js +0 -13
- package/box/types.d.ts +0 -32
- package/box/types.js +0 -5
- package/bulleted-list/BulletedList.d.ts +0 -7
- package/bulleted-list/BulletedList.js +0 -89
- package/bulleted-list/BulletedList.stories.tsx +0 -115
- package/bulleted-list/types.d.ts +0 -38
- package/bulleted-list/types.js +0 -5
- package/button/Button.d.ts +0 -4
- package/button/Button.js +0 -120
- package/button/Button.stories.tsx +0 -344
- package/button/Button.test.js +0 -38
- package/button/types.d.ts +0 -57
- package/button/types.js +0 -5
- package/card/Card.d.ts +0 -4
- package/card/Card.js +0 -120
- package/card/Card.stories.tsx +0 -171
- package/card/Card.test.js +0 -39
- package/card/types.d.ts +0 -62
- package/card/types.js +0 -5
- package/checkbox/Checkbox.d.ts +0 -4
- package/checkbox/Checkbox.js +0 -215
- package/checkbox/Checkbox.stories.tsx +0 -222
- package/checkbox/Checkbox.test.js +0 -199
- package/checkbox/types.d.ts +0 -72
- package/checkbox/types.js +0 -5
- package/chip/Chip.d.ts +0 -4
- package/chip/Chip.js +0 -121
- package/chip/Chip.stories.tsx +0 -214
- package/chip/Chip.test.js +0 -41
- package/chip/types.d.ts +0 -45
- package/chip/types.js +0 -5
- package/common/OpenSans.css +0 -69
- package/common/coreTokens.d.ts +0 -237
- package/common/coreTokens.js +0 -184
- package/common/fonts/OpenSans-Bold.ttf +0 -0
- package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-Italic.ttf +0 -0
- package/common/fonts/OpenSans-Light.ttf +0 -0
- package/common/fonts/OpenSans-LightItalic.ttf +0 -0
- package/common/fonts/OpenSans-Regular.ttf +0 -0
- package/common/fonts/OpenSans-SemiBold.ttf +0 -0
- package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/common/utils.d.ts +0 -1
- package/common/utils.js +0 -16
- package/common/variables.d.ts +0 -1395
- package/common/variables.js +0 -1267
- package/container/Container.d.ts +0 -4
- package/container/Container.js +0 -194
- package/container/Container.stories.tsx +0 -214
- package/container/types.d.ts +0 -74
- package/container/types.js +0 -5
- package/date-input/Calendar.d.ts +0 -4
- package/date-input/Calendar.js +0 -214
- package/date-input/DateInput.d.ts +0 -4
- package/date-input/DateInput.js +0 -223
- package/date-input/DateInput.stories.tsx +0 -285
- package/date-input/DateInput.test.js +0 -808
- package/date-input/DatePicker.d.ts +0 -4
- package/date-input/DatePicker.js +0 -115
- package/date-input/Icons.d.ts +0 -6
- package/date-input/Icons.js +0 -58
- package/date-input/YearPicker.d.ts +0 -4
- package/date-input/YearPicker.js +0 -100
- package/date-input/types.d.ts +0 -164
- package/date-input/types.js +0 -5
- package/dialog/Dialog.d.ts +0 -4
- package/dialog/Dialog.js +0 -104
- package/dialog/Dialog.stories.tsx +0 -365
- package/dialog/Dialog.test.js +0 -307
- package/dialog/types.d.ts +0 -36
- package/dialog/types.js +0 -5
- package/dropdown/Dropdown.d.ts +0 -4
- package/dropdown/Dropdown.js +0 -336
- package/dropdown/Dropdown.stories.tsx +0 -438
- package/dropdown/Dropdown.test.js +0 -599
- package/dropdown/DropdownMenu.d.ts +0 -4
- package/dropdown/DropdownMenu.js +0 -63
- package/dropdown/DropdownMenuItem.d.ts +0 -4
- package/dropdown/DropdownMenuItem.js +0 -67
- package/dropdown/types.d.ts +0 -98
- package/dropdown/types.js +0 -5
- package/file-input/FileInput.d.ts +0 -4
- package/file-input/FileInput.js +0 -479
- package/file-input/FileInput.stories.tsx +0 -618
- package/file-input/FileInput.test.js +0 -459
- package/file-input/FileItem.d.ts +0 -4
- package/file-input/FileItem.js +0 -135
- package/file-input/types.d.ts +0 -129
- package/file-input/types.js +0 -5
- package/flex/Flex.d.ts +0 -4
- package/flex/Flex.js +0 -57
- package/flex/Flex.stories.tsx +0 -112
- package/flex/types.d.ts +0 -97
- package/flex/types.js +0 -5
- package/footer/Footer.d.ts +0 -4
- package/footer/Footer.js +0 -138
- package/footer/Footer.stories.tsx +0 -171
- package/footer/Footer.test.js +0 -85
- package/footer/Icons.d.ts +0 -3
- package/footer/Icons.js +0 -136
- package/footer/types.d.ts +0 -64
- package/footer/types.js +0 -5
- package/grid/Grid.d.ts +0 -7
- package/grid/Grid.js +0 -76
- package/grid/Grid.stories.tsx +0 -219
- package/grid/types.d.ts +0 -115
- package/grid/types.js +0 -5
- package/header/Header.d.ts +0 -8
- package/header/Header.js +0 -220
- package/header/Header.stories.tsx +0 -251
- package/header/Header.test.js +0 -66
- package/header/Icons.d.ts +0 -2
- package/header/Icons.js +0 -29
- package/header/types.d.ts +0 -33
- package/header/types.js +0 -5
- package/heading/Heading.d.ts +0 -4
- package/heading/Heading.js +0 -137
- package/heading/Heading.stories.tsx +0 -54
- package/heading/Heading.test.js +0 -169
- package/heading/types.d.ts +0 -33
- package/heading/types.js +0 -5
- package/image/Image.d.ts +0 -4
- package/image/Image.js +0 -70
- package/image/Image.stories.tsx +0 -129
- package/image/types.d.ts +0 -72
- package/image/types.js +0 -5
- package/inset/Inset.d.ts +0 -3
- package/inset/Inset.js +0 -43
- package/inset/Inset.stories.tsx +0 -230
- package/inset/types.d.ts +0 -37
- package/inset/types.js +0 -5
- package/layout/ApplicationLayout.d.ts +0 -20
- package/layout/ApplicationLayout.js +0 -134
- package/layout/ApplicationLayout.stories.tsx +0 -162
- package/layout/Icons.d.ts +0 -8
- package/layout/Icons.js +0 -58
- package/layout/SidenavContext.d.ts +0 -5
- package/layout/SidenavContext.js +0 -13
- package/layout/types.d.ts +0 -41
- package/layout/types.js +0 -5
- package/link/Link.d.ts +0 -4
- package/link/Link.js +0 -115
- package/link/Link.stories.tsx +0 -253
- package/link/Link.test.js +0 -63
- package/link/types.d.ts +0 -54
- package/link/types.js +0 -5
- package/main.d.ts +0 -47
- package/main.js +0 -343
- package/nav-tabs/NavTabs.d.ts +0 -8
- package/nav-tabs/NavTabs.js +0 -93
- package/nav-tabs/NavTabs.stories.tsx +0 -276
- package/nav-tabs/NavTabs.test.js +0 -76
- package/nav-tabs/Tab.d.ts +0 -4
- package/nav-tabs/Tab.js +0 -118
- package/nav-tabs/types.d.ts +0 -52
- package/nav-tabs/types.js +0 -5
- package/number-input/NumberInput.d.ts +0 -11
- package/number-input/NumberInput.js +0 -86
- package/number-input/NumberInput.stories.tsx +0 -131
- package/number-input/NumberInput.test.js +0 -989
- package/number-input/types.d.ts +0 -130
- package/number-input/types.js +0 -5
- package/paginator/Icons.d.ts +0 -5
- package/paginator/Icons.js +0 -40
- package/paginator/Paginator.d.ts +0 -4
- package/paginator/Paginator.js +0 -135
- package/paginator/Paginator.stories.tsx +0 -87
- package/paginator/Paginator.test.js +0 -335
- package/paginator/types.d.ts +0 -38
- package/paginator/types.js +0 -5
- package/paragraph/Paragraph.d.ts +0 -5
- package/paragraph/Paragraph.js +0 -22
- package/paragraph/Paragraph.stories.tsx +0 -27
- package/password-input/Icons.d.ts +0 -6
- package/password-input/Icons.js +0 -35
- package/password-input/PasswordInput.d.ts +0 -4
- package/password-input/PasswordInput.js +0 -97
- package/password-input/PasswordInput.stories.tsx +0 -99
- package/password-input/PasswordInput.test.js +0 -198
- package/password-input/types.d.ts +0 -111
- package/password-input/types.js +0 -5
- package/progress-bar/ProgressBar.d.ts +0 -4
- package/progress-bar/ProgressBar.js +0 -144
- package/progress-bar/ProgressBar.stories.tsx +0 -93
- package/progress-bar/ProgressBar.test.js +0 -93
- package/progress-bar/types.d.ts +0 -37
- package/progress-bar/types.js +0 -5
- package/quick-nav/QuickNav.d.ts +0 -4
- package/quick-nav/QuickNav.js +0 -94
- package/quick-nav/QuickNav.stories.tsx +0 -356
- package/quick-nav/types.d.ts +0 -21
- package/quick-nav/types.js +0 -5
- package/radio-group/Radio.d.ts +0 -4
- package/radio-group/Radio.js +0 -124
- package/radio-group/RadioGroup.d.ts +0 -4
- package/radio-group/RadioGroup.js +0 -235
- package/radio-group/RadioGroup.stories.tsx +0 -214
- package/radio-group/RadioGroup.test.js +0 -756
- package/radio-group/types.d.ts +0 -114
- package/radio-group/types.js +0 -5
- package/resultset-table/Icons.d.ts +0 -7
- package/resultset-table/Icons.js +0 -47
- package/resultset-table/ResultsetTable.d.ts +0 -7
- package/resultset-table/ResultsetTable.js +0 -166
- package/resultset-table/ResultsetTable.stories.tsx +0 -397
- package/resultset-table/ResultsetTable.test.js +0 -371
- package/resultset-table/types.d.ts +0 -73
- package/resultset-table/types.js +0 -5
- package/select/Icons.d.ts +0 -10
- package/select/Icons.js +0 -89
- package/select/Listbox.d.ts +0 -4
- package/select/Listbox.js +0 -143
- package/select/Option.d.ts +0 -4
- package/select/Option.js +0 -87
- package/select/Select.d.ts +0 -4
- package/select/Select.js +0 -590
- package/select/Select.stories.tsx +0 -971
- package/select/Select.test.js +0 -2370
- package/select/types.d.ts +0 -209
- package/select/types.js +0 -5
- package/sidenav/Icons.d.ts +0 -7
- package/sidenav/Icons.js +0 -47
- package/sidenav/Sidenav.d.ts +0 -10
- package/sidenav/Sidenav.js +0 -196
- package/sidenav/Sidenav.stories.tsx +0 -282
- package/sidenav/Sidenav.test.js +0 -37
- package/sidenav/types.d.ts +0 -76
- package/sidenav/types.js +0 -5
- package/slider/Slider.d.ts +0 -4
- package/slider/Slider.js +0 -285
- package/slider/Slider.test.js +0 -254
- package/slider/types.d.ts +0 -86
- package/slider/types.js +0 -5
- package/spinner/Spinner.d.ts +0 -4
- package/spinner/Spinner.js +0 -206
- package/spinner/Spinner.stories.tsx +0 -129
- package/spinner/Spinner.test.js +0 -55
- package/spinner/types.d.ts +0 -32
- package/spinner/types.js +0 -5
- package/status-light/StatusLight.d.ts +0 -4
- package/status-light/StatusLight.js +0 -51
- package/status-light/StatusLight.stories.tsx +0 -74
- package/status-light/StatusLight.test.js +0 -25
- package/status-light/types.d.ts +0 -17
- package/status-light/types.js +0 -5
- package/switch/Switch.d.ts +0 -4
- package/switch/Switch.js +0 -214
- package/switch/Switch.stories.tsx +0 -137
- package/switch/Switch.test.js +0 -180
- package/switch/types.d.ts +0 -66
- package/switch/types.js +0 -5
- package/table/DropdownTheme.js +0 -62
- package/table/Table.d.ts +0 -8
- package/table/Table.js +0 -170
- package/table/Table.stories.tsx +0 -658
- package/table/Table.test.js +0 -113
- package/table/types.d.ts +0 -63
- package/table/types.js +0 -5
- package/tabs/Tab.d.ts +0 -4
- package/tabs/Tab.js +0 -116
- package/tabs/Tabs.d.ts +0 -4
- package/tabs/Tabs.js +0 -384
- package/tabs/Tabs.stories.tsx +0 -226
- package/tabs/Tabs.test.js +0 -294
- package/tabs/types.d.ts +0 -92
- package/tabs/types.js +0 -5
- package/tag/Tag.d.ts +0 -4
- package/tag/Tag.js +0 -151
- package/tag/Tag.stories.tsx +0 -155
- package/tag/Tag.test.js +0 -49
- package/tag/types.d.ts +0 -69
- package/tag/types.js +0 -5
- package/text-input/Icons.d.ts +0 -8
- package/text-input/Icons.js +0 -56
- package/text-input/Suggestion.d.ts +0 -4
- package/text-input/Suggestion.js +0 -67
- package/text-input/Suggestions.d.ts +0 -4
- package/text-input/Suggestions.js +0 -84
- package/text-input/TextInput.d.ts +0 -4
- package/text-input/TextInput.js +0 -565
- package/text-input/TextInput.stories.tsx +0 -465
- package/text-input/TextInput.test.js +0 -1756
- package/text-input/types.d.ts +0 -205
- package/text-input/types.js +0 -5
- package/textarea/Textarea.d.ts +0 -4
- package/textarea/Textarea.js +0 -234
- package/textarea/Textarea.stories.tsx +0 -174
- package/textarea/Textarea.test.js +0 -406
- package/textarea/types.d.ts +0 -141
- package/textarea/types.js +0 -5
- package/toggle-group/ToggleGroup.d.ts +0 -4
- package/toggle-group/ToggleGroup.js +0 -201
- package/toggle-group/ToggleGroup.stories.tsx +0 -218
- package/toggle-group/ToggleGroup.test.js +0 -137
- package/toggle-group/types.d.ts +0 -114
- package/toggle-group/types.js +0 -5
- package/typography/Typography.d.ts +0 -4
- package/typography/Typography.js +0 -23
- package/typography/Typography.stories.tsx +0 -198
- package/typography/types.d.ts +0 -18
- package/typography/types.js +0 -5
- package/useTheme.d.ts +0 -1148
- package/useTheme.js +0 -15
- package/useTranslatedLabels.d.ts +0 -85
- package/useTranslatedLabels.js +0 -14
- package/utils/BaseTypography.d.ts +0 -21
- package/utils/BaseTypography.js +0 -94
- package/utils/FocusLock.d.ts +0 -13
- package/utils/FocusLock.js +0 -124
- package/wizard/Wizard.d.ts +0 -4
- package/wizard/Wizard.js +0 -250
- package/wizard/Wizard.stories.tsx +0 -253
- package/wizard/Wizard.test.js +0 -114
- package/wizard/types.d.ts +0 -64
- package/wizard/types.js +0 -5
package/dialog/Dialog.test.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
6
|
-
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
7
|
-
var _Dialog = _interopRequireDefault(require("./Dialog.tsx"));
|
|
8
|
-
var _TextInput = _interopRequireDefault(require("../text-input/TextInput.tsx"));
|
|
9
|
-
var _Textarea = _interopRequireDefault(require("../textarea/Textarea.tsx"));
|
|
10
|
-
var _Checkbox = _interopRequireDefault(require("../checkbox/Checkbox.tsx"));
|
|
11
|
-
var _Select = _interopRequireDefault(require("../select/Select.tsx"));
|
|
12
|
-
var _Button = _interopRequireDefault(require("../button/Button.tsx"));
|
|
13
|
-
var _Link = _interopRequireDefault(require("../link/Link.tsx"));
|
|
14
|
-
var _Card = _interopRequireDefault(require("../card/Card.tsx"));
|
|
15
|
-
var _RadioGroup = _interopRequireDefault(require("../radio-group/RadioGroup.tsx"));
|
|
16
|
-
var _Slider = _interopRequireDefault(require("../slider/Slider.tsx"));
|
|
17
|
-
var _Switch = _interopRequireDefault(require("../switch/Switch.tsx"));
|
|
18
|
-
var options = [{
|
|
19
|
-
label: "Female",
|
|
20
|
-
value: "female"
|
|
21
|
-
}, {
|
|
22
|
-
label: "Male",
|
|
23
|
-
value: "male"
|
|
24
|
-
}, {
|
|
25
|
-
label: "Non-binary",
|
|
26
|
-
value: "non-binary"
|
|
27
|
-
}, {
|
|
28
|
-
label: "Other",
|
|
29
|
-
value: "other"
|
|
30
|
-
}];
|
|
31
|
-
describe("Dialog component tests", function () {
|
|
32
|
-
test("Dialog renders with correct text and accesibility attributes", function () {
|
|
33
|
-
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, "dialog-text")),
|
|
34
|
-
getByText = _render.getByText,
|
|
35
|
-
getByRole = _render.getByRole;
|
|
36
|
-
expect(getByRole("dialog")).toBeTruthy();
|
|
37
|
-
expect(getByRole("dialog").getAttribute("aria-modal")).toBe("true");
|
|
38
|
-
expect(getByText("dialog-text")).toBeTruthy();
|
|
39
|
-
});
|
|
40
|
-
test("Dialog renders without close button", function () {
|
|
41
|
-
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
42
|
-
isCloseVisible: false
|
|
43
|
-
}, "dialog-text")),
|
|
44
|
-
queryByRole = _render2.queryByRole;
|
|
45
|
-
expect(queryByRole("button")).toBeFalsy();
|
|
46
|
-
});
|
|
47
|
-
test("Dialog renders with aria-modal false when overlay is not used", function () {
|
|
48
|
-
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
49
|
-
isCloseVisible: false,
|
|
50
|
-
overlay: false
|
|
51
|
-
}, "dialog-text")),
|
|
52
|
-
getByRole = _render3.getByRole;
|
|
53
|
-
expect(getByRole("dialog")).toBeTruthy();
|
|
54
|
-
expect(getByRole("dialog").getAttribute("aria-modal")).toBe("false");
|
|
55
|
-
});
|
|
56
|
-
test("Calls correct function onCloseClick", function () {
|
|
57
|
-
var onCloseClick = jest.fn();
|
|
58
|
-
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
59
|
-
onCloseClick: onCloseClick
|
|
60
|
-
}, "dialog-text")),
|
|
61
|
-
getByRole = _render4.getByRole;
|
|
62
|
-
var closeButton = getByRole("button");
|
|
63
|
-
_react2.fireEvent.click(closeButton);
|
|
64
|
-
expect(onCloseClick).toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
test("Calls correct function onCloseClick when 'Escape' key is pressed", function () {
|
|
67
|
-
var onCloseClick = jest.fn();
|
|
68
|
-
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
69
|
-
onCloseClick: onCloseClick
|
|
70
|
-
}, "dialog-text")),
|
|
71
|
-
getByRole = _render5.getByRole;
|
|
72
|
-
_react2.fireEvent.keyDown(getByRole("dialog"), {
|
|
73
|
-
key: "Escape",
|
|
74
|
-
code: "Escape",
|
|
75
|
-
keyCode: 27,
|
|
76
|
-
charCode: 27
|
|
77
|
-
});
|
|
78
|
-
expect(onCloseClick).toHaveBeenCalled();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe("Dialog component: Focus lock tests", function () {
|
|
82
|
-
test("Close action: when there's no focusable content, the focus never leaves the close action (unless you click outside)", function () {
|
|
83
|
-
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, "example-dialog")),
|
|
84
|
-
getByRole = _render6.getByRole;
|
|
85
|
-
var button = getByRole("button");
|
|
86
|
-
var dialog = getByRole("dialog");
|
|
87
|
-
expect(document.activeElement).toEqual(button);
|
|
88
|
-
expect(button.getAttribute("aria-label")).toBe("Close dialog");
|
|
89
|
-
_userEvent["default"].tab();
|
|
90
|
-
expect(document.activeElement).toEqual(button);
|
|
91
|
-
_react2.fireEvent.keyDown(dialog, {
|
|
92
|
-
key: "Tab",
|
|
93
|
-
shiftKey: true
|
|
94
|
-
});
|
|
95
|
-
expect(document.activeElement).toEqual(button);
|
|
96
|
-
});
|
|
97
|
-
test("Autofocus with Button component", function () {
|
|
98
|
-
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
99
|
-
label: "Accept"
|
|
100
|
-
}))),
|
|
101
|
-
getAllByRole = _render7.getAllByRole;
|
|
102
|
-
var button = getAllByRole("button")[0];
|
|
103
|
-
expect(document.activeElement).toEqual(button);
|
|
104
|
-
expect(button.getAttribute("aria-label")).not.toBe("Close dialog");
|
|
105
|
-
});
|
|
106
|
-
test("Autofocus with Card component", function () {
|
|
107
|
-
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
108
|
-
linkHref: "https://developer.dxc.com/halstack/next/components/card/"
|
|
109
|
-
}, "example-card"))),
|
|
110
|
-
getByRole = _render8.getByRole;
|
|
111
|
-
var card = getByRole("link");
|
|
112
|
-
expect(document.activeElement).toEqual(card);
|
|
113
|
-
});
|
|
114
|
-
test("Autofocus with Checkbox component", function () {
|
|
115
|
-
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
116
|
-
label: "Name"
|
|
117
|
-
}))),
|
|
118
|
-
getByRole = _render9.getByRole;
|
|
119
|
-
var checkbox = getByRole("checkbox");
|
|
120
|
-
expect(document.activeElement).toEqual(checkbox);
|
|
121
|
-
});
|
|
122
|
-
test("Autofocus with Link component", function () {
|
|
123
|
-
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, "This is a text with a ", /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
124
|
-
href: "#"
|
|
125
|
-
}, "Link"), " to another page.")),
|
|
126
|
-
getByRole = _render10.getByRole;
|
|
127
|
-
var link = getByRole("link");
|
|
128
|
-
expect(document.activeElement).toEqual(link);
|
|
129
|
-
});
|
|
130
|
-
test("Autofocus with RadioGroup component", function () {
|
|
131
|
-
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
132
|
-
label: "Example",
|
|
133
|
-
options: options
|
|
134
|
-
}))),
|
|
135
|
-
getAllByRole = _render11.getAllByRole;
|
|
136
|
-
var checkedRadio = getAllByRole("radio")[0];
|
|
137
|
-
expect(document.activeElement).toEqual(checkedRadio);
|
|
138
|
-
});
|
|
139
|
-
test("Autofocus with Select component", function () {
|
|
140
|
-
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
141
|
-
label: "Country",
|
|
142
|
-
options: options
|
|
143
|
-
}))),
|
|
144
|
-
getByRole = _render12.getByRole;
|
|
145
|
-
var select = getByRole("combobox");
|
|
146
|
-
expect(document.activeElement).toEqual(select);
|
|
147
|
-
});
|
|
148
|
-
test("Autofocus with Slider component", function () {
|
|
149
|
-
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Slider["default"], {
|
|
150
|
-
label: "label",
|
|
151
|
-
minValue: 0,
|
|
152
|
-
maxValue: 100,
|
|
153
|
-
showLimitsValues: true
|
|
154
|
-
}))),
|
|
155
|
-
getByRole = _render13.getByRole;
|
|
156
|
-
var slider = getByRole("slider");
|
|
157
|
-
expect(document.activeElement).toEqual(slider);
|
|
158
|
-
});
|
|
159
|
-
test("Autofocus with Switch component", function () {
|
|
160
|
-
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
|
|
161
|
-
label: "Example"
|
|
162
|
-
}))),
|
|
163
|
-
getByRole = _render14.getByRole;
|
|
164
|
-
var switchButton = getByRole("switch");
|
|
165
|
-
expect(document.activeElement).toEqual(switchButton);
|
|
166
|
-
});
|
|
167
|
-
test("Autofocus with Text Input component", function () {
|
|
168
|
-
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
169
|
-
label: "Name"
|
|
170
|
-
}))),
|
|
171
|
-
getByRole = _render15.getByRole;
|
|
172
|
-
var input = getByRole("textbox");
|
|
173
|
-
expect(document.activeElement).toEqual(input);
|
|
174
|
-
});
|
|
175
|
-
test("Autofocus with Textarea component", function () {
|
|
176
|
-
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
177
|
-
label: "Name"
|
|
178
|
-
}))),
|
|
179
|
-
getByRole = _render16.getByRole;
|
|
180
|
-
var textarea = getByRole("textbox");
|
|
181
|
-
expect(document.activeElement).toEqual(textarea);
|
|
182
|
-
});
|
|
183
|
-
test("Negative tabindex elements are not automatically focused, even if it is enabled and a valid focusable item (programatically and by click)", function () {
|
|
184
|
-
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
185
|
-
label: "Name",
|
|
186
|
-
tabIndex: -1
|
|
187
|
-
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
188
|
-
label: "Name"
|
|
189
|
-
}))),
|
|
190
|
-
getAllByRole = _render17.getAllByRole,
|
|
191
|
-
getByRole = _render17.getByRole;
|
|
192
|
-
var inputs = getAllByRole("textbox");
|
|
193
|
-
var button = getByRole("button");
|
|
194
|
-
expect(document.activeElement).toEqual(inputs[1]);
|
|
195
|
-
_userEvent["default"].tab();
|
|
196
|
-
expect(document.activeElement).toEqual(button);
|
|
197
|
-
_userEvent["default"].tab();
|
|
198
|
-
expect(document.activeElement).toEqual(inputs[1]);
|
|
199
|
-
});
|
|
200
|
-
test("Focus jumps disabled components and negative tabIndexes when autofocusing first item", function () {
|
|
201
|
-
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
202
|
-
label: "Accept",
|
|
203
|
-
disabled: true
|
|
204
|
-
}), /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
205
|
-
label: "Older age",
|
|
206
|
-
disabled: true
|
|
207
|
-
}), /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
208
|
-
label: "Country",
|
|
209
|
-
options: options,
|
|
210
|
-
disabled: true
|
|
211
|
-
}), /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
212
|
-
label: "Country",
|
|
213
|
-
options: options,
|
|
214
|
-
disabled: true
|
|
215
|
-
}), /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
216
|
-
label: "Name",
|
|
217
|
-
disabled: true
|
|
218
|
-
}), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
219
|
-
label: "Accept",
|
|
220
|
-
tabIndex: -1
|
|
221
|
-
}), /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
222
|
-
label: "Older age",
|
|
223
|
-
tabIndex: -1
|
|
224
|
-
}), /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
225
|
-
label: "Country",
|
|
226
|
-
options: options,
|
|
227
|
-
tabIndex: -1
|
|
228
|
-
}), /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
229
|
-
label: "Country",
|
|
230
|
-
options: options,
|
|
231
|
-
tabIndex: -1
|
|
232
|
-
}), /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
233
|
-
label: "Name",
|
|
234
|
-
tabIndex: -1
|
|
235
|
-
}), /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
236
|
-
label: "Description"
|
|
237
|
-
}))),
|
|
238
|
-
getAllByRole = _render18.getAllByRole;
|
|
239
|
-
var textarea = getAllByRole("textbox")[2];
|
|
240
|
-
expect(document.activeElement).toEqual(textarea);
|
|
241
|
-
});
|
|
242
|
-
test("Focus jumps from last element to the first", function () {
|
|
243
|
-
var _render19 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
244
|
-
label: "Accept",
|
|
245
|
-
disabled: true
|
|
246
|
-
}), /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
247
|
-
label: "Name"
|
|
248
|
-
}), /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
249
|
-
label: "Name",
|
|
250
|
-
options: options
|
|
251
|
-
}))),
|
|
252
|
-
getByRole = _render19.getByRole;
|
|
253
|
-
var closeAction = getByRole("button");
|
|
254
|
-
var textarea = getByRole("textbox");
|
|
255
|
-
expect(document.activeElement).toEqual(textarea);
|
|
256
|
-
_userEvent["default"].tab();
|
|
257
|
-
_userEvent["default"].tab();
|
|
258
|
-
expect(document.activeElement).toEqual(closeAction);
|
|
259
|
-
_userEvent["default"].tab();
|
|
260
|
-
expect(document.activeElement).toEqual(textarea);
|
|
261
|
-
});
|
|
262
|
-
test("'display: none;', 'visibility: hidden;' and 'type = 'hidden'' elements are never autofocused", function () {
|
|
263
|
-
var _render20 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
264
|
-
label: "Name",
|
|
265
|
-
style: {
|
|
266
|
-
display: "none"
|
|
267
|
-
}
|
|
268
|
-
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
269
|
-
label: "Name",
|
|
270
|
-
style: {
|
|
271
|
-
visibility: "hidden"
|
|
272
|
-
}
|
|
273
|
-
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
274
|
-
type: "hidden",
|
|
275
|
-
name: "example"
|
|
276
|
-
}))),
|
|
277
|
-
getByRole = _render20.getByRole;
|
|
278
|
-
var closeAction = getByRole("button");
|
|
279
|
-
expect(document.activeElement).toEqual(closeAction);
|
|
280
|
-
_userEvent["default"].tab();
|
|
281
|
-
expect(document.activeElement).toEqual(closeAction);
|
|
282
|
-
});
|
|
283
|
-
test("Focus gets trapped in the Dialog when there are not focusable elements inside until it is closed", function () {
|
|
284
|
-
var _render21 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
285
|
-
label: "Name"
|
|
286
|
-
}), /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
287
|
-
isCloseVisible: false
|
|
288
|
-
}, /*#__PURE__*/_react["default"].createElement("h2", null, "Policy agreement"), /*#__PURE__*/_react["default"].createElement("p", null, "Sample text.")), /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
289
|
-
label: "Surname"
|
|
290
|
-
}))),
|
|
291
|
-
getAllByRole = _render21.getAllByRole;
|
|
292
|
-
var inputs = getAllByRole("textbox");
|
|
293
|
-
var dialog = getAllByRole("dialog")[0];
|
|
294
|
-
_userEvent["default"].tab();
|
|
295
|
-
_userEvent["default"].tab();
|
|
296
|
-
expect(document.activeElement).not.toEqual(inputs[1]);
|
|
297
|
-
_react2.fireEvent.keyDown(dialog, {
|
|
298
|
-
key: "Tab",
|
|
299
|
-
shiftKey: true
|
|
300
|
-
});
|
|
301
|
-
_react2.fireEvent.keyDown(dialog, {
|
|
302
|
-
key: "Tab",
|
|
303
|
-
shiftKey: true
|
|
304
|
-
});
|
|
305
|
-
expect(document.activeElement).not.toEqual(inputs[0]);
|
|
306
|
-
});
|
|
307
|
-
});
|
package/dialog/types.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type Props = {
|
|
3
|
-
/**
|
|
4
|
-
* If true, the close button will be visible.
|
|
5
|
-
*/
|
|
6
|
-
isCloseVisible?: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* This function will be called when the user clicks the close button.
|
|
9
|
-
* The responsibility of hiding the dialog lies with the user.
|
|
10
|
-
*/
|
|
11
|
-
onCloseClick?: () => void;
|
|
12
|
-
/**
|
|
13
|
-
* This function will be called when the user clicks on the background of the modal.
|
|
14
|
-
* The responsibility of hiding the dialog lies with the user.
|
|
15
|
-
*/
|
|
16
|
-
onBackgroundClick?: () => void;
|
|
17
|
-
/**
|
|
18
|
-
* If true, the dialog will be displayed over a darker background that covers the content behind.
|
|
19
|
-
*/
|
|
20
|
-
overlay?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Area within the dialog that can be used to render custom content.
|
|
23
|
-
* We strongly encourage users to not change the
|
|
24
|
-
* tabindex of the inner components or elements. This
|
|
25
|
-
* can lead to unpredictable behaviour for keyboard users, affecting
|
|
26
|
-
* the order of focus and focus locking within the dialog.
|
|
27
|
-
*/
|
|
28
|
-
children: React.ReactNode;
|
|
29
|
-
/**
|
|
30
|
-
* Value of the tabindex applied to the close button.
|
|
31
|
-
* Note that values greater than 0 are strongly discouraged. It can
|
|
32
|
-
* lead to unexpected behaviours with the focus within the dialog.
|
|
33
|
-
*/
|
|
34
|
-
tabIndex?: number;
|
|
35
|
-
};
|
|
36
|
-
export default Props;
|
package/dialog/types.js
DELETED
package/dropdown/Dropdown.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import DropdownPropsType from "./types";
|
|
3
|
-
declare const DxcDropdown: ({ options, optionsIconPosition, icon, iconPosition, label, caretHidden, disabled, expandOnHover, onSelectOption, margin, size, tabIndex, }: DropdownPropsType) => JSX.Element;
|
|
4
|
-
export default DxcDropdown;
|