@dxc-technology/halstack-react 0.0.0-da224ae → 0.0.0-da4b2be

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 (329) hide show
  1. package/BackgroundColorContext.d.ts +10 -0
  2. package/BackgroundColorContext.js +2 -5
  3. package/HalstackContext.d.ts +1336 -0
  4. package/HalstackContext.js +335 -0
  5. package/accordion/Accordion.d.ts +1 -1
  6. package/accordion/Accordion.js +118 -142
  7. package/accordion/Accordion.stories.tsx +395 -0
  8. package/accordion/Accordion.test.js +71 -0
  9. package/accordion/types.d.ts +9 -8
  10. package/accordion-group/AccordionGroup.d.ts +5 -4
  11. package/accordion-group/AccordionGroup.js +34 -76
  12. package/accordion-group/AccordionGroup.stories.tsx +251 -0
  13. package/accordion-group/AccordionGroup.test.js +126 -0
  14. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  15. package/accordion-group/AccordionGroupAccordion.js +43 -0
  16. package/accordion-group/types.d.ts +15 -8
  17. package/alert/Alert.js +11 -12
  18. package/alert/Alert.stories.tsx +28 -0
  19. package/alert/Alert.test.js +92 -0
  20. package/alert/types.d.ts +1 -1
  21. package/badge/Badge.d.ts +4 -0
  22. package/badge/Badge.js +6 -4
  23. package/badge/types.d.ts +5 -0
  24. package/bleed/Bleed.d.ts +3 -0
  25. package/bleed/Bleed.js +51 -0
  26. package/bleed/Bleed.stories.tsx +342 -0
  27. package/bleed/types.d.ts +37 -0
  28. package/bleed/types.js +5 -0
  29. package/box/Box.d.ts +1 -1
  30. package/box/Box.js +23 -55
  31. package/box/Box.stories.tsx +38 -51
  32. package/box/Box.test.js +18 -0
  33. package/box/types.d.ts +0 -15
  34. package/bulleted-list/BulletedList.d.ts +7 -0
  35. package/bulleted-list/BulletedList.js +125 -0
  36. package/bulleted-list/BulletedList.stories.tsx +206 -0
  37. package/bulleted-list/types.d.ts +38 -0
  38. package/bulleted-list/types.js +5 -0
  39. package/button/Button.d.ts +1 -1
  40. package/button/Button.js +61 -85
  41. package/button/Button.stories.tsx +163 -14
  42. package/button/Button.test.js +35 -0
  43. package/button/types.d.ts +8 -12
  44. package/card/Card.js +35 -40
  45. package/card/Card.stories.tsx +200 -0
  46. package/card/Card.test.js +50 -0
  47. package/card/ice-cream.jpg +0 -0
  48. package/card/types.d.ts +5 -6
  49. package/checkbox/Checkbox.d.ts +2 -2
  50. package/checkbox/Checkbox.js +108 -111
  51. package/checkbox/Checkbox.stories.tsx +198 -130
  52. package/checkbox/Checkbox.test.js +155 -0
  53. package/checkbox/types.d.ts +13 -5
  54. package/chip/Chip.d.ts +4 -0
  55. package/chip/Chip.js +37 -118
  56. package/chip/Chip.stories.tsx +123 -30
  57. package/chip/Chip.test.js +54 -0
  58. package/chip/types.d.ts +45 -0
  59. package/chip/types.js +5 -0
  60. package/common/OpenSans.css +68 -80
  61. package/common/coreTokens.d.ts +146 -0
  62. package/common/coreTokens.js +167 -0
  63. package/common/utils.d.ts +1 -0
  64. package/common/utils.js +4 -4
  65. package/common/variables.d.ts +1482 -0
  66. package/common/variables.js +1100 -1316
  67. package/date-input/Calendar.d.ts +4 -0
  68. package/date-input/Calendar.js +258 -0
  69. package/date-input/DateInput.js +174 -266
  70. package/date-input/DateInput.stories.tsx +199 -33
  71. package/date-input/DateInput.test.js +835 -0
  72. package/date-input/DatePicker.d.ts +4 -0
  73. package/date-input/DatePicker.js +146 -0
  74. package/date-input/Icons.d.ts +6 -0
  75. package/date-input/Icons.js +75 -0
  76. package/date-input/YearPicker.d.ts +4 -0
  77. package/date-input/YearPicker.js +126 -0
  78. package/date-input/types.d.ts +67 -9
  79. package/dialog/Dialog.d.ts +1 -1
  80. package/dialog/Dialog.js +69 -103
  81. package/dialog/Dialog.stories.tsx +154 -171
  82. package/dialog/Dialog.test.js +369 -0
  83. package/dialog/types.d.ts +0 -12
  84. package/dropdown/Dropdown.d.ts +1 -1
  85. package/dropdown/Dropdown.js +248 -277
  86. package/dropdown/Dropdown.stories.tsx +438 -0
  87. package/dropdown/Dropdown.test.js +586 -0
  88. package/dropdown/DropdownMenu.d.ts +4 -0
  89. package/dropdown/DropdownMenu.js +74 -0
  90. package/dropdown/DropdownMenuItem.d.ts +4 -0
  91. package/dropdown/DropdownMenuItem.js +79 -0
  92. package/dropdown/types.d.ts +28 -17
  93. package/file-input/FileInput.d.ts +4 -0
  94. package/file-input/FileInput.js +183 -168
  95. package/file-input/FileInput.stories.tsx +618 -0
  96. package/file-input/FileInput.test.js +457 -0
  97. package/file-input/FileItem.d.ts +4 -0
  98. package/file-input/FileItem.js +50 -81
  99. package/file-input/types.d.ts +129 -0
  100. package/file-input/types.js +5 -0
  101. package/flex/Flex.d.ts +4 -0
  102. package/flex/Flex.js +71 -0
  103. package/flex/Flex.stories.tsx +112 -0
  104. package/flex/types.d.ts +97 -0
  105. package/flex/types.js +5 -0
  106. package/footer/Footer.d.ts +1 -1
  107. package/footer/Footer.js +34 -117
  108. package/footer/Footer.stories.tsx +228 -0
  109. package/footer/Footer.test.js +97 -0
  110. package/footer/Icons.d.ts +2 -0
  111. package/footer/Icons.js +4 -4
  112. package/footer/types.d.ts +23 -18
  113. package/grid/Grid.d.ts +7 -0
  114. package/grid/Grid.js +91 -0
  115. package/grid/Grid.stories.tsx +219 -0
  116. package/grid/types.d.ts +115 -0
  117. package/grid/types.js +5 -0
  118. package/header/Header.d.ts +3 -2
  119. package/header/Header.js +110 -131
  120. package/header/Header.stories.tsx +315 -0
  121. package/header/Header.test.js +79 -0
  122. package/header/Icons.d.ts +2 -0
  123. package/header/Icons.js +2 -2
  124. package/header/types.d.ts +5 -2
  125. package/heading/Heading.js +2 -2
  126. package/heading/Heading.stories.tsx +54 -0
  127. package/heading/Heading.test.js +186 -0
  128. package/inset/Inset.d.ts +3 -0
  129. package/inset/Inset.js +51 -0
  130. package/inset/Inset.stories.tsx +230 -0
  131. package/inset/types.d.ts +37 -0
  132. package/inset/types.js +5 -0
  133. package/layout/ApplicationLayout.d.ts +20 -0
  134. package/layout/ApplicationLayout.js +72 -136
  135. package/layout/ApplicationLayout.stories.tsx +162 -0
  136. package/layout/Icons.d.ts +5 -0
  137. package/layout/Icons.js +13 -2
  138. package/layout/SidenavContext.d.ts +5 -0
  139. package/layout/SidenavContext.js +19 -0
  140. package/layout/types.d.ts +41 -0
  141. package/layout/types.js +5 -0
  142. package/link/Link.d.ts +3 -2
  143. package/link/Link.js +64 -89
  144. package/link/Link.stories.tsx +199 -16
  145. package/link/Link.test.js +81 -0
  146. package/link/types.d.ts +7 -27
  147. package/main.d.ts +13 -12
  148. package/main.js +68 -54
  149. package/nav-tabs/NavTabs.d.ts +8 -0
  150. package/nav-tabs/NavTabs.js +122 -0
  151. package/nav-tabs/NavTabs.stories.tsx +274 -0
  152. package/nav-tabs/NavTabs.test.js +82 -0
  153. package/nav-tabs/Tab.d.ts +4 -0
  154. package/nav-tabs/Tab.js +146 -0
  155. package/nav-tabs/types.d.ts +52 -0
  156. package/nav-tabs/types.js +5 -0
  157. package/number-input/NumberInput.js +14 -24
  158. package/number-input/NumberInput.stories.tsx +5 -5
  159. package/number-input/NumberInput.test.js +542 -0
  160. package/number-input/NumberInputContext.d.ts +4 -0
  161. package/number-input/NumberInputContext.js +5 -2
  162. package/number-input/numberInputContextTypes.d.ts +19 -0
  163. package/number-input/numberInputContextTypes.js +5 -0
  164. package/number-input/types.d.ts +17 -10
  165. package/package.json +22 -23
  166. package/paginator/Icons.d.ts +5 -0
  167. package/paginator/Icons.js +16 -28
  168. package/paginator/Paginator.js +22 -57
  169. package/paginator/Paginator.stories.tsx +24 -0
  170. package/paginator/Paginator.test.js +318 -0
  171. package/paragraph/Paragraph.d.ts +5 -0
  172. package/paragraph/Paragraph.js +38 -0
  173. package/paragraph/Paragraph.stories.tsx +44 -0
  174. package/password-input/PasswordInput.js +23 -19
  175. package/password-input/PasswordInput.stories.tsx +3 -3
  176. package/password-input/PasswordInput.test.js +181 -0
  177. package/password-input/types.d.ts +29 -19
  178. package/progress-bar/ProgressBar.js +63 -57
  179. package/progress-bar/ProgressBar.stories.jsx +47 -12
  180. package/progress-bar/ProgressBar.test.js +110 -0
  181. package/quick-nav/QuickNav.d.ts +4 -0
  182. package/quick-nav/QuickNav.js +117 -0
  183. package/quick-nav/QuickNav.stories.tsx +356 -0
  184. package/quick-nav/types.d.ts +21 -0
  185. package/quick-nav/types.js +5 -0
  186. package/radio-group/Radio.d.ts +4 -0
  187. package/radio-group/Radio.js +156 -0
  188. package/radio-group/RadioGroup.d.ts +4 -0
  189. package/radio-group/RadioGroup.js +281 -0
  190. package/radio-group/RadioGroup.stories.tsx +214 -0
  191. package/radio-group/RadioGroup.test.js +722 -0
  192. package/radio-group/types.d.ts +114 -0
  193. package/radio-group/types.js +5 -0
  194. package/resultsetTable/Icons.d.ts +7 -0
  195. package/resultsetTable/Icons.js +51 -0
  196. package/resultsetTable/ResultsetTable.d.ts +4 -0
  197. package/resultsetTable/ResultsetTable.js +54 -133
  198. package/resultsetTable/ResultsetTable.stories.tsx +300 -0
  199. package/resultsetTable/ResultsetTable.test.js +325 -0
  200. package/resultsetTable/types.d.ts +67 -0
  201. package/resultsetTable/types.js +5 -0
  202. package/select/Icons.d.ts +10 -0
  203. package/select/Icons.js +93 -0
  204. package/select/Listbox.d.ts +4 -0
  205. package/select/Listbox.js +169 -0
  206. package/select/Option.d.ts +4 -0
  207. package/select/Option.js +97 -0
  208. package/select/Select.d.ts +4 -0
  209. package/select/Select.js +202 -401
  210. package/select/Select.stories.tsx +600 -201
  211. package/select/Select.test.js +2228 -0
  212. package/select/types.d.ts +210 -0
  213. package/select/types.js +5 -0
  214. package/sidenav/Icons.d.ts +7 -0
  215. package/sidenav/Icons.js +51 -0
  216. package/sidenav/Sidenav.d.ts +6 -5
  217. package/sidenav/Sidenav.js +148 -46
  218. package/sidenav/Sidenav.stories.tsx +282 -0
  219. package/sidenav/Sidenav.test.js +44 -0
  220. package/sidenav/types.d.ts +52 -26
  221. package/slider/Slider.d.ts +2 -2
  222. package/slider/Slider.js +124 -99
  223. package/slider/Slider.stories.tsx +72 -9
  224. package/slider/Slider.test.js +250 -0
  225. package/slider/types.d.ts +8 -0
  226. package/spinner/Spinner.js +20 -26
  227. package/spinner/Spinner.stories.jsx +53 -26
  228. package/spinner/Spinner.test.js +64 -0
  229. package/switch/Switch.d.ts +2 -2
  230. package/switch/Switch.js +153 -70
  231. package/switch/Switch.stories.tsx +54 -43
  232. package/switch/Switch.test.js +225 -0
  233. package/switch/types.d.ts +10 -2
  234. package/table/Table.js +6 -6
  235. package/table/Table.stories.jsx +81 -1
  236. package/table/Table.test.js +26 -0
  237. package/tabs/Tab.d.ts +4 -0
  238. package/tabs/Tab.js +132 -0
  239. package/tabs/Tabs.d.ts +1 -1
  240. package/tabs/Tabs.js +362 -112
  241. package/tabs/Tabs.stories.tsx +226 -0
  242. package/tabs/Tabs.test.js +350 -0
  243. package/tabs/types.d.ts +39 -18
  244. package/tag/Tag.d.ts +1 -1
  245. package/tag/Tag.js +25 -37
  246. package/tag/Tag.stories.tsx +38 -28
  247. package/tag/Tag.test.js +60 -0
  248. package/tag/types.d.ts +23 -14
  249. package/text-input/Icons.d.ts +8 -0
  250. package/text-input/Icons.js +60 -0
  251. package/text-input/Suggestion.d.ts +4 -0
  252. package/text-input/Suggestion.js +84 -0
  253. package/text-input/Suggestions.d.ts +4 -0
  254. package/text-input/Suggestions.js +134 -0
  255. package/text-input/TextInput.d.ts +4 -0
  256. package/text-input/TextInput.js +236 -388
  257. package/text-input/TextInput.stories.tsx +569 -0
  258. package/text-input/TextInput.test.js +1723 -0
  259. package/text-input/types.d.ts +197 -0
  260. package/text-input/types.js +5 -0
  261. package/textarea/Textarea.d.ts +4 -0
  262. package/textarea/Textarea.js +41 -82
  263. package/textarea/Textarea.stories.jsx +96 -15
  264. package/textarea/Textarea.test.js +435 -0
  265. package/textarea/types.d.ts +137 -0
  266. package/textarea/types.js +5 -0
  267. package/toggle-group/ToggleGroup.d.ts +4 -0
  268. package/toggle-group/ToggleGroup.js +24 -49
  269. package/toggle-group/ToggleGroup.stories.tsx +69 -32
  270. package/toggle-group/ToggleGroup.test.js +156 -0
  271. package/toggle-group/types.d.ts +105 -0
  272. package/toggle-group/types.js +5 -0
  273. package/typography/Typography.d.ts +4 -0
  274. package/typography/Typography.js +32 -0
  275. package/typography/Typography.stories.tsx +198 -0
  276. package/typography/types.d.ts +18 -0
  277. package/typography/types.js +5 -0
  278. package/useTheme.d.ts +1235 -0
  279. package/useTheme.js +3 -3
  280. package/useTranslatedLabels.d.ts +85 -0
  281. package/useTranslatedLabels.js +20 -0
  282. package/utils/BaseTypography.d.ts +21 -0
  283. package/utils/BaseTypography.js +108 -0
  284. package/utils/FocusLock.d.ts +13 -0
  285. package/utils/FocusLock.js +138 -0
  286. package/wizard/Wizard.d.ts +1 -1
  287. package/wizard/Wizard.js +113 -59
  288. package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +48 -19
  289. package/wizard/Wizard.test.js +141 -0
  290. package/wizard/types.d.ts +10 -10
  291. package/ThemeContext.js +0 -246
  292. package/V3Select/V3Select.js +0 -455
  293. package/V3Select/index.d.ts +0 -27
  294. package/V3Textarea/V3Textarea.js +0 -260
  295. package/V3Textarea/index.d.ts +0 -27
  296. package/chip/index.d.ts +0 -22
  297. package/common/RequiredComponent.js +0 -32
  298. package/date/Date.js +0 -373
  299. package/date/index.d.ts +0 -27
  300. package/file-input/index.d.ts +0 -81
  301. package/footer/Footer.stories.jsx +0 -151
  302. package/input-text/Icons.js +0 -22
  303. package/input-text/InputText.js +0 -611
  304. package/input-text/index.d.ts +0 -36
  305. package/radio/Radio.d.ts +0 -4
  306. package/radio/Radio.js +0 -174
  307. package/radio/Radio.stories.tsx +0 -192
  308. package/radio/types.d.ts +0 -54
  309. package/resultsetTable/index.d.ts +0 -19
  310. package/select/index.d.ts +0 -131
  311. package/text-input/index.d.ts +0 -135
  312. package/textarea/index.d.ts +0 -117
  313. package/toggle/Toggle.js +0 -186
  314. package/toggle/index.d.ts +0 -21
  315. package/toggle-group/index.d.ts +0 -21
  316. package/upload/Upload.js +0 -201
  317. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  318. package/upload/buttons-upload/Icons.js +0 -40
  319. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  320. package/upload/dragAndDropArea/Icons.js +0 -39
  321. package/upload/file-upload/FileToUpload.js +0 -115
  322. package/upload/file-upload/Icons.js +0 -66
  323. package/upload/files-upload/FilesToUpload.js +0 -109
  324. package/upload/index.d.ts +0 -15
  325. package/upload/transaction/Icons.js +0 -160
  326. package/upload/transaction/Transaction.js +0 -104
  327. package/upload/transactions/Transactions.js +0 -94
  328. package/wizard/Icons.js +0 -65
  329. /package/{radio → badge}/types.js +0 -0
