@dxc-technology/halstack-react 0.0.0-3b81157 → 0.0.0-3ce9060

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.
Files changed (99) hide show
  1. package/HalstackContext.d.ts +11 -1
  2. package/HalstackContext.js +1 -1
  3. package/README.md +47 -0
  4. package/accordion/Accordion.d.ts +1 -1
  5. package/accordion/Accordion.js +2 -14
  6. package/accordion/Accordion.stories.tsx +2 -100
  7. package/accordion/types.d.ts +0 -12
  8. package/accordion-group/AccordionGroup.d.ts +4 -3
  9. package/accordion-group/AccordionGroup.js +21 -42
  10. package/accordion-group/AccordionGroup.stories.tsx +77 -76
  11. package/accordion-group/AccordionGroup.test.js +6 -16
  12. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  13. package/accordion-group/AccordionGroupAccordion.js +43 -0
  14. package/accordion-group/types.d.ts +0 -12
  15. package/alert/Alert.js +1 -3
  16. package/box/Box.d.ts +1 -1
  17. package/box/Box.js +5 -22
  18. package/box/Box.stories.tsx +25 -53
  19. package/box/types.d.ts +0 -12
  20. package/button/Button.d.ts +1 -1
  21. package/button/Button.js +45 -54
  22. package/button/Button.stories.tsx +1 -1
  23. package/button/Button.test.js +11 -0
  24. package/button/types.d.ts +4 -0
  25. package/card/Card.d.ts +1 -1
  26. package/card/Card.js +18 -35
  27. package/card/Card.stories.tsx +0 -29
  28. package/card/types.d.ts +1 -7
  29. package/chip/Chip.js +23 -36
  30. package/chip/Chip.stories.tsx +25 -17
  31. package/common/coreTokens.js +1 -1
  32. package/common/variables.d.ts +10 -0
  33. package/common/variables.js +10 -0
  34. package/date-input/Calendar.js +2 -2
  35. package/dialog/Dialog.d.ts +1 -1
  36. package/dialog/Dialog.js +4 -22
  37. package/dialog/Dialog.stories.tsx +52 -176
  38. package/dialog/types.d.ts +0 -13
  39. package/file-input/FileItem.js +2 -2
  40. package/file-input/types.d.ts +1 -1
  41. package/footer/Footer.d.ts +1 -1
  42. package/footer/Footer.js +43 -61
  43. package/footer/Footer.stories.tsx +19 -95
  44. package/footer/Footer.test.js +3 -1
  45. package/footer/types.d.ts +10 -12
  46. package/grid/Grid.d.ts +1 -1
  47. package/grid/Grid.js +1 -1
  48. package/grid/Grid.stories.tsx +38 -38
  49. package/header/Header.d.ts +1 -1
  50. package/header/Header.js +3 -30
  51. package/header/Header.stories.tsx +7 -71
  52. package/header/types.d.ts +0 -14
  53. package/image/Image.d.ts +4 -0
  54. package/image/Image.js +85 -0
  55. package/image/Image.stories.tsx +127 -0
  56. package/image/types.d.ts +72 -0
  57. package/layout/ApplicationLayout.d.ts +2 -2
  58. package/layout/ApplicationLayout.js +14 -11
  59. package/layout/ApplicationLayout.stories.tsx +1 -1
  60. package/layout/Icons.d.ts +7 -4
  61. package/layout/Icons.js +52 -56
  62. package/main.d.ts +2 -1
  63. package/main.js +8 -0
  64. package/nav-tabs/NavTabs.d.ts +2 -2
  65. package/nav-tabs/NavTabs.js +7 -10
  66. package/nav-tabs/NavTabs.stories.tsx +14 -0
  67. package/nav-tabs/Tab.js +22 -26
  68. package/nav-tabs/types.d.ts +8 -9
  69. package/number-input/NumberInput.d.ts +7 -0
  70. package/number-input/NumberInput.js +6 -4
  71. package/number-input/NumberInput.test.js +278 -95
  72. package/package.json +2 -2
  73. package/paginator/Paginator.js +1 -1
  74. package/paginator/Paginator.test.js +13 -0
  75. package/password-input/Icons.d.ts +6 -0
  76. package/password-input/Icons.js +39 -0
  77. package/password-input/PasswordInput.js +35 -82
  78. package/password-input/PasswordInput.stories.tsx +1 -0
  79. package/password-input/PasswordInput.test.js +27 -34
  80. package/radio-group/Radio.js +10 -10
  81. package/radio-group/RadioGroup.js +8 -10
  82. package/select/Select.stories.tsx +3 -3
  83. package/select/Select.test.js +4 -4
  84. package/text-input/TextInput.js +62 -78
  85. package/textarea/Textarea.js +24 -22
  86. package/textarea/Textarea.stories.jsx +8 -0
  87. package/textarea/Textarea.test.js +59 -15
  88. package/textarea/types.d.ts +4 -0
  89. package/toggle-group/ToggleGroup.js +79 -56
  90. package/toggle-group/ToggleGroup.stories.tsx +6 -3
  91. package/toggle-group/ToggleGroup.test.js +37 -23
  92. package/toggle-group/types.d.ts +22 -13
  93. package/useTheme.d.ts +10 -0
  94. package/utils/FocusLock.js +2 -3
  95. package/card/ice-cream.jpg +0 -0
  96. package/number-input/NumberInputContext.d.ts +0 -4
  97. package/number-input/NumberInputContext.js +0 -19
  98. package/number-input/numberInputContextTypes.d.ts +0 -19
  99. /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import Title from "../../.storybook/components/Title";
