@dxc-technology/halstack-react 0.0.0-64fdce7 → 0.0.0-6501724

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 (175) hide show
  1. package/BackgroundColorContext.d.ts +2 -2
  2. package/BackgroundColorContext.js +1 -1
  3. package/HalstackContext.d.ts +1329 -5
  4. package/HalstackContext.js +113 -72
  5. package/accordion/Accordion.js +6 -11
  6. package/accordion/Accordion.stories.tsx +52 -3
  7. package/accordion/Accordion.test.js +1 -1
  8. package/accordion/types.d.ts +3 -3
  9. package/accordion-group/AccordionGroup.d.ts +4 -3
  10. package/accordion-group/AccordionGroup.js +23 -44
  11. package/accordion-group/AccordionGroup.test.js +1 -1
  12. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  13. package/accordion-group/AccordionGroupAccordion.js +43 -0
  14. package/accordion-group/types.d.ts +2 -2
  15. package/alert/Alert.js +4 -8
  16. package/alert/Alert.stories.tsx +28 -0
  17. package/alert/Alert.test.js +1 -1
  18. package/bleed/Bleed.stories.tsx +1 -0
  19. package/box/Box.js +3 -5
  20. package/box/Box.stories.tsx +15 -0
  21. package/box/Box.test.js +1 -1
  22. package/bulleted-list/BulletedList.js +4 -2
  23. package/bulleted-list/BulletedList.stories.tsx +7 -1
  24. package/bulleted-list/types.d.ts +31 -4
  25. package/button/Button.js +2 -3
  26. package/button/Button.stories.tsx +95 -10
  27. package/button/Button.test.js +1 -1
  28. package/button/types.d.ts +3 -3
  29. package/card/Card.js +12 -13
  30. package/card/Card.stories.tsx +12 -13
  31. package/card/Card.test.js +1 -1
  32. package/checkbox/Checkbox.js +3 -3
  33. package/checkbox/Checkbox.stories.tsx +52 -0
  34. package/checkbox/Checkbox.test.js +1 -1
  35. package/checkbox/types.d.ts +2 -2
  36. package/chip/Chip.js +25 -34
  37. package/chip/Chip.stories.tsx +80 -17
  38. package/chip/Chip.test.js +3 -5
  39. package/common/OpenSans.css +68 -80
  40. package/common/coreTokens.d.ts +146 -0
  41. package/common/coreTokens.js +167 -0
  42. package/common/utils.d.ts +1 -0
  43. package/common/utils.js +4 -4
  44. package/common/variables.d.ts +1482 -0
  45. package/common/variables.js +962 -1123
  46. package/date-input/DateInput.stories.tsx +67 -0
  47. package/dialog/Dialog.d.ts +1 -1
  48. package/dialog/Dialog.js +55 -86
  49. package/dialog/Dialog.stories.tsx +145 -217
  50. package/dialog/Dialog.test.js +302 -3
  51. package/dialog/types.d.ts +0 -13
  52. package/dropdown/Dropdown.js +2 -2
  53. package/dropdown/Dropdown.stories.tsx +46 -1
  54. package/dropdown/Dropdown.test.js +3 -2
  55. package/dropdown/DropdownMenu.js +5 -1
  56. package/dropdown/DropdownMenuItem.js +0 -2
  57. package/dropdown/types.d.ts +3 -3
  58. package/file-input/FileInput.js +4 -8
  59. package/file-input/FileInput.stories.tsx +85 -2
  60. package/file-input/FileInput.test.js +1 -42
  61. package/file-input/FileItem.js +1 -0
  62. package/flex/Flex.js +4 -2
  63. package/flex/Flex.stories.tsx +35 -26
  64. package/flex/types.d.ts +70 -5
  65. package/footer/Footer.js +6 -8
  66. package/footer/Footer.stories.tsx +91 -0
  67. package/footer/Footer.test.js +14 -26
  68. package/grid/Grid.d.ts +7 -0
  69. package/grid/Grid.js +91 -0
  70. package/grid/Grid.stories.tsx +219 -0
  71. package/grid/types.d.ts +115 -0
  72. package/header/Header.d.ts +3 -2
  73. package/header/Header.js +3 -3
  74. package/header/Header.stories.tsx +115 -5
  75. package/header/Header.test.js +2 -2
  76. package/header/types.d.ts +2 -2
  77. package/heading/Heading.js +1 -1
  78. package/heading/Heading.test.js +1 -1
  79. package/inset/Inset.stories.tsx +2 -1
  80. package/layout/ApplicationLayout.d.ts +3 -3
  81. package/layout/ApplicationLayout.js +1 -1
  82. package/layout/types.d.ts +2 -3
  83. package/link/Link.js +3 -3
  84. package/link/Link.stories.tsx +60 -0
  85. package/link/Link.test.js +2 -4
  86. package/link/types.d.ts +2 -2
  87. package/main.d.ts +3 -2
  88. package/main.js +9 -1
  89. package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
  90. package/{tabs-nav → nav-tabs}/NavTabs.js +8 -11
  91. package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +103 -1
  92. package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
  93. package/{tabs-nav → nav-tabs}/Tab.js +47 -29
  94. package/{tabs-nav → nav-tabs}/types.d.ts +8 -9
  95. package/nav-tabs/types.js +5 -0
  96. package/number-input/NumberInput.test.js +1 -1
  97. package/package.json +2 -2
  98. package/paginator/Paginator.js +2 -4
  99. package/paginator/Paginator.stories.tsx +24 -0
  100. package/paginator/Paginator.test.js +40 -37
  101. package/paragraph/Paragraph.d.ts +3 -4
  102. package/paragraph/Paragraph.js +5 -5
  103. package/password-input/PasswordInput.test.js +1 -1
  104. package/progress-bar/ProgressBar.d.ts +2 -2
  105. package/progress-bar/ProgressBar.js +5 -5
  106. package/progress-bar/ProgressBar.stories.jsx +35 -2
  107. package/progress-bar/ProgressBar.test.js +1 -1
  108. package/progress-bar/types.d.ts +4 -3
  109. package/quick-nav/QuickNav.stories.tsx +14 -0
  110. package/radio-group/Radio.js +10 -10
  111. package/radio-group/RadioGroup.js +8 -10
  112. package/radio-group/RadioGroup.stories.tsx +131 -18
  113. package/radio-group/RadioGroup.test.js +1 -1
  114. package/resultsetTable/ResultsetTable.js +2 -2
  115. package/resultsetTable/ResultsetTable.test.js +1 -1
  116. package/resultsetTable/types.d.ts +3 -3
  117. package/select/Select.js +13 -11
  118. package/select/Select.stories.tsx +477 -175
  119. package/select/Select.test.js +59 -59
  120. package/sidenav/Icons.d.ts +7 -0
  121. package/sidenav/Icons.js +51 -0
  122. package/sidenav/Sidenav.d.ts +2 -2
  123. package/sidenav/Sidenav.js +66 -94
  124. package/sidenav/Sidenav.stories.tsx +110 -17
  125. package/sidenav/types.d.ts +21 -18
  126. package/slider/Slider.js +2 -3
  127. package/slider/Slider.stories.tsx +57 -0
  128. package/slider/Slider.test.js +1 -1
  129. package/slider/types.d.ts +2 -2
  130. package/spinner/Spinner.js +15 -21
  131. package/spinner/Spinner.stories.jsx +53 -27
  132. package/spinner/Spinner.test.js +1 -1
  133. package/switch/Switch.js +2 -2
  134. package/switch/Switch.stories.tsx +33 -0
  135. package/switch/Switch.test.js +1 -1
  136. package/switch/types.d.ts +2 -2
  137. package/table/Table.js +2 -2
  138. package/table/Table.stories.jsx +80 -1
  139. package/table/Table.test.js +1 -1
  140. package/tabs/Tab.js +9 -10
  141. package/tabs/Tabs.js +11 -17
  142. package/tabs/Tabs.stories.tsx +38 -0
  143. package/tabs/Tabs.test.js +4 -5
  144. package/tabs/types.d.ts +2 -2
  145. package/tag/Tag.js +7 -9
  146. package/tag/Tag.stories.tsx +14 -1
  147. package/tag/Tag.test.js +1 -1
  148. package/text-input/Suggestion.js +2 -2
  149. package/text-input/TextInput.js +4 -4
  150. package/text-input/TextInput.stories.tsx +69 -1
  151. package/text-input/TextInput.test.js +1 -2
  152. package/textarea/Textarea.js +3 -4
  153. package/textarea/Textarea.stories.jsx +60 -1
  154. package/textarea/Textarea.test.js +2 -4
  155. package/toggle-group/ToggleGroup.d.ts +2 -2
  156. package/toggle-group/ToggleGroup.js +7 -4
  157. package/toggle-group/ToggleGroup.stories.tsx +42 -0
  158. package/toggle-group/ToggleGroup.test.js +1 -1
  159. package/toggle-group/types.d.ts +1 -1
  160. package/typography/Typography.d.ts +2 -2
  161. package/typography/Typography.js +14 -113
  162. package/typography/Typography.stories.tsx +1 -1
  163. package/useTheme.d.ts +1234 -1
  164. package/useTheme.js +1 -1
  165. package/useTranslatedLabels.d.ts +84 -1
  166. package/utils/BaseTypography.d.ts +21 -0
  167. package/utils/BaseTypography.js +108 -0
  168. package/utils/FocusLock.d.ts +13 -0
  169. package/utils/FocusLock.js +138 -0
  170. package/wizard/Wizard.js +2 -2
  171. package/wizard/Wizard.stories.tsx +20 -0
  172. package/wizard/Wizard.test.js +1 -1
  173. package/wizard/types.d.ts +5 -6
  174. /package/{tabs-nav → grid}/types.js +0 -0
  175. /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
