@dxc-technology/halstack-react 0.0.0-d3ac293 → 0.0.0-d3df47e

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 (269) hide show
  1. package/BackgroundColorContext.d.ts +1 -10
  2. package/BackgroundColorContext.js +4 -21
  3. package/HalstackContext.d.ts +24 -139
  4. package/HalstackContext.js +11 -36
  5. package/README.md +47 -0
  6. package/accordion/Accordion.d.ts +1 -1
  7. package/accordion/Accordion.js +26 -83
  8. package/accordion/Accordion.stories.tsx +2 -114
  9. package/accordion/Accordion.test.js +18 -33
  10. package/accordion/types.d.ts +5 -17
  11. package/accordion-group/AccordionGroup.d.ts +4 -3
  12. package/accordion-group/AccordionGroup.js +27 -75
  13. package/accordion-group/AccordionGroup.stories.tsx +78 -77
  14. package/accordion-group/AccordionGroup.test.js +43 -71
  15. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  16. package/accordion-group/AccordionGroupAccordion.js +31 -0
  17. package/accordion-group/types.d.ts +6 -18
  18. package/action-icon/ActionIcon.d.ts +4 -0
  19. package/action-icon/ActionIcon.js +47 -0
  20. package/action-icon/ActionIcon.stories.tsx +41 -0
  21. package/action-icon/ActionIcon.test.js +64 -0
  22. package/action-icon/types.d.ts +26 -0
  23. package/alert/Alert.js +17 -56
  24. package/alert/Alert.test.js +28 -45
  25. package/alert/types.d.ts +5 -5
  26. package/badge/Badge.d.ts +1 -1
  27. package/badge/Badge.js +142 -42
  28. package/badge/Badge.stories.tsx +210 -0
  29. package/badge/Badge.test.js +30 -0
  30. package/badge/types.d.ts +52 -3
  31. package/bleed/Bleed.js +13 -21
  32. package/bleed/Bleed.stories.tsx +1 -0
  33. package/bleed/types.d.ts +2 -2
  34. package/box/Box.d.ts +1 -1
  35. package/box/Box.js +16 -55
  36. package/box/Box.stories.tsx +25 -53
  37. package/box/Box.test.js +1 -6
  38. package/box/types.d.ts +3 -15
  39. package/bulleted-list/BulletedList.js +19 -53
  40. package/bulleted-list/BulletedList.stories.tsx +8 -93
  41. package/bulleted-list/types.d.ts +32 -5
  42. package/button/Button.d.ts +1 -1
  43. package/button/Button.js +66 -100
  44. package/button/Button.stories.tsx +9 -90
  45. package/button/Button.test.js +19 -16
  46. package/button/types.d.ts +8 -4
  47. package/card/Card.d.ts +1 -1
  48. package/card/Card.js +47 -88
  49. package/card/Card.stories.tsx +12 -42
  50. package/card/Card.test.js +10 -21
  51. package/card/types.d.ts +6 -12
  52. package/checkbox/Checkbox.js +85 -120
  53. package/checkbox/Checkbox.stories.tsx +16 -54
  54. package/checkbox/Checkbox.test.js +107 -63
  55. package/checkbox/types.d.ts +8 -4
  56. package/chip/Chip.js +34 -68
  57. package/chip/Chip.stories.tsx +25 -17
  58. package/chip/Chip.test.js +15 -28
  59. package/chip/types.d.ts +4 -4
  60. package/common/OpenSans.css +68 -80
  61. package/common/coreTokens.d.ts +237 -0
  62. package/common/coreTokens.js +184 -0
  63. package/common/utils.js +2 -8
  64. package/common/variables.d.ts +24 -282
  65. package/common/variables.js +860 -1125
  66. package/container/Container.d.ts +4 -0
  67. package/container/Container.js +194 -0
  68. package/container/Container.stories.tsx +214 -0
  69. package/container/types.d.ts +74 -0
  70. package/date-input/Calendar.js +15 -59
  71. package/date-input/DateInput.js +50 -96
  72. package/date-input/DateInput.stories.tsx +11 -30
  73. package/date-input/DateInput.test.js +674 -701
  74. package/date-input/DatePicker.js +11 -42
  75. package/date-input/Icons.d.ts +6 -6
  76. package/date-input/Icons.js +6 -23
  77. package/date-input/YearPicker.js +8 -34
  78. package/date-input/types.d.ts +27 -21
  79. package/dialog/Dialog.d.ts +1 -1
  80. package/dialog/Dialog.js +15 -60
  81. package/dialog/Dialog.stories.tsx +215 -169
  82. package/dialog/Dialog.test.js +125 -187
  83. package/dialog/types.d.ts +18 -26
  84. package/dropdown/Dropdown.js +39 -93
  85. package/dropdown/Dropdown.test.js +391 -378
  86. package/dropdown/DropdownMenu.js +13 -20
  87. package/dropdown/DropdownMenuItem.js +5 -19
  88. package/dropdown/types.d.ts +17 -19
  89. package/file-input/FileInput.js +180 -249
  90. package/file-input/FileInput.stories.tsx +1 -1
  91. package/file-input/FileInput.test.js +356 -354
  92. package/file-input/FileItem.js +14 -41
  93. package/file-input/types.d.ts +10 -10
  94. package/flex/Flex.js +27 -39
  95. package/flex/Flex.stories.tsx +35 -26
  96. package/flex/types.d.ts +74 -9
  97. package/footer/Footer.d.ts +1 -1
  98. package/footer/Footer.js +69 -116
  99. package/footer/Footer.stories.tsx +38 -95
  100. package/footer/Footer.test.js +21 -33
  101. package/footer/Icons.d.ts +3 -2
  102. package/footer/Icons.js +66 -7
  103. package/footer/types.d.ts +25 -27
  104. package/grid/Grid.d.ts +7 -0
  105. package/grid/Grid.js +76 -0
  106. package/grid/Grid.stories.tsx +219 -0
  107. package/grid/types.d.ts +115 -0
  108. package/grid/types.js +5 -0
  109. package/header/Header.d.ts +4 -3
  110. package/header/Header.js +33 -116
  111. package/header/Header.stories.tsx +7 -71
  112. package/header/Header.test.js +12 -25
  113. package/header/Icons.d.ts +2 -2
  114. package/header/Icons.js +2 -7
  115. package/header/types.d.ts +5 -20
  116. package/heading/Heading.js +9 -31
  117. package/heading/Heading.test.js +70 -87
  118. package/heading/types.d.ts +7 -7
  119. package/image/Image.d.ts +4 -0
  120. package/image/Image.js +70 -0
  121. package/image/Image.stories.tsx +127 -0
  122. package/image/types.d.ts +72 -0
  123. package/image/types.js +5 -0
  124. package/inset/Inset.js +13 -21
  125. package/inset/Inset.stories.tsx +2 -1
  126. package/inset/types.d.ts +2 -2
  127. package/layout/ApplicationLayout.d.ts +5 -5
  128. package/layout/ApplicationLayout.js +28 -65
  129. package/layout/ApplicationLayout.stories.tsx +1 -1
  130. package/layout/Icons.d.ts +8 -5
  131. package/layout/Icons.js +51 -59
  132. package/layout/SidenavContext.d.ts +1 -1
  133. package/layout/SidenavContext.js +3 -9
  134. package/layout/types.d.ts +5 -6
  135. package/link/Link.js +23 -44
  136. package/link/Link.test.js +23 -41
  137. package/link/types.d.ts +14 -14
  138. package/main.d.ts +7 -4
  139. package/main.js +32 -58
  140. package/nav-tabs/NavTabs.d.ts +2 -2
  141. package/nav-tabs/NavTabs.js +22 -54
  142. package/nav-tabs/NavTabs.stories.tsx +21 -5
  143. package/nav-tabs/NavTabs.test.js +38 -44
  144. package/nav-tabs/Tab.js +40 -72
  145. package/nav-tabs/types.d.ts +14 -15
  146. package/number-input/NumberInput.d.ts +7 -0
  147. package/number-input/NumberInput.js +26 -35
  148. package/number-input/NumberInput.stories.tsx +42 -26
  149. package/number-input/NumberInput.test.js +700 -412
  150. package/number-input/types.d.ts +11 -5
  151. package/package.json +30 -28
  152. package/paginator/Icons.d.ts +5 -5
  153. package/paginator/Icons.js +5 -19
  154. package/paginator/Paginator.js +17 -47
  155. package/paginator/Paginator.test.js +229 -199
  156. package/paginator/types.d.ts +3 -3
  157. package/paragraph/Paragraph.d.ts +2 -3
  158. package/paragraph/Paragraph.js +3 -19
  159. package/paragraph/Paragraph.stories.tsx +0 -17
  160. package/password-input/Icons.d.ts +6 -0
  161. package/password-input/Icons.js +35 -0
  162. package/password-input/PasswordInput.js +57 -126
  163. package/password-input/PasswordInput.stories.tsx +1 -33
  164. package/password-input/PasswordInput.test.js +157 -140
  165. package/password-input/types.d.ts +8 -7
  166. package/progress-bar/ProgressBar.d.ts +2 -2
  167. package/progress-bar/ProgressBar.js +21 -53
  168. package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
  169. package/progress-bar/ProgressBar.test.js +35 -52
  170. package/progress-bar/types.d.ts +4 -3
  171. package/quick-nav/QuickNav.js +4 -27
  172. package/quick-nav/QuickNav.stories.tsx +1 -1
  173. package/quick-nav/types.d.ts +10 -10
  174. package/radio-group/Radio.d.ts +1 -1
  175. package/radio-group/Radio.js +31 -63
  176. package/radio-group/RadioGroup.js +45 -93
  177. package/radio-group/RadioGroup.stories.tsx +10 -10
  178. package/radio-group/RadioGroup.test.js +504 -470
  179. package/radio-group/types.d.ts +8 -8
  180. package/resultset-table/Icons.d.ts +7 -0
  181. package/{resultsetTable → resultset-table}/Icons.js +1 -5
  182. package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +1 -1
  183. package/{resultsetTable → resultset-table}/ResultsetTable.js +33 -63
  184. package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +19 -0
  185. package/{resultsetTable → resultset-table}/ResultsetTable.test.js +72 -92
  186. package/{resultsetTable → resultset-table}/types.d.ts +13 -7
  187. package/resultset-table/types.js +5 -0
  188. package/select/Icons.d.ts +7 -7
  189. package/select/Icons.js +1 -5
  190. package/select/Listbox.js +13 -39
  191. package/select/Option.js +17 -27
  192. package/select/Select.js +92 -166
  193. package/select/Select.stories.tsx +3 -3
  194. package/select/Select.test.js +1946 -1804
  195. package/select/types.d.ts +14 -15
  196. package/sidenav/Icons.d.ts +7 -0
  197. package/sidenav/Icons.js +47 -0
  198. package/sidenav/Sidenav.d.ts +2 -2
  199. package/sidenav/Sidenav.js +80 -150
  200. package/sidenav/Sidenav.stories.tsx +60 -60
  201. package/sidenav/Sidenav.test.js +3 -10
  202. package/sidenav/types.d.ts +31 -28
  203. package/slider/Slider.js +68 -126
  204. package/slider/Slider.test.js +107 -103
  205. package/slider/types.d.ts +4 -4
  206. package/spinner/Spinner.js +28 -72
  207. package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +28 -28
  208. package/spinner/Spinner.test.js +25 -34
  209. package/spinner/types.d.ts +3 -3
  210. package/status-light/StatusLight.d.ts +4 -0
  211. package/status-light/StatusLight.js +51 -0
  212. package/status-light/StatusLight.stories.tsx +74 -0
  213. package/status-light/StatusLight.test.js +25 -0
  214. package/status-light/types.d.ts +17 -0
  215. package/status-light/types.js +5 -0
  216. package/switch/Switch.js +49 -97
  217. package/switch/Switch.stories.tsx +0 -34
  218. package/switch/Switch.test.js +51 -96
  219. package/switch/types.d.ts +4 -4
  220. package/table/Table.d.ts +1 -1
  221. package/table/Table.js +23 -30
  222. package/table/{Table.stories.jsx → Table.stories.tsx} +98 -0
  223. package/table/Table.test.js +1 -6
  224. package/table/types.d.ts +12 -6
  225. package/tabs/Tab.js +19 -36
  226. package/tabs/Tabs.js +61 -144
  227. package/tabs/Tabs.stories.tsx +1 -1
  228. package/tabs/Tabs.test.js +65 -121
  229. package/tabs/types.d.ts +19 -19
  230. package/tag/Tag.js +26 -58
  231. package/tag/Tag.test.js +19 -30
  232. package/tag/types.d.ts +7 -7
  233. package/text-input/Icons.d.ts +5 -5
  234. package/text-input/Icons.js +1 -5
  235. package/text-input/Suggestion.js +11 -28
  236. package/text-input/Suggestions.d.ts +1 -1
  237. package/text-input/Suggestions.js +15 -65
  238. package/text-input/TextInput.js +217 -318
  239. package/text-input/TextInput.stories.tsx +48 -152
  240. package/text-input/TextInput.test.js +1210 -1194
  241. package/text-input/types.d.ts +25 -17
  242. package/textarea/Textarea.js +68 -111
  243. package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
  244. package/textarea/Textarea.test.js +151 -182
  245. package/textarea/types.d.ts +9 -5
  246. package/toggle-group/ToggleGroup.d.ts +2 -2
  247. package/toggle-group/ToggleGroup.js +91 -105
  248. package/toggle-group/ToggleGroup.stories.tsx +7 -4
  249. package/toggle-group/ToggleGroup.test.js +68 -87
  250. package/toggle-group/types.d.ts +26 -17
  251. package/typography/Typography.js +4 -13
  252. package/typography/types.d.ts +1 -1
  253. package/useTheme.d.ts +21 -136
  254. package/useTheme.js +1 -8
  255. package/useTranslatedLabels.js +1 -7
  256. package/utils/BaseTypography.d.ts +2 -2
  257. package/utils/BaseTypography.js +16 -30
  258. package/utils/FocusLock.js +28 -43
  259. package/wizard/Wizard.js +15 -50
  260. package/wizard/Wizard.test.js +53 -80
  261. package/wizard/types.d.ts +8 -9
  262. package/card/ice-cream.jpg +0 -0
  263. package/number-input/NumberInputContext.d.ts +0 -4
  264. package/number-input/NumberInputContext.js +0 -19
  265. package/number-input/numberInputContextTypes.d.ts +0 -19
  266. package/resultsetTable/Icons.d.ts +0 -7
  267. package/slider/Slider.stories.tsx +0 -240
  268. /package/{resultsetTable → action-icon}/types.js +0 -0
  269. /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