3
3
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
4
4
  import DxcBox from "./Box";
5
+ import DxcInset from "../inset/Inset";
5
6
  import { HalstackProvider } from "../HalstackContext";
6
7
 
7
8
  export default {
@@ -19,99 +20,70 @@ export const Chromatic = () => (
19
20
  <>
20
21
  <Title title="Display flex" theme="light" level={2} />
21
22
  <ExampleContainer>
22
- <DxcBox display="flex" padding="medium">
23
- Box
23
+ <DxcBox display="flex">
24
+ <DxcInset space="2rem">Box</DxcInset>
24
25
  </DxcBox>
25
26
  </ExampleContainer>
26
27
  <Title title="ShadowDepth" theme="light" level={2} />
27
28
  <ExampleContainer>
28
29
  <Title title="ShadowDepth 0" theme="light" level={4} />
29
- <DxcBox shadowDepth={0} margin="medium" padding="medium">
30
- Box
30
+ <DxcBox shadowDepth={0} margin="medium">
31
+ <DxcInset space="2rem">Box</DxcInset>
31
32
  </DxcBox>
32
33
  </ExampleContainer>
33
34
  <ExampleContainer>
34
35
  <Title title="ShadowDepth 1" theme="light" level={4} />
35
- <DxcBox shadowDepth={1} margin="medium" padding="medium">
36
- Box
36
+ <DxcBox shadowDepth={1} margin="medium">
37
+ <DxcInset space="2rem">Box</DxcInset>
37
38
  </DxcBox>
38
39
  </ExampleContainer>
39
40
  <ExampleContainer>
40
41
  <Title title="ShadowDepth 2" theme="light" level={4} />
41
- <DxcBox shadowDepth={2} margin="medium" padding="medium">
42
- Box
42
+ <DxcBox shadowDepth={2} margin="medium">
43
+ <DxcInset space="2rem">Box</DxcInset>
43
44
  </DxcBox>
44
45
  </ExampleContainer>
45
- <Title title="Paddings" theme="light" level={2} />
46
- <ExampleContainer>
47
- <Title title="Xxsmall padding" theme="light" level={4} />
48
- <DxcBox padding="xxsmall">Box</DxcBox>
49
- </ExampleContainer>
50
- <ExampleContainer>
51
- <Title title="Xsmall padding" theme="light" level={4} />
52
- <DxcBox padding="xsmall">Box</DxcBox>
53
- </ExampleContainer>
54
- <ExampleContainer>
55
- <Title title="Small padding" theme="light" level={4} />
56
- <DxcBox padding="small">Box</DxcBox>
57
- </ExampleContainer>
58
- <ExampleContainer>
59
- <Title title="Medium padding" theme="light" level={4} />
60
- <DxcBox padding="medium">Box</DxcBox>
61
- </ExampleContainer>
62
- <ExampleContainer>
63
- <Title title="Large padding" theme="light" level={4} />
64
- <DxcBox padding="large">Box</DxcBox>
65
- </ExampleContainer>
66
- <ExampleContainer>
67
- <Title title="Xlarge padding" theme="light" level={4} />
68
- <DxcBox padding="xlarge">Box</DxcBox>
69
- </ExampleContainer>
70
- <ExampleContainer>
71
- <Title title="Xxlarge padding" theme="light" level={4} />
72
- <DxcBox padding="xxlarge">Box</DxcBox>
73
- </ExampleContainer>
74
46
  <Title title="Margins" theme="light" level={2} />
75
47
  <ExampleContainer>
76
48
  <Title title="Xxsmall margin" theme="light" level={4} />
77
- <DxcBox margin="xxsmall" padding="medium">
78
- Box
49
+ <DxcBox margin="xxsmall">
50
+ <DxcInset space="2rem">Box</DxcInset>
79
51
  </DxcBox>
80
52
  </ExampleContainer>
81
53
  <ExampleContainer>
82
54
  <Title title="Xsmall margin" theme="light" level={4} />
83
- <DxcBox margin="xsmall" padding="medium">
84
- Box
55
+ <DxcBox margin="xsmall">
56
+ <DxcInset space="2rem">Box</DxcInset>
85
57
  </DxcBox>
86
58
  </ExampleContainer>
87
59
  <ExampleContainer>
88
60
  <Title title="Small margin" theme="light" level={4} />
89
- <DxcBox margin="small" padding="medium">
90
- Box
61
+ <DxcBox margin="small">
62
+ <DxcInset space="2rem">Box</DxcInset>
91
63
  </DxcBox>
92
64
  </ExampleContainer>
93
65
  <ExampleContainer>
94
66
  <Title title="Medium margin" theme="light" level={4} />
95
- <DxcBox margin="medium" padding="medium">
96
- Box
67
+ <DxcBox margin="medium">
68
+ <DxcInset space="2rem">Box</DxcInset>
97
69
  </DxcBox>
98
70
  </ExampleContainer>
99
71
  <ExampleContainer>
100
72
  <Title title="Large margin" theme="light" level={4} />
101
- <DxcBox margin="large" padding="medium">
102
- Box
73
+ <DxcBox margin="large">
74
+ <DxcInset space="2rem">Box</DxcInset>
103
75
  </DxcBox>
104
76
  </ExampleContainer>
105
77
  <ExampleContainer>
106
78
  <Title title="Xlarge margin" theme="light" level={4} />
107
- <DxcBox margin="xlarge" padding="medium">
108
- Box
79
+ <DxcBox margin="xlarge">
80
+ <DxcInset space="2rem">Box</DxcInset>
109
81
  </DxcBox>
110
82
  </ExampleContainer>
111
83
  <ExampleContainer>
112
84
  <Title title="Xxlarge margin" theme="light" level={4} />
113
- <DxcBox margin="xxlarge" padding="medium">
114
- Box
85
+ <DxcBox margin="xxlarge">
86
+ <DxcInset space="2rem">Box</DxcInset>
115
87
  </DxcBox>
116
88
  </ExampleContainer>
117
89
  <Title title="Sizes" theme="light" level={2} />
@@ -138,8 +110,8 @@ export const Chromatic = () => (
138
110
  <Title title="Opinionated theme" theme="light" level={2} />
139
111
  <ExampleContainer>
140
112
  <HalstackProvider theme={opinionatedTheme}>
141
- <DxcBox display="flex" padding="medium">
142
- Box
113
+ <DxcBox display="flex">
114
+ <DxcInset space="2rem">Box</DxcInset>
143
115
  </DxcBox>
144
116
  </HalstackProvider>
145
117
  </ExampleContainer>
package/box/types.d.ts CHANGED
@@ -6,12 +6,6 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type Padding = {
10
- top?: Space;
11
- bottom?: Space;
12
- left?: Space;
13
- right?: Space;
14
- };
15
9
  declare type Props = {
16
10
  /**
17
11
  * The size of the shadow to be displayed around the box.
@@ -30,12 +24,6 @@ declare type Props = {
30
24
  * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
31
25
  */
32
26
  margin?: Space | Margin;
33
- /**
34
- * @deprecated This prop will be removed shortly, consider using the Inset component for this purpose.
35
- * Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
36
- * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
37
- */
38
- padding?: Space | Padding;
39
27
  /**
40
28
  * Size of the component.
41
29
  */
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import ButtonPropsType from "./types";
3
- declare const DxcButton: ({ label, mode, disabled, iconPosition, type, icon, onClick, margin, size, tabIndex, }: ButtonPropsType) => JSX.Element;
3
+ declare const DxcButton: ({ label, mode, disabled, iconPosition, title, type, icon, onClick, margin, size, tabIndex, }: ButtonPropsType) => JSX.Element;
4
4
  export default DxcButton;
package/button/Button.js CHANGED
@@ -31,22 +31,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
31
31
 
32
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
33
 
34
- var sizes = {
35
- small: "42px",
36
- medium: "120px",
37
- large: "240px",
38
- fillParent: "100%",
39
- fitContent: "fit-content"
40
- };
41
-
42
- var calculateWidth = function calculateWidth(margin, size) {
43
- if (size === "fillParent") {
44
- return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
45
- }
46
-
47
- return sizes[size];
48
- };
49
-
50
34
  var DxcButton = function DxcButton(_ref) {
51
35
  var _ref$label = _ref.label,
52
36
  label = _ref$label === void 0 ? "" : _ref$label,
@@ -56,6 +40,7 @@ var DxcButton = function DxcButton(_ref) {
56
40
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
57
41
  _ref$iconPosition = _ref.iconPosition,
58
42
  iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
43
+ title = _ref.title,
59
44
  _ref$type = _ref.type,
60
45
  type = _ref$type === void 0 ? "button" : _ref$type,
61
46
  icon = _ref.icon,
@@ -72,31 +57,50 @@ var DxcButton = function DxcButton(_ref) {
72
57
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
73
58
  theme: colorsTheme.button
74
59
  }, /*#__PURE__*/_react["default"].createElement(Button, {
75
- type: type,
76
- mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
60
+ "aria-label": title,
77
61
  disabled: disabled,
62
+ onClick: function onClick() {
63
+ _onClick();
64
+ },
78
65
  tabIndex: disabled ? -1 : tabIndex,
66
+ title: title,
67
+ type: type,
68
+ $mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
69
+ hasLabel: label ? true : false,
70
+ hasIcon: icon ? true : false,
71
+ iconPosition: iconPosition,
79
72
  backgroundType: backgroundType,
80
73
  size: size,
81
- margin: margin,
82
- onClick: function onClick() {
83
- _onClick();
84
- }
85
- }, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
86
- icon: icon,
87
- iconPosition: iconPosition
88
- }, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
89
- label: label,
90
- iconPosition: iconPosition
91
- }, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
74
+ margin: margin
75
+ }, label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, null, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
92
76
  src: icon
93
- }) : icon), label && iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
94
- icon: icon,
95
- iconPosition: iconPosition
96
- }, label)));
77
+ }) : icon)));
78
+ };
79
+
80
+ var sizes = {
81
+ small: "42px",
82
+ medium: "120px",
83
+ large: "240px",
84
+ fillParent: "100%",
85
+ fitContent: "fit-content"
86
+ };
87
+
88
+ var calculateWidth = function calculateWidth(margin, size) {
89
+ return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
90
+ };
91
+
92
+ var getButtonStyles = function getButtonStyles(props) {
93
+ var $mode = props.$mode,
94
+ backgroundType = props.backgroundType,
95
+ disabled = props.disabled;
96
+ return "\n border-radius: ".concat($mode === "primary" ? props.theme.primaryBorderRadius : $mode === "secondary" ? props.theme.secondaryBorderRadius : props.theme.textBorderRadius, ";\n border-width: ").concat($mode === "primary" ? props.theme.primaryBorderThickness : $mode === "secondary" ? props.theme.secondaryBorderThickness : props.theme.textBorderThickness, ";\n border-style: ").concat($mode === "primary" ? props.theme.primaryBorderStyle : $mode === "secondary" ? props.theme.secondaryBorderStyle : props.theme.textBorderStyle, ";\n font-family: ").concat($mode === "primary" ? props.theme.primaryFontFamily : $mode === "secondary" ? props.theme.secondaryFontFamily : props.theme.textFontFamily, ";\n font-size: ").concat($mode === "primary" ? props.theme.primaryFontSize : $mode === "secondary" ? props.theme.secondaryFontSize : props.theme.textFontSize, ";\n font-weight: ").concat($mode === "primary" ? props.theme.primaryFontWeight : $mode === "secondary" ? props.theme.secondaryFontWeight : props.theme.textFontWeight, ";\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor : backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor : backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, ";\n border-color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor : "", ";\n &:hover {\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor : backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n }\n &:focus {\n border-color: ").concat($mode === "secondary" ? "transparent" : "", ";\n }\n &:active {\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor : backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, ";\n color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n border-color: ").concat($mode === "secondary" ? "transparent" : "", ";\n outline: none;\n box-shadow: ").concat(!disabled ? "0 0 0 2px ".concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor) : "", ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor : backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor : backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, ";\n border-color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor : "", ";\n }\n ");
97
97
  };