package/button/Button.js CHANGED
@@ -9,30 +9,44 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
-
14
12
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
13
 
16
- var _react = _interopRequireWildcard(require("react"));
14
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
17
15
 
18
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
16
+ var _react = _interopRequireWildcard(require("react"));
19
17
 
20
18
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
19
 
22
- var _variables = require("../common/variables.js");
20
+ var _variables = require("../common/variables");
23
21
 
24
- var _utils = require("../common/utils.js");
22
+ var _utils = require("../common/utils");
25
23
 
26
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
24
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
27
25
 
28
- var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
26
+ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
29
27
 
30
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
28
+ var _templateObject, _templateObject2, _templateObject3;
31
29
 
32
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); }
33
31
 
34
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; }
35
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
+
36
50
  var DxcButton = function DxcButton(_ref) {
37
51
  var _ref$label = _ref.label,
38
52
  label = _ref$label === void 0 ? "" : _ref$label,
@@ -45,86 +59,44 @@ var DxcButton = function DxcButton(_ref) {
45
59
  _ref$type = _ref.type,
46
60
  type = _ref$type === void 0 ? "button" : _ref$type,
47
61
  icon = _ref.icon,
48
- _ref$iconSrc = _ref.iconSrc,
49
- iconSrc = _ref$iconSrc === void 0 ? "" : _ref$iconSrc,
50
- onClick = _ref.onClick,
62
+ _ref$onClick = _ref.onClick,
63
+ _onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
51
64
  margin = _ref.margin,
52
65
  _ref$size = _ref.size,
53
66
  size = _ref$size === void 0 ? "fitContent" : _ref$size,
54
67
  _ref$tabIndex = _ref.tabIndex,
55
68
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
69
+
56
70
  var colorsTheme = (0, _useTheme["default"])();
57
71
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
58
72
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
59
73
  theme: colorsTheme.button
60
- }, /*#__PURE__*/_react["default"].createElement(DxCButton, {
74
+ }, /*#__PURE__*/_react["default"].createElement(Button, {
61
75
  type: type,
62
- margin: margin,
63
76
  mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
64
77
  disabled: disabled,
65
- iconPosition: iconPosition,
66
- size: size,
67
- backgroundType: backgroundType,
68
- icon: icon
69
- }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
70
- type: type,
71
- disabled: disabled,
72
- disableRipple: true,
73
- "aria-disabled": disabled,
74
78
  tabIndex: disabled ? -1 : tabIndex,
75
- onClick: onClick
76
- }, label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
79
+ backgroundType: backgroundType,
80
+ size: size,
81
+ margin: margin,
82
+ onClick: function onClick() {
83
+ _onClick();
84
+ }
85
+ }, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
77
86
  icon: icon,
78
87
  iconPosition: iconPosition
79
- }, label), icon ? /*#__PURE__*/_react["default"].createElement(IconContainer, {
88
+ }, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
80
89
  label: label,
81
90
  iconPosition: iconPosition
82
- }, (0, _typeof2["default"])(icon) === "object" ? icon : /*#__PURE__*/_react["default"].createElement(icon)) : iconSrc && /*#__PURE__*/_react["default"].createElement(ButtonIcon, {
83
- label: label,
84
- iconPosition: iconPosition,
85
- src: iconSrc
86
- }))));
87
- };
88
-
89
- var sizes = {
90
- small: "42px",
91
- medium: "120px",
92
- large: "240px",
93
- fillParent: "100%",
94
- fitContent: "unset"
95
- };
96
-
97
- var calculateWidth = function calculateWidth(margin, size) {
98
- if (size === "fillParent") {
99
- return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
100
- }
101
-
102
- return sizes[size];
91
+ }, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
92
+ src: icon
93
+ }) : icon), label && iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
94
+ icon: icon,
95
+ iconPosition: iconPosition
96
+ }, label)));
103
97
  };