package/button/types.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  /// <reference types="react" />
2
- export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- export declare type Margin = {
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
- export declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
- declare type Props = {
9
+ type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
+ type Props = {
11
11
  /**
12
12
  * Text to be placed in the button.
13
13
  */
@@ -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
@@ -1,70 +1,46 @@
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 _variables = require("../common/variables");
23
-
24
15
  var _useTheme = _interopRequireDefault(require("../useTheme"));
25
-
26
16
  var _Box = _interopRequireDefault(require("../box/Box"));
27
-
28
17
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
29
-
30
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
-
32
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
-
18
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
34
20
  var DxcCard = function DxcCard(_ref) {
35
21
  var imageSrc = _ref.imageSrc,
36
- _ref$imageBgColor = _ref.imageBgColor,
37
- imageBgColor = _ref$imageBgColor === void 0 ? "black" : _ref$imageBgColor,
38
- imagePadding = _ref.imagePadding,
39
- _ref$imagePosition = _ref.imagePosition,
40
- imagePosition = _ref$imagePosition === void 0 ? "before" : _ref$imagePosition,
41
- linkHref = _ref.linkHref,
42
- onClick = _ref.onClick,
43
- _ref$imageCover = _ref.imageCover,
44
- imageCover = _ref$imageCover === void 0 ? false : _ref$imageCover,
45
- margin = _ref.margin,
46
- contentPadding = _ref.contentPadding,
47
- _ref$tabIndex = _ref.tabIndex,
48
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
49
- _ref$outlined = _ref.outlined,
50
- outlined = _ref$outlined === void 0 ? true : _ref$outlined,
51
- children = _ref.children;
22
+ _ref$imageBgColor = _ref.imageBgColor,
23
+ imageBgColor = _ref$imageBgColor === void 0 ? "black" : _ref$imageBgColor,
24
+ imagePadding = _ref.imagePadding,
25
+ _ref$imagePosition = _ref.imagePosition,
26
+ imagePosition = _ref$imagePosition === void 0 ? "before" : _ref$imagePosition,
27
+ linkHref = _ref.linkHref,
28
+ onClick = _ref.onClick,
29
+ _ref$imageCover = _ref.imageCover,
30
+ imageCover = _ref$imageCover === void 0 ? false : _ref$imageCover,
31
+ margin = _ref.margin,
32
+ _ref$tabIndex = _ref.tabIndex,
33
+ tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
34
+ _ref$outlined = _ref.outlined,
35
+ outlined = _ref$outlined === void 0 ? true : _ref$outlined,
36
+ children = _ref.children;
52
37
  var colorsTheme = (0, _useTheme["default"])();
53
-
54
38
  var _useState = (0, _react.useState)(false),
55
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
56
- isHovered = _useState2[0],
57
- changeIsHovered = _useState2[1];
58
-
59
- var imageComponent = /*#__PURE__*/_react["default"].createElement(ImageContainer, {
60
- imageBgColor: imageBgColor
61
- }, /*#__PURE__*/_react["default"].createElement(TagImage, {
62
- imagePadding: imagePadding,
63
- cover: imageCover,
64
- src: imageSrc
65
- }));
66
-
67
- return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
39
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
40
+ isHovered = _useState2[0],
41
+ changeIsHovered = _useState2[1];
42
+ return /*#__PURE__*/_react["default"].createElement(Card, {
43
+ hasAction: onClick || linkHref ? true : false,
68
44
  margin: margin,
69
45
  onMouseEnter: function onMouseEnter() {
70
46
  return changeIsHovered(true);
@@ -73,7 +49,6 @@ var DxcCard = function DxcCard(_ref) {
73
49
  return changeIsHovered(false);
74
50
  },
75
51
  onClick: onClick,
76
- hasAction: onClick || linkHref,
77
52
  tabIndex: onClick || linkHref ? tabIndex : -1,
78
53
  as: linkHref && "a",
79
54
  href: linkHref
@@ -82,14 +57,17 @@ var DxcCard = function DxcCard(_ref) {
82
57
  }, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
83
58
  theme: colorsTheme.card
84
59
  }, /*#__PURE__*/_react["default"].createElement(CardContainer, {
85
- hasAction: onClick || linkHref,
86
- imagePosition: imagePosition
87
- }, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
88
- contentPadding: contentPadding
89
- }, children), imageSrc && imagePosition === "after" && imageComponent))));
60
+ hasAction: onClick || linkHref ? true : false,
61
+ imagePosition: imageSrc ? imagePosition : "none"
62
+ }, imageSrc && /*#__PURE__*/_react["default"].createElement(ImageContainer, {
63
+ imageBgColor: imageBgColor
64
+ }, /*#__PURE__*/_react["default"].createElement(TagImage, {
65
+ imagePadding: imagePadding,
66
+ imageCover: imageCover,
67
+ src: imageSrc
68
+ })), /*#__PURE__*/_react["default"].createElement(CardContent, null, children)))));
90
69
  };