+ import { BackgroundColorProvider } from "../BackgroundColorContext";
2
3
  import DxcButton from "./Button";
3
4
  import DxcFlex from "./../flex/Flex";
4
- import { BackgroundColorProvider } from "../BackgroundColorContext";
5
5
  import Title from "../../.storybook/components/Title";
6
6
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
7
7
  import DarkContainer from "../../.storybook/components/DarkSection";
8
+ import { HalstackProvider } from "../HalstackContext";
8
9
 
9
10
  export default {
10
11
  title: "Button",
@@ -48,6 +49,14 @@ const smallIcon = (
48
49
  </svg>
49
50
  );
50
51
 
52
+ const opinionatedTheme = {
53
+ button: {
54
+ baseColor: "#5f249f",
55
+ primaryFontColor: "#ffffff",
56
+ secondaryHoverFontColor: "#ffffff",
57
+ },
58
+ };
59
+
51
60
  export const Chromatic = () => (
52
61
  <>
53
62
  <Title title="Primary" theme="light" level={2} />
@@ -69,7 +78,7 @@ export const Chromatic = () => (
69
78
  </ExampleContainer>
70
79
  <ExampleContainer>
71
80
  <Title title="Disabled" theme="light" level={4} />
72
- <DxcButton label="Primary disabled" disabled />
81
+ <DxcButton label="Primary disabled" disabled icon={iconSVG} />
73
82
  </ExampleContainer>
74
83
  <ExampleContainer>
75
84
  <Title title="With left icon" theme="light" level={4} />
@@ -89,7 +98,7 @@ export const Chromatic = () => (
89
98
  </ExampleContainer>
90
99
  <ExampleContainer>
91
100
  <Title title="Big icon (image)" theme="light" level={4} />
92
- <DxcButton icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png" />
101
+ <DxcButton icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png" />
93
102
  </ExampleContainer>
94
103
  <ExampleContainer>
95
104
  <Title title="Small icon" theme="light" level={4} />
@@ -114,7 +123,7 @@ export const Chromatic = () => (
114
123
  </ExampleContainer>
115
124
  <ExampleContainer>
116
125
  <Title title="Disabled" theme="light" level={4} />
117
- <DxcButton mode="secondary" disabled label="Secondary disabled" />
126
+ <DxcButton mode="secondary" disabled label="Secondary disabled" icon={iconSVG} />
118
127
  </ExampleContainer>
119
128
  <ExampleContainer>
120
129
  <Title title="With icon" theme="light" level={4} />
@@ -124,7 +133,7 @@ export const Chromatic = () => (
124
133
  <Title title="Only icon (image)" theme="light" level={4} />
125
134
  <DxcButton
126
135
  mode="secondary"
127
- icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png"
136
+ icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
128
137
  />
129
138
  </ExampleContainer>
130
139
  <Title title="Text" theme="light" level={2} />
@@ -146,7 +155,7 @@ export const Chromatic = () => (
146
155
  </ExampleContainer>
147
156
  <ExampleContainer>
148
157
  <Title title="Disabled" theme="light" level={4} />
149
- <DxcButton mode="text" label="Text disabled" disabled />
158
+ <DxcButton mode="text" label="Text disabled" disabled icon={iconSVG} />
150
159
  </ExampleContainer>
151
160
  <ExampleContainer>
152
161
  <Title title="With icon" theme="light" level={4} />
@@ -180,7 +189,7 @@ export const Chromatic = () => (
180
189
  </ExampleContainer>
181
190
  <ExampleContainer>
182
191
  <Title title="Disabled" theme="dark" level={4} />
183
- <DxcButton label="Primary disabled" disabled />
192
+ <DxcButton label="Primary disabled" disabled icon={iconSVG} />
184
193
  </ExampleContainer>
185
194
  <ExampleContainer>
186
195
  <Title title="With icon" theme="dark" level={4} />
@@ -205,7 +214,7 @@ export const Chromatic = () => (
205
214
  </ExampleContainer>
206
215
  <ExampleContainer>
207
216
  <Title title="Disabled" theme="dark" level={4} />
208
- <DxcButton mode="secondary" disabled label="Secondary disabled" />
217
+ <DxcButton mode="secondary" disabled label="Secondary disabled" icon={iconSVG} />
209
218
  </ExampleContainer>
210
219
  <ExampleContainer>
211
220
  <Title title="With icon" theme="dark" level={4} />
@@ -230,7 +239,7 @@ export const Chromatic = () => (
230
239
  </ExampleContainer>
231
240
  <ExampleContainer>
232
241
  <Title title="Disabled" theme="dark" level={4} />
233
- <DxcButton mode="text" label="Text disabled" disabled />
242
+ <DxcButton mode="text" label="Text disabled" disabled icon={iconSVG} />
234
243
  </ExampleContainer>
235
244
  <ExampleContainer>
236
245
  <Title title="With icon" theme="dark" level={4} />
@@ -330,11 +339,87 @@ export const Chromatic = () => (
330
339
  </ExampleContainer>
331
340
  <Title title="Inside a flex" theme="light" level={2} />
332
341
  <ExampleContainer>
333
- <DxcFlex direction="column" gap="0.75rem">
342
+ <DxcFlex direction="column" gap="1rem">
334
343
  <DxcButton label="Button" />
335
344
  <DxcButton label="Button" />
336
345
  <DxcButton label="Button" />
337
346
  </DxcFlex>
338
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>
339
424
  </>
340
425
  );
@@ -6,7 +6,7 @@ var _react = _interopRequireDefault(require("react"));
6
6
 
7
7
  var _react2 = require("@testing-library/react");
8
8
 
9
- var _Button = _interopRequireDefault(require("./Button"));
9
+ var _Button = _interopRequireDefault(require("./Button.tsx"));
10
10
 
11
11
  describe("Button component tests", function () {
12
12
  test("Button renders with correct text", function () {
package/button/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
- export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- export declare type Margin = {
2
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ declare 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>;
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type Props = {
11
11
  /**
12
12
  * Text to be placed in the button.
package/card/Card.js CHANGED
@@ -19,7 +19,7 @@ var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
21
 
22
- var _variables = require("../common/variables.js");
22
+ var _variables = require("../common/variables");
23
23
 
24
24
  var _useTheme = _interopRequireDefault(require("../useTheme"));
25
25
 
@@ -60,7 +60,7 @@ var DxcCard = function DxcCard(_ref) {
60
60
  imageBgColor: imageBgColor
61
61
  }, /*#__PURE__*/_react["default"].createElement(TagImage, {
62
62
  imagePadding: imagePadding,
63
- cover: imageCover,
63
+ imageCover: imageCover,
64
64
  src: imageSrc
65
65
  }));
66
66
 
@@ -82,14 +82,13 @@ var DxcCard = function DxcCard(_ref) {
82
82
  }, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
83
83
  theme: colorsTheme.card
84
84
  }, /*#__PURE__*/_react["default"].createElement(CardContainer, {
85
- hasAction: onClick || linkHref,
86
- imagePosition: imagePosition
85
+ hasAction: onClick || linkHref
87
86
  }, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
88
87
  contentPadding: contentPadding
89
88
  }, children), imageSrc && imagePosition === "after" && imageComponent))));
90
89
  };
91
90
 
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) {
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) {
93
92
  var hasAction = _ref2.hasAction;
94
93
  return hasAction && "pointer" || "unset";
95
94
  }, function (_ref3) {
@@ -100,16 +99,16 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
100
99
  return margin && (0, _typeof2["default"])(margin) !== "object" ? _variables.spaces[margin] : "0px";
101
100
  }, function (_ref5) {
102
101
  var margin = _ref5.margin;
103
- return margin && margin.top ? _variables.spaces[margin.top] : "";
102
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.top ? _variables.spaces[margin.top] : "";
104
103
  }, function (_ref6) {
105
104
  var margin = _ref6.margin;
106
- return margin && margin.right ? _variables.spaces[margin.right] : "";
105
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.right ? _variables.spaces[margin.right] : "";
107
106
  }, function (_ref7) {
108
107
  var margin = _ref7.margin;
109
- return margin && margin.bottom ? _variables.spaces[margin.bottom] : "";
108
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.bottom ? _variables.spaces[margin.bottom] : "";
110
109
  }, function (_ref8) {
111
110
  var margin = _ref8.margin;
112
- return margin && margin.left ? _variables.spaces[margin.left] : "";
111
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
113
112
  }, function (_ref9) {
114
113
  var hasAction = _ref9.hasAction;
115
114
  return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
@@ -126,13 +125,13 @@ var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templ
126
125
 
127
126
  var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
128
127
  var imagePadding = _ref11.imagePadding;
129
- return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
128
+ return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
130
129
  }, function (_ref12) {
131
130
  var imagePadding = _ref12.imagePadding;
132
- return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
131
+ return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
133
132
  }, function (_ref13) {
134
- var cover = _ref13.cover;
135
- return cover ? "cover" : "contain";
133
+ var imageCover = _ref13.imageCover;
134
+ return imageCover ? "cover" : "contain";
136
135
  });
137
136
 
138
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) {
@@ -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,72 +37,72 @@ 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>
package/card/Card.test.js CHANGED
@@ -6,7 +6,7 @@ var _react = _interopRequireDefault(require("react"));
6
6
 
7
7
  var _react2 = require("@testing-library/react");
8
8
 
9
- var _Card = _interopRequireDefault(require("./Card"));
9
+ var _Card = _interopRequireDefault(require("./Card.tsx"));
10
10
 
11
11
  describe("Card component tests", function () {
12
12
  test("Card renders with correct content", function () {
@@ -19,9 +19,9 @@ var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
21
 
22
- var _variables = require("../common/variables.js");
22
+ var _variables = require("../common/variables");
23
23
 
24
- var _utils = require("../common/utils.js");
24
+ var _utils = require("../common/utils");
25
25
 
26
26
  var _uuid = require("uuid");
27
27
 
@@ -222,7 +222,7 @@ var Checkbox = _styledComponents["default"].span(_templateObject4 || (_templateO
222
222
  return props.disabled && "pointer-events: none;";
223
223
  });
224
224
 
225
- var MainContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n gap: ", ";\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n cursor: ", ";\n\n &:hover ", " {\n border: 2px solid\n ", ";\n background-color: ", ";\n color: ", ";\n }\n"])), function (props) {
225
+ var MainContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n gap: ", ";\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n\n &:hover ", " {\n border: 2px solid\n ", ";\n background-color: ", ";\n color: ", ";\n }\n"])), function (props) {
226
226
  return props.theme.checkLabelSpacing;
227
227
  }, function (props) {
228
228
  return calculateWidth(props.margin, props.size);
@@ -5,12 +5,21 @@ import Title from "../../.storybook/components/Title";
5
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
6
  import DarkContainer from "../../.storybook/components/DarkSection";
7
7
  import styled from "styled-components";
8
+ import { HalstackProvider } from "../HalstackContext";
8
9
 
9
10
  export default {
10
11
  title: "Checkbox",
11
12
  component: DxcCheckbox,
12
13
  };
13
14
 
15
+ const opinionatedTheme = {
16
+ checkbox: {
17
+ baseColor: "#0067b3",
18
+ checkColor: "#ffffff",
19
+ fontColor: "#000000",
20
+ },
21
+ };
22
+
14
23
  const Checkbox = () => (
15
24
  <>
16
25
  <ExampleContainer>
@@ -178,6 +187,49 @@ const Checkbox = () => (
178
187
  <DxcCheckbox label="Very long label to check its overflowing" labelPosition="after" />
179
188
  </SmallContainer>
180
189
  </ExampleContainer>
190
+ <Title title="Opinionated theme" theme="light" level={2} />
191
+ <ExampleContainer>
192
+ <Title title="Default" theme="light" level={4} />
193
+ <HalstackProvider theme={opinionatedTheme}>
194
+ <DxcCheckbox label="Checkbox" />
195
+ </HalstackProvider>
196
+ </ExampleContainer>
197
+ <ExampleContainer>
198
+ <Title title="Checked" theme="light" level={4} />
199
+ <HalstackProvider theme={opinionatedTheme}>
200
+ <DxcCheckbox label="Checkbox" defaultChecked />
201
+ </HalstackProvider>
202
+ </ExampleContainer>
203
+ <ExampleContainer>
204
+ <Title title="Disabled" theme="light" level={4} />
205
+ <HalstackProvider theme={opinionatedTheme}>
206
+ <DxcCheckbox label="Checkbox" disabled />
207
+ </HalstackProvider>
208
+ </ExampleContainer>
209
+ <ExampleContainer>
210
+ <Title title="Disabled checked" theme="light" level={4} />
211
+ <HalstackProvider theme={opinionatedTheme}>
212
+ <DxcCheckbox label="Checkbox" defaultChecked disabled />
213
+ </HalstackProvider>
214
+ </ExampleContainer>
215
+ <ExampleContainer pseudoState="pseudo-focus">
216
+ <Title title="Focused" theme="light" level={4} />
217
+ <HalstackProvider theme={opinionatedTheme}>
218
+ <DxcCheckbox label="Focused" />
219
+ </HalstackProvider>
220
+ </ExampleContainer>
221
+ <ExampleContainer pseudoState="pseudo-hover">
222
+ <Title title="Hovered" theme="light" level={4} />
223
+ <HalstackProvider theme={opinionatedTheme}>
224
+ <DxcCheckbox label="Hovered" />
225
+ </HalstackProvider>
226
+ </ExampleContainer>
227
+ <ExampleContainer pseudoState="pseudo-hover">
228
+ <Title title="Hovered and checked" theme="light" level={4} />
229
+ <HalstackProvider theme={opinionatedTheme}>
230
+ <DxcCheckbox label="Hovered" defaultChecked />
231
+ </HalstackProvider>
232
+ </ExampleContainer>
181
233
  </>
182
234
  );
183
235
 
@@ -8,7 +8,7 @@ var _react2 = require("@testing-library/react");
8
8
 
9
9
  var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
10
10
 
11
- var _Checkbox = _interopRequireDefault(require("./Checkbox"));
11
+ var _Checkbox = _interopRequireDefault(require("./Checkbox.tsx"));
12
12
 
13
13
  describe("Checkbox component tests", function () {
14
14
  test("Checkbox renders with correct aria-labelledby and aria-required", function () {
@@ -1,5 +1,5 @@
1
- export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
- export declare type Margin = {
1
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
+ declare type Margin = {
3
3
  top?: Space;
4
4
  bottom?: Space;
5
5
  left?: Space;
package/chip/Chip.js CHANGED
@@ -17,9 +17,9 @@ var _react = _interopRequireDefault(require("react"));
17
17
 
18
18
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
19
19
 
20
- var _variables = require("../common/variables.js");
20
+ var _variables = require("../common/variables");
21
21
 
22
- var _utils = require("../common/utils.js");
22
+ var _utils = require("../common/utils");
23
23
 
24
24
  var _useTheme = _interopRequireDefault(require("../useTheme"));
25
25
 
@@ -42,45 +42,42 @@ var DxcChip = function DxcChip(_ref) {
42
42
  var colorsTheme = (0, _useTheme["default"])();
43
43
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
44
44
  theme: colorsTheme.chip
45
- }, /*#__PURE__*/_react["default"].createElement(StyledDxcChip, {
45
+ }, /*#__PURE__*/_react["default"].createElement(Chip, {
46
46
  disabled: disabled,
47
47
  margin: margin
48
48
  }, prefixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
49
+ role: typeof onClickPrefix === "function" ? "button" : undefined,
49
50
  disabled: disabled,
50
- prefixIcon: true,
51
- label: label,
52
- mode: "prefix",
51
+ interactuable: typeof onClickPrefix === "function" && !disabled,
53
52
  tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
54
53
  onClick: function onClick() {
55
54
  return onClickPrefix && !disabled && onClickPrefix();
56
- },
57
- interactuable: typeof onClickPrefix === "function" && !disabled
55
+ }
58
56
  }, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
59
57
  src: prefixIcon
60
- }) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(ChipTextContainer, {
58
+ }) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
61
59
  disabled: disabled
62
60
  }, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
61
+ role: typeof onClickSuffix === "function" ? "button" : undefined,
63
62
  disabled: disabled,
64
- suffixIcon: true,
65
- mode: "suffix",
66
- label: label,
63
+ interactuable: typeof onClickSuffix === "function" && !disabled,
67
64
  tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
68
65
  onClick: function onClick() {
69
- return onClickSuffix && !disabled && onClickSuffix();
70
- },
71
- interactuable: typeof onClickSuffix === "function" && !disabled
66
+ return !disabled && (onClickSuffix === null || onClickSuffix === void 0 ? void 0 : onClickSuffix());
67
+ }
72
68
  }, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
73
69
  src: suffixIcon
74
70
  }) : suffixIcon)));
75
71
  };
76
72
 
77
- var getCursor = function getCursor(interactuable, disabled) {
78
- if (disabled) return "cursor: not-allowed;";else if (interactuable) return "cursor: pointer;";else return "cursor: default; outline:none;";
73
+ var calculateWidth = function calculateWidth(margin) {
74
+ return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
79
75
  };
80
76
 
81
- var StyledDxcChip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n"])), function (_ref2) {
82
- var margin = _ref2.margin;
83
- return "calc(100% - 40px - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
77
+ var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n"])), function (props) {
78
+ return props.theme.iconSpacing;
79
+ }, function (props) {
80
+ return calculateWidth(props.margin);
84
81
  }, function (props) {
85
82
  return props.disabled && props.theme.disabledBackgroundColor || props.theme.backgroundColor;
86
83
  }, function (props) {
@@ -109,12 +106,12 @@ var StyledDxcChip = _styledComponents["default"].div(_templateObject || (_templa
109
106
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
110
107
  }, function (props) {
111
108
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
112
- }, function (_ref3) {
113
- var disabled = _ref3.disabled;
109
+ }, function (_ref2) {
110
+ var disabled = _ref2.disabled;
114
111
  return disabled && "not-allowed";
115
112
  });
116
113
 
117
- var ChipTextContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-weight: ", ";\n font-style: ", ";\n color: ", ";\n cursor: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n"])), function (props) {
114
+ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-weight: ", ";\n font-style: ", ";\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n"])), function (props) {
118
115
  return props.theme.fontSize;
119
116
  }, function (props) {
120
117
  return props.theme.fontFamily;
@@ -124,21 +121,15 @@ var ChipTextContainer = _styledComponents["default"].span(_templateObject2 || (_
124
121
  return props.theme.fontStyle;
125
122
  }, function (props) {
126
123
  return props.disabled ? props.theme.disabledFontColor : props.theme.fontColor;
127
- }, function (_ref4) {
128
- var disabled = _ref4.disabled;
129
- return disabled && "not-allowed" || "default";
130
124
  });
131
125
 
132
- var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n ", "\n color: ", ";\n ", "\n\n &:focus {\n outline-color: ", ";\n outline-width: 2px;\n ", "\n }\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
133
- return props.prefixIcon ? "margin-right: ".concat((props.label || props.suffixIcon) && props.theme.iconSpacing || props.prefixIcon && "0", ";") : "margin-left: ".concat((props.label || props.prefixIcon) && props.theme.iconSpacing || props.prefixIcon && "0", ";");
134
- }, function (props) {
126
+ var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n ", "\n\n ", "\n\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
135
127
  return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
128
+ }, function (_ref3) {
129
+ var interactuable = _ref3.interactuable;
130
+ return interactuable && "cursor: pointer;";
136
131
  }, function (props) {
137
- return getCursor(props.interactuable, props.disabled);
138
- }, function (props) {
139
- return props.theme.focusColor;
140
- }, function (props) {
141
- return props.disabled && "outline: none;";
132
+ return props.interactuable && "\n &:hover {\n color: ".concat(props.theme.hoverIconColor, ";\n }\n &:focus,\n &:focus-visible {\n outline: ").concat(props.theme.focusBorderThickness, " solid ").concat(props.theme.focusColor, ";\n }\n &:active {\n color: ").concat(props.theme.activeIconColor, ";\n }\n ");
142
133
  }, function (props) {
143
134
  return props.theme.iconSize;
144
135
  }, function (props) {