98
98
 
99
- var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n display: inline-flex;\n width: ", ";\n height: 40px;\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n align-items: center;\n justify-content: center;\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n cursor: pointer;\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n ", "\n"])), function (props) {
99
+ var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: ", ";\n gap: 0.5rem;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: 40px;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n cursor: pointer;\n\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n\n ", "\n"])), function (props) {
100
+ return props.iconPosition === "after" ? "row" : "row-reverse";
101
+ }, function (props) {
102
+ return calculateWidth(props.margin, props.size);
103
+ }, function (props) {
100
104
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
101
105
  }, function (props) {
102
106
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
@@ -106,16 +110,14 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
106
110
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
107
111
  }, function (props) {
108
112
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
109
- }, function (props) {
110
- return calculateWidth(props.margin, props.size);
111
- }, function (props) {
112
- return props.theme.paddingLeft;
113
- }, function (props) {
114
- return props.theme.paddingRight;
115
113
  }, function (props) {
116
114
  return props.theme.paddingTop;
117
115
  }, function (props) {
118
116
  return props.theme.paddingBottom;
117
+ }, function (props) {
118
+ return props.hasIcon && !props.hasLabel ? props.theme.paddingLeft : "calc(".concat(props.theme.paddingLeft, " + 8px)");
119
+ }, function (props) {
120
+ return props.hasIcon && !props.hasLabel ? props.theme.paddingRight : "calc(".concat(props.theme.paddingRight, " + 8px)");
119
121
  }, function (props) {
120
122
  return props.theme.fontFamily;
121
123
  }, function (props) {
@@ -127,27 +129,16 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
127
129
  }, function (props) {
128
130
  return props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor;
129
131
  }, function (props) {
130
- var mode = props.mode,
131
- backgroundType = props.backgroundType,
132
- disabled = props.disabled;
133
- return "\n border-radius: ".concat(props.mode === "primary" ? props.theme.primaryBorderRadius : props.mode === "secondary" ? props.theme.secondaryBorderRadius : props.theme.textBorderRadius, ";\n border-width: ").concat(props.mode === "primary" ? props.theme.primaryBorderThickness : props.mode === "secondary" ? props.theme.secondaryBorderThickness : props.theme.textBorderThickness, ";\n border-style: ").concat(mode === "primary" ? props.theme.primaryBorderStyle : mode === "secondary" ? props.theme.secondaryBorderStyle : props.theme.textBorderStyle, ";\n font-family: ").concat(mode === "primary" ? props.theme.primaryFontFamily : mode === "secondary" ? props.theme.secondaryFontFamily : props.theme.textFontFamily, ";\n font-size: ").concat(mode === "primary" ? props.theme.primaryFontSize : mode === "secondary" ? props.theme.secondaryFontSize : props.theme.textFontSize, ";\n font-weight: ").concat(mode === "primary" ? props.theme.primaryFontWeight : mode === "secondary" ? props.theme.secondaryFontWeight : props.theme.textFontWeight, ";\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor : backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor : backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor : "", ";\n &:hover {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor : backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n }\n &:focus {\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n }\n &:active {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor : backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n outline: none;\n box-shadow: ").concat(!disabled ? "0 0 0 2px ".concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor) : "", ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor : backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor : backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor : "", ";\n }\n ");
132
+ return getButtonStyles(props);
134
133
  });