91
-
92
- 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 ", "\n"])), function (_ref2) {
70
+ 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) {
93
71
  var hasAction = _ref2.hasAction;
94
72
  return hasAction && "pointer" || "unset";
95
73
  }, function (_ref3) {
@@ -100,22 +78,23 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
100
78
  return margin && (0, _typeof2["default"])(margin) !== "object" ? _variables.spaces[margin] : "0px";
101
79
  }, function (_ref5) {
102
80
  var margin = _ref5.margin;
103
- return margin && margin.top ? _variables.spaces[margin.top] : "";
81
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.top ? _variables.spaces[margin.top] : "";
104
82
  }, function (_ref6) {
105
83
  var margin = _ref6.margin;
106
- return margin && margin.right ? _variables.spaces[margin.right] : "";
84
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.right ? _variables.spaces[margin.right] : "";
107
85
  }, function (_ref7) {
108
86
  var margin = _ref7.margin;
109
- return margin && margin.bottom ? _variables.spaces[margin.bottom] : "";
87
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.bottom ? _variables.spaces[margin.bottom] : "";
110
88
  }, function (_ref8) {
111
89
  var margin = _ref8.margin;
112
- return margin && margin.left ? _variables.spaces[margin.left] : "";
90
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
113
91
  }, function (_ref9) {
114
92
  var hasAction = _ref9.hasAction;
115
- return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
93
+ return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
116
94
  });