104
98
 
105
- var LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (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) {
106
- return props.theme.labelFontLineHeight;
107
- }, function (props) {
108
- return props.theme.fontSize;
109
- }, function (props) {
110
- return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
111
- }, function (props) {
112
- return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
113
- });
114
-
115
- var IconContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 24px;\n max-width: 24px;\n margin-left: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
116
- return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
117
- }, function (props) {
118
- return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
119
- });
120
-
121
- var ButtonIcon = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 24px;\n max-width: 24px;\n margin-left: ", ";\n margin-right: ", ";\n"])), function (props) {
122
- return props.iconPosition === "after" && props.label !== "" && "10px" || "0px";
123
- }, function (props) {
124
- return props.iconPosition === "before" && props.label !== "" && "10px" || "0px";
125
- });
126
-
127
- var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-block;\n width: ", ";\n cursor: ", ";\n\n .MuiButtonBase-root {\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n\n .MuiButton-label {\n display: flex;\n flex-direction: ", ";\n align-items: center;\n }\n\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n min-width: ", ";\n width: 100%;\n height: 40px;\n transition: none !important;\n\n &:focus {\n border-color: transparent;\n box-shadow: 0 0 0 2px\n ", ";\n }\n\n ", "\n }\n"])), function (props) {
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) {
128
100
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
129
101
  }, function (props) {
130
102
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
@@ -136,8 +108,6 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
136
108
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
137
109
  }, function (props) {
138
110
  return calculateWidth(props.margin, props.size);
139
- }, function (props) {
140
- return props.disabled && "not-allowed" || "pointer";
141
111
  }, function (props) {
142
112
  return props.theme.paddingLeft;
143
113
  }, function (props) {
@@ -146,8 +116,6 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
146
116
  return props.theme.paddingTop;
147
117
  }, function (props) {
148
118
  return props.theme.paddingBottom;
149
- }, function (props) {
150
- return props.iconPosition === "after" && "row" || "row-reverse";
151
119
  }, function (props) {
152
120
  return props.theme.fontFamily;
153
121
  }, function (props) {
@@ -156,21 +124,29 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
156
124
  return props.theme.fontWeight;
157
125
  }, function (props) {
158
126
  return props.theme.labelLetterSpacing;
159
- }, function (props) {
160
- return props.size === "small" && "calc(100% - 22px)" || "unset";
161
127
  }, function (props) {
162
128
  return props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor;
163
129
  }, function (props) {
164
130
  var mode = props.mode,
165
- backgroundType = props.backgroundType;
166
-
167
- if (mode === "primary") {
168
- return "\n border-radius: ".concat(props.theme.primaryBorderRadius, ";\n border-width: ").concat(props.theme.primaryBorderThickness, ";\n border-style: ").concat(props.theme.primaryBorderStyle, ";\n font-family: ").concat(props.theme.primaryFontFamily, ";\n font-size: ").concat(props.theme.primaryFontSize, ";\n font-weight: ").concat(props.theme.primaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor, ";\n color: ").concat(backgroundType && backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled { \n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor, "!important; \n }\n .MuiButton-label {\n z-index: 5;\n }\n ");
169
- } else if (mode === "secondary") {
170
- return "\n border-radius: ".concat(props.theme.secondaryBorderRadius, ";\n border-width: ").concat(props.theme.secondaryBorderThickness, ";\n border-style: ").concat(props.theme.secondaryBorderStyle, ";\n font-family: ").concat(props.theme.secondaryFontFamily, ";\n font-size: ").concat(props.theme.secondaryFontSize, ";\n font-weight: ").concat(props.theme.secondaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor, ";\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor, ";\n }\n .MuiButton-label {\n z-index: 5;\n }\n ");
171
- } else if (mode === "text") {
172
- return "\n border-radius: ".concat(props.theme.textBorderRadius, ";\n border-width: ").concat(props.theme.textBorderThickness, ";\n border-style: ").concat(props.theme.textBorderStyle, ";\n font-family: ").concat(props.theme.textFontFamily, ";\n font-size: ").concat(props.theme.textFontSize, ";\n font-weight: ").concat(props.theme.textFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor:not-allowed;\n color: ").concat(backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, " !important;\n background-color: ").concat(backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n }\n ");
173
- }
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 ");
134
+ });
135
+
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) {
137
+ return props.theme.labelFontLineHeight;
138
+ }, function (props) {
139
+ 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
+ });
145
+
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";
174
150
  });