135
134
 
136
- var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: ", ";\n font-size: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n text-transform: none;\n white-space: nowrap;\n margin-right: ", ";\n margin-left: ", ";\n"])), function (props) {
135
+ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: ", ";\n font-size: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n text-transform: none;\n white-space: nowrap;\n"])), function (props) {
137
136
  return props.theme.labelFontLineHeight;
138
137
  }, function (props) {
139
138
  return props.theme.fontSize;
140
- }, function (props) {
141
- return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
142
- }, function (props) {
143
- return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
144
139
  });
145
140
 
146
- var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-left: ", ";\n margin-right: ", ";\n\n img,\n svg {\n height: 24px;\n width: 24px;\n }\n"])), function (props) {
147
- return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
148
- }, function (props) {
149
- return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
150
- });
141
+ var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n img,\n svg {\n height: 24px;\n width: 24px;\n }\n"])));
151
142
 
152
143
  var _default = DxcButton;
153
144
  exports["default"] = _default;
@@ -165,7 +165,7 @@ export const Chromatic = () => (
165
165
  <Title title="Only icon (image)" theme="light" level={4} />
166
166
  <DxcButton
167
167
  mode="text"
168
- icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png"
168
+ icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
169
169
  />
170
170
  </ExampleContainer>
171
171
  <BackgroundColorProvider color="#333333">
@@ -32,4 +32,15 @@ describe("Button component tests", function () {
32
32
 
33
33
  expect(onClick).toHaveBeenCalled();
34
34
  });
35
+ test("Renders with correct accessibility attributes", function () {
36
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
37
+ label: "Home",
38
+ title: "Go home"
39
+ })),
40
+ getByRole = _render3.getByRole;
41
+
42
+ var button = getByRole("button");
43
+ expect(button.getAttribute("aria-label")).toBe("Go home");
44
+ expect(button.getAttribute("title")).toBe("Go home");
45
+ });
35
46
  });