117
-
118
- 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) {
95
+ 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) {
96
+ return props.imagePosition === "after" ? "row-reverse" : "row";
97
+ }, function (props) {
119
98
  return props.theme.height;
120
99
  }, function (props) {
121
100
  return props.theme.width;
@@ -123,39 +102,19 @@ var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templ
123
102
  var hasAction = _ref10.hasAction;
124
103
  return hasAction ? "" : "unset";
125
104
  });
126
-
127
105
  var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
128
106
  var imagePadding = _ref11.imagePadding;
129
- return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
107
+ return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
130
108
  }, function (_ref12) {
131
109
  var imagePadding = _ref12.imagePadding;
132
- return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
110
+ return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
133
111
  }, function (_ref13) {
134
- var cover = _ref13.cover;
135
- return cover ? "cover" : "contain";
112
+ var imageCover = _ref13.imageCover;
113
+ return imageCover ? "cover" : "contain";
136
114
  });
137
-
138
- 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) {
115
+ 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) {
139
116
  var imageBgColor = _ref14.imageBgColor;
140
117
  return imageBgColor;
141
118
  });
142
-
143
- 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) {
144
- var contentPadding = _ref15.contentPadding;
145
- return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
146
- }, function (_ref16) {
147
- var contentPadding = _ref16.contentPadding;
148
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
149
- }, function (_ref17) {
150
- var contentPadding = _ref17.contentPadding;
151
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
152
- }, function (_ref18) {
153
- var contentPadding = _ref18.contentPadding;
154
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
155
- }, function (_ref19) {
156
- var contentPadding = _ref19.contentPadding;
157
- return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
158
- });
159
-
160
- var _default = DxcCard;
161
- exports["default"] = _default;
119
+ var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n overflow: hidden;\n"])));
120
+ var _default = exports["default"] = DxcCard;
@@ -2,7 +2,6 @@ import React from "react";
2
2
  import Title from "../../.storybook/components/Title";
