@dxc-technology/halstack-react 0.0.0-b4fde6b → 0.0.0-b5ec444
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.d.ts +1 -10
- package/BackgroundColorContext.js +4 -21
- package/HalstackContext.d.ts +51 -138
- package/HalstackContext.js +10 -35
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +24 -76
- package/accordion/Accordion.stories.tsx +1 -113
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +5 -17
- package/accordion-group/AccordionGroup.js +15 -42
- package/accordion-group/AccordionGroup.stories.tsx +78 -77
- package/accordion-group/AccordionGroup.test.js +43 -71
- package/accordion-group/AccordionGroupAccordion.js +9 -21
- package/accordion-group/types.d.ts +6 -18
- 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 +15 -50
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +141 -43
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/bleed/Bleed.js +13 -21
- package/bleed/types.d.ts +2 -2
- package/box/Box.js +11 -33
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -3
- package/bulleted-list/BulletedList.js +18 -54
- package/bulleted-list/BulletedList.stories.tsx +1 -92
- package/bulleted-list/types.d.ts +5 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +66 -99
- package/button/Button.stories.tsx +6 -87
- package/button/Button.test.js +19 -16
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +39 -79
- package/card/Card.stories.tsx +0 -29
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +6 -12
- package/checkbox/Checkbox.js +85 -120
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +12 -31
- package/chip/Chip.stories.tsx +1 -1
- package/chip/Chip.test.js +15 -28
- package/chip/types.d.ts +4 -4
- package/common/coreTokens.d.ts +105 -14
- package/common/coreTokens.js +41 -24
- package/common/utils.js +2 -8
- package/common/variables.d.ts +51 -138
- package/common/variables.js +61 -155
- 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.js +15 -59
- package/date-input/DateInput.js +50 -96
- package/date-input/DateInput.stories.tsx +11 -30
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +11 -42
- package/date-input/Icons.d.ts +6 -6
- package/date-input/Icons.js +6 -23
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +27 -21
- package/dialog/Dialog.js +13 -40
- package/dialog/Dialog.stories.tsx +170 -0
- package/dialog/Dialog.test.js +125 -187
- package/dialog/types.d.ts +18 -13
- package/dropdown/Dropdown.js +48 -100
- package/dropdown/Dropdown.test.js +391 -378
- package/dropdown/DropdownMenu.js +8 -19
- package/dropdown/DropdownMenuItem.js +5 -17
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.js +180 -248
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +356 -354
- package/file-input/FileItem.js +14 -41
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +25 -39
- package/flex/types.d.ts +6 -6
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +70 -102
- package/footer/Footer.stories.tsx +37 -6
- package/footer/Footer.test.js +21 -33
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +66 -7
- package/footer/types.d.ts +25 -21
- package/grid/Grid.d.ts +1 -1
- package/grid/Grid.js +2 -17
- package/grid/Grid.stories.tsx +38 -38
- package/grid/types.d.ts +10 -10
- package/header/Header.d.ts +2 -2
- package/header/Header.js +31 -114
- package/header/Header.stories.tsx +7 -71
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +5 -20
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- 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/image/types.js +5 -0
- package/inset/Inset.js +13 -21
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +3 -3
- package/layout/ApplicationLayout.js +28 -65
- package/layout/ApplicationLayout.stories.tsx +1 -1
- 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 +3 -3
- package/link/Link.js +21 -42
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +6 -4
- package/main.js +25 -59
- package/nav-tabs/NavTabs.js +17 -46
- package/nav-tabs/NavTabs.stories.tsx +7 -5
- package/nav-tabs/NavTabs.test.js +38 -44
- package/nav-tabs/Tab.js +22 -50
- package/nav-tabs/types.d.ts +9 -9
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +47 -37
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +859 -412
- package/number-input/types.d.ts +11 -5
- package/package.json +30 -28
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +15 -43
- package/paginator/Paginator.test.js +224 -207
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.js +3 -19
- package/paragraph/Paragraph.stories.tsx +0 -17
- 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 +157 -140
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.js +21 -53
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +22 -54
- package/radio-group/RadioGroup.js +37 -83
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/resultset-table/ResultsetTable.d.ts +7 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.js +36 -64
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +102 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +138 -92
- package/{resultsetTable → resultset-table}/types.d.ts +13 -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 +13 -39
- package/select/Option.js +17 -27
- package/select/Select.js +87 -163
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +1946 -1804
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +4 -4
- package/sidenav/Icons.js +1 -5
- package/sidenav/Sidenav.js +26 -68
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +18 -18
- package/slider/Slider.js +68 -125
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +16 -54
- package/spinner/Spinner.test.js +25 -34
- 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.js +49 -97
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- package/table/ActionsCell.d.ts +4 -0
- package/table/ActionsCell.js +68 -0
- package/table/DropdownTheme.js +62 -0
- package/table/Table.d.ts +4 -1
- package/table/Table.js +24 -30
- package/table/{Table.stories.jsx → Table.stories.tsx} +304 -2
- package/table/Table.test.js +93 -6
- package/table/types.d.ts +45 -6
- package/tabs/Tab.js +17 -33
- package/tabs/Tabs.js +52 -129
- package/tabs/Tabs.stories.tsx +1 -1
- package/tabs/Tabs.test.js +62 -118
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +21 -51
- package/tag/Tag.test.js +19 -30
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +5 -5
- package/text-input/Icons.js +1 -5
- package/text-input/Suggestion.js +9 -26
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +15 -65
- package/text-input/TextInput.js +218 -326
- package/text-input/TextInput.stories.tsx +48 -152
- package/text-input/TextInput.test.js +1227 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +67 -109
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
- package/textarea/Textarea.test.js +150 -179
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.js +90 -107
- package/toggle-group/ToggleGroup.stories.tsx +7 -4
- package/toggle-group/ToggleGroup.test.js +68 -87
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +48 -135
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +25 -39
- package/wizard/Wizard.js +14 -49
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +6 -6
- package/card/ice-cream.jpg +0 -0
- 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/Icons.d.ts +0 -7
- package/resultsetTable/ResultsetTable.d.ts +0 -4
- package/slider/Slider.stories.tsx +0 -240
- /package/{resultsetTable → action-icon}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
- /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
package/HalstackContext.js
CHANGED
|
@@ -1,36 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = exports.HalstackProvider = exports.HalstackLanguageContext = void 0;
|
|
11
|
-
|
|
12
9
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _color = _interopRequireDefault(require("color"));
|
|
17
|
-
|
|
18
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
-
|
|
20
13
|
var _variables = require("./common/variables");
|
|
21
|
-
|
|
22
14
|
var _templateObject;
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
|
|
27
|
-
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && 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; }
|
|
28
17
|
var HalstackContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
29
|
-
|
|
30
|
-
var HalstackLanguageContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
31
|
-
|
|
32
|
-
exports.HalstackLanguageContext = HalstackLanguageContext;
|
|
33
|
-
|
|
18
|
+
var HalstackLanguageContext = exports.HalstackLanguageContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
34
19
|
var addLightness = function addLightness(newLightness, hexColor) {
|
|
35
20
|
try {
|
|
36
21
|
if (hexColor) {
|
|
@@ -43,7 +28,6 @@ var addLightness = function addLightness(newLightness, hexColor) {
|
|
|
43
28
|
return null;
|
|
44
29
|
}
|
|
45
30
|
};
|
|
46
|
-
|
|
47
31
|
var subLightness = function subLightness(newLightness, hexColor) {
|
|
48
32
|
try {
|
|
49
33
|
if (hexColor) {
|
|
@@ -56,7 +40,6 @@ var subLightness = function subLightness(newLightness, hexColor) {
|
|
|
56
40
|
return null;
|
|
57
41
|
}
|
|
58
42
|
};
|
|
59
|
-
|
|
60
43
|
var parseAdvancedTheme = function parseAdvancedTheme(advancedTheme) {
|
|
61
44
|
var allTokensCopy = JSON.parse(JSON.stringify(_variables.componentTokens));
|
|
62
45
|
Object.keys(allTokensCopy).map(function (component) {
|
|
@@ -70,10 +53,8 @@ var parseAdvancedTheme = function parseAdvancedTheme(advancedTheme) {
|
|
|
70
53
|
});
|
|
71
54
|
return allTokensCopy;
|
|
72
55
|
};
|
|
73
|
-
|
|
74
56
|
var parseTheme = function parseTheme(theme) {
|
|
75
57
|
var _theme$alert$baseColo, _theme$alert, _theme$alert$accentCo, _theme$alert2, _theme$alert$accentCo2, _theme$alert3, _theme$alert$overlayC, _theme$alert4, _theme$accordion$assi, _theme$accordion, _theme$accordion$titl, _theme$accordion2, _theme$accordion$acce, _theme$accordion3, _theme$accordion$acce2, _theme$accordion4, _addLightness, _theme$accordion5, _theme$box$baseColor, _theme$box, _theme$button$primary, _theme$button, _theme$button$baseCol, _theme$button2, _theme$button$baseCol2, _theme$button3, _theme$button$seconda, _theme$button4, _theme$button$baseCol3, _theme$button5, _theme$button$baseCol4, _theme$button6, _theme$button$baseCol5, _theme$button7, _subLightness, _theme$button8, _subLightness2, _theme$button9, _subLightness3, _theme$button10, _addLightness2, _theme$button11, _addLightness3, _theme$button12, _theme$checkbox$baseC, _theme$checkbox, _theme$checkbox$baseC2, _theme$checkbox2, _theme$checkbox$check, _theme$checkbox3, _theme$checkbox$fontC, _theme$checkbox4, _subLightness4, _theme$checkbox5, _subLightness5, _theme$checkbox6, _theme$chip$baseColor, _theme$chip, _theme$chip$fontColor, _theme$chip2, _theme$chip$iconColor, _theme$chip3, _subLightness6, _theme$chip4, _subLightness7, _theme$chip5, _theme$dateInput$base, _theme$dateInput, _theme$dateInput$sele, _theme$dateInput2, _subLightness8, _theme$dateInput3, _theme$dateInput$sele2, _theme$dateInput4, _theme$dateInput$base2, _theme$dateInput5, _subLightness9, _theme$dateInput6, _theme$dateInput$sele3, _theme$dateInput7, _addLightness4, _theme$dateInput8, _addLightness5, _theme$dateInput9, _addLightness6, _theme$dateInput10, _theme$dialog$baseCol, _theme$dialog, _theme$dialog$closeIc, _theme$dialog2, _theme$dialog$overlay, _theme$dialog3, _theme$dropdown$baseC, _theme$dropdown, _theme$dropdown$fontC, _theme$dropdown2, _theme$dropdown$fontC2, _theme$dropdown3, _theme$dropdown$fontC3, _theme$dropdown4, _theme$dropdown$optio, _theme$dropdown5, _theme$dropdown$optio2, _theme$dropdown6, _subLightness10, _theme$dropdown7, _subLightness11, _theme$dropdown8, _subLightness12, _theme$dropdown9, _subLightness13, _theme$dropdown10, _theme$fileInput$font, _theme$fileInput, _theme$fileInput$font2, _theme$fileInput2, _theme$fileInput$font3, _theme$fileInput3, _theme$fileInput$font4, _theme$fileInput4, _theme$footer$baseCol, _theme$footer, _theme$footer$fontCol, _theme$footer2, _theme$footer$fontCol2, _theme$footer3, _theme$footer$fontCol3, _theme$footer4, _theme$footer$accentC, _theme$footer5, _theme$footer$logo, _theme$footer6, _theme$header$baseCol, _theme$header, _theme$header$accentC, _theme$header2, _theme$header$menuBas, _theme$header3, _theme$header$fontCol, _theme$header4, _theme$header$hamburg, _theme$header5, _addLightness7, _theme$header6, _theme$header$logo, _theme$header7, _theme$header$logoRes, _theme$header8, _theme$header$content, _theme$header9, _theme$header$overlay, _theme$header10, _theme$link$baseColor, _theme$link, _theme$link$baseColor2, _theme$link2, _theme$navTabs$baseCo, _theme$navTabs, _theme$navTabs$baseCo2, _theme$navTabs2, _theme$navTabs$baseCo3, _theme$navTabs3, _theme$navTabs$baseCo4, _theme$navTabs4, _theme$navTabs$accent, _theme$navTabs5, _addLightness8, _theme$navTabs6, _addLightness9, _theme$navTabs7, _theme$paginator$base, _theme$paginator, _theme$paginator$font, _theme$paginator2, _theme$progressBar$ac, _theme$progressBar, _theme$progressBar$ba, _theme$progressBar2, _theme$progressBar$fo, _theme$progressBar3, _theme$progressBar$fo2, _theme$progressBar4, _theme$progressBar$fo3, _theme$progressBar5, _theme$progressBar$ov, _theme$progressBar6, _theme$progressBar$ov2, _theme$progressBar7, _theme$quickNav$fontC, _theme$quickNav, _theme$quickNav$accen, _theme$quickNav2, _theme$radioGroup$bas, _theme$radioGroup, _theme$radioGroup$fon, _theme$radioGroup2, _theme$radioGroup$fon2, _theme$radioGroup3, _theme$radioGroup$fon3, _theme$radioGroup4, _subLightness14, _theme$radioGroup5, _subLightness15, _theme$radioGroup6, _theme$select$selecte, _theme$select, _theme$select$fontCol, _theme$select2, _theme$select$fontCol2, _theme$select3, _theme$select$fontCol3, _theme$select4, _theme$select$optionF, _theme$select5, _addLightness10, _theme$select6, _theme$select$fontCol4, _theme$select7, _theme$select$hoverBo, _theme$select8, _subLightness16, _theme$select9, _subLightness17, _theme$select10, _theme$sidenav$baseCo, _theme$sidenav, _theme$slider$fontCol, _theme$slider, _theme$slider$fontCol2, _theme$slider2, _theme$slider$fontCol3, _theme$slider3, _theme$slider$baseCol, _theme$slider4, _theme$slider$baseCol2, _theme$slider5, _theme$slider$baseCol3, _theme$slider6, _theme$slider$baseCol4, _theme$slider7, _theme$slider$totalLi, _theme$slider8, _subLightness18, _theme$slider9, _subLightness19, _theme$slider10, _theme$spinner$accent, _theme$spinner, _theme$spinner$baseCo, _theme$spinner2, _theme$spinner$overla, _theme$spinner3, _theme$spinner$fontCo, _theme$spinner4, _theme$spinner$fontCo2, _theme$spinner5, _theme$spinner$overla2, _theme$spinner6, _theme$spinner$overla3, _theme$spinner7, _theme$switch$checked, _theme$switch, _theme$switch$fontCol, _theme$switch2, _addLightness11, _theme$switch3, _theme$table$baseColo, _theme$table, _theme$table$headerFo, _theme$table2, _theme$table$cellFont, _theme$table3, _theme$table$headerFo2, _theme$table4, _theme$tabs$baseColor, _theme$tabs, _theme$tabs$baseColor2, _theme$tabs2, _theme$tabs$baseColor3, _theme$tabs3, _theme$tabs$baseColor4, _theme$tabs4, _addLightness12, _theme$tabs5, _addLightness13, _theme$tabs6, _theme$tag$fontColor, _theme$tag, _theme$tag$iconColor, _theme$tag2, _theme$textInput$font, _theme$textInput, _theme$textInput$font2, _theme$textInput2, _theme$textInput$font3, _theme$textInput3, _theme$textInput$font4, _theme$textInput4, _theme$textInput$font5, _theme$textInput5, _theme$textInput$font6, _theme$textInput6, _theme$textInput$font7, _theme$textInput7, _theme$textInput$hove, _theme$textInput8, _addLightness14, _theme$textInput9, _addLightness15, _theme$textInput10, _addLightness16, _theme$textInput11, _theme$textarea$fontC, _theme$textarea, _theme$textarea$fontC2, _theme$textarea2, _theme$textarea$fontC3, _theme$textarea3, _theme$textarea$hover, _theme$textarea4, _addLightness17, _theme$textarea5, _theme$toggleGroup$se, _theme$toggleGroup, _theme$toggleGroup$se2, _theme$toggleGroup2, _theme$toggleGroup$un, _theme$toggleGroup3, _theme$toggleGroup$se3, _theme$toggleGroup4, _theme$toggleGroup$un2, _theme$toggleGroup5, _subLightness20, _theme$toggleGroup6, _subLightness21, _theme$toggleGroup7, _addLightness18, _theme$toggleGroup8, _addLightness19, _theme$toggleGroup9, _subLightness22, _theme$toggleGroup10, _theme$wizard$baseCol, _theme$wizard, _theme$wizard$selecte, _theme$wizard2, _theme$wizard$baseCol2, _theme$wizard3, _theme$wizard$fontCol, _theme$wizard4, _theme$wizard$fontCol2, _theme$wizard5, _theme$wizard$fontCol3, _theme$wizard6, _theme$wizard$fontCol4, _theme$wizard7, _addLightness20, _theme$wizard8, _addLightness21, _theme$wizard9, _addLightness22, _theme$wizard10, _addLightness23, _theme$wizard11;
|
|
76
|
-
|
|
77
58
|
var componentTokensCopy = JSON.parse(JSON.stringify(_variables.componentTokens));
|
|
78
59
|
var alertTokens = componentTokensCopy.alert;
|
|
79
60
|
alertTokens.infoBackgroundColor = (_theme$alert$baseColo = theme === null || theme === void 0 ? void 0 : (_theme$alert = theme.alert) === null || _theme$alert === void 0 ? void 0 : _theme$alert.baseColor) !== null && _theme$alert$baseColo !== void 0 ? _theme$alert$baseColo : alertTokens.infoBackgroundColor;
|
|
@@ -289,7 +270,6 @@ var parseTheme = function parseTheme(theme) {
|
|
|
289
270
|
wizardTokens.unvisitedHelperTextFontColor = (_addLightness23 = addLightness(40, theme === null || theme === void 0 ? void 0 : (_theme$wizard11 = theme.wizard) === null || _theme$wizard11 === void 0 ? void 0 : _theme$wizard11.fontColor)) !== null && _addLightness23 !== void 0 ? _addLightness23 : wizardTokens.unvisitedHelperTextFontColor;
|
|
290
271
|
return componentTokensCopy;
|
|
291
272
|
};
|
|
292
|
-
|
|
293
273
|
var parseLabels = function parseLabels(labels) {
|
|
294
274
|
var parsedLabels = _variables.defaultTranslatedComponentLabels;
|
|
295
275
|
Object.keys(labels).map(function (component) {
|
|
@@ -303,17 +283,17 @@ var parseLabels = function parseLabels(labels) {
|
|
|
303
283
|
});
|
|
304
284
|
return parsedLabels;
|
|
305
285
|
};
|
|
286
|
+
|
|
306
287
|
/**
|
|
307
288
|
* This type is used to allow partial themes and labels objects to be passed to the HalstackProvider.
|
|
308
|
-
* This is an extension of the already
|
|
289
|
+
* This is an extension of the already existing Partial type, which only allows one level of partiality.
|
|
309
290
|
*/
|
|
310
291
|
|
|
311
|
-
|
|
312
|
-
var HalstackProvider = function HalstackProvider(_ref) {
|
|
292
|
+
var HalstackProvider = exports.HalstackProvider = function HalstackProvider(_ref) {
|
|
313
293
|
var theme = _ref.theme,
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
294
|
+
advancedTheme = _ref.advancedTheme,
|
|
295
|
+
labels = _ref.labels,
|
|
296
|
+
children = _ref.children;
|
|
317
297
|
var parsedTheme = (0, _react.useMemo)(function () {
|
|
318
298
|
return theme ? parseTheme(theme) : advancedTheme ? parseAdvancedTheme(advancedTheme) : _variables.componentTokens;
|
|
319
299
|
}, [theme, advancedTheme]);
|
|
@@ -326,10 +306,5 @@ var HalstackProvider = function HalstackProvider(_ref) {
|
|
|
326
306
|
value: parsedLabels
|
|
327
307
|
}, children)));
|
|
328
308
|
};
|
|
329
|
-
|
|
330
|
-
exports.HalstackProvider = HalstackProvider;
|
|
331
|
-
|
|
332
309
|
var Halstack = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n @import url(\"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap\");\n"])));
|
|
333
|
-
|
|
334
|
-
var _default = HalstackContext;
|
|
335
|
-
exports["default"] = _default;
|
|
310
|
+
var _default = exports["default"] = HalstackContext;
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://developer.dxc.com/halstack/">
|
|
3
|
+
<img src="website/screens/common/images/halstack_logo.svg" alt="Halstack Design System logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Halstack Design System</h1>
|
|
8
|
+
|
|
9
|
+
Halstack is an Open Source Design System built and maintained by DXC Technology with the purpose of providing all the necessary tools for designing and implementing accessible, intuitive and consistent User Experiences with React.
|
|
10
|
+
|
|
11
|
+
## How to start
|
|
12
|
+
|
|
13
|
+
You can start using Halstack right now:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm i @dxc-technology/halstack-react
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Usage
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { DxcButton, DxcTextInput } from "@dxc-technology/halstack-react";
|
|
24
|
+
|
|
25
|
+
const App = () => (
|
|
26
|
+
<>
|
|
27
|
+
<DxcTextInput label="Enter your name" />
|
|
28
|
+
<DxcButton label="Submit" type="submit" />
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Where to start
|
|
34
|
+
|
|
35
|
+
Learn everything you need to know about Halstack principles and components on the [official documentation site](https://developer.dxc.com/halstack/).
|
|
36
|
+
|
|
37
|
+
## Contributing
|
|
38
|
+
|
|
39
|
+
Any feedback is always welcome in Halstack!
|
|
40
|
+
|
|
41
|
+
Before opening a new issue, pull request or discussion, please read carefully and respect our [contribution guidelines](https://github.com/dxc-technology/halstack-react/wiki/Contributing).
|
|
42
|
+
|
|
43
|
+
## Thanks
|
|
44
|
+
|
|
45
|
+
<a href="https://www.chromatic.com/"><img src="https://user-images.githubusercontent.com/321738/84662277-e3db4f80-af1b-11ea-88f5-91d67a5e59f6.png" width="153" height="30" alt="Chromatic" /></a>
|
|
46
|
+
|
|
47
|
+
Thanks to [Chromatic](https://www.chromatic.com/) for providing the visual testing platform that helps us review UI changes and catch visual regressions.
|
package/accordion/Accordion.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import AccordionPropsType from "./types";
|
|
3
|
-
declare const DxcAccordion: ({ label, defaultIsExpanded, isExpanded, icon, assistiveText, disabled, onChange, children, margin,
|
|
3
|
+
declare const DxcAccordion: ({ label, defaultIsExpanded, isExpanded, icon, assistiveText, disabled, onChange, children, margin, tabIndex, }: AccordionPropsType) => JSX.Element;
|
|
4
4
|
export default DxcAccordion;
|
package/accordion/Accordion.js
CHANGED
|
@@ -1,42 +1,24 @@
|
|
|
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
14
|
var _utils = require("../common/utils");
|
|
23
|
-
|
|
24
15
|
var _variables = require("../common/variables");
|
|
25
|
-
|
|
26
16
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
27
|
-
|
|
28
|
-
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
29
|
-
|
|
30
17
|
var _BaseTypography = _interopRequireDefault(require("../utils/BaseTypography"));
|
|
31
|
-
|
|
32
18
|
var _uuid = require("uuid");
|
|
33
|
-
|
|
34
19
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
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; }
|
|
39
|
-
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && 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; }
|
|
40
22
|
var expandLess = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
41
23
|
xmlns: "http://www.w3.org/2000/svg",
|
|
42
24
|
height: "24",
|
|
@@ -45,7 +27,6 @@ var expandLess = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
|
45
27
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
46
28
|
d: "m7.4 15.375-1.4-1.4 6-6 6 6-1.4 1.4-4.6-4.6Z"
|
|
47
29
|
}));
|
|
48
|
-
|
|
49
30
|
var expandMore = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
50
31
|
xmlns: "http://www.w3.org/2000/svg",
|
|
51
32
|
height: "24",
|
|
@@ -54,44 +35,36 @@ var expandMore = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
|
54
35
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
55
36
|
d: "m12 15.375-6-6 1.4-1.4 4.6 4.6 4.6-4.6 1.4 1.4Z"
|
|
56
37
|
}));
|
|
57
|
-
|
|
58
38
|
var DxcAccordion = function DxcAccordion(_ref) {
|
|
59
39
|
var _ref$label = _ref.label,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
74
|
-
|
|
40
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
41
|
+
defaultIsExpanded = _ref.defaultIsExpanded,
|
|
42
|
+
isExpanded = _ref.isExpanded,
|
|
43
|
+
icon = _ref.icon,
|
|
44
|
+
_ref$assistiveText = _ref.assistiveText,
|
|
45
|
+
assistiveText = _ref$assistiveText === void 0 ? "" : _ref$assistiveText,
|
|
46
|
+
_ref$disabled = _ref.disabled,
|
|
47
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
48
|
+
onChange = _ref.onChange,
|
|
49
|
+
children = _ref.children,
|
|
50
|
+
margin = _ref.margin,
|
|
51
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
52
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
75
53
|
var _useState = (0, _react.useState)((0, _uuid.v4)()),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
54
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
55
|
+
id = _useState2[0];
|
|
79
56
|
var _useState3 = (0, _react.useState)(defaultIsExpanded !== null && defaultIsExpanded !== void 0 ? defaultIsExpanded : false),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
58
|
+
innerIsExpanded = _useState4[0],
|
|
59
|
+
setInnerIsExpanded = _useState4[1];
|
|
84
60
|
var colorsTheme = (0, _useTheme["default"])();
|
|
85
|
-
|
|
86
61
|
var handleAccordionState = function handleAccordionState() {
|
|
87
62
|
var _isExpanded;
|
|
88
|
-
|
|
89
63
|
isExpanded !== null && isExpanded !== void 0 ? isExpanded : setInnerIsExpanded(function (innerIsExpanded) {
|
|
90
64
|
return !innerIsExpanded;
|
|
91
65
|
});
|
|
92
66
|
onChange === null || onChange === void 0 ? void 0 : onChange((_isExpanded = !isExpanded) !== null && _isExpanded !== void 0 ? _isExpanded : !innerIsExpanded);
|
|
93
67
|
};
|
|
94
|
-
|
|
95
68
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
96
69
|
theme: colorsTheme.accordion
|
|
97
70
|
}, /*#__PURE__*/_react["default"].createElement(AccordionContainer, {
|
|
@@ -129,17 +102,12 @@ var DxcAccordion = function DxcAccordion(_ref) {
|
|
|
129
102
|
}, (isExpanded !== null && isExpanded !== void 0 ? isExpanded : innerIsExpanded) ? expandLess : expandMore))), (isExpanded !== null && isExpanded !== void 0 ? isExpanded : innerIsExpanded) && /*#__PURE__*/_react["default"].createElement(AccordionPanel, {
|
|
130
103
|
id: "accordion-panel-".concat(id),
|
|
131
104
|
role: "region",
|
|
132
|
-
"aria-labelledby": "accordion-".concat(id)
|
|
133
|
-
|
|
134
|
-
}, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
|
|
135
|
-
color: colorsTheme.accordion.backgroundColor
|
|
136
|
-
}, children))));
|
|
105
|
+
"aria-labelledby": "accordion-".concat(id)
|
|
106
|
+
}, children)));
|
|
137
107
|
};
|
|
138
|
-
|
|
139
108
|
var calculateWidth = function calculateWidth(margin) {
|
|
140
109
|
return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
141
110
|
};
|
|
142
|
-
|
|
143
111
|
var AccordionContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n background-color: ", ";\n border-radius: ", ";\n ", "\n box-shadow: ", ";\n min-width: 280px;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n width: ", ";\n"])), function (props) {
|
|
144
112
|
return props.theme.backgroundColor;
|
|
145
113
|
}, function (props) {
|
|
@@ -161,9 +129,7 @@ var AccordionContainer = _styledComponents["default"].div(_templateObject || (_t
|
|
|
161
129
|
}, function (props) {
|
|
162
130
|
return calculateWidth(props.margin);
|
|
163
131
|
});
|
|
164
|
-
|
|
165
132
|
var AccordionHeader = _styledComponents["default"].h3(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n min-height: 48px;\n margin: 0;\n"])));
|
|
166
|
-
|
|
167
133
|
var AccordionTrigger = _styledComponents["default"].button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 24px;\n width: 100%;\n background-color: transparent;\n border: none;\n border-radius: ", ";\n ", "\n padding: 12px 16px;\n cursor: ", ";\n\n :focus {\n outline: ", ";\n }\n :hover:enabled {\n background-color: ", ";\n }\n :active:enabled {\n background-color: ", ";\n }\n"])), function (props) {
|
|
168
134
|
return props.theme.borderRadius;
|
|
169
135
|
}, function (props) {
|
|
@@ -177,9 +143,7 @@ var AccordionTrigger = _styledComponents["default"].button(_templateObject3 || (
|
|
|
177
143
|
}, function (props) {
|
|
178
144
|
return "".concat(props.theme.hoverBackgroundColor);
|
|
179
145
|
});
|
|
180
|
-
|
|
181
146
|
var AccordionInfo = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: space-between;\n width: 100%;\n"])));
|
|
182
|
-
|
|
183
147
|
var AccordionLabel = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-right: ", ";\n padding-left: ", ";\n"])), function (props) {
|
|
184
148
|
return props.theme.titleLabelPaddingTop;
|
|
185
149
|
}, function (props) {
|
|
@@ -189,7 +153,6 @@ var AccordionLabel = _styledComponents["default"].span(_templateObject5 || (_tem
|
|
|
189
153
|
}, function (props) {
|
|
190
154
|
return props.theme.titleLabelPaddingLeft;
|
|
191
155
|
});
|
|
192
|
-
|
|
193
156
|
var IconContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-left: ", ";\n margin-right: ", ";\n color: ", ";\n\n svg,\n img {\n height: ", ";\n width: ", ";\n }\n"])), function (props) {
|
|
194
157
|
return props.theme.iconMarginLeft;
|
|
195
158
|
}, function (props) {
|
|
@@ -201,7 +164,6 @@ var IconContainer = _styledComponents["default"].span(_templateObject6 || (_temp
|
|
|
201
164
|
}, function (props) {
|
|
202
165
|
return props.theme.iconSize;
|
|
203
166
|
});
|
|
204
|
-
|
|
205
167
|
var AccordionAssistiveText = _styledComponents["default"].span(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n min-width: ", ";\n padding-left: ", ";\n padding-right: ", ";\n"])), function (props) {
|
|
206
168
|
return props.theme.assistiveTextMinWidth;
|
|
207
169
|
}, function (props) {
|
|
@@ -209,26 +171,12 @@ var AccordionAssistiveText = _styledComponents["default"].span(_templateObject7
|
|
|
209
171
|
}, function (props) {
|
|
210
172
|
return props.theme.assistiveTextPaddingRight;
|
|
211
173
|
});
|
|
212
|
-
|
|
213
174
|
var CollapseIndicator = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n color: ", ";\n"])), function (props) {
|
|
214
175
|
return props.disabled ? props.theme.disabledArrowColor : props.theme.arrowColor;
|
|
215
176
|
});
|
|
216
|
-
|
|
217
|
-
var AccordionPanel = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n"])), function (props) {
|
|
177
|
+
var AccordionPanel = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n"])), function (props) {
|
|
218
178
|
return props.theme.borderRadius;
|
|
219
179
|
}, function (props) {
|
|
220
180
|
return props.theme.borderRadius;
|
|
221
|
-
}, function (props) {
|
|
222
|
-
return props.padding && (0, _typeof2["default"])(props.padding) !== "object" ? _variables.spaces[props.padding] : "0px";
|
|
223
|
-
}, function (props) {
|
|
224
|
-
return props.padding && (0, _typeof2["default"])(props.padding) === "object" && props.padding.top ? _variables.spaces[props.padding.top] : "";
|
|
225
|
-
}, function (props) {
|
|
226
|
-
return props.padding && (0, _typeof2["default"])(props.padding) === "object" && props.padding.right ? _variables.spaces[props.padding.right] : "";
|
|
227
|
-
}, function (props) {
|
|
228
|
-
return props.padding && (0, _typeof2["default"])(props.padding) === "object" && props.padding.bottom ? _variables.spaces[props.padding.bottom] : "";
|
|
229
|
-
}, function (props) {
|
|
230
|
-
return props.padding && (0, _typeof2["default"])(props.padding) === "object" && props.padding.left ? _variables.spaces[props.padding.left] : "";
|
|
231
181
|
});
|
|
232
|
-
|
|
233
|
-
var _default = DxcAccordion;
|
|
234
|
-
exports["default"] = _default;
|
|
182
|
+
var _default = exports["default"] = DxcAccordion;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import DxcAccordion from "./Accordion";
|
|
3
|
-
import DxcHeading from "../heading/Heading";
|
|
4
|
-
import DxcTextInput from "../text-input/TextInput";
|
|
5
|
-
import DxcButton from "../button/Button";
|
|
6
3
|
import Title from "../../.storybook/components/Title";
|
|
7
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
8
5
|
import { HalstackProvider } from "../HalstackContext";
|
|
@@ -119,7 +116,7 @@ export const Chromatic = () => (
|
|
|
119
116
|
</ExampleContainer>
|
|
120
117
|
<ExampleContainer>
|
|
121
118
|
<Title title="With bigger icon (SVG)" theme="light" level={4} />
|
|
122
|
-
<DxcAccordion label="
|
|
119
|
+
<DxcAccordion label="Accordion Test" assistiveText="Assistive text" icon={facebookIcon}>
|
|
123
120
|
<div>
|
|
124
121
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
|
|
125
122
|
lobortis eget.
|
|
@@ -176,115 +173,6 @@ export const Chromatic = () => (
|
|
|
176
173
|
</div>
|
|
177
174
|
</DxcAccordion>
|
|
178
175
|
</ExampleContainer>
|
|
179
|
-
<ExampleContainer>
|
|
180
|
-
<Title title="Background color provider over accordion content" theme="light" level={4} />
|
|
181
|
-
<HalstackProvider advancedTheme={advancedTheme}>
|
|
182
|
-
<DxcAccordion
|
|
183
|
-
label="Dark Accordion"
|
|
184
|
-
defaultIsExpanded
|
|
185
|
-
assistiveText="Assistive text"
|
|
186
|
-
icon={folderIcon}
|
|
187
|
-
padding="medium"
|
|
188
|
-
>
|
|
189
|
-
<div style={{ display: "flex", flexDirection: "column", gap: "36px" }}>
|
|
190
|
-
<DxcTextInput label="Label" helperText="HelperText" placeholder="Placeholder" size="fillParent" />
|
|
191
|
-
<DxcButton label="Submit" size="medium" />
|
|
192
|
-
</div>
|
|
193
|
-
</DxcAccordion>
|
|
194
|
-
</HalstackProvider>
|
|
195
|
-
</ExampleContainer>
|
|
196
|
-
<Title title="Paddings" theme="light" level={2} />
|
|
197
|
-
<ExampleContainer>
|
|
198
|
-
<Title title="Xxsmall padding" theme="light" level={4} />
|
|
199
|
-
<DxcAccordion label="Xxsmall padding" defaultIsExpanded padding="xxsmall">
|
|
200
|
-
<div>
|
|
201
|
-
<DxcHeading level={5} text="Content header" margin={{ bottom: "xxsmall" }} />
|
|
202
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
203
|
-
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
204
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
205
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
|
206
|
-
est laborum.
|
|
207
|
-
</div>
|
|
208
|
-
</DxcAccordion>
|
|
209
|
-
</ExampleContainer>
|
|
210
|
-
<ExampleContainer>
|
|
211
|
-
<Title title="Xsmall padding" theme="light" level={4} />
|
|
212
|
-
<DxcAccordion label="Xsmall padding" defaultIsExpanded padding="xsmall">
|
|
213
|
-
<div>
|
|
214
|
-
<DxcHeading level={5} text="Content header" margin={{ bottom: "xxsmall" }} />
|
|
215
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
216
|
-
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
217
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
218
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
|
219
|
-
est laborum.
|
|
220
|
-
</div>
|
|
221
|
-
</DxcAccordion>
|
|
222
|
-
</ExampleContainer>
|
|
223
|
-
<ExampleContainer>
|
|
224
|
-
<Title title="Small padding" theme="light" level={4} />
|
|
225
|
-
<DxcAccordion label="Small padding" defaultIsExpanded padding="small">
|
|
226
|
-
<div>
|
|
227
|
-
<DxcHeading level={5} text="Content header" margin={{ bottom: "xxsmall" }} />
|
|
228
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
229
|
-
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
230
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
231
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
|
232
|
-
est laborum.
|
|
233
|
-
</div>
|
|
234
|
-
</DxcAccordion>
|
|
235
|
-
</ExampleContainer>
|
|
236
|
-
<ExampleContainer>
|
|
237
|
-
<Title title="Medium padding" theme="light" level={4} />
|
|
238
|
-
<DxcAccordion label="Medium padding" defaultIsExpanded padding="medium">
|
|
239
|
-
<div>
|
|
240
|
-
<DxcHeading level={5} text="Content header" margin={{ bottom: "xxsmall" }} />
|
|
241
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
242
|
-
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
243
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
244
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
|
245
|
-
est laborum.
|
|
246
|
-
</div>
|
|
247
|
-
</DxcAccordion>
|
|
248
|
-
</ExampleContainer>
|
|
249
|
-
<ExampleContainer>
|
|
250
|
-
<Title title="Large padding" theme="light" level={4} />
|
|
251
|
-
<DxcAccordion label="Large padding" defaultIsExpanded padding="large">
|
|
252
|
-
<div>
|
|
253
|
-
<DxcHeading level={5} text="Content header" margin={{ bottom: "xxsmall" }} />
|
|
254
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
255
|
-
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
256
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
257
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
|
258
|
-
est laborum.
|
|
259
|
-
</div>
|
|
260
|
-
</DxcAccordion>
|
|
261
|
-
</ExampleContainer>
|
|
262
|
-
<ExampleContainer>
|
|
263
|
-
<Title title="Xlarge padding" theme="light" level={4} />
|
|
264
|
-
<DxcAccordion label="Xlarge padding" defaultIsExpanded padding="xlarge">
|
|
265
|
-
<div>
|
|
266
|
-
<DxcHeading level={5} text="Content header" margin={{ bottom: "xxsmall" }} />
|
|
267
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
268
|
-
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
269
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
270
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
|
271
|
-
est laborum.
|
|
272
|
-
</div>
|
|
273
|
-
</DxcAccordion>
|
|
274
|
-
</ExampleContainer>
|
|
275
|
-
<ExampleContainer>
|
|
276
|
-
<Title title="Xxlarge padding" theme="light" level={4} />
|
|
277
|
-
<DxcAccordion label="Xxlarge padding" defaultIsExpanded padding="xxlarge">
|
|
278
|
-
<div>
|
|
279
|
-
<DxcHeading level={5} text="Content header" margin={{ bottom: "xxsmall" }} />
|
|
280
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
281
|
-
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
282
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
283
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
|
284
|
-
est laborum.
|
|
285
|
-
</div>
|
|
286
|
-
</DxcAccordion>
|
|
287
|
-
</ExampleContainer>
|
|
288
176
|
<Title title="Margins" theme="light" level={2} />
|
|
289
177
|
<ExampleContainer>
|
|
290
178
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
6
|
var _Accordion = _interopRequireDefault(require("./Accordion.tsx"));
|
|
10
|
-
|
|
11
7
|
describe("Accordion component tests", function () {
|
|
12
8
|
test("Renders with correct aria accessibility attributes", function () {
|
|
13
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
label: "Accordion",
|
|
11
|
+
defaultIsExpanded: true
|
|
12
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "test-expanded"))),
|
|
13
|
+
getByRole = _render.getByRole;
|
|
19
14
|
var accordion = getByRole("button");
|
|
20
15
|
var panel = getByRole("region");
|
|
21
16
|
expect(accordion.getAttribute("aria-controls")).toBe(panel.id);
|
|
@@ -23,46 +18,36 @@ describe("Accordion component tests", function () {
|
|
|
23
18
|
});
|
|
24
19
|
test("Renders expanded by default when it is uncontrolled", function () {
|
|
25
20
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
label: "Accordion",
|
|
22
|
+
defaultIsExpanded: true
|
|
23
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "test-expanded"))),
|
|
24
|
+
getByRole = _render2.getByRole;
|
|
31
25
|
var accordion = getByRole("button");
|
|
32
26
|
expect(accordion.getAttribute("aria-expanded")).toBe("true");
|
|
33
27
|
});
|
|
34
28
|
test("Calls correct function on click", function () {
|
|
35
29
|
var onChange = jest.fn();
|
|
36
|
-
|
|
37
30
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
label: "Accordion",
|
|
32
|
+
onChange: onChange
|
|
33
|
+
})),
|
|
34
|
+
getByText = _render3.getByText;
|
|
43
35
|
_react2.fireEvent.click(getByText("Accordion"));
|
|
44
|
-
|
|
45
36
|
expect(onChange).toHaveBeenCalled();
|
|
46
37
|
});
|
|
47
38
|
test("Controlled accordion", function () {
|
|
48
39
|
var onChange = jest.fn();
|
|
49
|
-
|
|
50
40
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
label: "Accordion",
|
|
42
|
+
onChange: onChange,
|
|
43
|
+
isExpanded: true
|
|
44
|
+
})),
|
|
45
|
+
getByText = _render4.getByText,
|
|
46
|
+
getByRole = _render4.getByRole;
|
|
58
47
|
expect(getByRole("button").getAttribute("aria-expanded")).toBe("true");
|
|
59
|
-
|
|
60
48
|
_react2.fireEvent.click(getByText("Accordion"));
|
|
61
|
-
|
|
62
49
|
_react2.fireEvent.click(getByText("Accordion"));
|
|
63
|
-
|
|
64
50
|
_react2.fireEvent.click(getByText("Accordion"));
|
|
65
|
-
|
|
66
51
|
expect(onChange).toHaveBeenCalledTimes(3);
|
|
67
52
|
expect(onChange.mock.calls[0][0]).toBe(false);
|
|
68
53
|
expect(onChange.mock.calls[1][0]).toBe(false);
|
package/accordion/types.d.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
bottom?: Space;
|
|
12
|
-
left?: Space;
|
|
13
|
-
right?: Space;
|
|
14
|
-
};
|
|
15
|
-
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
16
|
-
declare type Props = {
|
|
9
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
type Props = {
|
|
17
11
|
/**
|
|
18
12
|
* The panel label.
|
|
19
13
|
*/
|
|
@@ -56,13 +50,7 @@ declare type Props = {
|
|
|
56
50
|
*/
|
|
57
51
|
margin?: Space | Margin;
|
|
58
52
|
/**
|
|
59
|
-
*
|
|
60
|
-
* Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
61
|
-
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
|
|
62
|
-
*/
|
|
63
|
-
padding?: Space | Padding;
|
|
64
|
-
/**
|
|
65
|
-
* Value of the tabindex.
|
|
53
|
+
* Value of the tabindex attribute.
|
|
66
54
|
*/
|
|
67
55
|
tabIndex?: number;
|
|
68
56
|
};
|