package/button/types.d.ts CHANGED
@@ -24,6 +24,10 @@ declare type Props = {
24
24
  * Whether the icon should appear after or before the label.
25
25
  */
26
26
  iconPosition?: "before" | "after";
27
+ /**
28
+ * Value for the HTML properties title and aria-label.
29
+ */
30
+ title?: string;
27
31
  /**
28
32
  * 'type' html prop of the button.
29
33
  */
package/card/Card.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import CardPropsType from "./types";
3
- declare const DxcCard: ({ imageSrc, imageBgColor, imagePadding, imagePosition, linkHref, onClick, imageCover, margin, contentPadding, tabIndex, outlined, children, }: CardPropsType) => JSX.Element;
3
+ declare const DxcCard: ({ imageSrc, imageBgColor, imagePadding, imagePosition, linkHref, onClick, imageCover, margin, tabIndex, outlined, children, }: CardPropsType) => JSX.Element;
4
4
  export default DxcCard;
package/card/Card.js CHANGED
@@ -43,7 +43,6 @@ var DxcCard = function DxcCard(_ref) {
43
43
  _ref$imageCover = _ref.imageCover,
44
44
  imageCover = _ref$imageCover === void 0 ? false : _ref$imageCover,
45
45
  margin = _ref.margin,
46
- contentPadding = _ref.contentPadding,
47
46
  _ref$tabIndex = _ref.tabIndex,
48
47
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
49
48
  _ref$outlined = _ref.outlined,
@@ -56,15 +55,8 @@ var DxcCard = function DxcCard(_ref) {
56
55
  isHovered = _useState2[0],
57
56
  changeIsHovered = _useState2[1];
58
57
 
59
- var imageComponent = /*#__PURE__*/_react["default"].createElement(ImageContainer, {
60
- imageBgColor: imageBgColor
61
- }, /*#__PURE__*/_react["default"].createElement(TagImage, {
62
- imagePadding: imagePadding,
63
- imageCover: imageCover,
64
- src: imageSrc
65
- }));
66
-
67
- return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
58
+ return /*#__PURE__*/_react["default"].createElement(Card, {
59
+ hasAction: onClick || linkHref ? true : false,
68
60
  margin: margin,
69
61
  onMouseEnter: function onMouseEnter() {
70
62
  return changeIsHovered(true);
@@ -73,7 +65,6 @@ var DxcCard = function DxcCard(_ref) {
73
65
  return changeIsHovered(false);
74
66
  },
75
67
  onClick: onClick,
76
- hasAction: onClick || linkHref,
77
68
  tabIndex: onClick || linkHref ? tabIndex : -1,
78
69
  as: linkHref && "a",
79
70
  href: linkHref
@@ -82,13 +73,18 @@ var DxcCard = function DxcCard(_ref) {
82
73
  }, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
83
74
  theme: colorsTheme.card
84
75
  }, /*#__PURE__*/_react["default"].createElement(CardContainer, {
85
- hasAction: onClick || linkHref
86
- }, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
87
- contentPadding: contentPadding
88
- }, children), imageSrc && imagePosition === "after" && imageComponent))));
76
+ hasAction: onClick || linkHref ? true : false,
77
+ imagePosition: imageSrc ? imagePosition : "none"
78
+ }, imageSrc && /*#__PURE__*/_react["default"].createElement(ImageContainer, {
79
+ imageBgColor: imageBgColor
80
+ }, /*#__PURE__*/_react["default"].createElement(TagImage, {
81
+ imagePadding: imagePadding,
82
+ imageCover: imageCover,
83
+ src: imageSrc
84
+ })), /*#__PURE__*/_react["default"].createElement(CardContent, null, children)))));
89
85
  };