3
3
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
4
4
  import DxcCard from "./Card";
5
- import imagePath from "./ice-cream.jpg";
6
5
  import { userEvent, within } from "@storybook/testing-library";
7
6
 
8
7
  export default {
@@ -38,104 +37,75 @@ const Card = () => (
38
37
  </ExampleContainer>
39
38
  <Title title="Default with image" theme="light" level={4} />
40
39
  <ExampleContainer>
41
- <DxcCard imageSrc={imagePath}>Default</DxcCard>
40
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300">Default</DxcCard>
42
41
  </ExampleContainer>
43
42
  <Title title="Default image with background color" theme="light" level={4} />
44
43
  <ExampleContainer>
45
- <DxcCard imageSrc={imagePath} imageBgColor="yellow">
44
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageBgColor="yellow">
46
45
  Background color
47
46
  </DxcCard>
48
47
  </ExampleContainer>
49
48
  <Title title="Default image with position after" theme="light" level={4} />
50
49
  <ExampleContainer>
51
- <DxcCard imageSrc={imagePath} imagePosition="after">
50
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePosition="after">
52
51
  Position after
53
52
  </DxcCard>
54
53
  </ExampleContainer>
55
54
  <Title title="Image cover" theme="light" level={4} />
56
55
  <ExampleContainer>
57
- <DxcCard imageSrc={imagePath} imageCover>
56
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageCover>
58
57
  Image cover
59
58
  </DxcCard>
60
59
  </ExampleContainer>
61
60
  <Title title="Image cover with position after" theme="light" level={4} />
62
61
  <ExampleContainer>
63
- <DxcCard imageSrc={imagePath} imageCover imagePosition="after">
62
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageCover imagePosition="after">
64
63
  Image cover with position after
65
64
  </DxcCard>
66
65
  </ExampleContainer>
67
66
  <Title title="Image padding" theme="light" level={2} />
68
67
  <ExampleContainer>
69
68
  <Title title="Xxsmall" theme="light" level={4} />
70
- <DxcCard imageSrc={imagePath} imagePadding="xxsmall" imageCover>
69
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xxsmall" imageCover>
71
70
  Xxsmall
72
71
  </DxcCard>
73
72
  </ExampleContainer>
74
73
  <ExampleContainer>
75
74
  <Title title="Xsmall" theme="light" level={4} />
76
- <DxcCard imageSrc={imagePath} imagePadding="xsmall" imageCover>
75
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xsmall" imageCover>
77
76
  Xsmall
78
77
  </DxcCard>
79
78
  </ExampleContainer>
80
79
  <ExampleContainer>
81
80
  <Title title="Small" theme="light" level={4} />
82
- <DxcCard imageSrc={imagePath} imagePadding="small" imageCover>
81
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="small" imageCover>
83
82
  Small
84
83
  </DxcCard>
85
84
  </ExampleContainer>
86
85
  <ExampleContainer>
87
86
  <Title title="Medium" theme="light" level={4} />
88
- <DxcCard imageSrc={imagePath} imagePadding="medium" imageCover>
87
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="medium" imageCover>
89
88
  Medium
90
89
  </DxcCard>
91
90
  </ExampleContainer>
92
91
  <ExampleContainer>
93
92
  <Title title="Large" theme="light" level={4} />
94
- <DxcCard imageSrc={imagePath} imagePadding="large" imageCover>
93
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="large" imageCover>
95
94
  Large
96
95
  </DxcCard>
97
96
  </ExampleContainer>
98
97
  <ExampleContainer>
99
98
  <Title title="Xlarge" theme="light" level={4} />
100
- <DxcCard imageSrc={imagePath} imagePadding="xlarge" imageCover>
99
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xlarge" imageCover>
101
100
  Xlarge
102
101
  </DxcCard>
103
102
  </ExampleContainer>
104
103
  <ExampleContainer>
105
104
  <Title title="Xxlarge" theme="light" level={4} />
106
- <DxcCard imageSrc={imagePath} imagePadding="xxlarge" imageCover>
105
+ <DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xxlarge" imageCover>
107
106
  Xxlarge
108
107
  </DxcCard>
109
108
  </ExampleContainer>
110
- <Title title="Content padding" theme="light" level={2} />
111
- <ExampleContainer>
112
- <Title title="Xxsmall" theme="light" level={4} />
113
- <DxcCard contentPadding="xxsmall">Xxsmall</DxcCard>
114
- </ExampleContainer>
115
- <ExampleContainer>
116
- <Title title="Xsmall" theme="light" level={4} />
117
- <DxcCard contentPadding="xsmall">Xsmall</DxcCard>
118
- </ExampleContainer>
119
- <ExampleContainer>
120
- <Title title="Small" theme="light" level={4} />
121
- <DxcCard contentPadding="small">Small</DxcCard>
122
- </ExampleContainer>
123
- <ExampleContainer>
124
- <Title title="Medium" theme="light" level={4} />
125
- <DxcCard contentPadding="medium">Medium</DxcCard>
126
- </ExampleContainer>
127
- <ExampleContainer>
128
- <Title title="Large" theme="light" level={4} />
129
- <DxcCard contentPadding="large">Large</DxcCard>
130
- </ExampleContainer>
131
- <ExampleContainer>
132
- <Title title="Xlarge" theme="light" level={4} />
133
- <DxcCard contentPadding="xlarge">Xlarge</DxcCard>
134
- </ExampleContainer>
135
- <ExampleContainer>
136
- <Title title="Xxlarge" theme="light" level={4} />
137
- <DxcCard contentPadding="xxlarge">Xxlarge</DxcCard>
138
- </ExampleContainer>
139
109
  <Title title="Margin" theme="light" level={2} />
140
110
  <ExampleContainer>
141
111
  <Title title="Xxsmall" theme="light" level={4} />
package/card/Card.test.js CHANGED
@@ -1,50 +1,39 @@
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 _Card = _interopRequireDefault(require("./Card.tsx"));
10
-
11
7
  describe("Card component tests", function () {
12
8
  test("Card renders with correct content", function () {
13
9
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], null, "test-card")),
14
- getByText = _render.getByText;
15
-
10
+ getByText = _render.getByText;
16
11
  expect(getByText("test-card")).toBeTruthy();
17
12
  });
18
13
  test("Card renders with correct href", function () {
19
14
  var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
20
- linkHref: "/testPage"
21
- }, "test-card")),
22
- getByRole = _render2.getByRole;
23
-
15
+ linkHref: "/testPage"
16
+ }, "test-card")),
17
+ getByRole = _render2.getByRole;
24
18
  var card = getByRole("link");
