@dxc-technology/halstack-react 0.0.0-e49dc66 → 0.0.0-e4ccd42
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 -0
- package/BackgroundColorContext.js +6 -26
- package/HalstackContext.d.ts +1249 -0
- package/HalstackContext.js +310 -0
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +118 -194
- package/accordion/Accordion.stories.tsx +283 -0
- package/accordion/Accordion.test.js +56 -0
- package/accordion/types.d.ts +12 -23
- package/accordion-group/AccordionGroup.d.ts +5 -4
- package/accordion-group/AccordionGroup.js +39 -108
- package/accordion-group/AccordionGroup.stories.tsx +252 -0
- package/accordion-group/AccordionGroup.test.js +98 -0
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +18 -23
- 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 +24 -60
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +75 -0
- package/alert/types.d.ts +6 -6
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +141 -41
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +54 -0
- package/badge/types.js +5 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +43 -0
- package/bleed/Bleed.stories.tsx +342 -0
- package/bleed/types.d.ts +37 -0
- package/bleed/types.js +5 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +32 -86
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +13 -0
- package/box/types.d.ts +3 -18
- 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/bulleted-list/types.js +5 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +65 -122
- package/button/Button.stories.tsx +164 -96
- package/button/Button.test.js +38 -0
- package/button/types.d.ts +14 -14
- package/card/Card.d.ts +1 -1
- package/card/Card.js +59 -104
- package/card/Card.stories.tsx +171 -0
- package/card/Card.test.js +39 -0
- package/card/types.d.ts +8 -15
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +145 -183
- package/checkbox/Checkbox.stories.tsx +166 -136
- package/checkbox/Checkbox.test.js +199 -0
- package/checkbox/types.d.ts +20 -8
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +48 -148
- package/chip/Chip.stories.tsx +214 -0
- package/chip/Chip.test.js +41 -0
- package/chip/types.d.ts +45 -0
- package/chip/types.js +5 -0
- 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 +1395 -0
- package/common/variables.js +1033 -1343
- 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/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +214 -0
- package/date-input/DateInput.js +175 -313
- package/date-input/DateInput.stories.tsx +203 -56
- package/date-input/DateInput.test.js +808 -0
- 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 +86 -22
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +69 -130
- package/dialog/Dialog.stories.tsx +365 -0
- package/dialog/Dialog.test.js +307 -0
- package/dialog/types.d.ts +18 -25
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +250 -331
- package/dropdown/Dropdown.stories.tsx +438 -0
- package/dropdown/Dropdown.test.js +599 -0
- 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 +37 -28
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +274 -327
- package/file-input/FileInput.stories.tsx +618 -0
- package/file-input/FileInput.test.js +459 -0
- package/file-input/FileItem.d.ts +4 -0
- package/file-input/FileItem.js +54 -112
- package/file-input/types.d.ts +129 -0
- package/file-input/types.js +5 -0
- 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/flex/types.js +5 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +73 -201
- package/footer/{Footer.stories.jsx → Footer.stories.tsx} +57 -37
- package/footer/Footer.test.js +85 -0
- package/footer/Icons.d.ts +3 -0
- package/footer/Icons.js +67 -8
- package/footer/types.d.ts +41 -38
- 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/grid/types.js +5 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +100 -204
- package/header/Header.stories.tsx +251 -0
- package/header/Header.test.js +66 -0
- package/header/Icons.d.ts +2 -0
- package/header/Icons.js +4 -9
- package/header/types.d.ts +4 -16
- package/heading/Heading.d.ts +4 -0
- package/heading/Heading.js +16 -55
- package/heading/Heading.stories.tsx +54 -0
- package/heading/Heading.test.js +169 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +129 -0
- package/image/types.d.ts +72 -0
- package/image/types.js +5 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +43 -0
- package/inset/Inset.stories.tsx +230 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +20 -0
- package/layout/ApplicationLayout.js +83 -184
- package/layout/ApplicationLayout.stories.tsx +162 -0
- package/layout/Icons.d.ts +8 -0
- package/layout/Icons.js +51 -48
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +13 -0
- package/layout/types.d.ts +41 -0
- package/layout/types.js +5 -0
- package/link/Link.d.ts +3 -2
- package/link/Link.js +65 -111
- package/link/Link.stories.tsx +199 -16
- package/link/Link.test.js +63 -0
- package/link/types.d.ts +15 -35
- package/main.d.ts +17 -14
- package/main.js +78 -98
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +93 -0
- package/nav-tabs/NavTabs.stories.tsx +276 -0
- package/nav-tabs/NavTabs.test.js +76 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +118 -0
- package/nav-tabs/types.d.ts +52 -0
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.d.ts +11 -0
- package/number-input/NumberInput.js +49 -91
- package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +44 -28
- package/number-input/NumberInput.test.js +989 -0
- package/number-input/types.d.ts +130 -0
- package/number-input/types.js +5 -0
- package/package.json +46 -45
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +21 -47
- package/paginator/Paginator.js +35 -98
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +335 -0
- 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 +60 -125
- package/password-input/PasswordInput.stories.tsx +3 -35
- package/password-input/PasswordInput.test.js +198 -0
- package/password-input/types.d.ts +35 -24
- package/progress-bar/ProgressBar.js +66 -92
- package/progress-bar/ProgressBar.stories.tsx +93 -0
- package/progress-bar/ProgressBar.test.js +93 -0
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +94 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +124 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +235 -0
- package/radio-group/RadioGroup.stories.tsx +214 -0
- package/radio-group/RadioGroup.test.js +756 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultset-table/Icons.d.ts +7 -0
- package/resultset-table/Icons.js +47 -0
- package/resultset-table/ResultsetTable.d.ts +7 -0
- package/resultset-table/ResultsetTable.js +166 -0
- package/resultset-table/ResultsetTable.stories.tsx +397 -0
- package/resultset-table/ResultsetTable.test.js +371 -0
- package/resultset-table/types.d.ts +73 -0
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +89 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +143 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +87 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +240 -515
- package/select/Select.stories.tsx +971 -0
- package/select/Select.test.js +2370 -0
- package/select/types.d.ts +209 -0
- package/select/types.js +5 -0
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +10 -0
- package/sidenav/Sidenav.js +132 -81
- package/sidenav/Sidenav.stories.tsx +282 -0
- package/sidenav/Sidenav.test.js +37 -0
- package/sidenav/types.d.ts +76 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +151 -183
- package/slider/Slider.test.js +254 -0
- package/slider/types.d.ts +11 -3
- package/spinner/Spinner.js +32 -76
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -26
- package/spinner/Spinner.test.js +55 -0
- 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 +150 -115
- package/switch/Switch.stories.tsx +45 -68
- package/switch/Switch.test.js +180 -0
- package/switch/types.d.ts +13 -5
- package/table/DropdownTheme.js +62 -0
- package/table/Table.d.ts +6 -2
- package/table/Table.js +89 -37
- package/table/Table.stories.tsx +658 -0
- package/table/Table.test.js +113 -0
- package/table/types.d.ts +48 -6
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +116 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +318 -145
- package/tabs/Tabs.stories.tsx +226 -0
- package/tabs/Tabs.test.js +294 -0
- package/tabs/types.d.ts +48 -27
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +44 -86
- package/tag/Tag.stories.tsx +38 -28
- package/tag/Tag.test.js +49 -0
- package/tag/types.d.ts +25 -16
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +56 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +67 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +84 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +333 -593
- package/text-input/TextInput.stories.tsx +465 -0
- package/text-input/TextInput.test.js +1756 -0
- package/text-input/types.d.ts +205 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +98 -181
- package/textarea/Textarea.stories.tsx +174 -0
- package/textarea/Textarea.test.js +406 -0
- package/textarea/types.d.ts +141 -0
- package/textarea/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +100 -142
- package/toggle-group/ToggleGroup.stories.tsx +218 -0
- package/toggle-group/ToggleGroup.test.js +137 -0
- package/toggle-group/types.d.ts +114 -0
- package/toggle-group/types.js +5 -0
- 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 +1148 -0
- package/useTheme.js +4 -11
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +14 -0
- 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.d.ts +4 -0
- package/wizard/Wizard.js +130 -151
- package/wizard/Wizard.stories.tsx +253 -0
- package/wizard/Wizard.test.js +114 -0
- package/wizard/types.d.ts +64 -0
- package/wizard/types.js +5 -0
- package/ThemeContext.js +0 -246
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/chip/index.d.ts +0 -22
- package/common/RequiredComponent.js +0 -32
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/file-input/index.d.ts +0 -81
- package/heading/index.d.ts +0 -17
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/number-input/NumberInputContext.js +0 -16
- package/number-input/index.d.ts +0 -113
- package/progress-bar/ProgressBar.stories.jsx +0 -58
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/resultsetTable/ResultsetTable.js +0 -274
- package/resultsetTable/index.d.ts +0 -19
- package/select/index.d.ts +0 -131
- package/sidenav/index.d.ts +0 -13
- package/slider/Slider.stories.tsx +0 -172
- package/table/Table.stories.jsx +0 -276
- package/text-input/index.d.ts +0 -135
- package/textarea/Textarea.stories.jsx +0 -135
- package/textarea/index.d.ts +0 -117
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/toggle-group/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- package/wizard/Icons.js +0 -65
- package/wizard/index.d.ts +0 -18
- /package/{radio → action-icon}/types.js +0 -0
package/alert/Alert.js
CHANGED
|
@@ -1,36 +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
|
|
23
|
-
|
|
24
|
-
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
25
|
-
|
|
26
|
-
var _BackgroundColorContext = require("../BackgroundColorContext.js");
|
|
27
|
-
|
|
13
|
+
var _variables = require("../common/variables");
|
|
14
|
+
var _utils = require("../common/utils");
|
|
15
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
16
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
28
17
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
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; }
|
|
33
|
-
|
|
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; }
|
|
34
20
|
var alertIcons = {
|
|
35
21
|
close: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
36
22
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -94,26 +80,24 @@ var alertIcons = {
|
|
|
94
80
|
fill: "none"
|
|
95
81
|
}))
|
|
96
82
|
};
|
|
97
|
-
|
|
98
83
|
var DxcAlert = function DxcAlert(_ref) {
|
|
99
84
|
var _ref$type = _ref.type,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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;
|
|
111
96
|
var colorsTheme = (0, _useTheme["default"])();
|
|
112
|
-
|
|
97
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
113
98
|
var getTypeText = function getTypeText() {
|
|
114
|
-
return type === "info" ?
|
|
99
|
+
return type === "info" ? translatedLabels.alert.infoTitleText : type === "confirm" ? translatedLabels.alert.successTitleText : type === "warning" ? translatedLabels.alert.warningTitleText : translatedLabels.alert.errorTitleText;
|
|
115
100
|
};
|
|
116
|
-
|
|
117
101
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
118
102
|
theme: colorsTheme.alert
|
|
119
103
|
}, /*#__PURE__*/_react["default"].createElement(AlertModal, {
|
|
@@ -128,28 +112,21 @@ var DxcAlert = function DxcAlert(_ref) {
|
|
|
128
112
|
size: size
|
|
129
113
|
}, /*#__PURE__*/_react["default"].createElement(AlertInfo, null, /*#__PURE__*/_react["default"].createElement(AlertIcon, {
|
|
130
114
|
type: type
|
|
131
|
-
}, 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, {
|
|
132
|
-
type: type
|
|
133
|
-
}, 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, {
|
|
134
116
|
onClick: onClose,
|
|
135
117
|
tabIndex: tabIndex
|
|
136
|
-
}, alertIcons.close)), children && /*#__PURE__*/_react["default"].createElement(AlertContent, null,
|
|
137
|
-
color: type === "info" && colorsTheme.alert.infoBackgroundColor || type === "confirm" && colorsTheme.alert.successBackgroundColor || type === "warning" && colorsTheme.alert.warningBackgroundColor || type === "error" && colorsTheme.alert.errorBackgroundColor
|
|
138
|
-
}, children)))));
|
|
118
|
+
}, alertIcons.close)), children && /*#__PURE__*/_react["default"].createElement(AlertContent, null, children))));
|
|
139
119
|
};
|
|
140
|
-
|
|
141
120
|
var sizes = {
|
|
142
121
|
small: "280px",
|
|
143
122
|
medium: "480px",
|
|
144
123
|
large: "820px",
|
|
145
124
|
fillParent: "100%",
|
|
146
|
-
fitContent: "
|
|
125
|
+
fitContent: "fit-content"
|
|
147
126
|
};
|
|
148
|
-
|
|
149
127
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
150
128
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
151
129
|
};
|
|
152
|
-
|
|
153
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) {
|
|
154
131
|
return props.theme.fontSizeBase;
|
|
155
132
|
}, function (props) {
|
|
@@ -171,7 +148,6 @@ var AlertModal = _styledComponents["default"].div(_templateObject || (_templateO
|
|
|
171
148
|
}, function (props) {
|
|
172
149
|
return props.mode === "modal" ? "1200" : "";
|
|
173
150
|
});
|
|
174
|
-
|
|
175
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) {
|
|
176
152
|
return props.mode === "modal" ? "".concat(props.theme.overlayColor) : "transparent";
|
|
177
153
|
}, function (props) {
|
|
@@ -185,7 +161,6 @@ var OverlayContainer = _styledComponents["default"].div(_templateObject2 || (_te
|
|
|
185
161
|
}, function (props) {
|
|
186
162
|
return props.mode === "modal" ? "0" : "";
|
|
187
163
|
});
|
|
188
|
-
|
|
189
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) {
|
|
190
165
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
191
166
|
}, function (props) {
|
|
@@ -219,11 +194,9 @@ var AlertContainer = _styledComponents["default"].div(_templateObject3 || (_temp
|
|
|
219
194
|
}, function (props) {
|
|
220
195
|
return props.mode === "modal" ? "1300" : "";
|
|
221
196
|
});
|
|
222
|
-
|
|
223
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) {
|
|
224
198
|
return props.theme.borderThickness;
|
|
225
199
|
});
|
|
226
|
-
|
|
227
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) {
|
|
228
201
|
return props.theme.titlePaddingRight;
|
|
229
202
|
}, function (props) {
|
|
@@ -241,7 +214,6 @@ var AlertTitle = _styledComponents["default"].div(_templateObject5 || (_template
|
|
|
241
214
|
}, function (props) {
|
|
242
215
|
return props.theme.titleTextTransform;
|
|
243
216
|
});
|
|
244
|
-
|
|
245
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) {
|
|
246
218
|
return props.theme.inlineTextPaddingRight;
|
|
247
219
|
}, function (props) {
|
|
@@ -257,7 +229,6 @@ var AlertInlineText = _styledComponents["default"].div(_templateObject6 || (_tem
|
|
|
257
229
|
}, function (props) {
|
|
258
230
|
return props.theme.inlineTextFontColor;
|
|
259
231
|
});
|
|
260
|
-
|
|
261
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) {
|
|
262
233
|
return props.theme.iconPaddingRight;
|
|
263
234
|
}, function (props) {
|
|
@@ -269,22 +240,15 @@ var AlertIcon = _styledComponents["default"].span(_templateObject7 || (_template
|
|
|
269
240
|
}, function (props) {
|
|
270
241
|
return props.theme.iconSize;
|
|
271
242
|
});
|
|
272
|
-
|
|
273
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"])));
|
|
274
|
-
|
|
275
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) {
|
|
276
245
|
return "".concat(props.theme.contentPaddingTop, " ").concat(props.theme.contentPaddingRight, " ").concat(props.theme.contentPaddingBottom, " ").concat(props.theme.contentPaddingLeft);
|
|
277
246
|
});
|
|
278
|
-
|
|
279
|
-
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) {
|
|
280
248
|
return props.theme.hoverActionBackgroundColor;
|
|
281
249
|
}, function (props) {
|
|
282
250
|
return props.theme.focusActionBorderColor;
|
|
283
|
-
}, function (props) {
|
|
284
|
-
return props.theme.focusActionBorderColor;
|
|
285
251
|
}, function (props) {
|
|
286
252
|
return props.theme.activeActionBackgroundColor;
|
|
287
253
|
});
|
|
288
|
-
|
|
289
|
-
var _default = DxcAlert;
|
|
290
|
-
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
|
+
);
|
|
@@ -0,0 +1,75 @@
|
|
|
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 _Alert = _interopRequireDefault(require("./Alert.tsx"));
|
|
7
|
+
describe("Alert component tests", function () {
|
|
8
|
+
test("Info alert renders with correct text", function () {
|
|
9
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
10
|
+
type: "info",
|
|
11
|
+
inlineText: "info-alert-text"
|
|
12
|
+
})),
|
|
13
|
+
getByText = _render.getByText;
|
|
14
|
+
expect(getByText("information")).toBeTruthy();
|
|
15
|
+
expect(getByText("info-alert-text")).toBeTruthy();
|
|
16
|
+
});
|
|
17
|
+
test("Confirm alert renders with correct text", function () {
|
|
18
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
19
|
+
type: "confirm",
|
|
20
|
+
inlineText: "confirm-alert-text"
|
|
21
|
+
})),
|
|
22
|
+
getByText = _render2.getByText;
|
|
23
|
+
expect(getByText("success")).toBeTruthy();
|
|
24
|
+
expect(getByText("confirm-alert-text")).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
test("Warning alert renders with correct text", function () {
|
|
27
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
28
|
+
type: "warning",
|
|
29
|
+
inlineText: "warning-alert-text"
|
|
30
|
+
})),
|
|
31
|
+
getByText = _render3.getByText;
|
|
32
|
+
expect(getByText("warning")).toBeTruthy();
|
|
33
|
+
expect(getByText("warning-alert-text")).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
test("Error alert renders with correct text", function () {
|
|
36
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
37
|
+
type: "error",
|
|
38
|
+
inlineText: "error-alert-text"
|
|
39
|
+
})),
|
|
40
|
+
getByText = _render4.getByText;
|
|
41
|
+
expect(getByText("error")).toBeTruthy();
|
|
42
|
+
expect(getByText("error-alert-text")).toBeTruthy();
|
|
43
|
+
});
|
|
44
|
+
test("Alert renders with correct children", function () {
|
|
45
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
46
|
+
inlineText: "alert-text"
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement("p", null, "sample-children"))),
|
|
48
|
+
getByText = _render5.getByText;
|
|
49
|
+
expect(getByText("alert-text")).toBeTruthy();
|
|
50
|
+
expect(getByText("sample-children")).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
test("Calls correct function on close", function () {
|
|
53
|
+
var onClose = jest.fn();
|
|
54
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
55
|
+
onClose: onClose,
|
|
56
|
+
inlineText: "info-alert-text"
|
|
57
|
+
})),
|
|
58
|
+
getByRole = _render6.getByRole;
|
|
59
|
+
var closeButton = getByRole("button");
|
|
60
|
+
_react2.fireEvent.click(closeButton);
|
|
61
|
+
expect(onClose).toHaveBeenCalled();
|
|
62
|
+
});
|
|
63
|
+
test("Modal alert calls correct function on close", function () {
|
|
64
|
+
var onClose = jest.fn();
|
|
65
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
66
|
+
onClose: onClose,
|
|
67
|
+
mode: "modal",
|
|
68
|
+
inlineText: "info-alert-text"
|
|
69
|
+
})),
|
|
70
|
+
getByRole = _render7.getByRole;
|
|
71
|
+
var closeButton = getByRole("button");
|
|
72
|
+
_react2.fireEvent.click(closeButton);
|
|
73
|
+
expect(onClose).toHaveBeenCalled();
|
|
74
|
+
});
|
|
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
|
/**
|
|
@@ -38,11 +38,11 @@ declare type Props = {
|
|
|
38
38
|
*/
|
|
39
39
|
margin?: Space | Margin;
|
|
40
40
|
/**
|
|
41
|
-
* Size of the component
|
|
41
|
+
* Size of the component.
|
|
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
ADDED
package/badge/Badge.js
CHANGED
|
@@ -1,59 +1,159 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
|
8
5
|
value: true
|
|
9
6
|
});
|
|
10
7
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
9
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
var _Flex = _interopRequireDefault(require("../flex/Flex"));
|
|
12
|
+
var _coreTokens = _interopRequireDefault(require("../common/coreTokens"));
|
|
13
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
14
|
+
var contextualColorMap = {
|
|
15
|
+
grey: {
|
|
16
|
+
background: _coreTokens["default"].color_grey_200,
|
|
17
|
+
text: _coreTokens["default"].color_grey_900
|
|
18
|
+
},
|
|
19
|
+
blue: {
|
|
20
|
+
background: _coreTokens["default"].color_blue_200,
|
|
21
|
+
text: _coreTokens["default"].color_blue_900
|
|
22
|
+
},
|
|
23
|
+
green: {
|
|
24
|
+
background: _coreTokens["default"].color_green_200,
|
|
25
|
+
text: _coreTokens["default"].color_green_900
|
|
26
|
+
},
|
|
27
|
+
orange: {
|
|
28
|
+
background: _coreTokens["default"].color_orange_200,
|
|
29
|
+
text: _coreTokens["default"].color_orange_900
|
|
30
|
+
},
|
|
31
|
+
red: {
|
|
32
|
+
background: _coreTokens["default"].color_red_200,
|
|
33
|
+
text: _coreTokens["default"].color_red_900
|
|
34
|
+
},
|
|
35
|
+
yellow: {
|
|
36
|
+
background: _coreTokens["default"].color_yellow_200,
|
|
37
|
+
text: _coreTokens["default"].color_yellow_900
|
|
38
|
+
},
|
|
39
|
+
purple: {
|
|
40
|
+
background: _coreTokens["default"].color_purple_200,
|
|
41
|
+
text: _coreTokens["default"].color_purple_900
|
|
42
|
+
}
|
|
34
43
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
var sizeMap = {
|
|
45
|
+
small: {
|
|
46
|
+
height: "20px",
|
|
47
|
+
width: "20px",
|
|
48
|
+
minWidth: "20px",
|
|
49
|
+
fontSize: _coreTokens["default"].type_scale_01,
|
|
50
|
+
borderRadius: _coreTokens["default"].spacing_12,
|
|
51
|
+
iconSize: "14px",
|
|
52
|
+
padding: {
|
|
53
|
+
contextual: "".concat(_coreTokens["default"].spacing_4),
|
|
54
|
+
notification: "".concat(_coreTokens["default"].spacing_0, " ").concat(_coreTokens["default"].spacing_4)
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
medium: {
|
|
58
|
+
height: "24px",
|
|
59
|
+
width: "24px",
|
|
60
|
+
minWidth: "24px",
|
|
61
|
+
fontSize: _coreTokens["default"].type_scale_02,
|
|
62
|
+
borderRadius: _coreTokens["default"].spacing_12,
|
|
63
|
+
iconSize: "16px",
|
|
64
|
+
padding: {
|
|
65
|
+
contextual: "".concat(_coreTokens["default"].spacing_4, " ").concat(_coreTokens["default"].spacing_8),
|
|
66
|
+
notification: "".concat(_coreTokens["default"].spacing_0, " ").concat(_coreTokens["default"].spacing_4)
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
large: {
|
|
70
|
+
height: "32px",
|
|
71
|
+
width: "32px",
|
|
72
|
+
minWidth: "32px",
|
|
73
|
+
fontSize: _coreTokens["default"].type_scale_04,
|
|
74
|
+
borderRadius: _coreTokens["default"].spacing_24,
|
|
75
|
+
iconSize: "24px",
|
|
76
|
+
padding: {
|
|
77
|
+
contextual: "".concat(_coreTokens["default"].spacing_4, " ").concat(_coreTokens["default"].spacing_8),
|
|
78
|
+
notification: "".concat(_coreTokens["default"].spacing_0, " ").concat(_coreTokens["default"].spacing_8)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var Label = function Label(_ref) {
|
|
83
|
+
var label = _ref.label,
|
|
84
|
+
notificationLimit = _ref.notificationLimit,
|
|
85
|
+
size = _ref.size;
|
|
86
|
+
return /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
87
|
+
size: size
|
|
88
|
+
}, typeof label === "number" ? label > notificationLimit ? "+" + notificationLimit : label : label);
|
|
89
|
+
};
|
|
90
|
+
var DxcBadge = function DxcBadge(_ref2) {
|
|
91
|
+
var label = _ref2.label,
|
|
92
|
+
title = _ref2.title,
|
|
93
|
+
_ref2$mode = _ref2.mode,
|
|
94
|
+
mode = _ref2$mode === void 0 ? "contextual" : _ref2$mode,
|
|
95
|
+
_ref2$color = _ref2.color,
|
|
96
|
+
color = _ref2$color === void 0 ? "grey" : _ref2$color,
|
|
97
|
+
icon = _ref2.icon,
|
|
98
|
+
_ref2$notificationLim = _ref2.notificationLimit,
|
|
99
|
+
notificationLimit = _ref2$notificationLim === void 0 ? 99 : _ref2$notificationLim,
|
|
100
|
+
_ref2$size = _ref2.size,
|
|
101
|
+
size = _ref2$size === void 0 ? "medium" : _ref2$size;
|
|
102
|
+
return /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
|
|
103
|
+
label: label,
|
|
104
|
+
mode: mode,
|
|
105
|
+
color: mode === "contextual" && color || undefined,
|
|
106
|
+
size: size,
|
|
107
|
+
title: title,
|
|
108
|
+
"aria-label": title
|
|
109
|
+
}, mode === "contextual" && /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
|
|
110
|
+
gap: "0.125rem",
|
|
111
|
+
alignItems: "center"
|
|
112
|
+
}, icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
113
|
+
size: size
|
|
114
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
115
|
+
src: icon,
|
|
116
|
+
alt: title
|
|
117
|
+
}) : icon), /*#__PURE__*/_react["default"].createElement(Label, {
|
|
118
|
+
label: label,
|
|
119
|
+
notificationLimit: notificationLimit,
|
|
120
|
+
size: size
|
|
121
|
+
})) || /*#__PURE__*/_react["default"].createElement(Label, {
|
|
122
|
+
label: label,
|
|
123
|
+
notificationLimit: notificationLimit,
|
|
124
|
+
size: size
|
|
125
|
+
}));
|
|
126
|
+
};
|
|
127
|
+
var getColor = function getColor(mode, color) {
|
|
128
|
+
return mode === "contextual" ? contextualColorMap[color].text : _coreTokens["default"].color_white;
|
|
129
|
+
};
|
|
130
|
+
var getBackgroundColor = function getBackgroundColor(mode, color) {
|
|
131
|
+
return mode === "contextual" ? contextualColorMap[color].background : _coreTokens["default"].color_red_700;
|
|
132
|
+
};
|
|
133
|
+
var getPadding = function getPadding(mode, size) {
|
|
134
|
+
return mode === "contextual" ? sizeMap[size].padding.contextual : sizeMap[size].padding.notification;
|
|
135
|
+
};
|
|
136
|
+
var BadgeContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n background-color: ", ";\n border-radius: ", ";\n width: ", ";\n min-width: ", ";\n height: ", ";\n padding: ", ";\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n"])), function (props) {
|
|
137
|
+
return getColor(props.mode, props.color);
|
|
42
138
|
}, function (props) {
|
|
43
|
-
return props.
|
|
139
|
+
return getBackgroundColor(props.mode, props.color);
|
|
44
140
|
}, function (props) {
|
|
45
|
-
return props.
|
|
141
|
+
return sizeMap[props.size].borderRadius;
|
|
46
142
|
}, function (props) {
|
|
47
|
-
return props.
|
|
143
|
+
return !props.label && props.mode === "notification" ? sizeMap[props.size].width : "fit-content";
|
|
48
144
|
}, function (props) {
|
|
49
|
-
return props.
|
|
145
|
+
return props.mode === "notification" && sizeMap[props.size].minWidth;
|
|
50
146
|
}, function (props) {
|
|
51
|
-
return props.
|
|
147
|
+
return sizeMap[props.size].height;
|
|
52
148
|
}, function (props) {
|
|
53
|
-
return props.
|
|
149
|
+
return props.label ? getPadding(props.mode, props.size) : "";
|
|
150
|
+
});
|
|
151
|
+
var IconContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n img,\n svg {\n height: ", ";\n width: ", ";\n }\n"])), function (props) {
|
|
152
|
+
return sizeMap[props.size].iconSize;
|
|
54
153
|
}, function (props) {
|
|
55
|
-
return props.
|
|
154
|
+
return sizeMap[props.size].iconSize;
|
|
56
155
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
156
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n white-space: nowrap;\n"])), _coreTokens["default"].type_sans, function (props) {
|
|
157
|
+
return sizeMap[props.size].fontSize;
|
|
158
|
+
}, _coreTokens["default"].type_semibold);
|
|
159
|
+
var _default = exports["default"] = DxcBadge;
|