@dxc-technology/halstack-react 10.1.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 +4 -21
- package/HalstackContext.d.ts +45 -143
- package/HalstackContext.js +10 -35
- package/accordion/Accordion.accessibility.test.js +71 -0
- package/accordion/Accordion.js +33 -84
- package/accordion/Accordion.stories.tsx +8 -64
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +6 -6
- package/accordion-group/AccordionGroup.accessibility.test.js +88 -0
- package/accordion-group/AccordionGroup.d.ts +2 -3
- package/accordion-group/AccordionGroup.js +17 -44
- package/accordion-group/AccordionGroup.stories.tsx +24 -24
- package/accordion-group/AccordionGroup.test.js +42 -60
- package/accordion-group/AccordionGroupAccordion.js +11 -23
- package/accordion-group/AccordionGroupContext.d.ts +3 -0
- package/accordion-group/AccordionGroupContext.js +8 -0
- package/accordion-group/types.d.ts +7 -7
- 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/alert/Alert.accessibility.test.js +95 -0
- package/alert/Alert.js +34 -120
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.accessibility.test.js +129 -0
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +142 -42
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/bleed/Bleed.js +13 -21
- package/bleed/types.d.ts +2 -2
- package/box/Box.accessibility.test.js +33 -0
- package/box/Box.js +11 -33
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -3
- 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 +22 -55
- package/bulleted-list/BulletedList.stories.tsx +2 -93
- package/bulleted-list/types.d.ts +5 -5
- package/button/Button.accessibility.test.js +127 -0
- package/button/Button.js +36 -59
- package/button/Button.stories.tsx +35 -135
- package/button/Button.test.js +13 -21
- package/button/types.d.ts +5 -5
- package/card/Card.accessibility.test.js +36 -0
- package/card/Card.js +23 -45
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +5 -5
- package/checkbox/Checkbox.accessibility.test.js +87 -0
- package/checkbox/Checkbox.js +88 -123
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.accessibility.test.js +67 -0
- package/chip/Chip.js +22 -36
- package/chip/Chip.stories.tsx +10 -25
- package/chip/Chip.test.js +17 -30
- package/chip/types.d.ts +4 -4
- package/common/coreTokens.d.ts +105 -14
- package/common/coreTokens.js +40 -23
- package/common/utils.js +2 -8
- package/common/variables.d.ts +46 -144
- package/common/variables.js +120 -225
- 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 +13 -57
- package/date-input/DateInput.accessibility.test.js +228 -0
- package/date-input/DateInput.js +53 -100
- package/date-input/DateInput.stories.tsx +19 -31
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +23 -48
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +28 -22
- package/dialog/Dialog.accessibility.test.js +69 -0
- package/dialog/Dialog.js +21 -59
- package/dialog/Dialog.stories.tsx +176 -0
- package/dialog/Dialog.test.js +126 -188
- package/dialog/types.d.ts +18 -13
- 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 +63 -130
- package/dropdown/Dropdown.stories.tsx +15 -26
- package/dropdown/Dropdown.test.js +402 -389
- package/dropdown/DropdownMenu.js +12 -23
- package/dropdown/DropdownMenuItem.js +13 -21
- package/dropdown/types.d.ts +20 -24
- package/file-input/FileInput.accessibility.test.js +160 -0
- package/file-input/FileInput.js +180 -284
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +279 -354
- package/file-input/FileItem.js +29 -66
- package/file-input/types.d.ts +9 -9
- package/flex/Flex.js +25 -39
- package/flex/types.d.ts +6 -6
- package/footer/Footer.accessibility.test.js +125 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +43 -68
- package/footer/Footer.stories.tsx +58 -2
- package/footer/Footer.test.js +18 -32
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +53 -22
- package/footer/types.d.ts +17 -17
- package/grid/Grid.js +1 -16
- package/grid/types.d.ts +10 -10
- package/header/Header.accessibility.test.js +93 -0
- package/header/Header.d.ts +1 -1
- package/header/Header.js +38 -104
- package/header/Header.stories.tsx +16 -0
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +3 -13
- package/header/types.d.ts +7 -8
- package/heading/Heading.accessibility.test.js +33 -0
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- package/heading/types.d.ts +7 -7
- 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.d.ts +2 -2
- package/image/Image.js +17 -32
- package/image/Image.stories.tsx +3 -1
- package/image/types.d.ts +2 -2
- package/inset/Inset.js +13 -21
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +2 -2
- package/layout/ApplicationLayout.js +23 -60
- package/layout/Icons.d.ts +4 -5
- package/layout/Icons.js +2 -16
- package/layout/types.d.ts +3 -3
- package/link/Link.accessibility.test.js +108 -0
- package/link/Link.js +28 -47
- package/link/Link.stories.tsx +4 -4
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +8 -4
- package/main.js +39 -60
- package/nav-tabs/NavTabs.accessibility.test.js +44 -0
- package/nav-tabs/NavTabs.d.ts +1 -2
- package/nav-tabs/NavTabs.js +19 -48
- package/nav-tabs/NavTabs.stories.tsx +30 -25
- package/nav-tabs/NavTabs.test.js +45 -50
- package/nav-tabs/NavTabsContext.d.ts +3 -0
- package/nav-tabs/NavTabsContext.js +8 -0
- package/nav-tabs/Tab.js +38 -67
- package/nav-tabs/types.d.ts +10 -10
- package/number-input/NumberInput.accessibility.test.js +228 -0
- package/number-input/NumberInput.d.ts +0 -7
- package/number-input/NumberInput.js +47 -39
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +839 -575
- package/number-input/NumberInputContext.d.ts +3 -0
- package/number-input/NumberInputContext.js +8 -0
- package/number-input/types.d.ts +17 -5
- package/package.json +41 -37
- package/paginator/Paginator.accessibility.test.js +79 -0
- package/paginator/Paginator.js +27 -52
- package/paginator/Paginator.test.js +224 -207
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.accessibility.test.js +28 -0
- package/paragraph/Paragraph.js +3 -19
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/PasswordInput.accessibility.test.js +153 -0
- package/password-input/PasswordInput.js +32 -54
- package/password-input/PasswordInput.stories.tsx +1 -34
- package/password-input/PasswordInput.test.js +153 -129
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.accessibility.test.js +35 -0
- package/progress-bar/ProgressBar.js +26 -56
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.accessibility.test.js +57 -0
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +22 -54
- package/radio-group/RadioGroup.accessibility.test.js +97 -0
- package/radio-group/RadioGroup.js +38 -83
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/resultset-table/ResultsetTable.accessibility.test.js +285 -0
- package/resultset-table/ResultsetTable.d.ts +7 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.js +45 -69
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +118 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +148 -92
- package/{resultsetTable → resultset-table}/types.d.ts +44 -11
- package/resultset-table/types.js +5 -0
- package/select/Listbox.js +40 -54
- package/select/Option.js +28 -36
- package/select/Select.accessibility.test.js +228 -0
- package/select/Select.js +107 -171
- package/select/Select.stories.tsx +59 -111
- package/select/Select.test.js +1895 -1858
- package/select/types.d.ts +15 -16
- package/sidenav/Sidenav.accessibility.test.js +59 -0
- package/sidenav/Sidenav.js +44 -81
- package/sidenav/Sidenav.stories.tsx +4 -9
- package/sidenav/Sidenav.test.js +3 -10
- package/{layout → sidenav}/SidenavContext.d.ts +1 -1
- package/{layout → sidenav}/SidenavContext.js +3 -9
- package/sidenav/types.d.ts +20 -20
- package/slider/Slider.accessibility.test.js +104 -0
- package/slider/Slider.js +70 -126
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.accessibility.test.js +96 -0
- package/spinner/Spinner.js +21 -55
- package/spinner/Spinner.test.js +25 -34
- package/spinner/types.d.ts +3 -3
- 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 +49 -97
- package/switch/Switch.stories.tsx +12 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- 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 +76 -33
- package/table/{Table.stories.jsx → Table.stories.tsx} +309 -2
- package/table/Table.test.js +93 -6
- package/table/types.d.ts +34 -6
- package/tabs/Tab.js +22 -37
- package/tabs/Tabs.accessibility.test.js +56 -0
- package/tabs/Tabs.js +59 -147
- package/tabs/Tabs.stories.tsx +8 -4
- package/tabs/Tabs.test.js +57 -131
- package/tabs/types.d.ts +21 -21
- package/tag/Tag.accessibility.test.js +69 -0
- package/tag/Tag.js +27 -57
- package/tag/Tag.stories.tsx +4 -7
- package/tag/Tag.test.js +17 -36
- package/tag/types.d.ts +9 -9
- package/text-input/Suggestion.js +9 -26
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +30 -70
- package/text-input/TextInput.accessibility.test.js +321 -0
- package/text-input/TextInput.js +203 -289
- package/text-input/TextInput.stories.tsx +65 -160
- package/text-input/TextInput.test.js +1227 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.accessibility.test.js +155 -0
- package/textarea/Textarea.js +68 -109
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
- package/textarea/Textarea.test.js +150 -179
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
- package/toggle-group/ToggleGroup.js +25 -64
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +48 -81
- package/toggle-group/types.d.ts +12 -12
- package/typography/Typography.accessibility.test.js +339 -0
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +43 -141
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +25 -39
- package/wizard/Wizard.accessibility.test.js +55 -0
- package/wizard/Wizard.js +27 -73
- package/wizard/Wizard.stories.tsx +19 -0
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +8 -8
- 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 -75
- package/paginator/Icons.d.ts +0 -5
- package/paginator/Icons.js +0 -54
- package/password-input/Icons.d.ts +0 -6
- package/password-input/Icons.js +0 -39
- package/resultsetTable/Icons.d.ts +0 -7
- package/resultsetTable/ResultsetTable.d.ts +0 -4
- package/select/Icons.d.ts +0 -10
- package/select/Icons.js +0 -93
- package/sidenav/Icons.d.ts +0 -7
- package/sidenav/Icons.js +0 -51
- package/slider/Slider.stories.tsx +0 -240
- package/text-input/Icons.d.ts +0 -8
- package/text-input/Icons.js +0 -60
- /package/{resultsetTable → action-icon}/types.js +0 -0
- /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
package/nav-tabs/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
3
|
+
export type NavTabsContextProps = {
|
|
4
4
|
iconPosition: "top" | "left";
|
|
5
5
|
tabIndex: number;
|
|
6
6
|
focusedLabel: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type TabProps = {
|
|
9
9
|
/**
|
|
10
10
|
* Whether the tab is active or not.
|
|
11
11
|
*/
|
|
@@ -19,7 +19,7 @@ export declare type TabProps = {
|
|
|
19
19
|
*/
|
|
20
20
|
href?: string;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Material Symbol name or SVG element used as the icon that will be displayed in the tab.
|
|
23
23
|
*/
|
|
24
24
|
icon?: string | SVG;
|
|
25
25
|
/**
|
|
@@ -31,22 +31,22 @@ export declare type TabProps = {
|
|
|
31
31
|
*/
|
|
32
32
|
notificationNumber?: boolean | number;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Tab text label.
|
|
35
35
|
*/
|
|
36
36
|
children: string;
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
type Props = {
|
|
39
39
|
/**
|
|
40
40
|
* Whether the icon should appear above or to the left of the label.
|
|
41
41
|
*/
|
|
42
42
|
iconPosition?: "top" | "left";
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Contains one or more DxcNavTabs.Tab.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
children: React.ReactNode;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Value of the tabindex attribute applied to each tab.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
tabIndex?: number;
|
|
51
51
|
};
|
|
52
52
|
export default Props;
|
|
@@ -0,0 +1,228 @@
|
|
|
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 _NumberInput = _interopRequireDefault(require("./NumberInput.tsx"));
|
|
12
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
13
|
+
global.globalThis = global;
|
|
14
|
+
global.DOMRect = {
|
|
15
|
+
fromRect: function fromRect() {
|
|
16
|
+
return {
|
|
17
|
+
top: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
bottom: 0,
|
|
20
|
+
right: 0,
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
27
|
+
function ResizeObserver() {
|
|
28
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
29
|
+
}
|
|
30
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
31
|
+
key: "observe",
|
|
32
|
+
value: function observe() {}
|
|
33
|
+
}, {
|
|
34
|
+
key: "unobserve",
|
|
35
|
+
value: function unobserve() {}
|
|
36
|
+
}, {
|
|
37
|
+
key: "disconnect",
|
|
38
|
+
value: function disconnect() {}
|
|
39
|
+
}]);
|
|
40
|
+
return ResizeObserver;
|
|
41
|
+
}();
|
|
42
|
+
describe("Number input component accessibility tests", function () {
|
|
43
|
+
it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
44
|
+
var _render, container, results;
|
|
45
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
46
|
+
while (1) switch (_context.prev = _context.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
|
|
49
|
+
label: "Number input label",
|
|
50
|
+
helperText: "Helper text",
|
|
51
|
+
placeholder: "Placeholder",
|
|
52
|
+
defaultValue: "10",
|
|
53
|
+
margin: "medium",
|
|
54
|
+
min: 0,
|
|
55
|
+
max: 100,
|
|
56
|
+
suffix: "Suffix",
|
|
57
|
+
prefix: "Prefix",
|
|
58
|
+
name: "Name",
|
|
59
|
+
size: "medium",
|
|
60
|
+
step: 1
|
|
61
|
+
})), container = _render.container;
|
|
62
|
+
_context.next = 3;
|
|
63
|
+
return (0, _axeHelper.axe)(container);
|
|
64
|
+
case 3:
|
|
65
|
+
results = _context.sent;
|
|
66
|
+
expect(results).toHaveNoViolations();
|
|
67
|
+
case 5:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
})));
|
|
73
|
+
it("Should not have basic accessibility issues for optional mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
74
|
+
var _render2, container, results;
|
|
75
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
76
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
|
|
79
|
+
label: "Number input label",
|
|
80
|
+
helperText: "Helper text",
|
|
81
|
+
placeholder: "Placeholder",
|
|
82
|
+
defaultValue: "10",
|
|
83
|
+
margin: "medium",
|
|
84
|
+
min: 0,
|
|
85
|
+
max: 100,
|
|
86
|
+
suffix: "Suffix",
|
|
87
|
+
prefix: "Prefix",
|
|
88
|
+
name: "Name",
|
|
89
|
+
size: "medium",
|
|
90
|
+
step: 1,
|
|
91
|
+
optional: true
|
|
92
|
+
})), container = _render2.container;
|
|
93
|
+
_context2.next = 3;
|
|
94
|
+
return (0, _axeHelper.axe)(container);
|
|
95
|
+
case 3:
|
|
96
|
+
results = _context2.sent;
|
|
97
|
+
expect(results).toHaveNoViolations();
|
|
98
|
+
case 5:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context2.stop();
|
|
101
|
+
}
|
|
102
|
+
}, _callee2);
|
|
103
|
+
})));
|
|
104
|
+
it("Should not have basic accessibility issues for error mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
105
|
+
var _render3, container, results;
|
|
106
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
107
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
108
|
+
case 0:
|
|
109
|
+
_render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
|
|
110
|
+
label: "Number input label",
|
|
111
|
+
helperText: "Helper text",
|
|
112
|
+
placeholder: "Placeholder",
|
|
113
|
+
defaultValue: "10",
|
|
114
|
+
margin: "medium",
|
|
115
|
+
min: 0,
|
|
116
|
+
max: 100,
|
|
117
|
+
suffix: "Suffix",
|
|
118
|
+
prefix: "Prefix",
|
|
119
|
+
name: "Name",
|
|
120
|
+
error: "Input error",
|
|
121
|
+
size: "medium",
|
|
122
|
+
step: 1
|
|
123
|
+
})), container = _render3.container;
|
|
124
|
+
_context3.next = 3;
|
|
125
|
+
return (0, _axeHelper.axe)(container);
|
|
126
|
+
case 3:
|
|
127
|
+
results = _context3.sent;
|
|
128
|
+
expect(results).toHaveNoViolations();
|
|
129
|
+
case 5:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context3.stop();
|
|
132
|
+
}
|
|
133
|
+
}, _callee3);
|
|
134
|
+
})));
|
|
135
|
+
it("Should not have basic accessibility issues for disabled mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
136
|
+
var _render4, container, results;
|
|
137
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
138
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
_render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
|
|
141
|
+
label: "Number input label",
|
|
142
|
+
helperText: "Helper text",
|
|
143
|
+
placeholder: "Placeholder",
|
|
144
|
+
defaultValue: "10",
|
|
145
|
+
margin: "medium",
|
|
146
|
+
min: 0,
|
|
147
|
+
max: 100,
|
|
148
|
+
suffix: "Suffix",
|
|
149
|
+
prefix: "Prefix",
|
|
150
|
+
name: "Name",
|
|
151
|
+
size: "medium",
|
|
152
|
+
step: 1,
|
|
153
|
+
disabled: true
|
|
154
|
+
})), container = _render4.container;
|
|
155
|
+
_context4.next = 3;
|
|
156
|
+
return (0, _axeHelper.axe)(container);
|
|
157
|
+
case 3:
|
|
158
|
+
results = _context4.sent;
|
|
159
|
+
expect(results).toHaveNoViolations();
|
|
160
|
+
case 5:
|
|
161
|
+
case "end":
|
|
162
|
+
return _context4.stop();
|
|
163
|
+
}
|
|
164
|
+
}, _callee4);
|
|
165
|
+
})));
|
|
166
|
+
it("Should not have basic accessibility issues for read-only mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
167
|
+
var _render5, container, results;
|
|
168
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
169
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
170
|
+
case 0:
|
|
171
|
+
_render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
|
|
172
|
+
label: "Number input label",
|
|
173
|
+
helperText: "Helper text",
|
|
174
|
+
placeholder: "Placeholder",
|
|
175
|
+
defaultValue: "10",
|
|
176
|
+
margin: "medium",
|
|
177
|
+
min: 0,
|
|
178
|
+
max: 100,
|
|
179
|
+
suffix: "Suffix",
|
|
180
|
+
prefix: "Prefix",
|
|
181
|
+
name: "Name",
|
|
182
|
+
size: "medium",
|
|
183
|
+
step: 1,
|
|
184
|
+
readOnly: true
|
|
185
|
+
})), container = _render5.container;
|
|
186
|
+
_context5.next = 3;
|
|
187
|
+
return (0, _axeHelper.axe)(container);
|
|
188
|
+
case 3:
|
|
189
|
+
results = _context5.sent;
|
|
190
|
+
expect(results).toHaveNoViolations();
|
|
191
|
+
case 5:
|
|
192
|
+
case "end":
|
|
193
|
+
return _context5.stop();
|
|
194
|
+
}
|
|
195
|
+
}, _callee5);
|
|
196
|
+
})));
|
|
197
|
+
it("Should not have basic accessibility issues for autocomplete mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
198
|
+
var _render6, container, results;
|
|
199
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
200
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
201
|
+
case 0:
|
|
202
|
+
_render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
|
|
203
|
+
label: "Number input label",
|
|
204
|
+
helperText: "Helper text",
|
|
205
|
+
placeholder: "Placeholder",
|
|
206
|
+
defaultValue: "10",
|
|
207
|
+
margin: "medium",
|
|
208
|
+
min: 0,
|
|
209
|
+
max: 100,
|
|
210
|
+
suffix: "Suffix",
|
|
211
|
+
prefix: "Prefix",
|
|
212
|
+
name: "Name",
|
|
213
|
+
size: "medium",
|
|
214
|
+
step: 1,
|
|
215
|
+
autocomplete: "on"
|
|
216
|
+
})), container = _render6.container;
|
|
217
|
+
_context6.next = 3;
|
|
218
|
+
return (0, _axeHelper.axe)(container);
|
|
219
|
+
case 3:
|
|
220
|
+
results = _context6.sent;
|
|
221
|
+
expect(results).toHaveNoViolations();
|
|
222
|
+
case 5:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context6.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee6);
|
|
227
|
+
})));
|
|
228
|
+
});
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import NumberInputPropsType from "./types";
|
|
3
|
-
declare type NumberInputContextProps = {
|
|
4
|
-
typeNumber?: string;
|
|
5
|
-
minNumber?: number;
|
|
6
|
-
maxNumber?: number;
|
|
7
|
-
stepNumber?: number;
|
|
8
|
-
};
|
|
9
|
-
export declare const NumberInputContext: React.Context<NumberInputContextProps>;
|
|
10
3
|
declare const DxcNumberInput: React.ForwardRefExoticComponent<NumberInputPropsType & React.RefAttributes<HTMLDivElement>>;
|
|
11
4
|
export default DxcNumberInput;
|
|
@@ -1,56 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] =
|
|
9
|
-
|
|
8
|
+
exports["default"] = void 0;
|
|
10
9
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
11
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
-
|
|
16
12
|
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
17
|
-
|
|
13
|
+
var _NumberInputContext = require("./NumberInputContext");
|
|
18
14
|
var _templateObject;
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
exports.NumberInputContext = NumberInputContext;
|
|
23
|
-
|
|
15
|
+
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); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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; }
|
|
24
17
|
var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
25
18
|
var label = _ref.label,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
name = _ref.name,
|
|
20
|
+
defaultValue = _ref.defaultValue,
|
|
21
|
+
value = _ref.value,
|
|
22
|
+
helperText = _ref.helperText,
|
|
23
|
+
placeholder = _ref.placeholder,
|
|
24
|
+
disabled = _ref.disabled,
|
|
25
|
+
optional = _ref.optional,
|
|
26
|
+
readOnly = _ref.readOnly,
|
|
27
|
+
prefix = _ref.prefix,
|
|
28
|
+
suffix = _ref.suffix,
|
|
29
|
+
min = _ref.min,
|
|
30
|
+
max = _ref.max,
|
|
31
|
+
_ref$step = _ref.step,
|
|
32
|
+
step = _ref$step === void 0 ? 1 : _ref$step,
|
|
33
|
+
onChange = _ref.onChange,
|
|
34
|
+
onBlur = _ref.onBlur,
|
|
35
|
+
error = _ref.error,
|
|
36
|
+
autocomplete = _ref.autocomplete,
|
|
37
|
+
margin = _ref.margin,
|
|
38
|
+
size = _ref.size,
|
|
39
|
+
tabIndex = _ref.tabIndex;
|
|
40
|
+
var numberInputRef = _react["default"].useRef(null);
|
|
41
|
+
(0, _react.useEffect)(function () {
|
|
42
|
+
var _numberInputRef$curre;
|
|
43
|
+
var input = (_numberInputRef$curre = numberInputRef.current) === null || _numberInputRef$curre === void 0 ? void 0 : _numberInputRef$curre.getElementsByTagName("input")[0];
|
|
44
|
+
var preventDefault = function preventDefault(event) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
};
|
|
47
|
+
input === null || input === void 0 ? void 0 : input.addEventListener("wheel", preventDefault, {
|
|
48
|
+
passive: false
|
|
49
|
+
});
|
|
50
|
+
return function () {
|
|
51
|
+
input === null || input === void 0 ? void 0 : input.removeEventListener("wheel", preventDefault);
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
return /*#__PURE__*/_react["default"].createElement(_NumberInputContext.NumberInputContext.Provider, {
|
|
47
55
|
value: {
|
|
48
56
|
typeNumber: "number",
|
|
49
57
|
minNumber: min,
|
|
50
58
|
maxNumber: max,
|
|
51
59
|
stepNumber: step
|
|
52
60
|
}
|
|
53
|
-
}, /*#__PURE__*/_react["default"].createElement(NumberInputContainer,
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement(NumberInputContainer, {
|
|
62
|
+
ref: numberInputRef
|
|
63
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
54
64
|
label: label,
|
|
55
65
|
name: name,
|
|
56
66
|
defaultValue: defaultValue,
|
|
@@ -59,6 +69,7 @@ var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, r
|
|
|
59
69
|
placeholder: placeholder,
|
|
60
70
|
disabled: disabled,
|
|
61
71
|
optional: optional,
|
|
72
|
+
readOnly: readOnly,
|
|
62
73
|
prefix: prefix,
|
|
63
74
|
suffix: suffix,
|
|
64
75
|
error: error,
|
|
@@ -71,8 +82,5 @@ var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, r
|
|
|
71
82
|
ref: ref
|
|
72
83
|
})));
|
|
73
84
|
});
|
|
74
|
-
|
|
75
85
|
var NumberInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n // Chrome, Safari, Edge, Opera\n input::-webkit-outer-spin-button,\n input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n // Firefox\n input[type=\"number\"] {\n -moz-appearance: textfield;\n }\n"])));
|
|
76
|
-
|
|
77
|
-
var _default = DxcNumberInput;
|
|
78
|
-
exports["default"] = _default;
|
|
86
|
+
var _default = exports["default"] = DxcNumberInput;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
3
2
|
import Title from "../../.storybook/components/Title";
|
|
4
3
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
-
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
6
4
|
import DxcNumberInput from "./NumberInput";
|
|
7
5
|
|
|
8
6
|
export default {
|
|
9
|
-
title: "Number
|
|
7
|
+
title: "Number Input",
|
|
10
8
|
component: DxcNumberInput,
|
|
11
9
|
};
|
|
12
10
|
|
|
@@ -32,6 +30,39 @@ export const Chromatic = () => (
|
|
|
32
30
|
<Title title="Disabled, helper text, optional and value" theme="light" level={4} />
|
|
33
31
|
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional defaultValue="10" />
|
|
34
32
|
</ExampleContainer>
|
|
33
|
+
<ExampleContainer>
|
|
34
|
+
<Title title="Read only" theme="light" level={4} />
|
|
35
|
+
<DxcNumberInput
|
|
36
|
+
label="Example label"
|
|
37
|
+
helperText="Help message"
|
|
38
|
+
readOnly
|
|
39
|
+
optional
|
|
40
|
+
prefix="€"
|
|
41
|
+
defaultValue="33"
|
|
42
|
+
/>
|
|
43
|
+
</ExampleContainer>
|
|
44
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
45
|
+
<Title title="Hovered read only" theme="light" level={4} />
|
|
46
|
+
<DxcNumberInput
|
|
47
|
+
label="Example label"
|
|
48
|
+
helperText="Help message"
|
|
49
|
+
readOnly
|
|
50
|
+
optional
|
|
51
|
+
prefix="€"
|
|
52
|
+
defaultValue="1"
|
|
53
|
+
/>
|
|
54
|
+
</ExampleContainer>
|
|
55
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
56
|
+
<Title title="Active read only" theme="light" level={4} />
|
|
57
|
+
<DxcNumberInput
|
|
58
|
+
label="Example label"
|
|
59
|
+
helperText="Help message"
|
|
60
|
+
readOnly
|
|
61
|
+
optional
|
|
62
|
+
prefix="€"
|
|
63
|
+
placeholder="Placeholder"
|
|
64
|
+
/>
|
|
65
|
+
</ExampleContainer>
|
|
35
66
|
<ExampleContainer>
|
|
36
67
|
<Title title="Prefix" theme="light" level={4} />
|
|
37
68
|
<DxcNumberInput label="With prefix" prefix="+34" />
|
|
@@ -42,29 +73,14 @@ export const Chromatic = () => (
|
|
|
42
73
|
</ExampleContainer>
|
|
43
74
|
<ExampleContainer>
|
|
44
75
|
<Title title="Invalid" theme="light" level={4} />
|
|
45
|
-
<DxcNumberInput
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</ExampleContainer>
|
|
54
|
-
<ExampleContainer>
|
|
55
|
-
<Title title="Helper text, value and error" theme="dark" level={4} />
|
|
56
|
-
<DxcNumberInput label="Number input" helperText="Help message" error="Error message." defaultValue="199" />
|
|
57
|
-
</ExampleContainer>
|
|
58
|
-
<ExampleContainer>
|
|
59
|
-
<Title title="Disabled and placeholder" theme="dark" level={4} />
|
|
60
|
-
<DxcNumberInput label="Disabled number input" disabled placeholder="Placeholder" />
|
|
61
|
-
</ExampleContainer>
|
|
62
|
-
<ExampleContainer>
|
|
63
|
-
<Title title="Disabled, helper text, optional and value" theme="dark" level={4} />
|
|
64
|
-
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional defaultValue="1232454" />
|
|
65
|
-
</ExampleContainer>
|
|
66
|
-
</DarkContainer>
|
|
67
|
-
</BackgroundColorProvider>
|
|
76
|
+
<DxcNumberInput
|
|
77
|
+
label="Error number input"
|
|
78
|
+
helperText="Help message"
|
|
79
|
+
error="Error message."
|
|
80
|
+
defaultValue="23"
|
|
81
|
+
optional
|
|
82
|
+
/>
|
|
83
|
+
</ExampleContainer>
|
|
68
84
|
<Title title="Margins" theme="light" level={2} />
|
|
69
85
|
<ExampleContainer>
|
|
70
86
|
<Title title="Xxsmall margin" theme="light" level={4} />
|