25
19
  expect(card.getAttribute("href")).toEqual("/testPage");
26
20
  });
27
21
  test("Card renders with correct image", function () {
28
22
  var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
29
- imageSrc: "/testImage"
30
- }, "test-card")),
31
- getByRole = _render3.getByRole;
32
-
23
+ imageSrc: "/testImage"
24
+ }, "test-card")),
25
+ getByRole = _render3.getByRole;
33
26
  var card = getByRole("img");
34
27
  expect(card.getAttribute("src")).toEqual("/testImage");
35
28
  });
36
29
  test("OnClick function is called", function () {
37
30
  var onClick = jest.fn();
38
-
39
31
  var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
40
- onClick: onClick
41
- }, "test-card")),
42
- getByText = _render4.getByText;
43
-
32
+ onClick: onClick
33
+ }, "test-card")),
34
+ getByText = _render4.getByText;
44
35
  var card = getByText("test-card");
45
-
46
36
  _react2.fireEvent.click(card);
47
-
48
37
  expect(onClick).toHaveBeenCalled();
49
38
  });
50
39
  });
package/card/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- declare type Size = {
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Size = {
4
4
  top?: Space;
5
5
  bottom?: Space;
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type Props = {
9
+ type Props = {
10
10
  /**
11
11
  * URL of the image that will be placed in the card component.
12
12
  * In case of omission, the image container will not appear and
@@ -47,21 +47,15 @@ declare type Props = {
47
47
  */
48
48
  margin?: Space | Size;
49
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
- /**
56
- * Value of the tabindex given when there is an href.
50
+ * Value of the tabindex attribute applied when the component is clickable.
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
  /**
64
- * Custom content that will be placed in the card component.
58
+ * Custom content that will be placed inside the component.
65
59
  */
66
60
  children?: React.ReactNode;
67
61
  };