90
86
 
91
- var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n outline: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n text-decoration: none;\n ", "\n"])), function (_ref2) {
87
+ var Card = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n outline: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n text-decoration: none;\n ", "\n"])), function (_ref2) {
92
88
  var hasAction = _ref2.hasAction;
93
89
  return hasAction && "pointer" || "unset";
94
90
  }, function (_ref3) {
@@ -111,10 +107,12 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
111
107
  return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
112
108
  }, function (_ref9) {
113
109
  var hasAction = _ref9.hasAction;
114
- return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
110
+ return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
115
111
  });
116
112
 
117
- var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n height: ", ";\n width: ", ";\n &:hover {\n border-color: ", ";\n }\n"])), function (props) {
113
+ var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: ", ";\n height: ", ";\n width: ", ";\n &:hover {\n border-color: ", ";\n }\n"])), function (props) {
114
+ return props.imagePosition === "after" ? "row-reverse" : "row";
115
+ }, function (props) {
118
116
  return props.theme.height;
119
117
  }, function (props) {
120
118
  return props.theme.width;
@@ -134,27 +132,12 @@ var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateOb
134
132
  return imageCover ? "cover" : "contain";
135
133
  });
136
134
 
137
- var ImageContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n width: 35%;\n height: 100%;\n flex-shrink: 0;\n background: ", ";\n justify-content: center;\n align-items: center;\n display: inline-flex;\n"])), function (_ref14) {
135
+ var ImageContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n flex-shrink: 0;\n width: 35%;\n height: 100%;\n background-color: ", ";\n"])), function (_ref14) {
138
136
  var imageBgColor = _ref14.imageBgColor;
