@dxc-technology/halstack-react 11.0.0 → 12.0.0
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 +1 -10
- package/BackgroundColorContext.js +3 -8
- package/HalstackContext.d.ts +32 -142
- package/HalstackContext.js +2 -2
- package/accordion/Accordion.accessibility.test.js +71 -0
- package/accordion/Accordion.js +13 -27
- package/accordion/Accordion.stories.tsx +7 -49
- package/accordion/types.d.ts +1 -1
- package/accordion-group/AccordionGroup.accessibility.test.js +88 -0
- package/accordion-group/AccordionGroup.d.ts +2 -3
- package/accordion-group/AccordionGroup.js +4 -4
- package/accordion-group/AccordionGroup.stories.tsx +23 -23
- package/accordion-group/AccordionGroupAccordion.js +3 -3
- package/accordion-group/AccordionGroupContext.d.ts +3 -0
- package/accordion-group/AccordionGroupContext.js +8 -0
- package/accordion-group/types.d.ts +1 -1
- package/action-icon/ActionIcon.accessibility.test.js +63 -0
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +48 -0
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/action-icon/types.js +5 -0
- package/alert/Alert.accessibility.test.js +95 -0
- package/alert/Alert.js +21 -75
- package/badge/Badge.accessibility.test.js +129 -0
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +141 -28
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/box/Box.accessibility.test.js +33 -0
- package/box/Box.js +2 -5
- package/breadcrumbs/Breadcrumbs.accessibility.test.d.ts +1 -0
- package/breadcrumbs/Breadcrumbs.accessibility.test.js +96 -0
- package/breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/breadcrumbs/Breadcrumbs.js +79 -0
- package/breadcrumbs/Breadcrumbs.stories.tsx +194 -0
- package/breadcrumbs/Breadcrumbs.test.d.ts +1 -0
- package/breadcrumbs/Breadcrumbs.test.js +169 -0
- package/breadcrumbs/Item.d.ts +4 -0
- package/breadcrumbs/Item.js +52 -0
- package/breadcrumbs/dropdownTheme.d.ts +53 -0
- package/breadcrumbs/dropdownTheme.js +62 -0
- package/breadcrumbs/types.d.ts +16 -0
- package/breadcrumbs/types.js +5 -0
- package/bulleted-list/BulletedList.accessibility.test.js +119 -0
- package/bulleted-list/BulletedList.js +16 -23
- package/bulleted-list/BulletedList.stories.tsx +1 -2
- package/button/Button.accessibility.test.js +127 -0
- package/button/Button.js +16 -16
- package/button/Button.stories.tsx +34 -53
- package/button/Button.test.js +3 -1
- package/button/types.d.ts +1 -1
- package/card/Card.accessibility.test.js +36 -0
- package/card/Card.js +3 -2
- package/checkbox/Checkbox.accessibility.test.js +87 -0
- package/checkbox/Checkbox.js +31 -36
- package/chip/Chip.accessibility.test.js +67 -0
- package/chip/Chip.js +11 -6
- package/chip/Chip.stories.tsx +10 -25
- package/chip/Chip.test.js +4 -4
- package/common/coreTokens.d.ts +105 -14
- package/common/coreTokens.js +40 -22
- package/common/variables.d.ts +31 -138
- package/common/variables.js +103 -210
- package/container/Container.d.ts +4 -0
- package/container/Container.js +194 -0
- package/container/Container.stories.tsx +214 -0
- package/container/types.d.ts +74 -0
- package/container/types.js +5 -0
- package/contextual-menu/ContextualMenu.accessibility.test.js +97 -0
- package/contextual-menu/ContextualMenu.d.ts +5 -0
- package/contextual-menu/ContextualMenu.js +88 -0
- package/contextual-menu/ContextualMenu.stories.tsx +232 -0
- package/contextual-menu/ContextualMenu.test.js +205 -0
- package/contextual-menu/GroupItem.d.ts +4 -0
- package/contextual-menu/GroupItem.js +67 -0
- package/contextual-menu/ItemAction.d.ts +4 -0
- package/contextual-menu/ItemAction.js +51 -0
- package/contextual-menu/MenuItem.d.ts +4 -0
- package/contextual-menu/MenuItem.js +29 -0
- package/contextual-menu/SingleItem.d.ts +4 -0
- package/contextual-menu/SingleItem.js +38 -0
- package/contextual-menu/types.d.ts +58 -0
- package/contextual-menu/types.js +5 -0
- package/date-input/Calendar.js +1 -1
- package/date-input/DateInput.accessibility.test.js +228 -0
- package/date-input/DateInput.js +4 -5
- package/date-input/DateInput.stories.tsx +15 -8
- package/date-input/DatePicker.js +13 -7
- package/date-input/YearPicker.js +1 -1
- package/date-input/types.d.ts +2 -2
- package/dialog/Dialog.accessibility.test.js +69 -0
- package/dialog/Dialog.js +11 -25
- package/dialog/Dialog.stories.tsx +176 -0
- package/dialog/Dialog.test.js +1 -1
- package/divider/Divider.accessibility.test.js +33 -0
- package/divider/Divider.d.ts +4 -0
- package/divider/Divider.js +36 -0
- package/divider/Divider.stories.tsx +223 -0
- package/divider/Divider.test.js +38 -0
- package/divider/types.d.ts +21 -0
- package/divider/types.js +5 -0
- package/dropdown/Dropdown.accessibility.test.js +180 -0
- package/dropdown/Dropdown.js +26 -39
- package/dropdown/Dropdown.stories.tsx +15 -26
- package/dropdown/Dropdown.test.js +18 -18
- package/dropdown/DropdownMenu.js +4 -4
- package/dropdown/DropdownMenuItem.js +8 -4
- package/dropdown/types.d.ts +3 -5
- package/file-input/FileInput.accessibility.test.js +160 -0
- package/file-input/FileInput.js +126 -141
- package/file-input/FileInput.test.js +84 -110
- package/file-input/FileItem.js +18 -28
- package/file-input/types.d.ts +1 -1
- package/footer/Footer.accessibility.test.js +125 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +36 -31
- package/footer/Footer.stories.tsx +58 -2
- package/footer/Icons.d.ts +1 -0
- package/footer/Icons.js +52 -16
- package/footer/types.d.ts +8 -8
- package/header/Header.accessibility.test.js +93 -0
- package/header/Header.js +20 -41
- package/header/Header.stories.tsx +16 -0
- package/header/Icons.js +1 -6
- package/header/types.d.ts +4 -3
- package/heading/Heading.accessibility.test.js +33 -0
- package/heading/Heading.js +1 -1
- package/icon/Icon.accessibility.test.js +30 -0
- package/icon/Icon.d.ts +4 -0
- package/icon/Icon.js +33 -0
- package/icon/Icon.stories.tsx +28 -0
- package/icon/types.d.ts +4 -0
- package/icon/types.js +5 -0
- package/image/Image.accessibility.test.js +56 -0
- package/image/Image.js +1 -1
- package/image/Image.stories.tsx +3 -1
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +10 -7
- package/layout/Icons.d.ts +0 -1
- package/layout/Icons.js +1 -11
- package/link/Link.accessibility.test.js +108 -0
- package/link/Link.js +8 -6
- package/link/Link.stories.tsx +4 -4
- package/link/types.d.ts +1 -1
- package/main.d.ts +7 -3
- package/main.js +37 -9
- package/nav-tabs/NavTabs.accessibility.test.js +44 -0
- package/nav-tabs/NavTabs.d.ts +1 -2
- package/nav-tabs/NavTabs.js +10 -7
- package/nav-tabs/NavTabs.stories.tsx +29 -24
- package/nav-tabs/NavTabs.test.js +11 -9
- package/nav-tabs/NavTabsContext.d.ts +3 -0
- package/nav-tabs/NavTabsContext.js +8 -0
- package/nav-tabs/Tab.js +23 -23
- package/nav-tabs/types.d.ts +1 -1
- package/number-input/NumberInput.accessibility.test.js +228 -0
- package/number-input/NumberInput.d.ts +0 -7
- package/number-input/NumberInput.js +24 -5
- package/number-input/NumberInput.test.js +165 -6
- package/number-input/NumberInputContext.d.ts +3 -0
- package/number-input/NumberInputContext.js +8 -0
- package/number-input/types.d.ts +6 -0
- package/package.json +16 -14
- package/paginator/Paginator.accessibility.test.js +79 -0
- package/paginator/Paginator.js +14 -14
- package/paragraph/Paragraph.accessibility.test.js +28 -0
- package/paragraph/Paragraph.js +2 -7
- package/password-input/PasswordInput.accessibility.test.js +153 -0
- package/password-input/PasswordInput.js +7 -7
- package/password-input/PasswordInput.stories.tsx +0 -1
- package/password-input/PasswordInput.test.js +4 -4
- package/progress-bar/ProgressBar.accessibility.test.js +35 -0
- package/progress-bar/ProgressBar.js +11 -15
- package/quick-nav/QuickNav.accessibility.test.js +57 -0
- package/quick-nav/QuickNav.js +1 -1
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.accessibility.test.js +97 -0
- package/radio-group/RadioGroup.js +3 -2
- package/resultset-table/ResultsetTable.accessibility.test.js +285 -0
- package/resultset-table/ResultsetTable.d.ts +4 -1
- package/resultset-table/ResultsetTable.js +25 -13
- package/resultset-table/ResultsetTable.stories.tsx +118 -5
- package/resultset-table/ResultsetTable.test.js +76 -0
- package/resultset-table/types.d.ts +40 -7
- package/select/Listbox.js +28 -16
- package/select/Option.js +19 -10
- package/select/Select.accessibility.test.js +228 -0
- package/select/Select.js +57 -37
- package/select/Select.stories.tsx +59 -111
- package/select/Select.test.js +387 -456
- package/select/types.d.ts +3 -3
- package/sidenav/Sidenav.accessibility.test.js +59 -0
- package/sidenav/Sidenav.js +21 -19
- package/sidenav/Sidenav.stories.tsx +4 -9
- package/sidenav/types.d.ts +2 -2
- package/slider/Slider.accessibility.test.js +104 -0
- package/slider/Slider.js +40 -48
- package/spinner/Spinner.accessibility.test.js +96 -0
- package/spinner/Spinner.js +12 -16
- package/status-light/StatusLight.accessibility.test.js +157 -0
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/switch/Switch.accessibility.test.js +98 -0
- package/switch/Switch.js +24 -29
- package/switch/Switch.stories.tsx +12 -0
- package/table/DropdownTheme.js +62 -0
- package/table/Table.accessibility.test.js +93 -0
- package/table/Table.d.ts +6 -2
- package/table/Table.js +74 -12
- package/table/Table.stories.tsx +309 -2
- package/table/Table.test.js +92 -0
- package/table/types.d.ts +28 -0
- package/tabs/Tab.js +13 -9
- package/tabs/Tabs.accessibility.test.js +56 -0
- package/tabs/Tabs.js +12 -24
- package/tabs/Tabs.stories.tsx +8 -4
- package/tabs/Tabs.test.js +19 -37
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.accessibility.test.js +69 -0
- package/tag/Tag.js +7 -7
- package/tag/Tag.stories.tsx +4 -7
- package/tag/Tag.test.js +4 -12
- package/tag/types.d.ts +2 -2
- package/text-input/Suggestion.js +1 -1
- package/text-input/Suggestions.js +19 -14
- package/text-input/TextInput.accessibility.test.js +321 -0
- package/text-input/TextInput.js +84 -105
- package/text-input/TextInput.stories.tsx +17 -8
- package/text-input/TextInput.test.js +96 -79
- package/textarea/Textarea.accessibility.test.js +155 -0
- package/textarea/Textarea.js +12 -17
- package/textarea/Textarea.stories.tsx +0 -1
- package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
- package/toggle-group/ToggleGroup.js +6 -8
- package/toggle-group/ToggleGroup.stories.tsx +3 -3
- package/toggle-group/types.d.ts +2 -2
- package/typography/Typography.accessibility.test.js +339 -0
- package/useTheme.d.ts +31 -138
- package/utils/BaseTypography.js +1 -1
- package/utils/FocusLock.js +16 -6
- package/wizard/Wizard.accessibility.test.js +55 -0
- package/wizard/Wizard.js +14 -25
- package/wizard/Wizard.stories.tsx +19 -0
- package/wizard/types.d.ts +2 -2
- package/common/OpenSans.css +0 -69
- 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/date-input/Icons.d.ts +0 -6
- package/date-input/Icons.js +0 -58
- package/paginator/Icons.d.ts +0 -5
- package/paginator/Icons.js +0 -40
- package/password-input/Icons.d.ts +0 -6
- package/password-input/Icons.js +0 -35
- package/select/Icons.d.ts +0 -10
- package/select/Icons.js +0 -89
- package/sidenav/Icons.d.ts +0 -7
- package/sidenav/Icons.js +0 -47
- package/text-input/Icons.d.ts +0 -8
- package/text-input/Icons.js +0 -56
- /package/{layout → sidenav}/SidenavContext.d.ts +0 -0
- /package/{layout → sidenav}/SidenavContext.js +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
/**
|
|
3
|
+
* The divider can be shown in horizontal or vertical.
|
|
4
|
+
*/
|
|
5
|
+
orientation?: "horizontal" | "vertical";
|
|
6
|
+
/**
|
|
7
|
+
* Modifies the thickness of the divider.
|
|
8
|
+
*/
|
|
9
|
+
weight?: "regular" | "strong";
|
|
10
|
+
/**
|
|
11
|
+
* Modifies the color of the divider.
|
|
12
|
+
*/
|
|
13
|
+
color?: "lightGrey" | "mediumGrey" | "darkGrey";
|
|
14
|
+
/**
|
|
15
|
+
* Specifies whether the divider serves a purely decorative purpose
|
|
16
|
+
* or functions as a semantic separator for content. Additionally, it
|
|
17
|
+
* determines whether the divider is accessible to screen readers.
|
|
18
|
+
*/
|
|
19
|
+
decorative?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export default Props;
|
package/divider/types.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
5
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _react2 = require("@testing-library/react");
|
|
10
|
+
var _axeHelper = require("../../test/accessibility/axe-helper.js");
|
|
11
|
+
var _Dropdown = _interopRequireDefault(require("./Dropdown.tsx"));
|
|
12
|
+
var iconSVG = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
height: "24",
|
|
15
|
+
width: "24",
|
|
16
|
+
fill: "currentColor"
|
|
17
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
18
|
+
d: "M0 0h24v24H0z",
|
|
19
|
+
fill: "none"
|
|
20
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
21
|
+
d: "M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"
|
|
22
|
+
}));
|
|
23
|
+
var iconUrl = "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png";
|
|
24
|
+
|
|
25
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
26
|
+
global.globalThis = global;
|
|
27
|
+
global.DOMRect = {
|
|
28
|
+
fromRect: function fromRect() {
|
|
29
|
+
return {
|
|
30
|
+
top: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
bottom: 0,
|
|
33
|
+
right: 0,
|
|
34
|
+
width: 0,
|
|
35
|
+
height: 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
40
|
+
function ResizeObserver() {
|
|
41
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
42
|
+
}
|
|
43
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
44
|
+
key: "observe",
|
|
45
|
+
value: function observe() {}
|
|
46
|
+
}, {
|
|
47
|
+
key: "unobserve",
|
|
48
|
+
value: function unobserve() {}
|
|
49
|
+
}, {
|
|
50
|
+
key: "disconnect",
|
|
51
|
+
value: function disconnect() {}
|
|
52
|
+
}]);
|
|
53
|
+
return ResizeObserver;
|
|
54
|
+
}();
|
|
55
|
+
var options = [{
|
|
56
|
+
value: "1",
|
|
57
|
+
label: "Amazon",
|
|
58
|
+
icon: iconUrl
|
|
59
|
+
}, {
|
|
60
|
+
value: "2",
|
|
61
|
+
label: "Ebay",
|
|
62
|
+
icon: iconUrl
|
|
63
|
+
}, {
|
|
64
|
+
value: "3",
|
|
65
|
+
label: "Wallapop",
|
|
66
|
+
icon: iconSVG
|
|
67
|
+
}, {
|
|
68
|
+
value: "4",
|
|
69
|
+
label: "Aliexpress",
|
|
70
|
+
icon: iconSVG
|
|
71
|
+
}];
|
|
72
|
+
describe("Dropdown component accessibility tests", function () {
|
|
73
|
+
it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
74
|
+
var _render, baseElement, results;
|
|
75
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
76
|
+
while (1) switch (_context.prev = _context.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
// baseElement is needed when using React Portals
|
|
79
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
|
|
80
|
+
options: options,
|
|
81
|
+
label: "dropdown-test",
|
|
82
|
+
icon: iconSVG,
|
|
83
|
+
iconPosition: "before",
|
|
84
|
+
margin: "medium",
|
|
85
|
+
size: "medium",
|
|
86
|
+
optionsIconPosition: "before"
|
|
87
|
+
})), baseElement = _render.baseElement;
|
|
88
|
+
_context.next = 3;
|
|
89
|
+
return (0, _axeHelper.axe)(baseElement);
|
|
90
|
+
case 3:
|
|
91
|
+
results = _context.sent;
|
|
92
|
+
expect(results).toHaveNoViolations();
|
|
93
|
+
case 5:
|
|
94
|
+
case "end":
|
|
95
|
+
return _context.stop();
|
|
96
|
+
}
|
|
97
|
+
}, _callee);
|
|
98
|
+
})));
|
|
99
|
+
it("Should not have basic accessibility issues for disabled mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
100
|
+
var _render2, baseElement, results;
|
|
101
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
102
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
// baseElement is needed when using React Portals
|
|
105
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
|
|
106
|
+
options: options,
|
|
107
|
+
label: "dropdown-test",
|
|
108
|
+
icon: iconSVG,
|
|
109
|
+
iconPosition: "before",
|
|
110
|
+
margin: "medium",
|
|
111
|
+
size: "medium",
|
|
112
|
+
optionsIconPosition: "before",
|
|
113
|
+
disabled: true
|
|
114
|
+
})), baseElement = _render2.baseElement;
|
|
115
|
+
_context2.next = 3;
|
|
116
|
+
return (0, _axeHelper.axe)(baseElement);
|
|
117
|
+
case 3:
|
|
118
|
+
results = _context2.sent;
|
|
119
|
+
expect(results).toHaveNoViolations();
|
|
120
|
+
case 5:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context2.stop();
|
|
123
|
+
}
|
|
124
|
+
}, _callee2);
|
|
125
|
+
})));
|
|
126
|
+
it("Should not have basic accessibility issues for caret-hidden mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
127
|
+
var _render3, baseElement, results;
|
|
128
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
129
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
// baseElement is needed when using React Portals
|
|
132
|
+
_render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
|
|
133
|
+
options: options,
|
|
134
|
+
label: "dropdown-test",
|
|
135
|
+
icon: iconSVG,
|
|
136
|
+
iconPosition: "after",
|
|
137
|
+
margin: "medium",
|
|
138
|
+
size: "medium",
|
|
139
|
+
optionsIconPosition: "after",
|
|
140
|
+
caretHidden: true
|
|
141
|
+
})), baseElement = _render3.baseElement;
|
|
142
|
+
_context3.next = 3;
|
|
143
|
+
return (0, _axeHelper.axe)(baseElement);
|
|
144
|
+
case 3:
|
|
145
|
+
results = _context3.sent;
|
|
146
|
+
expect(results).toHaveNoViolations();
|
|
147
|
+
case 5:
|
|
148
|
+
case "end":
|
|
149
|
+
return _context3.stop();
|
|
150
|
+
}
|
|
151
|
+
}, _callee3);
|
|
152
|
+
})));
|
|
153
|
+
it("Should not have basic accessibility issues for expand-on-hover mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
154
|
+
var _render4, baseElement, results;
|
|
155
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
156
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
// baseElement is needed when using React Portals
|
|
159
|
+
_render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
|
|
160
|
+
options: options,
|
|
161
|
+
label: "dropdown-test",
|
|
162
|
+
icon: iconSVG,
|
|
163
|
+
iconPosition: "after",
|
|
164
|
+
margin: "medium",
|
|
165
|
+
size: "medium",
|
|
166
|
+
optionsIconPosition: "after",
|
|
167
|
+
expandOnHover: true
|
|
168
|
+
})), baseElement = _render4.baseElement;
|
|
169
|
+
_context4.next = 3;
|
|
170
|
+
return (0, _axeHelper.axe)(baseElement);
|
|
171
|
+
case 3:
|
|
172
|
+
results = _context4.sent;
|
|
173
|
+
expect(results).toHaveNoViolations();
|
|
174
|
+
case 5:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context4.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee4);
|
|
179
|
+
})));
|
|
180
|
+
});
|
package/dropdown/Dropdown.js
CHANGED
|
@@ -17,33 +17,10 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
17
17
|
var _uuid = require("uuid");
|
|
18
18
|
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
19
19
|
var _DropdownMenu = _interopRequireDefault(require("./DropdownMenu"));
|
|
20
|
+
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
20
21
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
21
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
23
|
-
var upArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
24
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
-
width: "24",
|
|
26
|
-
height: "24",
|
|
27
|
-
viewBox: "0 0 24 24",
|
|
28
|
-
fill: "currentColor"
|
|
29
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
30
|
-
d: "M7 14l5-5 5 5z"
|
|
31
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
32
|
-
d: "M0 0h24v24H0z",
|
|
33
|
-
fill: "none"
|
|
34
|
-
}));
|
|
35
|
-
var downArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
36
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
37
|
-
width: "24",
|
|
38
|
-
height: "24",
|
|
39
|
-
viewBox: "0 0 24 24",
|
|
40
|
-
fill: "currentColor"
|
|
41
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
42
|
-
d: "M7 10l5 5 5-5z"
|
|
43
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
44
|
-
d: "M0 0h24v24H0z",
|
|
45
|
-
fill: "none"
|
|
46
|
-
}));
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
47
24
|
var useWidth = function useWidth(target) {
|
|
48
25
|
var _useState = (0, _react.useState)(0),
|
|
49
26
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -224,18 +201,22 @@ var DxcDropdown = function DxcDropdown(_ref) {
|
|
|
224
201
|
size: size,
|
|
225
202
|
id: triggerId,
|
|
226
203
|
"aria-haspopup": "true",
|
|
227
|
-
"aria-controls": menuId,
|
|
204
|
+
"aria-controls": isOpen ? menuId : undefined,
|
|
228
205
|
"aria-expanded": isOpen ? true : undefined,
|
|
206
|
+
"aria-label": "Show options",
|
|
229
207
|
tabIndex: tabIndex,
|
|
230
208
|
ref: triggerRef
|
|
231
209
|
}, /*#__PURE__*/_react["default"].createElement(DropdownTriggerContent, null, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(DropdownTriggerLabel, null, label), icon && /*#__PURE__*/_react["default"].createElement(DropdownTriggerIcon, {
|
|
232
210
|
disabled: disabled,
|
|
233
|
-
role: typeof icon === "string" ? undefined : "img"
|
|
234
|
-
|
|
235
|
-
|
|
211
|
+
role: typeof icon === "string" ? undefined : "img",
|
|
212
|
+
"aria-hidden": true
|
|
213
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
214
|
+
icon: icon
|
|
236
215
|
}) : icon), label && iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(DropdownTriggerLabel, null, label)), !caretHidden && /*#__PURE__*/_react["default"].createElement(CaretIcon, {
|
|
237
216
|
disabled: disabled
|
|
238
|
-
},
|
|
217
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
218
|
+
icon: isOpen ? "arrow_drop_up" : "arrow_drop_down"
|
|
219
|
+
}), " "))), /*#__PURE__*/_react["default"].createElement(Popover.Portal, null, /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
239
220
|
asChild: true,
|
|
240
221
|
sideOffset: 1
|
|
241
222
|
}, /*#__PURE__*/_react["default"].createElement(_DropdownMenu["default"], {
|
|
@@ -263,7 +244,7 @@ var sizes = {
|
|
|
263
244
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
264
245
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
265
246
|
};
|
|
266
|
-
var DropdownContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
247
|
+
var DropdownContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
267
248
|
return calculateWidth(props.margin, props.size);
|
|
268
249
|
}, function (props) {
|
|
269
250
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -276,18 +257,20 @@ var DropdownContainer = _styledComponents["default"].div(_templateObject || (_te
|
|
|
276
257
|
}, function (props) {
|
|
277
258
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
278
259
|
});
|
|
279
|
-
var DropdownTrigger = _styledComponents["default"].button(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: ", ";\n width: 100%;\n
|
|
260
|
+
var DropdownTrigger = _styledComponents["default"].button(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: ", ";\n width: 100%;\n height: ", ";\n min-width: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n background-color: ", ";\n color: ", ";\n cursor: ", ";\n\n ", ";\n"])), function (props) {
|
|
280
261
|
return props.theme.caretIconSpacing;
|
|
262
|
+
}, function (props) {
|
|
263
|
+
return props.theme.buttonHeight;
|
|
281
264
|
}, function (props) {
|
|
282
265
|
return props.label === "" ? "0px" : calculateWidth(props.margin, props.size);
|
|
283
266
|
}, function (props) {
|
|
284
|
-
return props.theme.
|
|
267
|
+
return props.theme.buttonBorderRadius;
|
|
285
268
|
}, function (props) {
|
|
286
|
-
return props.theme.
|
|
269
|
+
return props.theme.buttonBorderThickness;
|
|
287
270
|
}, function (props) {
|
|
288
|
-
return props.theme.
|
|
271
|
+
return props.theme.buttonBorderStyle;
|
|
289
272
|
}, function (props) {
|
|
290
|
-
return props.disabled ? props.theme.
|
|
273
|
+
return props.disabled ? props.theme.disabledButtonBorderColor : props.theme.buttonBorderColor;
|
|
291
274
|
}, function (props) {
|
|
292
275
|
return props.theme.buttonPaddingTop;
|
|
293
276
|
}, function (props) {
|
|
@@ -303,7 +286,7 @@ var DropdownTrigger = _styledComponents["default"].button(_templateObject2 || (_
|
|
|
303
286
|
}, function (props) {
|
|
304
287
|
return props.disabled ? "not-allowed" : "pointer";
|
|
305
288
|
}, function (props) {
|
|
306
|
-
return !props.disabled && "\n &:focus {\n outline: ".concat(props.theme.focusColor, "
|
|
289
|
+
return !props.disabled && "\n &:focus {\n outline: 2px solid ".concat(props.theme.focusColor, ";\n }\n &:hover {\n background-color: ").concat(props.theme.hoverButtonBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(props.theme.activeButtonBackgroundColor, ";\n }\n ");
|
|
307
290
|
});
|
|
308
291
|
var DropdownTriggerContent = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n gap: ", ";\n margin-left: 0px;\n margin-right: 0px;\n width: 100%;\n overflow: hidden;\n white-space: nowrap;\n"])), function (props) {
|
|
309
292
|
return props.theme.buttonIconSpacing;
|
|
@@ -317,18 +300,22 @@ var DropdownTriggerLabel = _styledComponents["default"].span(_templateObject4 ||
|
|
|
317
300
|
}, function (props) {
|
|
318
301
|
return props.theme.buttonFontWeight;
|
|
319
302
|
});
|
|
320
|
-
var DropdownTriggerIcon = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n\n
|
|
303
|
+
var DropdownTriggerIcon = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n font-size: ", ";\n\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
321
304
|
return props.disabled ? props.theme.disabledColor : props.theme.buttonIconColor;
|
|
322
305
|
}, function (props) {
|
|
323
306
|
return props.theme.buttonIconSize;
|
|
324
307
|
}, function (props) {
|
|
325
308
|
return props.theme.buttonIconSize;
|
|
309
|
+
}, function (props) {
|
|
310
|
+
return props.theme.buttonIconSize;
|
|
326
311
|
});
|
|
327
|
-
var CaretIcon = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
312
|
+
var CaretIcon = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n font-size: ", ";\n\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
328
313
|
return props.disabled ? props.theme.disabledColor : props.theme.caretIconColor;
|
|
329
314
|
}, function (props) {
|
|
330
315
|
return props.theme.caretIconSize;
|
|
331
316
|
}, function (props) {
|
|
332
317
|
return props.theme.caretIconSize;
|
|
318
|
+
}, function (props) {
|
|
319
|
+
return props.theme.caretIconSize;
|
|
333
320
|
});
|
|
334
321
|
var _default = exports["default"] = DxcDropdown;
|
|
@@ -15,11 +15,6 @@ export default {
|
|
|
15
15
|
component: DxcDropdown,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const hamburguerIcon = (
|
|
19
|
-
<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20">
|
|
20
|
-
<path d="M3 14.5V13h14v1.5Zm0-3.75v-1.5h14v1.5ZM3 7V5.5h14V7Z" />
|
|
21
|
-
</svg>
|
|
22
|
-
);
|
|
23
18
|
const iconSVG = (
|
|
24
19
|
<svg viewBox="0 0 24 24" height="24" width="24" fill="currentColor">
|
|
25
20
|
<path d="M0 0h24v24H0z" fill="none" />
|
|
@@ -31,8 +26,7 @@ const iconSVGLarge = (
|
|
|
31
26
|
<path d="M11 44q-1.2 0-2.1-.9Q8 42.2 8 41V15q0-1.2.9-2.1.9-.9 2.1-.9h5.5v-.5q0-3.15 2.175-5.325Q20.85 4 24 4q3.15 0 5.325 2.175Q31.5 8.35 31.5 11.5v.5H37q1.2 0 2.1.9.9.9.9 2.1v26q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h26V15h-5.5v4.5q0 .65-.425 1.075Q30.65 21 30 21q-.65 0-1.075-.425-.425-.425-.425-1.075V15h-9v4.5q0 .65-.425 1.075Q18.65 21 18 21q-.65 0-1.075-.425-.425-.425-.425-1.075V15H11v26Zm8.5-29h9v-.5q0-1.9-1.3-3.2Q25.9 7 24 7q-1.9 0-3.2 1.3-1.3 1.3-1.3 3.2ZM11 41V15v26Z" />
|
|
32
27
|
</svg>
|
|
33
28
|
);
|
|
34
|
-
const
|
|
35
|
-
const icons = [iconSVG, iconSVGLarge, iconUrl];
|
|
29
|
+
const icons = [iconSVG, iconSVGLarge, "nutrition"];
|
|
36
30
|
|
|
37
31
|
const defaultOptions: Option[] = [
|
|
38
32
|
{
|
|
@@ -86,7 +80,7 @@ const optionWithIcon: Option[] = [
|
|
|
86
80
|
{
|
|
87
81
|
value: "1",
|
|
88
82
|
label: "Ebay",
|
|
89
|
-
icon:
|
|
83
|
+
icon: "shopping_cart",
|
|
90
84
|
},
|
|
91
85
|
];
|
|
92
86
|
|
|
@@ -136,7 +130,7 @@ const Dropdown = () => (
|
|
|
136
130
|
label="Icon after"
|
|
137
131
|
options={options}
|
|
138
132
|
onSelectOption={(value) => {}}
|
|
139
|
-
icon="
|
|
133
|
+
icon="shopping_cart"
|
|
140
134
|
iconPosition="after"
|
|
141
135
|
/>
|
|
142
136
|
</ExampleContainer>
|
|
@@ -146,7 +140,7 @@ const Dropdown = () => (
|
|
|
146
140
|
</ExampleContainer>
|
|
147
141
|
<ExampleContainer>
|
|
148
142
|
<Title title="Only icon without caret" theme="light" level={4} />
|
|
149
|
-
<DxcDropdown options={options} onSelectOption={(value) => {}} icon=
|
|
143
|
+
<DxcDropdown options={options} onSelectOption={(value) => {}} icon="menu" caretHidden />
|
|
150
144
|
</ExampleContainer>
|
|
151
145
|
<ExampleContainer>
|
|
152
146
|
<Title title="Large icon (SVG)" theme="light" level={4} />
|
|
@@ -154,12 +148,7 @@ const Dropdown = () => (
|
|
|
154
148
|
</ExampleContainer>
|
|
155
149
|
<ExampleContainer>
|
|
156
150
|
<Title title="Large icon (image)" theme="light" level={4} />
|
|
157
|
-
<DxcDropdown
|
|
158
|
-
label="Large icon"
|
|
159
|
-
options={options}
|
|
160
|
-
onSelectOption={(value) => {}}
|
|
161
|
-
icon="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Hamburger_icon.svg/2048px-Hamburger_icon.svg.png"
|
|
162
|
-
/>
|
|
151
|
+
<DxcDropdown label="Large icon" options={options} onSelectOption={(value) => {}} icon="menu" />
|
|
163
152
|
</ExampleContainer>
|
|
164
153
|
<ExampleContainer>
|
|
165
154
|
<Title title="Disabled with icon" theme="light" level={4} />
|
|
@@ -292,8 +281,8 @@ const DropdownListStates = () => {
|
|
|
292
281
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
293
282
|
<Title title="Hovered option" theme="light" level={4} />
|
|
294
283
|
<DropdownMenu
|
|
295
|
-
id="
|
|
296
|
-
dropdownTriggerId="
|
|
284
|
+
id="x1"
|
|
285
|
+
dropdownTriggerId="dtx1"
|
|
297
286
|
iconsPosition="before"
|
|
298
287
|
visualFocusIndex={-1}
|
|
299
288
|
menuItemOnClick={(value) => {}}
|
|
@@ -305,8 +294,8 @@ const DropdownListStates = () => {
|
|
|
305
294
|
<ExampleContainer pseudoState="pseudo-active">
|
|
306
295
|
<Title title="Active option" theme="light" level={4} />
|
|
307
296
|
<DropdownMenu
|
|
308
|
-
id="
|
|
309
|
-
dropdownTriggerId="
|
|
297
|
+
id="x2"
|
|
298
|
+
dropdownTriggerId="dtx2"
|
|
310
299
|
iconsPosition="before"
|
|
311
300
|
visualFocusIndex={-1}
|
|
312
301
|
menuItemOnClick={(value) => {}}
|
|
@@ -318,8 +307,8 @@ const DropdownListStates = () => {
|
|
|
318
307
|
<ExampleContainer>
|
|
319
308
|
<Title title="Focused option" theme="light" level={4} />
|
|
320
309
|
<DropdownMenu
|
|
321
|
-
id="
|
|
322
|
-
dropdownTriggerId="
|
|
310
|
+
id="x3"
|
|
311
|
+
dropdownTriggerId="dtx3"
|
|
323
312
|
iconsPosition="before"
|
|
324
313
|
visualFocusIndex={0}
|
|
325
314
|
menuItemOnClick={(value) => {}}
|
|
@@ -332,8 +321,8 @@ const DropdownListStates = () => {
|
|
|
332
321
|
<ExampleContainer>
|
|
333
322
|
<Title title="Before" theme="light" level={4} />
|
|
334
323
|
<DropdownMenu
|
|
335
|
-
id="
|
|
336
|
-
dropdownTriggerId="
|
|
324
|
+
id="x4"
|
|
325
|
+
dropdownTriggerId="dtx4"
|
|
337
326
|
iconsPosition="before"
|
|
338
327
|
visualFocusIndex={-1}
|
|
339
328
|
menuItemOnClick={(value) => {}}
|
|
@@ -343,8 +332,8 @@ const DropdownListStates = () => {
|
|
|
343
332
|
/>
|
|
344
333
|
<Title title="After" theme="light" level={4} />
|
|
345
334
|
<DropdownMenu
|
|
346
|
-
id="
|
|
347
|
-
dropdownTriggerId="
|
|
335
|
+
id="x5"
|
|
336
|
+
dropdownTriggerId="dtx5"
|
|
348
337
|
iconsPosition="after"
|
|
349
338
|
visualFocusIndex={-1}
|
|
350
339
|
menuItemOnClick={(value) => {}}
|
|
@@ -72,7 +72,7 @@ describe("Dropdown component tests", function () {
|
|
|
72
72
|
menu = getByRole("menu");
|
|
73
73
|
expect(dropdown.getAttribute("aria-controls")).toBe(menu.id);
|
|
74
74
|
expect(dropdown.getAttribute("aria-expanded")).toBe("true");
|
|
75
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
75
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
76
76
|
expect(menu.getAttribute("aria-orientation")).toBe("vertical");
|
|
77
77
|
expect(menu.getAttribute("aria-labelledby")).toBe(dropdown.id);
|
|
78
78
|
expect(getAllByRole("menuitem").length).toBe(4);
|
|
@@ -180,7 +180,7 @@ describe("Dropdown component tests", function () {
|
|
|
180
180
|
var menu = getByRole("menu");
|
|
181
181
|
expect(menu).toBeTruthy();
|
|
182
182
|
expect(document.activeElement === menu).toBeTruthy();
|
|
183
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
183
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
184
184
|
});
|
|
185
185
|
test("The menu is closed when the dropdown loses the focus (blur)", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
186
186
|
var _render6, getByRole, queryByRole, dropdown;
|
|
@@ -220,7 +220,7 @@ describe("Dropdown component tests", function () {
|
|
|
220
220
|
var menu = getByRole("menu");
|
|
221
221
|
expect(menu).toBeTruthy();
|
|
222
222
|
expect(document.activeElement === menu).toBeTruthy();
|
|
223
|
-
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("option-3");
|
|
223
|
+
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-3"));
|
|
224
224
|
});
|
|
225
225
|
test("Menu button key events - Arrow down opens the list and moves the focus to the first menu item", function () {
|
|
226
226
|
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
|
|
@@ -238,7 +238,7 @@ describe("Dropdown component tests", function () {
|
|
|
238
238
|
var menu = getByRole("menu");
|
|
239
239
|
expect(menu).toBeTruthy();
|
|
240
240
|
expect(document.activeElement === menu).toBeTruthy();
|
|
241
|
-
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("option-0");
|
|
241
|
+
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
242
242
|
});
|
|
243
243
|
test("Menu button key events - Enter opens the list and moves the focus to the first menu item", function () {
|
|
244
244
|
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
|
|
@@ -256,7 +256,7 @@ describe("Dropdown component tests", function () {
|
|
|
256
256
|
var menu = getByRole("menu");
|
|
257
257
|
expect(menu).toBeTruthy();
|
|
258
258
|
expect(document.activeElement === menu).toBeTruthy();
|
|
259
|
-
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("option-0");
|
|
259
|
+
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
260
260
|
});
|
|
261
261
|
test("Menu button key events - Space opens the list and moves the focus to the first menu item", function () {
|
|
262
262
|
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
|
|
@@ -274,7 +274,7 @@ describe("Dropdown component tests", function () {
|
|
|
274
274
|
var menu = getByRole("menu");
|
|
275
275
|
expect(menu).toBeTruthy();
|
|
276
276
|
expect(document.activeElement === menu).toBeTruthy();
|
|
277
|
-
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("option-0");
|
|
277
|
+
expect(getByRole("menu").getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
278
278
|
});
|
|
279
279
|
test("Menu key events - Arrow up moves the focus to the previous menu item", function () {
|
|
280
280
|
var onSelectOption = jest.fn();
|
|
@@ -298,7 +298,7 @@ describe("Dropdown component tests", function () {
|
|
|
298
298
|
charCode: 38
|
|
299
299
|
});
|
|
300
300
|
expect(document.activeElement === menu).toBeTruthy();
|
|
301
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-2");
|
|
301
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-2"));
|
|
302
302
|
_react2.fireEvent.keyDown(menu, {
|
|
303
303
|
key: "Enter",
|
|
304
304
|
code: "Enter",
|
|
@@ -329,7 +329,7 @@ describe("Dropdown component tests", function () {
|
|
|
329
329
|
charCode: 38
|
|
330
330
|
});
|
|
331
331
|
expect(document.activeElement === menu).toBeTruthy();
|
|
332
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-3");
|
|
332
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-3"));
|
|
333
333
|
_react2.fireEvent.keyDown(menu, {
|
|
334
334
|
key: "Enter",
|
|
335
335
|
code: "Enter",
|
|
@@ -371,7 +371,7 @@ describe("Dropdown component tests", function () {
|
|
|
371
371
|
charCode: 40
|
|
372
372
|
});
|
|
373
373
|
expect(document.activeElement === menu).toBeTruthy();
|
|
374
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-2");
|
|
374
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-2"));
|
|
375
375
|
_react2.fireEvent.keyDown(menu, {
|
|
376
376
|
key: "Enter",
|
|
377
377
|
code: "Enter",
|
|
@@ -407,7 +407,7 @@ describe("Dropdown component tests", function () {
|
|
|
407
407
|
charCode: 40
|
|
408
408
|
});
|
|
409
409
|
expect(document.activeElement === menu).toBeTruthy();
|
|
410
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
410
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
411
411
|
_react2.fireEvent.keyDown(menu, {
|
|
412
412
|
key: "Enter",
|
|
413
413
|
code: "Enter",
|
|
@@ -484,14 +484,14 @@ describe("Dropdown component tests", function () {
|
|
|
484
484
|
charCode: 38
|
|
485
485
|
});
|
|
486
486
|
var menu = getByRole("menu");
|
|
487
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-3");
|
|
487
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-3"));
|
|
488
488
|
_react2.fireEvent.keyDown(menu, {
|
|
489
489
|
key: "Home",
|
|
490
490
|
code: "Home",
|
|
491
491
|
keyCode: 36,
|
|
492
492
|
charCode: 36
|
|
493
493
|
});
|
|
494
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
494
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
495
495
|
});
|
|
496
496
|
test("Menu key events - End moves the focus to the last menu item", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
|
|
497
497
|
var _render18, getByRole, menu;
|
|
@@ -506,14 +506,14 @@ describe("Dropdown component tests", function () {
|
|
|
506
506
|
return _userEvent["default"].click(getByRole("button"));
|
|
507
507
|
case 3:
|
|
508
508
|
menu = getByRole("menu");
|
|
509
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
509
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
510
510
|
_react2.fireEvent.keyDown(menu, {
|
|
511
511
|
key: "End",
|
|
512
512
|
code: "End",
|
|
513
513
|
keyCode: 35,
|
|
514
514
|
charCode: 35
|
|
515
515
|
});
|
|
516
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-3");
|
|
516
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-3"));
|
|
517
517
|
case 7:
|
|
518
518
|
case "end":
|
|
519
519
|
return _context10.stop();
|
|
@@ -533,14 +533,14 @@ describe("Dropdown component tests", function () {
|
|
|
533
533
|
charCode: 38
|
|
534
534
|
});
|
|
535
535
|
var menu = getByRole("menu");
|
|
536
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-3");
|
|
536
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-3"));
|
|
537
537
|
_react2.fireEvent.keyDown(menu, {
|
|
538
538
|
key: "PageUp",
|
|
539
539
|
code: "PageUp",
|
|
540
540
|
keyCode: 33,
|
|
541
541
|
charCode: 33
|
|
542
542
|
});
|
|
543
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
543
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
544
544
|
});
|
|
545
545
|
test("Menu key events - PageDown moves the focus to the last menu item", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
|
|
546
546
|
var _render20, getByRole, menu;
|
|
@@ -555,14 +555,14 @@ describe("Dropdown component tests", function () {
|
|
|
555
555
|
return _userEvent["default"].click(getByRole("button"));
|
|
556
556
|
case 3:
|
|
557
557
|
menu = getByRole("menu");
|
|
558
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
558
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-0"));
|
|
559
559
|
_react2.fireEvent.keyDown(menu, {
|
|
560
560
|
key: "PageDown",
|
|
561
561
|
code: "PageDown",
|
|
562
562
|
keyCode: 34,
|
|
563
563
|
charCode: 34
|
|
564
564
|
});
|
|
565
|
-
expect(menu.getAttribute("aria-activedescendant")).toBe("option-3");
|
|
565
|
+
expect(menu.getAttribute("aria-activedescendant")).toBe("".concat(menu.id, "-option-3"));
|
|
566
566
|
case 7:
|
|
567
567
|
case "end":
|
|
568
568
|
return _context11.stop();
|
package/dropdown/DropdownMenu.js
CHANGED
|
@@ -21,7 +21,7 @@ var DropdownMenu = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
21
21
|
styles = _ref.styles;
|
|
22
22
|
return /*#__PURE__*/_react["default"].createElement(DropdownMenuContainer, {
|
|
23
23
|
onMouseDown: function onMouseDown(event) {
|
|
24
|
-
// Prevent the onBlur event from closing menu when clicking on the menu since
|
|
24
|
+
// Prevent the onBlur event from closing menu when clicking on the menu since
|
|
25
25
|
// it is implemented with a Portal and the menu is not a direct child of the container
|
|
26
26
|
event.preventDefault();
|
|
27
27
|
},
|
|
@@ -30,14 +30,14 @@ var DropdownMenu = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
30
30
|
role: "menu",
|
|
31
31
|
"aria-labelledby": dropdownTriggerId,
|
|
32
32
|
"aria-orientation": "vertical",
|
|
33
|
-
"aria-activedescendant": "option-".concat(visualFocusIndex),
|
|
33
|
+
"aria-activedescendant": visualFocusIndex !== -1 ? "".concat(id, "-option-").concat(visualFocusIndex) : undefined,
|
|
34
34
|
tabIndex: -1,
|
|
35
35
|
ref: ref,
|
|
36
36
|
style: styles
|
|
37
37
|
}, options.map(function (option, index) {
|
|
38
38
|
return /*#__PURE__*/_react["default"].createElement(_DropdownMenuItem["default"], {
|
|
39
|
-
id: "option-".concat(index),
|
|
40
|
-
key: "option-".concat(index),
|
|
39
|
+
id: "".concat(id, "-option-").concat(index),
|
|
40
|
+
key: "".concat(id, "-option-").concat(index),
|
|
41
41
|
visuallyFocused: index === visualFocusIndex,
|
|
42
42
|
iconPosition: iconsPosition,
|
|
43
43
|
onClick: menuItemOnClick,
|