175
151
 
176
152
  var _default = DxcButton;
@@ -1,23 +1,62 @@
1
1
  import React from "react";
2
- import DxcButton from "./Button";
3
2
  import { BackgroundColorProvider } from "../BackgroundColorContext";
3
+ import DxcButton from "./Button";
4
+ import DxcFlex from "./../flex/Flex";
4
5
  import Title from "../../.storybook/components/Title";
5
6
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
7
  import DarkContainer from "../../.storybook/components/DarkSection";
8
+ import { HalstackProvider } from "../HalstackContext";
7
9
 
8
10
  export default {
9
11
  title: "Button",
10
12
  component: DxcButton,
11
13
  };
12
14
 
13
- const iconSVG = () => {
14
- return (
15
- <svg viewBox="0 0 24 24" fill="currentColor">
16
- <path d="M0 0h24v24H0z" fill="none" />
17
- <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
18
- </svg>
19
- );
15
+ const iconSVG = (
16
+ <svg width="24px" height="24px" viewBox="0 0 24 24" fill="currentColor">
17
+ <path d="M0 0h24v24H0z" fill="none" />
18
+ <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
19
+ </svg>
20
+ );
21
+
22
+ const facebookIcon = (
23
+ <svg
24
+ version="1.1"
25
+ id="Capa_1"
26
+ x="0px"
27
+ y="0px"
28
+ width="438.536px"
29
+ height="438.536px"
30
+ viewBox="0 0 438.536 438.536"
31
+ fill="currentColor"
32
+ >
33
+ <g>
34
+ <path
35
+ d="M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123
36
+ C8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126
37
+ h274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225
38
+ C438.532,59.576,430.49,40.204,414.41,24.123z M373.155,225.548h-49.963V406.84h-74.802V225.548H210.99V163.02h37.401v-37.402
39
+ c0-26.838,6.283-47.107,18.843-60.813c12.559-13.706,33.304-20.555,62.242-20.555h49.963v62.526h-31.401
40
+ c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.119h56.534L373.155,225.548z"
41
+ />
42
+ </g>
43
+ </svg>
44
+ );
45
+
46
+ const smallIcon = (
47
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20" fill="currentColor">
48
+ <path d="m7.646 18.333-.313-2.625q-.208-.125-.458-.27-.25-.146-.458-.271l-2.438 1.021-2.354-4.063 2.083-1.583V9.458L1.625 7.875l2.354-4.063 2.438 1.021q.208-.125.458-.27.25-.146.458-.271l.313-2.625h4.708l.313 2.625q.208.125.458.271.25.145.458.27l2.438-1.021 2.354 4.063-2.063 1.583v1.084l2.063 1.583-2.354 4.063-2.438-1.021q-.208.125-.458.271-.25.145-.458.27l-.313 2.625ZM10 12.979q1.229 0 2.104-.875T12.979 10q0-1.229-.875-2.104T10 7.021q-1.229 0-2.104.875T7.021 10q0 1.229.875 2.104t2.104.875Zm0-1.75q-.5 0-.865-.364-.364-.365-.364-.865t.364-.865q.365-.364.865-.364t.865.364q.364.365.364.865t-.364.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.166q.605-.167 1.167-.5.562-.334 1.021-.792l2.021.854.833-1.375-1.771-1.354q.104-.292.146-.604.042-.313.042-.646 0-.292-.042-.594t-.125-.635l1.771-1.375-.834-1.375-2.02.875q-.48-.479-1.032-.802-.552-.323-1.156-.49l-.271-2.187H9.167l-.271 2.187q-.604.167-1.156.49-.552.323-1.011.781l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.459.458 1.011.781.552.323 1.156.49Z" />
49
+ </svg>
50
+ );
51
+
52
+ const opinionatedTheme = {
53
+ button: {
54
+ baseColor: "#5f249f",
55
+ primaryFontColor: "#ffffff",
56
+ secondaryHoverFontColor: "#ffffff",
57
+ },
20
58
  };
59
+
21
60
  export const Chromatic = () => (
22
61
  <>
23
62
  <Title title="Primary" theme="light" level={2} />
@@ -39,7 +78,7 @@ export const Chromatic = () => (
39
78
  </ExampleContainer>
40
79
  <ExampleContainer>
41
80
  <Title title="Disabled" theme="light" level={4} />
42
- <DxcButton label="Primary disabled" disabled />
81
+ <DxcButton label="Primary disabled" disabled icon={iconSVG} />
43
82
  </ExampleContainer>
44
83
  <ExampleContainer>
45
84
  <Title title="With left icon" theme="light" level={4} />
@@ -53,6 +92,18 @@ export const Chromatic = () => (
53
92
  <Title title="Only icon" theme="light" level={4} />
54
93
  <DxcButton icon={iconSVG} />
55
94
  </ExampleContainer>
95
+ <ExampleContainer>
96
+ <Title title="Big icon (SVG)" theme="light" level={4} />
97
+ <DxcButton icon={facebookIcon} />
98
+ </ExampleContainer>
99
+ <ExampleContainer>
100
+ <Title title="Big icon (image)" theme="light" level={4} />
101
+ <DxcButton icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png" />
102
+ </ExampleContainer>
103
+ <ExampleContainer>
104
+ <Title title="Small icon" theme="light" level={4} />
105
+ <DxcButton icon={smallIcon} />
106
+ </ExampleContainer>
56
107
  <Title title="Secondary" theme="light" level={2} />
57
108
  <ExampleContainer>
58
109
  <Title title="Enabled" theme="light" level={4} />
@@ -72,12 +123,19 @@ export const Chromatic = () => (
72
123
  </ExampleContainer>
73
124
  <ExampleContainer>
74
125
  <Title title="Disabled" theme="light" level={4} />
75
- <DxcButton mode="secondary" disabled label="Secondary disabled" />
126
+ <DxcButton mode="secondary" disabled label="Secondary disabled" icon={iconSVG} />
76
127
  </ExampleContainer>
77
128
  <ExampleContainer>
78
129
  <Title title="With icon" theme="light" level={4} />
79
130
  <DxcButton mode="secondary" label="Secondary" icon={iconSVG} />
80
131
  </ExampleContainer>
132
+ <ExampleContainer>
133
+ <Title title="Only icon (image)" theme="light" level={4} />
134
+ <DxcButton
135
+ mode="secondary"
136
+ icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
137
+ />
138
+ </ExampleContainer>
81
139
  <Title title="Text" theme="light" level={2} />
82
140
  <ExampleContainer>
83
141
  <Title title="Enabled" theme="light" level={4} />
@@ -97,12 +155,19 @@ export const Chromatic = () => (
97
155
  </ExampleContainer>
98
156
  <ExampleContainer>
99
157
  <Title title="Disabled" theme="light" level={4} />
100
- <DxcButton mode="text" label="Text disabled" disabled />
158
+ <DxcButton mode="text" label="Text disabled" disabled icon={iconSVG} />
101
159
  </ExampleContainer>
102
160
  <ExampleContainer>
103
161
  <Title title="With icon" theme="light" level={4} />
104
162
  <DxcButton label="Text" mode="text" icon={iconSVG} />
105
163
  </ExampleContainer>
164
+ <ExampleContainer>
165
+ <Title title="Only icon (image)" theme="light" level={4} />
166
+ <DxcButton
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"
169
+ />
170
+ </ExampleContainer>
106
171
  <BackgroundColorProvider color="#333333">
107
172
  <DarkContainer>
108
173
  <Title title="Primary" theme="dark" level={2} />
@@ -124,7 +189,7 @@ export const Chromatic = () => (
124
189
  </ExampleContainer>
125
190
  <ExampleContainer>
126
191
  <Title title="Disabled" theme="dark" level={4} />
127
- <DxcButton label="Primary disabled" disabled />
192
+ <DxcButton label="Primary disabled" disabled icon={iconSVG} />
128
193
  </ExampleContainer>
129
194
  <ExampleContainer>
130
195
  <Title title="With icon" theme="dark" level={4} />
@@ -149,7 +214,7 @@ export const Chromatic = () => (
149
214
  </ExampleContainer>
150
215
  <ExampleContainer>
151
216
  <Title title="Disabled" theme="dark" level={4} />
152
- <DxcButton mode="secondary" disabled label="Secondary disabled" />
217
+ <DxcButton mode="secondary" disabled label="Secondary disabled" icon={iconSVG} />
153
218
  </ExampleContainer>
154
219
  <ExampleContainer>
155
220
  <Title title="With icon" theme="dark" level={4} />
@@ -174,7 +239,7 @@ export const Chromatic = () => (
174
239
  </ExampleContainer>
175
240
  <ExampleContainer>
176
241
  <Title title="Disabled" theme="dark" level={4} />
177
- <DxcButton mode="text" label="Text disabled" disabled />
242
+ <DxcButton mode="text" label="Text disabled" disabled icon={iconSVG} />
178
243
  </ExampleContainer>
179
244
  <ExampleContainer>
180
245
  <Title title="With icon" theme="dark" level={4} />
@@ -272,5 +337,89 @@ export const Chromatic = () => (
272
337
  <Title title="Xxlarge margin" theme="light" level={4} />
273
338
  <DxcButton label="Xxlarge margin" margin="xxlarge" />
274
339
  </ExampleContainer>
340
+ <Title title="Inside a flex" theme="light" level={2} />
341
+ <ExampleContainer>
342
+ <DxcFlex direction="column" gap="1rem">
343
+ <DxcButton label="Button" />
344
+ <DxcButton label="Button" />
345
+ <DxcButton label="Button" />
346
+ </DxcFlex>
347
+ </ExampleContainer>
348
+ <Title title="Opinionated theme" theme="light" level={2} />
349
+ <Title title="Primary" theme="light" level={3} />
350
+ <ExampleContainer>
351
+ <Title title="Enabled" theme="light" level={4} />
352
+ <HalstackProvider theme={opinionatedTheme}>
353
+ <DxcButton label="Primary" icon={iconSVG} />
354
+ </HalstackProvider>
355
+ </ExampleContainer>
356
+ <ExampleContainer pseudoState="pseudo-hover">
357
+ <Title title="Hovered" theme="light" level={4} />
358
+ <DxcButton label="Primary hovered" icon={iconSVG} />
359
+ </ExampleContainer>
360
+ <ExampleContainer pseudoState="pseudo-focus">
361
+ <Title title="Focused" theme="light" level={4} />
362
+ <DxcButton label="Primary focused" icon={iconSVG} />
363
+ </ExampleContainer>
364
+ <ExampleContainer pseudoState="pseudo-active">
365
+ <Title title="Actived" theme="light" level={4} />
366
+ <DxcButton label="Primary actived" icon={iconSVG} />
367
+ </ExampleContainer>
368
+ <ExampleContainer>
369
+ <Title title="Disabled" theme="light" level={4} />
370
+ <HalstackProvider theme={opinionatedTheme}>
371
+ <DxcButton label="Primary" icon={iconSVG} disabled />
372
+ </HalstackProvider>
373
+ </ExampleContainer>
374
+ <Title title="Secondary" theme="light" level={3} />
375
+ <ExampleContainer>
376
+ <Title title="Enabled" theme="light" level={4} />
377
+ <HalstackProvider theme={opinionatedTheme}>
378
+ <DxcButton mode="secondary" label="Secondary" icon={iconSVG} />
379
+ </HalstackProvider>
380
+ </ExampleContainer>
381
+ <ExampleContainer pseudoState="pseudo-hover">
382
+ <Title title="Hovered" theme="light" level={4} />
383
+ <DxcButton mode="secondary" label="Secondary hovered" icon={iconSVG} />
384
+ </ExampleContainer>
385
+ <ExampleContainer pseudoState="pseudo-focus">
386
+ <Title title="Focused" theme="light" level={4} />
387
+ <DxcButton mode="secondary" label="Secondary focused" icon={iconSVG} />
388
+ </ExampleContainer>
389
+ <ExampleContainer pseudoState="pseudo-active">
390
+ <Title title="Actived" theme="light" level={4} />
391
+ <DxcButton mode="secondary" label="Secondary actived" icon={iconSVG} />
392
+ </ExampleContainer>
393
+ <ExampleContainer>
394
+ <Title title="Disabled" theme="light" level={4} />
395
+ <HalstackProvider theme={opinionatedTheme}>
396
+ <DxcButton mode="secondary" label="Secondary" icon={iconSVG} disabled />
397
+ </HalstackProvider>
398
+ </ExampleContainer>
399
+ <Title title="Text" theme="light" level={3} />
400
+ <ExampleContainer>
401
+ <Title title="Enabled" theme="light" level={4} />
402
+ <HalstackProvider theme={opinionatedTheme}>
403
+ <DxcButton mode="text" label="Text" icon={iconSVG} />
404
+ </HalstackProvider>
405
+ </ExampleContainer>
406
+ <ExampleContainer pseudoState="pseudo-hover">
407
+ <Title title="Hovered" theme="light" level={4} />
408
+ <DxcButton mode="text" label="Text hovered" icon={iconSVG} />
409
+ </ExampleContainer>
410
+ <ExampleContainer pseudoState="pseudo-focus">
411
+ <Title title="Focused" theme="light" level={4} />
412
+ <DxcButton mode="text" label="Text focused" icon={iconSVG} />
413
+ </ExampleContainer>
414
+ <ExampleContainer pseudoState="pseudo-active">
415
+ <Title title="Actived" theme="light" level={4} />
416
+ <DxcButton mode="text" label="Text actived" icon={iconSVG} />
417
+ </ExampleContainer>
418
+ <ExampleContainer>
419
+ <Title title="Disabled" theme="light" level={4} />
420
+ <HalstackProvider theme={opinionatedTheme}>
421
+ <DxcButton mode="text" label="Text disabled" icon={iconSVG} disabled />
422
+ </HalstackProvider>
423
+ </ExampleContainer>
275
424
  </>
276
425
  );
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _Button = _interopRequireDefault(require("./Button.tsx"));
10
+
11
+ describe("Button component tests", function () {
12
+ test("Button renders with correct text", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
14
+ label: "Button"
15
+ })),
16
+ getByText = _render.getByText;
17
+
18
+ expect(getByText("Button")).toBeTruthy();
19
+ });
20
+ test("Calls correct function on click", function () {
21
+ var onClick = jest.fn();
22
+
23
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
24
+ label: "Button",
25
+ onClick: onClick
26
+ })),
27
+ getByText = _render2.getByText;
28
+
29
+ var button = getByText("Button");
30
+
31
+ _react2.fireEvent.click(button);
32
+
33
+ expect(onClick).toHaveBeenCalled();
34
+ });
35
+ });
package/button/types.d.ts CHANGED
@@ -6,14 +6,14 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type Props = {
11
11
  /**
12
- * Text to be placed next to the button.
12
+ * Text to be placed in the button.
13
13
  */
14
14
  label?: string;
15
15
  /**
16
- * Uses one of the available button modes.
16
+ * The available button modes.
17
17
  */
18
18
  mode?: "primary" | "secondary" | "text";
19
19
  /**
@@ -25,21 +25,17 @@ declare type Props = {
25
25
  */
26
26
  iconPosition?: "before" | "after";
27
27
  /**
28
- * This prop corresponds to the 'type' prop of the button in html.
28
+ * 'type' html prop of the button.
29
29
  */
30
30
  type?: "button" | "reset" | "submit";
31
31
  /**
32
- * Element used as the icon that will be placed next to the button label.
32
+ * Element or path used as the icon that will be placed next to the label.
33
33
  */
34
- icon?: SVG;
34
+ icon?: string | SVG;
35
35
  /**
36
- * @deprecated URL of the icon that will be placed next to the button label.
36
+ * This function will be called when the user clicks the button.
37
37
  */
38
- iconSrc?: string;
39
- /**
40
- * This function will be called when the user clicks the button. The event object will be passed as a parameter.
41
- */
42
- onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
38
+ onClick?: () => void;
43
39
  /**
44
40
  * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
45
41
  * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.