139
137
  return imageBgColor;
140
138
  });
141
139
 
142
- var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n overflow: hidden;\n"])), function (_ref15) {
143
- var contentPadding = _ref15.contentPadding;
144
- return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
145
- }, function (_ref16) {
146
- var contentPadding = _ref16.contentPadding;
147
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
148
- }, function (_ref17) {
149
- var contentPadding = _ref17.contentPadding;
150
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
151
- }, function (_ref18) {
152
- var contentPadding = _ref18.contentPadding;
153
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
154
- }, function (_ref19) {
155
- var contentPadding = _ref19.contentPadding;
156
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
157
- });
140
+ var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n overflow: hidden;\n"])));
158
141
 
159
142
  var _default = DxcCard;
160
143
  exports["default"] = _default;
@@ -106,35 +106,6 @@ const Card = () => (
106
106
  Xxlarge
107
107
  </DxcCard>
108
108
  </ExampleContainer>
109
- <Title title="Content padding" theme="light" level={2} />
110
- <ExampleContainer>
111
- <Title title="Xxsmall" theme="light" level={4} />
112
- <DxcCard contentPadding="xxsmall">Xxsmall</DxcCard>
113
- </ExampleContainer>
114
- <ExampleContainer>
115
- <Title title="Xsmall" theme="light" level={4} />
116
- <DxcCard contentPadding="xsmall">Xsmall</DxcCard>
117
- </ExampleContainer>
118
- <ExampleContainer>
119
- <Title title="Small" theme="light" level={4} />
120
- <DxcCard contentPadding="small">Small</DxcCard>
121
- </ExampleContainer>
122
- <ExampleContainer>
123
- <Title title="Medium" theme="light" level={4} />
124
- <DxcCard contentPadding="medium">Medium</DxcCard>
125
- </ExampleContainer>
126
- <ExampleContainer>
127
- <Title title="Large" theme="light" level={4} />
128
- <DxcCard contentPadding="large">Large</DxcCard>
129
- </ExampleContainer>
130
- <ExampleContainer>
131
- <Title title="Xlarge" theme="light" level={4} />
132
- <DxcCard contentPadding="xlarge">Xlarge</DxcCard>
133
- </ExampleContainer>
134
- <ExampleContainer>
135
- <Title title="Xxlarge" theme="light" level={4} />
136
- <DxcCard contentPadding="xxlarge">Xxlarge</DxcCard>
137
- </ExampleContainer>
138
109
  <Title title="Margin" theme="light" level={2} />
139
110
  <ExampleContainer>
140
111
  <Title title="Xxsmall" theme="light" level={4} />
package/card/types.d.ts CHANGED
@@ -46,18 +46,12 @@ declare type Props = {
46
46
  * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
47
47
  */
48
48
  margin?: Space | Size;
49
- /**
50
- * @deprecated This prop will be removed shortly, consider using the Inset component for this purpose.
51
- * Size of the padding to be applied to the content area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
52
- * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
53
- */
54
- contentPadding?: Space | Size;
55
49
  /**
56
50
  * Value of the tabindex given when there is an href.
57
51
  */
58
52
  tabIndex?: number;
59
53
  /**
60
- * Whether the card must be outlined.
54
+ * Determines whether or not the component should have an outline.
61
55
  */
62
56
  outlined?: boolean;
63
57
  /**