@dxc-technology/halstack-react 11.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.d.ts +1 -10
- package/BackgroundColorContext.js +3 -8
- package/HalstackContext.d.ts +32 -145
- package/HalstackContext.js +3 -7
- package/accordion/Accordion.accessibility.test.d.ts +1 -0
- package/accordion/Accordion.accessibility.test.js +71 -0
- package/accordion/Accordion.js +18 -35
- package/accordion/Accordion.stories.tsx +7 -49
- package/accordion/Accordion.test.d.ts +1 -0
- package/accordion/Accordion.test.js +3 -3
- package/accordion/types.d.ts +1 -1
- package/accordion-group/AccordionGroup.accessibility.test.d.ts +1 -0
- package/accordion-group/AccordionGroup.accessibility.test.js +82 -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/AccordionGroup.test.d.ts +1 -0
- package/accordion-group/AccordionGroup.test.js +5 -9
- 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.d.ts +1 -0
- 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.d.ts +1 -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.d.ts +1 -0
- package/alert/Alert.accessibility.test.js +95 -0
- package/alert/Alert.js +21 -75
- package/alert/Alert.test.d.ts +1 -0
- package/alert/Alert.test.js +1 -1
- package/badge/Badge.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/box/Box.accessibility.test.d.ts +1 -0
- package/box/Box.accessibility.test.js +33 -0
- package/box/Box.js +2 -5
- package/box/Box.test.d.ts +1 -0
- package/box/Box.test.js +1 -1
- 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.d.ts +1 -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.d.ts +1 -0
- 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.d.ts +1 -0
- package/button/Button.test.js +4 -2
- package/button/types.d.ts +1 -1
- package/card/Card.accessibility.test.d.ts +1 -0
- package/card/Card.accessibility.test.js +36 -0
- package/card/Card.js +3 -2
- package/card/Card.test.d.ts +1 -0
- package/card/Card.test.js +1 -1
- package/checkbox/Checkbox.accessibility.test.d.ts +1 -0
- package/checkbox/Checkbox.accessibility.test.js +87 -0
- package/checkbox/Checkbox.js +36 -44
- package/checkbox/Checkbox.test.d.ts +1 -0
- package/checkbox/Checkbox.test.js +1 -1
- package/chip/Chip.accessibility.test.d.ts +1 -0
- package/chip/Chip.accessibility.test.js +69 -0
- package/chip/Chip.js +20 -26
- package/chip/Chip.stories.tsx +67 -50
- package/chip/Chip.test.d.ts +1 -0
- package/chip/Chip.test.js +5 -5
- package/chip/types.d.ts +35 -12
- package/common/coreTokens.d.ts +105 -14
- package/common/coreTokens.js +40 -22
- package/common/fonts.css +2 -0
- package/common/variables.d.ts +31 -141
- package/common/variables.js +104 -214
- 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.d.ts +1 -0
- package/contextual-menu/ContextualMenu.accessibility.test.js +98 -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.d.ts +1 -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.d.ts +1 -0
- package/date-input/DateInput.accessibility.test.js +230 -0
- package/date-input/DateInput.js +19 -20
- package/date-input/DateInput.stories.tsx +15 -8
- package/date-input/DateInput.test.d.ts +1 -0
- package/date-input/DateInput.test.js +9 -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.d.ts +1 -0
- package/dialog/Dialog.accessibility.test.js +69 -0
- package/dialog/Dialog.js +11 -25
- package/dialog/Dialog.stories.tsx +175 -0
- package/dialog/Dialog.test.d.ts +1 -0
- package/dialog/Dialog.test.js +113 -49
- package/divider/Divider.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -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.d.ts +1 -0
- package/dropdown/Dropdown.accessibility.test.js +184 -0
- package/dropdown/Dropdown.js +37 -51
- package/dropdown/Dropdown.stories.tsx +15 -26
- package/dropdown/Dropdown.test.d.ts +1 -0
- package/dropdown/Dropdown.test.js +100 -70
- 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.d.ts +1 -0
- package/file-input/FileInput.accessibility.test.js +167 -0
- package/file-input/FileInput.js +127 -145
- package/file-input/FileInput.test.d.ts +1 -0
- package/file-input/FileInput.test.js +125 -129
- package/file-input/FileItem.js +18 -28
- package/file-input/types.d.ts +1 -1
- package/footer/Footer.accessibility.test.d.ts +1 -0
- 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/Footer.test.d.ts +1 -0
- package/footer/Footer.test.js +1 -1
- 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.d.ts +1 -0
- package/header/Header.accessibility.test.js +94 -0
- package/header/Header.js +20 -41
- package/header/Header.stories.tsx +16 -0
- package/header/Header.test.d.ts +1 -0
- package/header/Header.test.js +1 -1
- package/header/Icons.js +1 -6
- package/header/types.d.ts +4 -3
- package/heading/Heading.accessibility.test.d.ts +1 -0
- package/heading/Heading.accessibility.test.js +33 -0
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.d.ts +1 -0
- package/heading/Heading.test.js +1 -14
- package/icon/Icon.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -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.d.ts +1 -0
- package/link/Link.accessibility.test.js +108 -0
- package/link/Link.js +8 -6
- package/link/Link.stories.tsx +4 -4
- package/link/Link.test.d.ts +1 -0
- package/link/Link.test.js +1 -1
- package/link/types.d.ts +1 -1
- package/main.d.ts +8 -3
- package/main.js +38 -9
- package/nav-tabs/NavTabs.accessibility.test.d.ts +1 -0
- package/nav-tabs/NavTabs.accessibility.test.js +44 -0
- package/nav-tabs/NavTabs.d.ts +1 -2
- package/nav-tabs/NavTabs.js +25 -7
- package/nav-tabs/NavTabs.stories.tsx +44 -24
- package/nav-tabs/NavTabs.test.d.ts +1 -0
- package/nav-tabs/NavTabs.test.js +12 -10
- 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.d.ts +1 -0
- 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.d.ts +1 -0
- package/number-input/NumberInput.test.js +166 -7
- 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 +20 -18
- package/paginator/Paginator.accessibility.test.d.ts +1 -0
- package/paginator/Paginator.accessibility.test.js +79 -0
- package/paginator/Paginator.js +14 -14
- package/paginator/Paginator.test.d.ts +1 -0
- package/paginator/Paginator.test.js +1 -1
- package/paragraph/Paragraph.accessibility.test.d.ts +1 -0
- package/paragraph/Paragraph.accessibility.test.js +28 -0
- package/paragraph/Paragraph.js +2 -7
- package/password-input/PasswordInput.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -0
- package/password-input/PasswordInput.test.js +5 -5
- package/progress-bar/ProgressBar.accessibility.test.d.ts +1 -0
- package/progress-bar/ProgressBar.accessibility.test.js +35 -0
- package/progress-bar/ProgressBar.js +11 -15
- package/progress-bar/ProgressBar.test.d.ts +1 -0
- package/progress-bar/ProgressBar.test.js +1 -1
- package/quick-nav/QuickNav.accessibility.test.d.ts +1 -0
- package/quick-nav/QuickNav.accessibility.test.js +57 -0
- package/quick-nav/QuickNav.js +1 -1
- package/radio-group/Radio.js +6 -9
- package/radio-group/RadioGroup.accessibility.test.d.ts +1 -0
- package/radio-group/RadioGroup.accessibility.test.js +97 -0
- package/radio-group/RadioGroup.js +15 -17
- package/radio-group/RadioGroup.test.d.ts +1 -0
- package/radio-group/RadioGroup.test.js +3 -5
- package/resultset-table/ResultsetTable.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -0
- package/resultset-table/ResultsetTable.test.js +76 -1
- package/resultset-table/types.d.ts +40 -7
- package/select/Listbox.js +24 -16
- package/select/Option.js +19 -10
- package/select/Select.accessibility.test.d.ts +1 -0
- package/select/Select.accessibility.test.js +228 -0
- package/select/Select.js +72 -54
- package/select/Select.stories.tsx +59 -111
- package/select/Select.test.d.ts +1 -0
- package/select/Select.test.js +393 -459
- package/select/types.d.ts +3 -3
- package/sidenav/Sidenav.accessibility.test.d.ts +1 -0
- package/sidenav/Sidenav.accessibility.test.js +59 -0
- package/sidenav/Sidenav.js +21 -19
- package/sidenav/Sidenav.stories.tsx +4 -9
- package/sidenav/Sidenav.test.d.ts +1 -0
- package/sidenav/Sidenav.test.js +1 -1
- package/sidenav/types.d.ts +2 -2
- package/slider/Slider.accessibility.test.d.ts +1 -0
- package/slider/Slider.accessibility.test.js +104 -0
- package/slider/Slider.js +31 -42
- package/slider/Slider.stories.tsx +180 -0
- package/slider/Slider.test.d.ts +1 -0
- package/slider/Slider.test.js +12 -9
- package/spinner/Spinner.accessibility.test.d.ts +1 -0
- package/spinner/Spinner.accessibility.test.js +96 -0
- package/spinner/Spinner.js +12 -16
- package/spinner/Spinner.test.d.ts +1 -0
- package/spinner/Spinner.test.js +1 -1
- package/status-light/StatusLight.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -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.d.ts +1 -0
- package/switch/Switch.accessibility.test.js +98 -0
- package/switch/Switch.js +29 -37
- package/switch/Switch.stories.tsx +12 -0
- package/switch/Switch.test.d.ts +1 -0
- package/switch/Switch.test.js +1 -1
- package/table/DropdownTheme.js +62 -0
- package/table/Table.accessibility.test.d.ts +1 -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.d.ts +1 -0
- package/table/Table.test.js +92 -1
- package/table/types.d.ts +28 -0
- package/tabs/Tab.js +13 -9
- package/tabs/Tabs.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -0
- package/tabs/Tabs.test.js +20 -38
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.accessibility.test.d.ts +1 -0
- 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.d.ts +1 -0
- package/tag/Tag.test.js +5 -13
- 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.d.ts +1 -0
- package/text-input/TextInput.accessibility.test.js +321 -0
- package/text-input/TextInput.js +103 -126
- package/text-input/TextInput.stories.tsx +17 -8
- package/text-input/TextInput.test.d.ts +1 -0
- package/text-input/TextInput.test.js +97 -80
- package/textarea/Textarea.accessibility.test.d.ts +1 -0
- package/textarea/Textarea.accessibility.test.js +155 -0
- package/textarea/Textarea.js +13 -21
- package/textarea/Textarea.stories.tsx +0 -1
- package/textarea/Textarea.test.d.ts +1 -0
- package/textarea/Textarea.test.js +1 -1
- package/toggle-group/ToggleGroup.accessibility.test.d.ts +1 -0
- package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
- package/toggle-group/ToggleGroup.js +11 -16
- package/toggle-group/ToggleGroup.stories.tsx +3 -3
- package/toggle-group/ToggleGroup.test.d.ts +1 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +2 -2
- package/typography/Typography.accessibility.test.d.ts +1 -0
- package/typography/Typography.accessibility.test.js +339 -0
- package/useTheme.d.ts +31 -141
- package/utils/BaseTypography.js +1 -1
- package/utils/FocusLock.js +16 -6
- package/wizard/Wizard.accessibility.test.d.ts +1 -0
- package/wizard/Wizard.accessibility.test.js +55 -0
- package/wizard/Wizard.js +14 -25
- package/wizard/Wizard.stories.tsx +19 -0
- package/wizard/Wizard.test.d.ts +1 -0
- package/wizard/Wizard.test.js +1 -1
- 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,155 @@
|
|
|
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 _react = _interopRequireDefault(require("react"));
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
var _axeHelper = require("../../test/accessibility/axe-helper.js");
|
|
9
|
+
var _Textarea = _interopRequireDefault(require("./Textarea"));
|
|
10
|
+
describe("Textarea component accessibility tests", function () {
|
|
11
|
+
it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
12
|
+
var _render, container, results;
|
|
13
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
14
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
17
|
+
label: "Example label",
|
|
18
|
+
helperText: "Helper Text",
|
|
19
|
+
defaultValue: "Value",
|
|
20
|
+
margin: "medium",
|
|
21
|
+
placeholder: "Placeholder",
|
|
22
|
+
verticalGrow: "manual",
|
|
23
|
+
name: "Name",
|
|
24
|
+
autocomplete: "on",
|
|
25
|
+
minLength: 0,
|
|
26
|
+
maxLength: 100,
|
|
27
|
+
optional: true
|
|
28
|
+
})), container = _render.container;
|
|
29
|
+
_context.next = 3;
|
|
30
|
+
return (0, _axeHelper.axe)(container);
|
|
31
|
+
case 3:
|
|
32
|
+
results = _context.sent;
|
|
33
|
+
expect(results).toHaveNoViolations();
|
|
34
|
+
case 5:
|
|
35
|
+
case "end":
|
|
36
|
+
return _context.stop();
|
|
37
|
+
}
|
|
38
|
+
}, _callee);
|
|
39
|
+
})));
|
|
40
|
+
it("Should not have basic accessibility issues for pattern mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
41
|
+
var _render2, container, results;
|
|
42
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
43
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
46
|
+
label: "Example label",
|
|
47
|
+
helperText: "Helper Text",
|
|
48
|
+
defaultValue: "Value",
|
|
49
|
+
margin: "medium",
|
|
50
|
+
placeholder: "Placeholder",
|
|
51
|
+
verticalGrow: "manual",
|
|
52
|
+
name: "Name",
|
|
53
|
+
autocomplete: "on",
|
|
54
|
+
minLength: 0,
|
|
55
|
+
maxLength: 100,
|
|
56
|
+
pattern: "^.*(?=.*[a-zA-Z])(?=.*)(?=.*[!&$%&? \"]).*$"
|
|
57
|
+
})), container = _render2.container;
|
|
58
|
+
_context2.next = 3;
|
|
59
|
+
return (0, _axeHelper.axe)(container);
|
|
60
|
+
case 3:
|
|
61
|
+
results = _context2.sent;
|
|
62
|
+
expect(results).toHaveNoViolations();
|
|
63
|
+
case 5:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context2.stop();
|
|
66
|
+
}
|
|
67
|
+
}, _callee2);
|
|
68
|
+
})));
|
|
69
|
+
it("Should not have basic accessibility issues for error mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
70
|
+
var _render3, container, results;
|
|
71
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
72
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
_render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
75
|
+
label: "Example label",
|
|
76
|
+
helperText: "Helper Text",
|
|
77
|
+
defaultValue: "Value",
|
|
78
|
+
margin: "medium",
|
|
79
|
+
placeholder: "Placeholder",
|
|
80
|
+
verticalGrow: "manual",
|
|
81
|
+
name: "Name",
|
|
82
|
+
error: "Error message.",
|
|
83
|
+
minLength: 0,
|
|
84
|
+
maxLength: 100
|
|
85
|
+
})), container = _render3.container;
|
|
86
|
+
_context3.next = 3;
|
|
87
|
+
return (0, _axeHelper.axe)(container);
|
|
88
|
+
case 3:
|
|
89
|
+
results = _context3.sent;
|
|
90
|
+
expect(results).toHaveNoViolations();
|
|
91
|
+
case 5:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context3.stop();
|
|
94
|
+
}
|
|
95
|
+
}, _callee3);
|
|
96
|
+
})));
|
|
97
|
+
it("Should not have basic accessibility issues for disabled mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
98
|
+
var _render4, container, results;
|
|
99
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
100
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
_render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
103
|
+
label: "Example label",
|
|
104
|
+
helperText: "Helper Text",
|
|
105
|
+
defaultValue: "Value",
|
|
106
|
+
margin: "medium",
|
|
107
|
+
placeholder: "Placeholder",
|
|
108
|
+
verticalGrow: "manual",
|
|
109
|
+
name: "Name",
|
|
110
|
+
autocomplete: "on",
|
|
111
|
+
minLength: 0,
|
|
112
|
+
maxLength: 100,
|
|
113
|
+
disabled: true
|
|
114
|
+
})), container = _render4.container;
|
|
115
|
+
_context4.next = 3;
|
|
116
|
+
return (0, _axeHelper.axe)(container);
|
|
117
|
+
case 3:
|
|
118
|
+
results = _context4.sent;
|
|
119
|
+
expect(results).toHaveNoViolations();
|
|
120
|
+
case 5:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context4.stop();
|
|
123
|
+
}
|
|
124
|
+
}, _callee4);
|
|
125
|
+
})));
|
|
126
|
+
it("Should not have basic accessibility issues for read-only mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
127
|
+
var _render5, container, results;
|
|
128
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
129
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
_render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
132
|
+
label: "Example label",
|
|
133
|
+
helperText: "Helper Text",
|
|
134
|
+
defaultValue: "Value",
|
|
135
|
+
margin: "medium",
|
|
136
|
+
placeholder: "Placeholder",
|
|
137
|
+
verticalGrow: "manual",
|
|
138
|
+
name: "Name",
|
|
139
|
+
autocomplete: "on",
|
|
140
|
+
minLength: 0,
|
|
141
|
+
maxLength: 100,
|
|
142
|
+
readOnly: true
|
|
143
|
+
})), container = _render5.container;
|
|
144
|
+
_context5.next = 3;
|
|
145
|
+
return (0, _axeHelper.axe)(container);
|
|
146
|
+
case 3:
|
|
147
|
+
results = _context5.sent;
|
|
148
|
+
expect(results).toHaveNoViolations();
|
|
149
|
+
case 5:
|
|
150
|
+
case "end":
|
|
151
|
+
return _context5.stop();
|
|
152
|
+
}
|
|
153
|
+
}, _callee5);
|
|
154
|
+
})));
|
|
155
|
+
});
|
package/textarea/Textarea.js
CHANGED
|
@@ -15,11 +15,9 @@ var _utils = require("../common/utils");
|
|
|
15
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
16
16
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
17
17
|
var _variables = require("../common/variables");
|
|
18
|
-
var _uuid = require("uuid");
|
|
19
|
-
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
20
18
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
21
19
|
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 &&
|
|
20
|
+
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; }
|
|
23
21
|
var patternMatch = function patternMatch(pattern, value) {
|
|
24
22
|
return new RegExp(pattern).test(value);
|
|
25
23
|
};
|
|
@@ -60,11 +58,8 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
60
58
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
61
59
|
innerValue = _useState2[0],
|
|
62
60
|
setInnerValue = _useState2[1];
|
|
63
|
-
var
|
|
64
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
65
|
-
textareaId = _useState4[0];
|
|
61
|
+
var textareaId = "textarea-".concat((0, _react.useId)());
|
|
66
62
|
var colorsTheme = (0, _useTheme["default"])();
|
|
67
|
-
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
68
63
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
69
64
|
var textareaRef = (0, _react.useRef)(null);
|
|
70
65
|
var errorId = "error-".concat(textareaId);
|
|
@@ -123,11 +118,9 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
123
118
|
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
124
119
|
htmlFor: textareaId,
|
|
125
120
|
disabled: disabled,
|
|
126
|
-
backgroundType: backgroundType,
|
|
127
121
|
helperText: helperText
|
|
128
122
|
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
129
|
-
disabled: disabled
|
|
130
|
-
backgroundType: backgroundType
|
|
123
|
+
disabled: disabled
|
|
131
124
|
}, helperText), /*#__PURE__*/_react["default"].createElement(Textarea, {
|
|
132
125
|
id: textareaId,
|
|
133
126
|
name: name,
|
|
@@ -143,7 +136,6 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
143
136
|
minLength: minLength,
|
|
144
137
|
maxLength: maxLength,
|
|
145
138
|
autoComplete: autocomplete,
|
|
146
|
-
backgroundType: backgroundType,
|
|
147
139
|
ref: textareaRef,
|
|
148
140
|
tabIndex: tabIndex,
|
|
149
141
|
"aria-invalid": error ? true : false,
|
|
@@ -151,7 +143,7 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
151
143
|
"aria-required": !disabled && !optional
|
|
152
144
|
}), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
153
145
|
id: errorId,
|
|
154
|
-
|
|
146
|
+
role: "alert",
|
|
155
147
|
"aria-live": error ? "assertive" : "off"
|
|
156
148
|
}, error)));
|
|
157
149
|
});
|
|
@@ -178,7 +170,7 @@ var TextareaContainer = _styledComponents["default"].div(_templateObject || (_te
|
|
|
178
170
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
179
171
|
});
|
|
180
172
|
var Label = _styledComponents["default"].label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
|
|
181
|
-
return props.disabled ? props.
|
|
173
|
+
return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
|
|
182
174
|
}, function (props) {
|
|
183
175
|
return props.theme.fontFamily;
|
|
184
176
|
}, function (props) {
|
|
@@ -196,7 +188,7 @@ var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_temp
|
|
|
196
188
|
return props.theme.optionalLabelFontWeight;
|
|
197
189
|
});
|
|
198
190
|
var HelperText = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-bottom: 0.25rem;\n"])), function (props) {
|
|
199
|
-
return props.disabled ? props.
|
|
191
|
+
return props.disabled ? props.theme.disabledHelperTextFontColor : props.theme.helperTextFontColor;
|
|
200
192
|
}, function (props) {
|
|
201
193
|
return props.theme.fontFamily;
|
|
202
194
|
}, function (props) {
|
|
@@ -212,15 +204,15 @@ var Textarea = _styledComponents["default"].textarea(_templateObject5 || (_templ
|
|
|
212
204
|
var verticalGrow = _ref2.verticalGrow;
|
|
213
205
|
if (verticalGrow === "none") return "resize: none;";else if (verticalGrow === "auto") return "resize: none; overflow: hidden;";else if (verticalGrow === "manual") return "resize: vertical;";else return "resize: none;";
|
|
214
206
|
}, function (props) {
|
|
215
|
-
|
|
207
|
+
return props.disabled ? "background-color: ".concat(props.theme.disabledContainerFillColor, ";") : "background-color: transparent;";
|
|
216
208
|
}, function (props) {
|
|
217
|
-
if (props.disabled) return props.
|
|
209
|
+
if (props.disabled) return props.theme.disabledBorderColor;else if (props.error) return "transparent";else if (props.readOnly) return props.theme.readOnlyBorderColor;else props.theme.enabledBorderColor;
|
|
218
210
|
}, function (props) {
|
|
219
|
-
return props.error && !props.disabled && "box-shadow: 0 0 0 2px ".concat(props.
|
|
211
|
+
return props.error && !props.disabled && "box-shadow: 0 0 0 2px ".concat(props.theme.errorBorderColor, ";\n ");
|
|
220
212
|
}, function (props) {
|
|
221
|
-
return !props.disabled ? "&:hover {\n border-color: ".concat(props.error ? "transparent" : props.readOnly ? props.theme.hoverReadOnlyBorderColor : props.
|
|
213
|
+
return !props.disabled ? "&:hover {\n border-color: ".concat(props.error ? "transparent" : props.readOnly ? props.theme.hoverReadOnlyBorderColor : props.theme.hoverBorderColor, ";\n ").concat(props.error && "box-shadow: 0 0 0 2px ".concat(props.theme.hoverErrorBorderColor, ";"), "\n }\n &:focus, &:focus-within {\n outline: none;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.theme.focusBorderColor, ";\n }") : "cursor: not-allowed;";
|
|
222
214
|
}, function (props) {
|
|
223
|
-
return props.disabled ? props.
|
|
215
|
+
return props.disabled ? props.theme.disabledValueFontColor : props.theme.valueFontColor;
|
|
224
216
|
}, function (props) {
|
|
225
217
|
return props.theme.fontFamily;
|
|
226
218
|
}, function (props) {
|
|
@@ -230,10 +222,10 @@ var Textarea = _styledComponents["default"].textarea(_templateObject5 || (_templ
|
|
|
230
222
|
}, function (props) {
|
|
231
223
|
return props.theme.valueFontWeight;
|
|
232
224
|
}, function (props) {
|
|
233
|
-
return props.disabled ? props.
|
|
225
|
+
return props.disabled ? props.theme.disabledPlaceholderFontColor : props.theme.placeholderFontColor;
|
|
234
226
|
});
|
|
235
227
|
var Error = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n min-height: 1.5em;\n line-height: 1.5em;\n margin-top: 0.25rem;\n"])), function (props) {
|
|
236
|
-
return props.
|
|
228
|
+
return props.theme.errorMessageColor;
|
|
237
229
|
}, function (props) {
|
|
238
230
|
return props.theme.fontFamily;
|
|
239
231
|
});
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import DxcTextarea from "./Textarea";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
-
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
6
5
|
import { HalstackProvider } from "../HalstackContext";
|
|
7
6
|
|
|
8
7
|
export default {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,7 +6,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
6
6
|
var _react = _interopRequireDefault(require("react"));
|
|
7
7
|
var _react2 = require("@testing-library/react");
|
|
8
8
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
9
|
-
var _Textarea = _interopRequireDefault(require("./Textarea
|
|
9
|
+
var _Textarea = _interopRequireDefault(require("./Textarea"));
|
|
10
10
|
describe("Textarea component tests", function () {
|
|
11
11
|
test("Renders with correct label", function () {
|
|
12
12
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
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 _react = _interopRequireDefault(require("react"));
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
var _axeHelper = require("../../test/accessibility/axe-helper.js");
|
|
9
|
+
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup"));
|
|
10
|
+
var ethernetSVG = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
height: "24px",
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
width: "24px",
|
|
15
|
+
fill: "currentColor"
|
|
16
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
17
|
+
d: "M0 0h24v24H0V0z",
|
|
18
|
+
fill: "none"
|
|
19
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
20
|
+
d: "M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z"
|
|
21
|
+
}));
|
|
22
|
+
var gMobileSVG = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
23
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
24
|
+
height: "24px",
|
|
25
|
+
viewBox: "0 0 24 24",
|
|
26
|
+
width: "24px",
|
|
27
|
+
fill: "currentColor"
|
|
28
|
+
}, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
29
|
+
d: "M0,0h24v24H0V0z",
|
|
30
|
+
fill: "none"
|
|
31
|
+
})), /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
32
|
+
d: "M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z"
|
|
33
|
+
}))));
|
|
34
|
+
var wifiSVG = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
35
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
36
|
+
height: "24px",
|
|
37
|
+
viewBox: "0 0 24 24",
|
|
38
|
+
width: "24px",
|
|
39
|
+
fill: "currentColor"
|
|
40
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
41
|
+
d: "M0 0h24v24H0V0zm0 0h24v24H0V0z",
|
|
42
|
+
fill: "none"
|
|
43
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
44
|
+
d: "M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z"
|
|
45
|
+
}));
|
|
46
|
+
var options = [{
|
|
47
|
+
value: 1,
|
|
48
|
+
icon: wifiSVG,
|
|
49
|
+
title: "WiFi connection"
|
|
50
|
+
}, {
|
|
51
|
+
value: 2,
|
|
52
|
+
icon: ethernetSVG,
|
|
53
|
+
title: "Ethernet connection"
|
|
54
|
+
}, {
|
|
55
|
+
value: 3,
|
|
56
|
+
icon: gMobileSVG,
|
|
57
|
+
title: "3G Mobile data connection"
|
|
58
|
+
}];
|
|
59
|
+
describe("Toggle group component accessibility tests", function () {
|
|
60
|
+
it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
61
|
+
var _render, container, results;
|
|
62
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
63
|
+
while (1) switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
66
|
+
label: "Toggle group label",
|
|
67
|
+
helperText: "Toggle group helper text",
|
|
68
|
+
options: options,
|
|
69
|
+
margin: "medium",
|
|
70
|
+
defaultValue: [2],
|
|
71
|
+
multiple: true
|
|
72
|
+
})), container = _render.container;
|
|
73
|
+
_context.next = 3;
|
|
74
|
+
return (0, _axeHelper.axe)(container);
|
|
75
|
+
case 3:
|
|
76
|
+
results = _context.sent;
|
|
77
|
+
expect(results).toHaveNoViolations();
|
|
78
|
+
case 5:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context.stop();
|
|
81
|
+
}
|
|
82
|
+
}, _callee);
|
|
83
|
+
})));
|
|
84
|
+
it("Should not have basic accessibility issues for disabled mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
85
|
+
var _render2, container, results;
|
|
86
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
87
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
88
|
+
case 0:
|
|
89
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
90
|
+
label: "Toggle group label",
|
|
91
|
+
helperText: "Toggle group helper text",
|
|
92
|
+
options: options,
|
|
93
|
+
margin: "medium",
|
|
94
|
+
disabled: true
|
|
95
|
+
})), container = _render2.container;
|
|
96
|
+
_context2.next = 3;
|
|
97
|
+
return (0, _axeHelper.axe)(container);
|
|
98
|
+
case 3:
|
|
99
|
+
results = _context2.sent;
|
|
100
|
+
expect(results).toHaveNoViolations();
|
|
101
|
+
case 5:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context2.stop();
|
|
104
|
+
}
|
|
105
|
+
}, _callee2);
|
|
106
|
+
})));
|
|
107
|
+
});
|
|
@@ -11,14 +11,13 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
14
|
-
var _uuid = require("uuid");
|
|
15
14
|
var _variables = require("../common/variables");
|
|
16
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
17
|
-
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
18
16
|
var _Flex = _interopRequireDefault(require("../flex/Flex"));
|
|
17
|
+
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
19
18
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
20
19
|
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); }
|
|
21
|
-
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 &&
|
|
20
|
+
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; }
|
|
22
21
|
var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
23
22
|
var label = _ref.label,
|
|
24
23
|
helperText = _ref.helperText,
|
|
@@ -33,15 +32,12 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
33
32
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
34
33
|
_ref$tabIndex = _ref.tabIndex,
|
|
35
34
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
selectedValue = _useState4[0],
|
|
42
|
-
setSelectedValue = _useState4[1];
|
|
35
|
+
var toggleGroupLabelId = "label-toggle-group-".concat((0, _react.useId)());
|
|
36
|
+
var _useState = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : -1),
|
|
37
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
38
|
+
selectedValue = _useState2[0],
|
|
39
|
+
setSelectedValue = _useState2[1];
|
|
43
40
|
var colorsTheme = (0, _useTheme["default"])();
|
|
44
|
-
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
45
41
|
var handleToggleChange = function handleToggleChange(selectedOption) {
|
|
46
42
|
var newSelectedOptions;
|
|
47
43
|
if (value == null) {
|
|
@@ -101,7 +97,6 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
101
97
|
},
|
|
102
98
|
tabIndex: !disabled ? tabIndex : -1,
|
|
103
99
|
title: option.title,
|
|
104
|
-
backgroundType: backgroundType,
|
|
105
100
|
hasIcon: option.icon,
|
|
106
101
|
optionLabel: option.label,
|
|
107
102
|
selected: multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue
|
|
@@ -109,8 +104,8 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
109
104
|
alignItems: "center"
|
|
110
105
|
}, option.icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
111
106
|
optionLabel: option.label
|
|
112
|
-
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement("
|
|
113
|
-
|
|
107
|
+
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
108
|
+
icon: option.icon
|
|
114
109
|
}) : option.icon), option.label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, option.label)));
|
|
115
110
|
}))));
|
|
116
111
|
};
|
|
@@ -183,7 +178,7 @@ var ToggleButton = _styledComponents["default"].button(_templateObject5 || (_tem
|
|
|
183
178
|
}, function (props) {
|
|
184
179
|
return props.selected ? props.theme.selectedActiveBackgroundColor : props.theme.unselectedActiveBackgroundColor;
|
|
185
180
|
}, function (props) {
|
|
186
|
-
return "0 0 0 ".concat(props.theme.optionFocusBorderThickness, " ").concat(props.
|
|
181
|
+
return "0 0 0 ".concat(props.theme.optionFocusBorderThickness, " ").concat(props.theme.focusColor);
|
|
187
182
|
}, function (props) {
|
|
188
183
|
return props.selected ? props.theme.selectedDisabledBackgroundColor : props.theme.unselectedDisabledBackgroundColor;
|
|
189
184
|
}, function (props) {
|
|
@@ -198,7 +193,7 @@ var LabelContainer = _styledComponents["default"].span(_templateObject6 || (_tem
|
|
|
198
193
|
}, function (props) {
|
|
199
194
|
return props.theme.optionLabelFontWeight;
|
|
200
195
|
});
|
|
201
|
-
var IconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n
|
|
196
|
+
var IconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-right: ", ";\n overflow: hidden;\n font-size: 24px;\n svg {\n height: 24px;\n width: 24px;\n }\n"])), function (props) {
|
|
202
197
|
return props.optionLabel && props.theme.iconMarginRight;
|
|
203
198
|
});
|
|
204
199
|
var _default = exports["default"] = DxcToggleGroup;
|
|
@@ -52,17 +52,17 @@ const options = [
|
|
|
52
52
|
const optionsWithIcon = [
|
|
53
53
|
{
|
|
54
54
|
value: 1,
|
|
55
|
-
icon:
|
|
55
|
+
icon: "wifi",
|
|
56
56
|
title: "WiFi connection",
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
value: 2,
|
|
60
|
-
icon:
|
|
60
|
+
icon: "filled_lan",
|
|
61
61
|
title: "Ethernet connection",
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
value: 3,
|
|
65
|
-
icon:
|
|
65
|
+
icon: "5g",
|
|
66
66
|
title: "3G Mobile data connection",
|
|
67
67
|
},
|
|
68
68
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
-
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup
|
|
6
|
+
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup"));
|
|
7
7
|
var options = [{
|
|
8
8
|
value: 1,
|
|
9
9
|
label: "Amazon"
|
package/toggle-group/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type OptionIcon = {
|
|
|
13
13
|
*/
|
|
14
14
|
label?: never;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Material Symbols icon or SVG element. Icon and label can't be used at same time.
|
|
17
17
|
*/
|
|
18
18
|
icon: string | SVG;
|
|
19
19
|
/**
|
|
@@ -28,7 +28,7 @@ export type OptionLabel = {
|
|
|
28
28
|
*/
|
|
29
29
|
label: string;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Material Symbols icon or SVG element. Icon and label can't be used at same time.
|
|
32
32
|
*/
|
|
33
33
|
icon?: string | SVG;
|
|
34
34
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|