@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/alert/Alert.js
CHANGED
|
@@ -1,122 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
12
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
|
-
|
|
20
13
|
var _variables = require("../common/variables");
|
|
21
|
-
|
|
22
14
|
var _utils = require("../common/utils");
|
|
23
|
-
|
|
24
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
16
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
|
-
|
|
28
|
-
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
29
|
-
|
|
17
|
+
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
30
18
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
-
|
|
36
|
-
var alertIcons = {
|
|
37
|
-
close: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
38
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
39
|
-
width: "20",
|
|
40
|
-
height: "20",
|
|
41
|
-
viewBox: "0 0 24 24",
|
|
42
|
-
fill: "currentColor"
|
|
43
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
44
|
-
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
|
45
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
46
|
-
d: "M0 0h24v24H0z",
|
|
47
|
-
fill: "none"
|
|
48
|
-
})),
|
|
49
|
-
info: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
50
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
51
|
-
width: "23",
|
|
52
|
-
height: "23",
|
|
53
|
-
viewBox: "0 0 24 24",
|
|
54
|
-
fill: "currentColor"
|
|
55
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
56
|
-
d: "M0 0h24v24H0z",
|
|
57
|
-
fill: "none"
|
|
58
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
59
|
-
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"
|
|
60
|
-
})),
|
|
61
|
-
success: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
62
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
63
|
-
width: "23",
|
|
64
|
-
height: "23",
|
|
65
|
-
viewBox: "0 0 24 24",
|
|
66
|
-
fill: "currentColor"
|
|
67
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
68
|
-
d: "M0 0h24v24H0z",
|
|
69
|
-
fill: "none"
|
|
70
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
71
|
-
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
|
|
72
|
-
})),
|
|
73
|
-
warning: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
74
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
75
|
-
width: "23",
|
|
76
|
-
height: "23",
|
|
77
|
-
viewBox: "0 0 24 24",
|
|
78
|
-
fill: "currentColor"
|
|
79
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
80
|
-
d: "M0 0h24v24H0z",
|
|
81
|
-
fill: "none"
|
|
82
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
83
|
-
d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"
|
|
84
|
-
})),
|
|
85
|
-
error: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
86
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
87
|
-
width: "23",
|
|
88
|
-
height: "23",
|
|
89
|
-
viewBox: "0 0 24 24",
|
|
90
|
-
fill: "currentColor"
|
|
91
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
92
|
-
d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z",
|
|
93
|
-
fill: "currentColor"
|
|
94
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
95
|
-
d: "M0 0h24v24H0z",
|
|
96
|
-
fill: "none"
|
|
97
|
-
}))
|
|
98
|
-
};
|
|
99
|
-
|
|
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); }
|
|
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; }
|
|
100
21
|
var DxcAlert = function DxcAlert(_ref) {
|
|
101
22
|
var _ref$type = _ref.type,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
23
|
+
type = _ref$type === void 0 ? "info" : _ref$type,
|
|
24
|
+
_ref$mode = _ref.mode,
|
|
25
|
+
mode = _ref$mode === void 0 ? "inline" : _ref$mode,
|
|
26
|
+
_ref$inlineText = _ref.inlineText,
|
|
27
|
+
inlineText = _ref$inlineText === void 0 ? "" : _ref$inlineText,
|
|
28
|
+
onClose = _ref.onClose,
|
|
29
|
+
children = _ref.children,
|
|
30
|
+
margin = _ref.margin,
|
|
31
|
+
_ref$size = _ref.size,
|
|
32
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
33
|
+
tabIndex = _ref.tabIndex;
|
|
113
34
|
var colorsTheme = (0, _useTheme["default"])();
|
|
114
35
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
115
|
-
|
|
116
36
|
var getTypeText = function getTypeText() {
|
|
117
37
|
return type === "info" ? translatedLabels.alert.infoTitleText : type === "confirm" ? translatedLabels.alert.successTitleText : type === "warning" ? translatedLabels.alert.warningTitleText : translatedLabels.alert.errorTitleText;
|
|
118
38
|
};
|
|
119
|
-
|
|
120
39
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
121
40
|
theme: colorsTheme.alert
|
|
122
41
|
}, /*#__PURE__*/_react["default"].createElement(AlertModal, {
|
|
@@ -128,17 +47,27 @@ var DxcAlert = function DxcAlert(_ref) {
|
|
|
128
47
|
mode: mode,
|
|
129
48
|
type: type,
|
|
130
49
|
margin: margin,
|
|
131
|
-
size: size
|
|
50
|
+
size: size,
|
|
51
|
+
role: type === "error" ? "alert" : "status",
|
|
52
|
+
"aria-live": type === "error" ? "assertive" : "off"
|
|
132
53
|
}, /*#__PURE__*/_react["default"].createElement(AlertInfo, null, /*#__PURE__*/_react["default"].createElement(AlertIcon, {
|
|
133
54
|
type: type
|
|
134
|
-
}, type === "info" &&
|
|
55
|
+
}, type === "info" && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
56
|
+
icon: "filled_info"
|
|
57
|
+
}) || type === "confirm" && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
58
|
+
icon: "filled_check_circle"
|
|
59
|
+
}) || type === "warning" && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
60
|
+
icon: "filled_warning"
|
|
61
|
+
}) || type === "error" && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
62
|
+
icon: "filled_cancel"
|
|
63
|
+
})), /*#__PURE__*/_react["default"].createElement(AlertText, null, /*#__PURE__*/_react["default"].createElement(AlertTitle, null, getTypeText()), inlineText && inlineText !== "" && "-", /*#__PURE__*/_react["default"].createElement(AlertInlineText, null, inlineText)), onClose && /*#__PURE__*/_react["default"].createElement(AlertCloseAction, {
|
|
135
64
|
onClick: onClose,
|
|
136
|
-
tabIndex: tabIndex
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
65
|
+
tabIndex: tabIndex,
|
|
66
|
+
"aria-label": "Close alert"
|
|
67
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
68
|
+
icon: "close"
|
|
69
|
+
}))), children && /*#__PURE__*/_react["default"].createElement(AlertContent, null, children))));
|
|
140
70
|
};
|
|
141
|
-
|
|
142
71
|
var sizes = {
|
|
143
72
|
small: "280px",
|
|
144
73
|
medium: "480px",
|
|
@@ -146,11 +75,9 @@ var sizes = {
|
|
|
146
75
|
fillParent: "100%",
|
|
147
76
|
fitContent: "fit-content"
|
|
148
77
|
};
|
|
149
|
-
|
|
150
78
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
151
79
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
152
80
|
};
|
|
153
|
-
|
|
154
81
|
var AlertModal = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n width: ", ";\n height: ", ";\n justify-content: ", ";\n align-items: ", ";\n top: ", ";\n left: ", ";\n position: ", ";\n display: ", ";\n z-index: ", ";\n"])), function (props) {
|
|
155
82
|
return props.theme.fontSizeBase;
|
|
156
83
|
}, function (props) {
|
|
@@ -172,7 +99,6 @@ var AlertModal = _styledComponents["default"].div(_templateObject || (_templateO
|
|
|
172
99
|
}, function (props) {
|
|
173
100
|
return props.mode === "modal" ? "1200" : "";
|
|
174
101
|
});
|
|
175
|
-
|
|
176
102
|
var OverlayContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n position: ", ";\n top: ", ";\n bottom: ", ";\n left: ", ";\n right: ", ";\n"])), function (props) {
|
|
177
103
|
return props.mode === "modal" ? "".concat(props.theme.overlayColor) : "transparent";
|
|
178
104
|
}, function (props) {
|
|
@@ -186,7 +112,6 @@ var OverlayContainer = _styledComponents["default"].div(_templateObject2 || (_te
|
|
|
186
112
|
}, function (props) {
|
|
187
113
|
return props.mode === "modal" ? "0" : "";
|
|
188
114
|
});
|
|
189
|
-
|
|
190
115
|
var AlertContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n display: ", ";\n overflow: hidden;\n box-sizing: border-box;\n\n background-color: ", ";\n\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-left: 12px;\n padding-right: 12px;\n justify-content: ", ";\n align-items: ", ";\n max-width: ", ";\n width: ", ";\n z-index: ", ";\n"])), function (props) {
|
|
191
116
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
192
117
|
}, function (props) {
|
|
@@ -220,11 +145,9 @@ var AlertContainer = _styledComponents["default"].div(_templateObject3 || (_temp
|
|
|
220
145
|
}, function (props) {
|
|
221
146
|
return props.mode === "modal" ? "1300" : "";
|
|
222
147
|
});
|
|
223
|
-
|
|
224
148
|
var AlertInfo = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n height: calc(48px - calc(", " * 2));\n align-items: center;\n width: 100%;\n"])), function (props) {
|
|
225
149
|
return props.theme.borderThickness;
|
|
226
150
|
});
|
|
227
|
-
|
|
228
151
|
var AlertTitle = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: 8px;\n padding-right: ", ";\n padding-left: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n"])), function (props) {
|
|
229
152
|
return props.theme.titlePaddingRight;
|
|
230
153
|
}, function (props) {
|
|
@@ -242,7 +165,6 @@ var AlertTitle = _styledComponents["default"].div(_templateObject5 || (_template
|
|
|
242
165
|
}, function (props) {
|
|
243
166
|
return props.theme.titleTextTransform;
|
|
244
167
|
});
|
|
245
|
-
|
|
246
168
|
var AlertInlineText = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 8px;\n padding-right: ", ";\n padding-left: ", ";\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n"])), function (props) {
|
|
247
169
|
return props.theme.inlineTextPaddingRight;
|
|
248
170
|
}, function (props) {
|
|
@@ -258,8 +180,7 @@ var AlertInlineText = _styledComponents["default"].div(_templateObject6 || (_tem
|
|
|
258
180
|
}, function (props) {
|
|
259
181
|
return props.theme.inlineTextFontColor;
|
|
260
182
|
});
|
|
261
|
-
|
|
262
|
-
var AlertIcon = _styledComponents["default"].span(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n margin-right: 12px;\n padding-right: ", ";\n padding-left: ", ";\n\n color: ", ";\n\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
183
|
+
var AlertIcon = _styledComponents["default"].span(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n margin-right: 12px;\n padding-right: ", ";\n padding-left: ", ";\n\n color: ", ";\n\n font-size: ", ";\n"])), function (props) {
|
|
263
184
|
return props.theme.iconPaddingRight;
|
|
264
185
|
}, function (props) {
|
|
265
186
|
return props.theme.iconPaddingLeft;
|
|
@@ -267,23 +188,16 @@ var AlertIcon = _styledComponents["default"].span(_templateObject7 || (_template
|
|
|
267
188
|
return props.type === "info" && props.theme.infoIconColor || props.type === "confirm" && props.theme.successIconColor || props.type === "warning" && props.theme.warningIconColor || props.type === "error" && props.theme.errorIconColor;
|
|
268
189
|
}, function (props) {
|
|
269
190
|
return props.theme.iconSize;
|
|
270
|
-
}, function (props) {
|
|
271
|
-
return props.theme.iconSize;
|
|
272
191
|
});
|
|
273
|
-
|
|
274
192
|
var AlertText = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n flex-grow: 1;\n align-items: center;\n overflow: hidden;\n"])));
|
|
275
|
-
|
|
276
193
|
var AlertContent = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n flex: 1 1 auto;\n padding: ", ";\n overflow-y: auto;\n"])), function (props) {
|
|
277
194
|
return "".concat(props.theme.contentPaddingTop, " ").concat(props.theme.contentPaddingRight, " ").concat(props.theme.contentPaddingBottom, " ").concat(props.theme.contentPaddingLeft);
|
|
278
195
|
});
|
|
279
|
-
|
|
280
|
-
var AlertCloseAction = _styledComponents["default"].button(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n border: 1px solid transparent;\n border-radius: 2px;\n box-shadow: 0 0 0 2px transparent;\n padding: 3px;\n margin-left: 12px;\n background-color: transparent;\n color: #000000;\n cursor: pointer;\n\n &:hover {\n background-color: ", ";\n }\n &:focus,\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
196
|
+
var AlertCloseAction = _styledComponents["default"].button(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n font-size: 20px;\n border: 1px solid transparent;\n border-radius: 2px;\n box-shadow: 0 0 0 2px transparent;\n padding: 3px;\n margin-left: 12px;\n background-color: transparent;\n color: #000000;\n cursor: pointer;\n\n &:hover {\n background-color: ", ";\n }\n &:focus,\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
281
197
|
return props.theme.hoverActionBackgroundColor;
|
|
282
198
|
}, function (props) {
|
|
283
199
|
return props.theme.focusActionBorderColor;
|
|
284
200
|
}, function (props) {
|
|
285
201
|
return props.theme.activeActionBackgroundColor;
|
|
286
202
|
});
|
|
287
|
-
|
|
288
|
-
var _default = DxcAlert;
|
|
289
|
-
exports["default"] = _default;
|
|
203
|
+
var _default = exports["default"] = DxcAlert;
|
package/alert/Alert.test.js
CHANGED
|
@@ -1,92 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
6
|
var _Alert = _interopRequireDefault(require("./Alert.tsx"));
|
|
10
|
-
|
|
11
7
|
describe("Alert component tests", function () {
|
|
12
8
|
test("Info alert renders with correct text", function () {
|
|
13
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
type: "info",
|
|
11
|
+
inlineText: "info-alert-text"
|
|
12
|
+
})),
|
|
13
|
+
getByText = _render.getByText;
|
|
19
14
|
expect(getByText("information")).toBeTruthy();
|
|
20
15
|
expect(getByText("info-alert-text")).toBeTruthy();
|
|
21
16
|
});
|
|
22
17
|
test("Confirm alert renders with correct text", function () {
|
|
23
18
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
type: "confirm",
|
|
20
|
+
inlineText: "confirm-alert-text"
|
|
21
|
+
})),
|
|
22
|
+
getByText = _render2.getByText;
|
|
29
23
|
expect(getByText("success")).toBeTruthy();
|
|
30
24
|
expect(getByText("confirm-alert-text")).toBeTruthy();
|
|
31
25
|
});
|
|
32
26
|
test("Warning alert renders with correct text", function () {
|
|
33
27
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
type: "warning",
|
|
29
|
+
inlineText: "warning-alert-text"
|
|
30
|
+
})),
|
|
31
|
+
getByText = _render3.getByText;
|
|
39
32
|
expect(getByText("warning")).toBeTruthy();
|
|
40
33
|
expect(getByText("warning-alert-text")).toBeTruthy();
|
|
41
34
|
});
|
|
42
35
|
test("Error alert renders with correct text", function () {
|
|
43
36
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
type: "error",
|
|
38
|
+
inlineText: "error-alert-text"
|
|
39
|
+
})),
|
|
40
|
+
getByText = _render4.getByText;
|
|
49
41
|
expect(getByText("error")).toBeTruthy();
|
|
50
42
|
expect(getByText("error-alert-text")).toBeTruthy();
|
|
51
43
|
});
|
|
52
44
|
test("Alert renders with correct children", function () {
|
|
53
45
|
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
inlineText: "alert-text"
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement("p", null, "sample-children"))),
|
|
48
|
+
getByText = _render5.getByText;
|
|
58
49
|
expect(getByText("alert-text")).toBeTruthy();
|
|
59
50
|
expect(getByText("sample-children")).toBeTruthy();
|
|
60
51
|
});
|
|
61
52
|
test("Calls correct function on close", function () {
|
|
62
53
|
var onClose = jest.fn();
|
|
63
|
-
|
|
64
54
|
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
onClose: onClose,
|
|
56
|
+
inlineText: "info-alert-text"
|
|
57
|
+
})),
|
|
58
|
+
getByRole = _render6.getByRole;
|
|
70
59
|
var closeButton = getByRole("button");
|
|
71
|
-
|
|
72
60
|
_react2.fireEvent.click(closeButton);
|
|
73
|
-
|
|
74
61
|
expect(onClose).toHaveBeenCalled();
|
|
75
62
|
});
|
|
76
63
|
test("Modal alert calls correct function on close", function () {
|
|
77
64
|
var onClose = jest.fn();
|
|
78
|
-
|
|
79
65
|
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
onClose: onClose,
|
|
67
|
+
mode: "modal",
|
|
68
|
+
inlineText: "info-alert-text"
|
|
69
|
+
})),
|
|
70
|
+
getByRole = _render7.getByRole;
|
|
86
71
|
var closeButton = getByRole("button");
|
|
87
|
-
|
|
88
72
|
_react2.fireEvent.click(closeButton);
|
|
89
|
-
|
|
90
73
|
expect(onClose).toHaveBeenCalled();
|
|
91
74
|
});
|
|
92
75
|
});
|
package/alert/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type Props = {
|
|
10
10
|
/**
|
|
11
11
|
* Uses on of the available alert types.
|
|
12
12
|
*/
|
|
@@ -17,7 +17,7 @@ declare type Props = {
|
|
|
17
17
|
* There is no overlay layer. Position should be decided by the user.
|
|
18
18
|
* 'modal': The alert will be displayed in the middle of the screen with an overlay layer behind.
|
|
19
19
|
* The onClose function will be executed when the X button or the overlay is clicked. d
|
|
20
|
-
* The user has the responsibility of
|
|
20
|
+
* The user has the responsibility of hiding the modal in the onClose function, otherwise the modal will remain visible.
|
|
21
21
|
*/
|
|
22
22
|
mode?: "inline" | "modal";
|
|
23
23
|
/**
|
|
@@ -42,7 +42,7 @@ declare type Props = {
|
|
|
42
42
|
*/
|
|
43
43
|
size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Value of the tabindex attribute applied to the close button.
|
|
46
46
|
*/
|
|
47
47
|
tabIndex?: number;
|
|
48
48
|
};
|
|
@@ -0,0 +1,129 @@
|
|
|
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 _Badge = _interopRequireDefault(require("./Badge.tsx"));
|
|
10
|
+
var _Flex = _interopRequireDefault(require("../flex/Flex.tsx"));
|
|
11
|
+
var icon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
12
|
+
width: "24",
|
|
13
|
+
height: "24",
|
|
14
|
+
viewBox: "0 0 24 24",
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
16
|
+
fill: "currentColor"
|
|
17
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
18
|
+
d: "M11 17H13V11H11V17ZM12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20ZM11 9H13V7H11V9Z"
|
|
19
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
20
|
+
d: "M11 7H13V9H11V7ZM11 11H13V17H11V11Z"
|
|
21
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
22
|
+
d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20Z"
|
|
23
|
+
}));
|
|
24
|
+
describe("Badge component accessibility tests", function () {
|
|
25
|
+
it("Should not have basic accessibility issues for contextual mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
26
|
+
var _render, container, results;
|
|
27
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
31
|
+
color: "blue",
|
|
32
|
+
mode: "contextual",
|
|
33
|
+
label: "Label",
|
|
34
|
+
size: "small",
|
|
35
|
+
icon: icon,
|
|
36
|
+
title: "Badge1"
|
|
37
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
38
|
+
color: "green",
|
|
39
|
+
mode: "contextual",
|
|
40
|
+
label: "Label",
|
|
41
|
+
size: "small",
|
|
42
|
+
icon: icon,
|
|
43
|
+
title: "Badge1"
|
|
44
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
45
|
+
color: "grey",
|
|
46
|
+
mode: "contextual",
|
|
47
|
+
label: "Label",
|
|
48
|
+
size: "small",
|
|
49
|
+
icon: icon,
|
|
50
|
+
title: "Badge1"
|
|
51
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
52
|
+
color: "orange",
|
|
53
|
+
mode: "contextual",
|
|
54
|
+
label: "Label",
|
|
55
|
+
size: "small",
|
|
56
|
+
icon: icon,
|
|
57
|
+
title: "Badge1"
|
|
58
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
59
|
+
color: "purple",
|
|
60
|
+
mode: "contextual",
|
|
61
|
+
label: "Label",
|
|
62
|
+
size: "small",
|
|
63
|
+
icon: icon,
|
|
64
|
+
title: "Badge1"
|
|
65
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
66
|
+
color: "red",
|
|
67
|
+
mode: "contextual",
|
|
68
|
+
label: "Label",
|
|
69
|
+
size: "small",
|
|
70
|
+
icon: icon,
|
|
71
|
+
title: "Badge1"
|
|
72
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
73
|
+
color: "yellow",
|
|
74
|
+
mode: "contextual",
|
|
75
|
+
label: "Label",
|
|
76
|
+
size: "small",
|
|
77
|
+
icon: icon,
|
|
78
|
+
title: "Badge1"
|
|
79
|
+
}))), container = _render.container;
|
|
80
|
+
_context.next = 3;
|
|
81
|
+
return (0, _axeHelper.axe)(container);
|
|
82
|
+
case 3:
|
|
83
|
+
results = _context.sent;
|
|
84
|
+
expect(results).toHaveNoViolations();
|
|
85
|
+
case 5:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee);
|
|
90
|
+
})));
|
|
91
|
+
it("Should not have basic accessibility issues for notification mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
92
|
+
var _render2, container, results;
|
|
93
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
94
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
97
|
+
mode: "notification",
|
|
98
|
+
label: 100,
|
|
99
|
+
size: "large",
|
|
100
|
+
icon: icon,
|
|
101
|
+
notificationLimit: 99,
|
|
102
|
+
title: "Badge2"
|
|
103
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
104
|
+
mode: "notification",
|
|
105
|
+
label: 50,
|
|
106
|
+
size: "large",
|
|
107
|
+
icon: icon,
|
|
108
|
+
notificationLimit: 99,
|
|
109
|
+
title: "Badge2"
|
|
110
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
111
|
+
mode: "notification",
|
|
112
|
+
label: 1000000,
|
|
113
|
+
size: "large",
|
|
114
|
+
icon: icon,
|
|
115
|
+
notificationLimit: 99999999,
|
|
116
|
+
title: "Badge2"
|
|
117
|
+
}))), container = _render2.container;
|
|
118
|
+
_context2.next = 3;
|
|
119
|
+
return (0, _axeHelper.axe)(container);
|
|
120
|
+
case 3:
|
|
121
|
+
results = _context2.sent;
|
|
122
|
+
expect(results).toHaveNoViolations();
|
|
123
|
+
case 5:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context2.stop();
|
|
126
|
+
}
|
|
127
|
+
}, _callee2);
|
|
128
|
+
})));
|
|
129
|
+
});
|
package/badge/Badge.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import BadgePropsType from "./types";
|
|
3
|
-
declare const DxcBadge: ({
|
|
3
|
+
declare const DxcBadge: ({ label, title, mode, color, icon, notificationLimit, size, }: BadgePropsType) => JSX.Element;
|
|
4
4
|
export default DxcBadge;
|