@dxc-technology/halstack-react 0.0.0-c291a0c → 0.0.0-c3c521c
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 +5 -22
- package/HalstackContext.d.ts +1215 -6
- package/HalstackContext.js +125 -110
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +116 -160
- package/accordion/Accordion.stories.tsx +102 -126
- package/accordion/Accordion.test.js +25 -41
- package/accordion/types.d.ts +5 -16
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +31 -98
- package/accordion-group/AccordionGroup.stories.tsx +94 -67
- package/accordion-group/AccordionGroup.test.js +52 -105
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +11 -16
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +47 -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.js +20 -59
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +29 -46
- package/alert/types.d.ts +5 -5
- 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/Bleed.stories.tsx +64 -63
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +19 -60
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +2 -7
- package/box/types.d.ts +3 -14
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +89 -0
- package/bulleted-list/BulletedList.stories.tsx +115 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +63 -117
- package/button/Button.stories.tsx +160 -90
- package/button/Button.test.js +20 -17
- package/button/types.d.ts +12 -8
- package/card/Card.d.ts +1 -1
- package/card/Card.js +48 -89
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +11 -22
- package/card/types.d.ts +6 -11
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +140 -182
- package/checkbox/Checkbox.stories.tsx +128 -94
- package/checkbox/Checkbox.test.js +160 -39
- package/checkbox/types.d.ts +11 -3
- package/chip/Chip.js +39 -79
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +16 -31
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +237 -0
- package/common/coreTokens.js +184 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +6 -12
- package/common/variables.d.ts +1367 -0
- package/common/variables.js +909 -1140
- 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/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +214 -0
- package/date-input/DateInput.js +150 -299
- package/date-input/DateInput.stories.tsx +203 -56
- package/date-input/DateInput.test.js +700 -371
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +115 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +58 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +100 -0
- package/date-input/types.d.ts +72 -15
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +73 -107
- package/dialog/Dialog.stories.tsx +320 -167
- package/dialog/Dialog.test.js +287 -20
- package/dialog/types.d.ts +18 -25
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +243 -300
- package/dropdown/Dropdown.stories.tsx +245 -56
- package/dropdown/Dropdown.test.js +575 -165
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +63 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +67 -0
- package/dropdown/types.d.ts +32 -14
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +241 -355
- package/file-input/FileInput.stories.tsx +123 -12
- package/file-input/FileInput.test.js +369 -367
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +45 -96
- package/file-input/types.d.ts +25 -8
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +112 -0
- package/flex/types.d.ts +97 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +70 -117
- package/footer/Footer.stories.tsx +60 -19
- package/footer/Footer.test.js +33 -57
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +66 -7
- package/footer/types.d.ts +25 -26
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +76 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +85 -168
- package/header/Header.stories.tsx +118 -39
- package/header/Header.test.js +13 -26
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +4 -9
- package/header/types.d.ts +5 -19
- package/heading/Heading.js +10 -32
- package/heading/Heading.test.js +71 -88
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/inset/Inset.js +13 -21
- package/inset/Inset.stories.tsx +5 -4
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +15 -6
- package/layout/ApplicationLayout.js +50 -115
- package/layout/ApplicationLayout.stories.tsx +81 -45
- package/layout/Icons.d.ts +8 -5
- package/layout/Icons.js +51 -59
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +21 -32
- package/link/Link.js +25 -46
- package/link/Link.stories.tsx +73 -6
- package/link/Link.test.js +24 -44
- package/link/types.d.ts +14 -14
- package/main.d.ts +12 -13
- package/main.js +45 -103
- package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
- package/{tabs-nav → nav-tabs}/NavTabs.js +28 -60
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +115 -9
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +39 -45
- package/nav-tabs/Tab.js +118 -0
- package/{tabs-nav → nav-tabs}/types.d.ts +14 -15
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +26 -35
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +701 -377
- package/number-input/types.d.ts +11 -5
- package/package.json +43 -46
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +21 -47
- package/paginator/Paginator.js +23 -59
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +253 -226
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +22 -0
- package/paragraph/Paragraph.stories.tsx +27 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -126
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +160 -142
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.js +65 -91
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +39 -4
- package/progress-bar/ProgressBar.test.js +72 -44
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.js +27 -45
- package/quick-nav/QuickNav.stories.tsx +146 -27
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +59 -76
- package/radio-group/RadioGroup.js +67 -114
- package/radio-group/RadioGroup.stories.tsx +132 -18
- package/radio-group/RadioGroup.test.js +518 -457
- package/radio-group/types.d.ts +10 -10
- package/resultset-table/Icons.d.ts +7 -0
- package/resultset-table/Icons.js +47 -0
- package/resultset-table/ResultsetTable.js +159 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +50 -25
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +101 -144
- package/{resultsetTable → resultset-table}/types.d.ts +7 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +17 -49
- package/select/Option.js +27 -50
- package/select/Select.js +132 -202
- package/select/Select.stories.tsx +497 -152
- package/select/Select.test.js +1966 -1758
- package/select/types.d.ts +16 -19
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +127 -78
- package/sidenav/Sidenav.stories.tsx +251 -151
- package/sidenav/Sidenav.test.js +26 -45
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +148 -181
- package/slider/Slider.test.js +185 -81
- package/slider/types.d.ts +7 -3
- package/spinner/Spinner.js +31 -75
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -27
- package/spinner/Spinner.test.js +26 -35
- package/spinner/types.d.ts +3 -3
- 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.d.ts +2 -2
- package/switch/Switch.js +145 -126
- package/switch/Switch.stories.tsx +37 -60
- package/switch/Switch.test.js +138 -56
- package/switch/types.d.ts +7 -3
- package/table/Table.js +8 -30
- package/table/{Table.stories.jsx → Table.stories.tsx} +80 -1
- package/table/Table.test.js +3 -8
- package/table/types.d.ts +8 -8
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +116 -0
- package/tabs/Tabs.js +314 -141
- package/tabs/Tabs.stories.tsx +120 -6
- package/tabs/Tabs.test.js +223 -69
- package/tabs/types.d.ts +28 -18
- package/tag/Tag.js +29 -61
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +20 -31
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +56 -0
- package/text-input/Suggestion.js +40 -28
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +84 -0
- package/text-input/TextInput.js +308 -506
- package/text-input/TextInput.stories.tsx +266 -275
- package/text-input/TextInput.test.js +1402 -1375
- package/text-input/types.d.ts +43 -16
- package/textarea/Textarea.js +70 -113
- package/textarea/Textarea.stories.tsx +174 -0
- package/textarea/Textarea.test.js +152 -183
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +92 -106
- package/toggle-group/ToggleGroup.stories.tsx +49 -4
- package/toggle-group/ToggleGroup.test.js +69 -88
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +23 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1119 -1
- package/useTheme.js +2 -9
- package/useTranslatedLabels.d.ts +84 -1
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +94 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +124 -0
- package/wizard/Wizard.js +24 -66
- package/wizard/Wizard.stories.tsx +40 -1
- package/wizard/Wizard.test.js +54 -81
- package/wizard/types.d.ts +7 -7
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- package/inline/Inline.d.ts +0 -4
- package/inline/Inline.js +0 -54
- package/inline/Inline.stories.tsx +0 -264
- package/inline/types.d.ts +0 -32
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -89
- package/list/types.d.ts +0 -7
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/resultsetTable/ResultsetTable.js +0 -254
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/slider/Slider.stories.tsx +0 -177
- package/stack/Stack.d.ts +0 -4
- package/stack/Stack.js +0 -50
- package/stack/Stack.stories.tsx +0 -225
- package/stack/types.d.ts +0 -28
- package/tabs-nav/Tab.js +0 -132
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/textarea/Textarea.stories.jsx +0 -157
- /package/{inline → action-icon}/types.js +0 -0
- /package/{list → bulleted-list}/types.js +0 -0
- /package/{resultsetTable → container}/types.js +0 -0
- /package/{row → flex}/types.js +0 -0
- /package/{stack → grid}/types.js +0 -0
- /package/{tabs-nav → image}/types.js +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{number-input/numberInputContextTypes.js → nav-tabs/types.js} +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
var _coreTokens = _interopRequireDefault(require("../common/coreTokens"));
|
|
12
|
+
var _templateObject;
|
|
13
|
+
var DxcActionIcon = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
14
|
+
var _ref$disabled = _ref.disabled,
|
|
15
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
16
|
+
title = _ref.title,
|
|
17
|
+
icon = _ref.icon,
|
|
18
|
+
onClick = _ref.onClick,
|
|
19
|
+
tabIndex = _ref.tabIndex;
|
|
20
|
+
return /*#__PURE__*/_react["default"].createElement(ActionIcon, {
|
|
21
|
+
"aria-label": title,
|
|
22
|
+
disabled: disabled,
|
|
23
|
+
onClick: onClick,
|
|
24
|
+
onMouseDown: function onMouseDown(event) {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
},
|
|
27
|
+
tabIndex: tabIndex,
|
|
28
|
+
title: title,
|
|
29
|
+
type: "button",
|
|
30
|
+
ref: ref
|
|
31
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
32
|
+
src: icon
|
|
33
|
+
}) : icon);
|
|
34
|
+
});
|
|
35
|
+
var ActionIcon = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n border: none;\n border-radius: 2px;\n width: 24px;\n height: 24px;\n padding: 3px;\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n background-color: ", ";\n color: ", ";\n\n ", "\n\n img, svg {\n width: 16px;\n height: 16px;\n }\n"])), function (props) {
|
|
36
|
+
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
37
|
+
}, function (props) {
|
|
38
|
+
var _props$theme$disabled, _props$theme$actionBa;
|
|
39
|
+
return props.disabled ? (_props$theme$disabled = props.theme.disabledActionBackgroundColor) !== null && _props$theme$disabled !== void 0 ? _props$theme$disabled : _coreTokens["default"].color_transparent : (_props$theme$actionBa = props.theme.actionBackgroundColor) !== null && _props$theme$actionBa !== void 0 ? _props$theme$actionBa : _coreTokens["default"].color_transparent;
|
|
40
|
+
}, function (props) {
|
|
41
|
+
var _props$theme$disabled2, _props$theme$actionIc;
|
|
42
|
+
return props.disabled ? (_props$theme$disabled2 = props.theme.disabledActionIconColor) !== null && _props$theme$disabled2 !== void 0 ? _props$theme$disabled2 : _coreTokens["default"].color_grey_500 : (_props$theme$actionIc = props.theme.actionIconColor) !== null && _props$theme$actionIc !== void 0 ? _props$theme$actionIc : _coreTokens["default"].color_black;
|
|
43
|
+
}, function (props) {
|
|
44
|
+
var _props$theme$focusAct, _props$theme$focusAct2, _props$theme$hoverAct, _props$theme$hoverAct2, _props$theme$activeAc, _props$theme$activeAc2;
|
|
45
|
+
return !props.disabled && "\n &:focus,\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ".concat((_props$theme$focusAct = props.theme.focusActionBorderColor) !== null && _props$theme$focusAct !== void 0 ? _props$theme$focusAct : _coreTokens["default"].color_blue_600, ";\n color: ").concat((_props$theme$focusAct2 = props.theme.focusActionIconColor) !== null && _props$theme$focusAct2 !== void 0 ? _props$theme$focusAct2 : _coreTokens["default"].color_black, ";\n }\n &:hover {\n background-color: ").concat((_props$theme$hoverAct = props.theme.hoverActionBackgroundColor) !== null && _props$theme$hoverAct !== void 0 ? _props$theme$hoverAct : _coreTokens["default"].color_grey_100, ";\n color: ").concat((_props$theme$hoverAct2 = props.theme.hoverActionIconColor) !== null && _props$theme$hoverAct2 !== void 0 ? _props$theme$hoverAct2 : _coreTokens["default"].color_black, ";\n }\n &:active {\n background-color: ").concat((_props$theme$activeAc = props.theme.activeActionBackgroundColor) !== null && _props$theme$activeAc !== void 0 ? _props$theme$activeAc : _coreTokens["default"].color_grey_300, ";\n color: ").concat((_props$theme$activeAc2 = props.theme.activeActionIconColor) !== null && _props$theme$activeAc2 !== void 0 ? _props$theme$activeAc2 : _coreTokens["default"].color_black, ";\n }\n ");
|
|
46
|
+
});
|
|
47
|
+
var _default = exports["default"] = DxcActionIcon;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
|
+
import DxcActionIcon from "./ActionIcon";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "Action Icon ",
|
|
8
|
+
component: DxcActionIcon,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const iconSVG = (
|
|
12
|
+
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="currentColor">
|
|
13
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
14
|
+
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
15
|
+
</svg>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const Chromatic = () => (
|
|
19
|
+
<>
|
|
20
|
+
<Title title="Default" theme="light" level={2} />
|
|
21
|
+
<ExampleContainer>
|
|
22
|
+
<DxcActionIcon icon={"https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"} title="Favourite" />
|
|
23
|
+
</ExampleContainer>
|
|
24
|
+
<Title title="Disabled" theme="light" level={2} />
|
|
25
|
+
<ExampleContainer>
|
|
26
|
+
<DxcActionIcon icon={iconSVG} title="Favourite" disabled />
|
|
27
|
+
</ExampleContainer>
|
|
28
|
+
<Title title="Hover" theme="light" level={2} />
|
|
29
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
30
|
+
<DxcActionIcon icon={iconSVG} title="Favourite" />
|
|
31
|
+
</ExampleContainer>
|
|
32
|
+
<Title title="Focus" theme="light" level={2} />
|
|
33
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
34
|
+
<DxcActionIcon icon={iconSVG} title="Favourite" />
|
|
35
|
+
</ExampleContainer>
|
|
36
|
+
<Title title="Active" theme="light" level={2} />
|
|
37
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
38
|
+
<DxcActionIcon icon={iconSVG} title="Favourite" />
|
|
39
|
+
</ExampleContainer>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _ActionIcon = _interopRequireDefault(require("./ActionIcon.tsx"));
|
|
7
|
+
var iconSVG = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
8
|
+
width: "24px",
|
|
9
|
+
height: "24px",
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
fill: "currentColor"
|
|
12
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
13
|
+
d: "M0 0h24v24H0z",
|
|
14
|
+
fill: "none"
|
|
15
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
16
|
+
d: "M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"
|
|
17
|
+
}));
|
|
18
|
+
describe("Action icon component tests", function () {
|
|
19
|
+
test("Action icon renders with correct text", function () {
|
|
20
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ActionIcon["default"], {
|
|
21
|
+
icon: iconSVG,
|
|
22
|
+
title: "favourite"
|
|
23
|
+
})),
|
|
24
|
+
getByTitle = _render.getByTitle;
|
|
25
|
+
expect(getByTitle("favourite")).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
test("Calls correct function on click", function () {
|
|
28
|
+
var onClick = jest.fn();
|
|
29
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ActionIcon["default"], {
|
|
30
|
+
icon: iconSVG,
|
|
31
|
+
title: "favourite",
|
|
32
|
+
onClick: onClick
|
|
33
|
+
})),
|
|
34
|
+
getByTitle = _render2.getByTitle;
|
|
35
|
+
var action = getByTitle("favourite");
|
|
36
|
+
_react2.fireEvent.click(action);
|
|
37
|
+
expect(onClick).toHaveBeenCalled();
|
|
38
|
+
});
|
|
39
|
+
test("On click is not called when disabled", function () {
|
|
40
|
+
var onClick = jest.fn();
|
|
41
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ActionIcon["default"], {
|
|
42
|
+
disabled: true,
|
|
43
|
+
icon: iconSVG,
|
|
44
|
+
title: "favourite",
|
|
45
|
+
onClick: onClick
|
|
46
|
+
})),
|
|
47
|
+
getByTitle = _render3.getByTitle;
|
|
48
|
+
var action = getByTitle("favourite");
|
|
49
|
+
_react2.fireEvent.click(action);
|
|
50
|
+
expect(onClick).toHaveBeenCalledTimes(0);
|
|
51
|
+
});
|
|
52
|
+
test("Renders with correct accessibility attributes", function () {
|
|
53
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ActionIcon["default"], {
|
|
54
|
+
icon: iconSVG,
|
|
55
|
+
title: "favourite",
|
|
56
|
+
tabIndex: 1
|
|
57
|
+
})),
|
|
58
|
+
getByRole = _render4.getByRole;
|
|
59
|
+
var button = getByRole("button");
|
|
60
|
+
expect(button.getAttribute("aria-label")).toBe("favourite");
|
|
61
|
+
expect(button.getAttribute("title")).toBe("favourite");
|
|
62
|
+
expect(button.getAttribute("tabindex")).toBe("1");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* If true, the component will be disabled.
|
|
6
|
+
*/
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Value for the HTML properties title and aria-label.
|
|
10
|
+
*/
|
|
11
|
+
title: string;
|
|
12
|
+
/**
|
|
13
|
+
* Element or path used as the icon that will be placed next to the label.
|
|
14
|
+
*/
|
|
15
|
+
icon: string | SVG;
|
|
16
|
+
/**
|
|
17
|
+
* This function will be called when the user clicks the button.
|
|
18
|
+
*/
|
|
19
|
+
onClick?: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Value of the tabindex attribute.
|
|
22
|
+
*/
|
|
23
|
+
tabIndex?: number;
|
|
24
|
+
};
|
|
25
|
+
export type RefType = HTMLButtonElement;
|
|
26
|
+
export default Props;
|
package/alert/Alert.js
CHANGED
|
@@ -1,38 +1,22 @@
|
|
|
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
|
-
var
|
|
21
|
-
|
|
22
|
-
var _utils = require("../common/utils.js");
|
|
23
|
-
|
|
13
|
+
var _variables = require("../common/variables");
|
|
14
|
+
var _utils = require("../common/utils");
|
|
24
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
16
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
|
-
|
|
28
|
-
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
29
|
-
|
|
30
17
|
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
|
-
|
|
18
|
+
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); }
|
|
19
|
+
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 && Object.prototype.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; }
|
|
36
20
|
var alertIcons = {
|
|
37
21
|
close: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
38
22
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -96,27 +80,24 @@ var alertIcons = {
|
|
|
96
80
|
fill: "none"
|
|
97
81
|
}))
|
|
98
82
|
};
|
|
99
|
-
|
|
100
83
|
var DxcAlert = function DxcAlert(_ref) {
|
|
101
84
|
var _ref$type = _ref.type,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
85
|
+
type = _ref$type === void 0 ? "info" : _ref$type,
|
|
86
|
+
_ref$mode = _ref.mode,
|
|
87
|
+
mode = _ref$mode === void 0 ? "inline" : _ref$mode,
|
|
88
|
+
_ref$inlineText = _ref.inlineText,
|
|
89
|
+
inlineText = _ref$inlineText === void 0 ? "" : _ref$inlineText,
|
|
90
|
+
onClose = _ref.onClose,
|
|
91
|
+
children = _ref.children,
|
|
92
|
+
margin = _ref.margin,
|
|
93
|
+
_ref$size = _ref.size,
|
|
94
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
95
|
+
tabIndex = _ref.tabIndex;
|
|
113
96
|
var colorsTheme = (0, _useTheme["default"])();
|
|
114
97
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
115
|
-
|
|
116
98
|
var getTypeText = function getTypeText() {
|
|
117
99
|
return type === "info" ? translatedLabels.alert.infoTitleText : type === "confirm" ? translatedLabels.alert.successTitleText : type === "warning" ? translatedLabels.alert.warningTitleText : translatedLabels.alert.errorTitleText;
|
|
118
100
|
};
|
|
119
|
-
|
|
120
101
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
121
102
|
theme: colorsTheme.alert
|
|
122
103
|
}, /*#__PURE__*/_react["default"].createElement(AlertModal, {
|
|
@@ -131,28 +112,21 @@ var DxcAlert = function DxcAlert(_ref) {
|
|
|
131
112
|
size: size
|
|
132
113
|
}, /*#__PURE__*/_react["default"].createElement(AlertInfo, null, /*#__PURE__*/_react["default"].createElement(AlertIcon, {
|
|
133
114
|
type: type
|
|
134
|
-
}, type === "info" && alertIcons.info || type === "confirm" && alertIcons.success || type === "warning" && alertIcons.warning || type === "error" && alertIcons.error), /*#__PURE__*/_react["default"].createElement(AlertText, null, /*#__PURE__*/_react["default"].createElement(AlertTitle, {
|
|
135
|
-
type: type
|
|
136
|
-
}, getTypeText()), inlineText && inlineText !== "" && "-", /*#__PURE__*/_react["default"].createElement(AlertInlineText, null, inlineText)), onClose && /*#__PURE__*/_react["default"].createElement(AlertCloseAction, {
|
|
115
|
+
}, type === "info" && alertIcons.info || type === "confirm" && alertIcons.success || type === "warning" && alertIcons.warning || type === "error" && alertIcons.error), /*#__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, {
|
|
137
116
|
onClick: onClose,
|
|
138
117
|
tabIndex: tabIndex
|
|
139
|
-
}, alertIcons.close)), children && /*#__PURE__*/_react["default"].createElement(AlertContent, null,
|
|
140
|
-
color: type === "info" && colorsTheme.alert.infoBackgroundColor || type === "confirm" && colorsTheme.alert.successBackgroundColor || type === "warning" && colorsTheme.alert.warningBackgroundColor || type === "error" && colorsTheme.alert.errorBackgroundColor
|
|
141
|
-
}, children)))));
|
|
118
|
+
}, alertIcons.close)), children && /*#__PURE__*/_react["default"].createElement(AlertContent, null, children))));
|
|
142
119
|
};
|
|
143
|
-
|
|
144
120
|
var sizes = {
|
|
145
121
|
small: "280px",
|
|
146
122
|
medium: "480px",
|
|
147
123
|
large: "820px",
|
|
148
124
|
fillParent: "100%",
|
|
149
|
-
fitContent: "
|
|
125
|
+
fitContent: "fit-content"
|
|
150
126
|
};
|
|
151
|
-
|
|
152
127
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
153
128
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
154
129
|
};
|
|
155
|
-
|
|
156
130
|
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) {
|
|
157
131
|
return props.theme.fontSizeBase;
|
|
158
132
|
}, function (props) {
|
|
@@ -174,7 +148,6 @@ var AlertModal = _styledComponents["default"].div(_templateObject || (_templateO
|
|
|
174
148
|
}, function (props) {
|
|
175
149
|
return props.mode === "modal" ? "1200" : "";
|
|
176
150
|
});
|
|
177
|
-
|
|
178
151
|
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) {
|
|
179
152
|
return props.mode === "modal" ? "".concat(props.theme.overlayColor) : "transparent";
|
|
180
153
|
}, function (props) {
|
|
@@ -188,7 +161,6 @@ var OverlayContainer = _styledComponents["default"].div(_templateObject2 || (_te
|
|
|
188
161
|
}, function (props) {
|
|
189
162
|
return props.mode === "modal" ? "0" : "";
|
|
190
163
|
});
|
|
191
|
-
|
|
192
164
|
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) {
|
|
193
165
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
194
166
|
}, function (props) {
|
|
@@ -222,11 +194,9 @@ var AlertContainer = _styledComponents["default"].div(_templateObject3 || (_temp
|
|
|
222
194
|
}, function (props) {
|
|
223
195
|
return props.mode === "modal" ? "1300" : "";
|
|
224
196
|
});
|
|
225
|
-
|
|
226
197
|
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) {
|
|
227
198
|
return props.theme.borderThickness;
|
|
228
199
|
});
|
|
229
|
-
|
|
230
200
|
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) {
|
|
231
201
|
return props.theme.titlePaddingRight;
|
|
232
202
|
}, function (props) {
|
|
@@ -244,7 +214,6 @@ var AlertTitle = _styledComponents["default"].div(_templateObject5 || (_template
|
|
|
244
214
|
}, function (props) {
|
|
245
215
|
return props.theme.titleTextTransform;
|
|
246
216
|
});
|
|
247
|
-
|
|
248
217
|
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) {
|
|
249
218
|
return props.theme.inlineTextPaddingRight;
|
|
250
219
|
}, function (props) {
|
|
@@ -260,7 +229,6 @@ var AlertInlineText = _styledComponents["default"].div(_templateObject6 || (_tem
|
|
|
260
229
|
}, function (props) {
|
|
261
230
|
return props.theme.inlineTextFontColor;
|
|
262
231
|
});
|
|
263
|
-
|
|
264
232
|
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) {
|
|
265
233
|
return props.theme.iconPaddingRight;
|
|
266
234
|
}, function (props) {
|
|
@@ -272,22 +240,15 @@ var AlertIcon = _styledComponents["default"].span(_templateObject7 || (_template
|
|
|
272
240
|
}, function (props) {
|
|
273
241
|
return props.theme.iconSize;
|
|
274
242
|
});
|
|
275
|
-
|
|
276
243
|
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"])));
|
|
277
|
-
|
|
278
244
|
var AlertContent = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n flex: 1 1 auto;\n padding: ", ";\n overflow-y: auto;\n"])), function (props) {
|
|
279
245
|
return "".concat(props.theme.contentPaddingTop, " ").concat(props.theme.contentPaddingRight, " ").concat(props.theme.contentPaddingBottom, " ").concat(props.theme.contentPaddingLeft);
|
|
280
246
|
});
|
|
281
|
-
|
|
282
|
-
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 outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
247
|
+
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) {
|
|
283
248
|
return props.theme.hoverActionBackgroundColor;
|
|
284
249
|
}, function (props) {
|
|
285
250
|
return props.theme.focusActionBorderColor;
|
|
286
|
-
}, function (props) {
|
|
287
|
-
return props.theme.focusActionBorderColor;
|
|
288
251
|
}, function (props) {
|
|
289
252
|
return props.theme.activeActionBackgroundColor;
|
|
290
253
|
});
|
|
291
|
-
|
|
292
|
-
var _default = DxcAlert;
|
|
293
|
-
exports["default"] = _default;
|
|
254
|
+
var _default = exports["default"] = DxcAlert;
|
package/alert/Alert.stories.tsx
CHANGED
|
@@ -2,12 +2,21 @@ import React from "react";
|
|
|
2
2
|
import DxcAlert from "./Alert";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: "Alert",
|
|
8
9
|
component: DxcAlert,
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
const opinionatedTheme = {
|
|
13
|
+
alert: {
|
|
14
|
+
baseColor: "#e6f4ff",
|
|
15
|
+
accentColor: "#0067b3",
|
|
16
|
+
overlayColor: "#000000b3",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
export const Chromatic = () => (
|
|
12
21
|
<>
|
|
13
22
|
<ExampleContainer>
|
|
@@ -155,6 +164,12 @@ export const Chromatic = () => (
|
|
|
155
164
|
</div>
|
|
156
165
|
</DxcAlert>
|
|
157
166
|
</ExampleContainer>
|
|
167
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
168
|
+
<ExampleContainer>
|
|
169
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
170
|
+
<DxcAlert inlineText="Info type alert with inline text." />
|
|
171
|
+
</HalstackProvider>
|
|
172
|
+
</ExampleContainer>
|
|
158
173
|
</>
|
|
159
174
|
);
|
|
160
175
|
|
|
@@ -168,3 +183,16 @@ export const ModalAlert = () => (
|
|
|
168
183
|
</DxcAlert>
|
|
169
184
|
</ExampleContainer>
|
|
170
185
|
);
|
|
186
|
+
|
|
187
|
+
export const ModalAlertOpinionated = () => (
|
|
188
|
+
<ExampleContainer>
|
|
189
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
190
|
+
<DxcAlert inlineText="Modal alert." mode="modal" onClose={() => {}}>
|
|
191
|
+
<div>
|
|
192
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
|
|
193
|
+
lobortis eget.
|
|
194
|
+
</div>
|
|
195
|
+
</DxcAlert>
|
|
196
|
+
</HalstackProvider>
|
|
197
|
+
</ExampleContainer>
|
|
198
|
+
);
|
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
|
-
var _Alert = _interopRequireDefault(require("./Alert"));
|
|
10
|
-
|
|
6
|
+
var _Alert = _interopRequireDefault(require("./Alert.tsx"));
|
|
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
|
};
|
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;
|