@dxc-technology/halstack-react 0.0.0-ee92231 → 0.0.0-f0d662d

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 (203) hide show
  1. package/BackgroundColorContext.d.ts +10 -0
  2. package/BackgroundColorContext.js +1 -4
  3. package/ThemeContext.d.ts +15 -0
  4. package/ThemeContext.js +5 -8
  5. package/V3Select/V3Select.js +2 -2
  6. package/V3Textarea/V3Textarea.js +2 -2
  7. package/accordion/Accordion.js +2 -2
  8. package/accordion/Accordion.stories.tsx +307 -0
  9. package/accordion/types.d.ts +1 -1
  10. package/accordion-group/AccordionGroup.js +2 -2
  11. package/accordion-group/AccordionGroup.stories.tsx +225 -0
  12. package/accordion-group/types.d.ts +1 -1
  13. package/alert/Alert.js +2 -2
  14. package/alert/Alert.stories.tsx +170 -0
  15. package/alert/types.d.ts +1 -1
  16. package/badge/Badge.js +1 -1
  17. package/bleed/Bleed.d.ts +3 -0
  18. package/bleed/Bleed.js +84 -0
  19. package/bleed/Bleed.stories.tsx +342 -0
  20. package/bleed/types.d.ts +13 -0
  21. package/bleed/types.js +5 -0
  22. package/box/Box.d.ts +1 -1
  23. package/box/Box.js +4 -7
  24. package/box/types.d.ts +0 -4
  25. package/button/Button.d.ts +1 -1
  26. package/button/Button.js +13 -19
  27. package/button/Button.stories.tsx +222 -241
  28. package/button/types.d.ts +5 -9
  29. package/card/Card.js +5 -6
  30. package/card/Card.stories.tsx +201 -0
  31. package/card/ice-cream.jpg +0 -0
  32. package/card/types.d.ts +4 -6
  33. package/checkbox/Checkbox.js +2 -2
  34. package/checkbox/types.d.ts +2 -2
  35. package/chip/Chip.d.ts +4 -0
  36. package/chip/Chip.js +5 -27
  37. package/chip/Chip.stories.tsx +121 -0
  38. package/chip/types.d.ts +53 -0
  39. package/chip/types.js +5 -0
  40. package/common/variables.js +70 -27
  41. package/date/Date.js +1 -1
  42. package/date-input/DateInput.js +10 -13
  43. package/date-input/DateInput.stories.tsx +138 -0
  44. package/dialog/Dialog.js +4 -3
  45. package/dialog/Dialog.stories.tsx +212 -0
  46. package/dropdown/Dropdown.js +1 -1
  47. package/dropdown/Dropdown.stories.tsx +247 -0
  48. package/dropdown/types.d.ts +1 -1
  49. package/file-input/FileInput.d.ts +4 -0
  50. package/file-input/FileInput.js +167 -109
  51. package/file-input/FileInput.stories.tsx +507 -0
  52. package/file-input/FileItem.d.ts +14 -0
  53. package/file-input/FileItem.js +12 -21
  54. package/file-input/types.d.ts +112 -0
  55. package/file-input/types.js +5 -0
  56. package/footer/Footer.d.ts +1 -1
  57. package/footer/Footer.js +28 -36
  58. package/footer/{Footer.stories.jsx → Footer.stories.tsx} +1 -22
  59. package/footer/Icons.d.ts +2 -0
  60. package/footer/Icons.js +3 -3
  61. package/footer/types.d.ts +22 -18
  62. package/header/Header.js +2 -2
  63. package/header/Header.stories.tsx +162 -0
  64. package/header/Icons.d.ts +2 -0
  65. package/header/types.d.ts +4 -2
  66. package/heading/Heading.d.ts +4 -0
  67. package/heading/Heading.js +7 -24
  68. package/heading/Heading.stories.tsx +54 -0
  69. package/heading/types.d.ts +33 -0
  70. package/heading/types.js +5 -0
  71. package/input-text/InputText.js +2 -2
  72. package/inset/Inset.d.ts +3 -0
  73. package/inset/Inset.js +84 -0
  74. package/inset/Inset.stories.tsx +229 -0
  75. package/inset/types.d.ts +13 -0
  76. package/inset/types.js +5 -0
  77. package/layout/ApplicationLayout.d.ts +10 -0
  78. package/layout/ApplicationLayout.js +9 -19
  79. package/layout/ApplicationLayout.stories.tsx +171 -0
  80. package/layout/types.d.ts +57 -0
  81. package/layout/types.js +5 -0
  82. package/link/Link.js +3 -3
  83. package/link/Link.stories.tsx +146 -0
  84. package/list/List.d.ts +4 -0
  85. package/list/List.js +47 -0
  86. package/list/List.stories.tsx +95 -0
  87. package/list/types.d.ts +7 -0
  88. package/list/types.js +5 -0
  89. package/main.d.ts +7 -3
  90. package/main.js +34 -2
  91. package/number-input/NumberInput.d.ts +4 -0
  92. package/number-input/NumberInput.js +5 -50
  93. package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +0 -0
  94. package/number-input/NumberInputContext.d.ts +4 -0
  95. package/number-input/NumberInputContext.js +5 -2
  96. package/number-input/numberInputContextTypes.d.ts +19 -0
  97. package/number-input/numberInputContextTypes.js +5 -0
  98. package/number-input/types.d.ts +117 -0
  99. package/number-input/types.js +5 -0
  100. package/package.json +4 -2
  101. package/paginator/Paginator.js +2 -8
  102. package/password-input/PasswordInput.js +19 -18
  103. package/password-input/PasswordInput.stories.tsx +3 -3
  104. package/password-input/types.d.ts +17 -10
  105. package/progress-bar/ProgressBar.js +4 -4
  106. package/radio/Radio.js +2 -2
  107. package/radio/types.d.ts +2 -2
  108. package/radio-group/Radio.d.ts +4 -0
  109. package/radio-group/Radio.js +140 -0
  110. package/radio-group/RadioGroup.d.ts +4 -0
  111. package/radio-group/RadioGroup.js +273 -0
  112. package/radio-group/RadioGroup.stories.tsx +79 -0
  113. package/radio-group/RadioGroup.test.js +248 -0
  114. package/radio-group/types.d.ts +36 -0
  115. package/radio-group/types.js +5 -0
  116. package/resultsetTable/ResultsetTable.d.ts +4 -0
  117. package/resultsetTable/ResultsetTable.js +5 -28
  118. package/resultsetTable/ResultsetTable.stories.tsx +275 -0
  119. package/resultsetTable/types.d.ts +67 -0
  120. package/resultsetTable/types.js +5 -0
  121. package/row/Row.d.ts +3 -0
  122. package/row/Row.js +127 -0
  123. package/row/Row.stories.tsx +237 -0
  124. package/row/types.d.ts +10 -0
  125. package/row/types.js +5 -0
  126. package/select/Select.d.ts +4 -0
  127. package/select/Select.js +20 -22
  128. package/select/Select.stories.tsx +572 -0
  129. package/select/types.d.ts +170 -0
  130. package/select/types.js +5 -0
  131. package/sidenav/Sidenav.d.ts +9 -0
  132. package/sidenav/Sidenav.js +6 -15
  133. package/sidenav/Sidenav.stories.tsx +182 -0
  134. package/sidenav/types.d.ts +50 -0
  135. package/sidenav/types.js +5 -0
  136. package/slider/Slider.d.ts +1 -1
  137. package/slider/Slider.js +43 -32
  138. package/slider/Slider.stories.tsx +177 -0
  139. package/slider/types.d.ts +2 -7
  140. package/spinner/Spinner.js +2 -2
  141. package/spinner/Spinner.stories.jsx +1 -0
  142. package/stack/Stack.d.ts +3 -0
  143. package/stack/Stack.js +97 -0
  144. package/stack/Stack.stories.tsx +164 -0
  145. package/stack/types.d.ts +9 -0
  146. package/stack/types.js +5 -0
  147. package/switch/Switch.js +2 -2
  148. package/switch/Switch.stories.tsx +1 -1
  149. package/table/Table.js +3 -3
  150. package/table/Table.stories.jsx +2 -1
  151. package/tabs/Tabs.js +11 -9
  152. package/tabs/Tabs.stories.tsx +120 -0
  153. package/tabs/types.d.ts +25 -18
  154. package/tag/Tag.d.ts +4 -0
  155. package/tag/Tag.js +4 -25
  156. package/tag/{Tag.stories.jsx → Tag.stories.tsx} +1 -1
  157. package/tag/types.d.ts +60 -0
  158. package/tag/types.js +5 -0
  159. package/text/Text.d.ts +7 -0
  160. package/text/Text.js +30 -0
  161. package/text/Text.stories.tsx +19 -0
  162. package/text-input/TextInput.d.ts +4 -0
  163. package/text-input/TextInput.js +54 -85
  164. package/text-input/TextInput.stories.tsx +456 -0
  165. package/text-input/types.d.ts +159 -0
  166. package/text-input/types.js +5 -0
  167. package/textarea/Textarea.d.ts +4 -0
  168. package/textarea/Textarea.js +27 -60
  169. package/textarea/Textarea.stories.jsx +4 -3
  170. package/textarea/types.d.ts +130 -0
  171. package/textarea/types.js +5 -0
  172. package/toggle/Toggle.js +1 -1
  173. package/toggle-group/ToggleGroup.d.ts +4 -0
  174. package/toggle-group/ToggleGroup.js +16 -45
  175. package/toggle-group/ToggleGroup.stories.tsx +173 -0
  176. package/toggle-group/types.d.ts +97 -0
  177. package/toggle-group/types.js +5 -0
  178. package/upload/buttons-upload/ButtonsUpload.js +2 -2
  179. package/upload/dragAndDropArea/DragAndDropArea.js +2 -2
  180. package/upload/file-upload/FileToUpload.js +1 -1
  181. package/upload/files-upload/FilesToUpload.js +1 -1
  182. package/upload/transaction/Transaction.js +2 -2
  183. package/upload/transactions/Transactions.js +1 -1
  184. package/useTheme.d.ts +2 -0
  185. package/useTheme.js +1 -1
  186. package/wizard/Wizard.d.ts +4 -0
  187. package/wizard/Wizard.js +69 -59
  188. package/wizard/Wizard.stories.tsx +224 -0
  189. package/wizard/types.d.ts +60 -0
  190. package/wizard/types.js +5 -0
  191. package/chip/index.d.ts +0 -22
  192. package/file-input/index.d.ts +0 -81
  193. package/heading/index.d.ts +0 -17
  194. package/number-input/index.d.ts +0 -113
  195. package/resultsetTable/index.d.ts +0 -19
  196. package/select/index.d.ts +0 -131
  197. package/sidenav/index.d.ts +0 -13
  198. package/tag/index.d.ts +0 -24
  199. package/text-input/index.d.ts +0 -135
  200. package/textarea/index.d.ts +0 -117
  201. package/toggle-group/index.d.ts +0 -21
  202. package/wizard/Icons.js +0 -65
  203. package/wizard/index.d.ts +0 -18
@@ -0,0 +1,201 @@
1
+ import React from "react";
2
+ import Title from "../../.storybook/components/Title";
3
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
4
+ import DxcCard from "./Card";
5
+ import imagePath from "./ice-cream.jpg";
6
+ import { userEvent, within } from "@storybook/testing-library";
7
+
8
+ export default {
9
+ title: "Card",
10
+ component: DxcCard,
11
+ };
12
+
13
+ const Card = () => (
14
+ <>
15
+ <Title title="Default" theme="light" level={4} />
16
+ <ExampleContainer>
17
+ <DxcCard>Default</DxcCard>
18
+ </ExampleContainer>
19
+ <Title title="Not outlined" theme="light" level={4} />
20
+ <ExampleContainer>
21
+ <DxcCard outlined={false}>Not outlined</DxcCard>
22
+ </ExampleContainer>
23
+ <Title title="Default with link" theme="light" level={4} />
24
+ <ExampleContainer>
25
+ <DxcCard linkHref="https://www.dxc.com">Default with link</DxcCard>
26
+ </ExampleContainer>
27
+ <Title title="Focused default with link" theme="light" level={4} />
28
+ <ExampleContainer>
29
+ <DxcCard linkHref="https://www.dxc.com">Focused default with link</DxcCard>
30
+ </ExampleContainer>
31
+ <Title title="Hovered default with link" theme="light" level={4} />
32
+ <ExampleContainer>
33
+ <DxcCard linkHref="https://www.dxc.com">Hovered default with link</DxcCard>
34
+ </ExampleContainer>
35
+ <Title title="Default with action" theme="light" level={4} />
36
+ <ExampleContainer>
37
+ <DxcCard onClick={() => {}}>Default with action</DxcCard>
38
+ </ExampleContainer>
39
+ <Title title="Default with image" theme="light" level={4} />
40
+ <ExampleContainer>
41
+ <DxcCard imageSrc={imagePath}>Default</DxcCard>
42
+ </ExampleContainer>
43
+ <Title title="Default image with background color" theme="light" level={4} />
44
+ <ExampleContainer>
45
+ <DxcCard imageSrc={imagePath} imageBgColor="yellow">
46
+ Background color
47
+ </DxcCard>
48
+ </ExampleContainer>
49
+ <Title title="Default image with position after" theme="light" level={4} />
50
+ <ExampleContainer>
51
+ <DxcCard imageSrc={imagePath} imagePosition="after">
52
+ Position after
53
+ </DxcCard>
54
+ </ExampleContainer>
55
+ <Title title="Image cover" theme="light" level={4} />
56
+ <ExampleContainer>
57
+ <DxcCard imageSrc={imagePath} imageCover>
58
+ Image cover
59
+ </DxcCard>
60
+ </ExampleContainer>
61
+ <Title title="Image cover with position after" theme="light" level={4} />
62
+ <ExampleContainer>
63
+ <DxcCard imageSrc={imagePath} imageCover imagePosition="after">
64
+ Image cover with position after
65
+ </DxcCard>
66
+ </ExampleContainer>
67
+ <Title title="Image padding" theme="light" level={2} />
68
+ <ExampleContainer>
69
+ <Title title="Xxsmall" theme="light" level={4} />
70
+ <DxcCard imageSrc={imagePath} imagePadding="xxsmall" imageCover>
71
+ Xxsmall
72
+ </DxcCard>
73
+ </ExampleContainer>
74
+ <ExampleContainer>
75
+ <Title title="Xsmall" theme="light" level={4} />
76
+ <DxcCard imageSrc={imagePath} imagePadding="xsmall" imageCover>
77
+ Xsmall
78
+ </DxcCard>
79
+ </ExampleContainer>
80
+ <ExampleContainer>
81
+ <Title title="Small" theme="light" level={4} />
82
+ <DxcCard imageSrc={imagePath} imagePadding="small" imageCover>
83
+ Small
84
+ </DxcCard>
85
+ </ExampleContainer>
86
+ <ExampleContainer>
87
+ <Title title="Medium" theme="light" level={4} />
88
+ <DxcCard imageSrc={imagePath} imagePadding="medium" imageCover>
89
+ Medium
90
+ </DxcCard>
91
+ </ExampleContainer>
92
+ <ExampleContainer>
93
+ <Title title="Large" theme="light" level={4} />
94
+ <DxcCard imageSrc={imagePath} imagePadding="large" imageCover>
95
+ Large
96
+ </DxcCard>
97
+ </ExampleContainer>
98
+ <ExampleContainer>
99
+ <Title title="Xlarge" theme="light" level={4} />
100
+ <DxcCard imageSrc={imagePath} imagePadding="xlarge" imageCover>
101
+ Xlarge
102
+ </DxcCard>
103
+ </ExampleContainer>
104
+ <ExampleContainer>
105
+ <Title title="Xxlarge" theme="light" level={4} />
106
+ <DxcCard imageSrc={imagePath} imagePadding="xxlarge" imageCover>
107
+ Xxlarge
108
+ </DxcCard>
109
+ </ExampleContainer>
110
+ <Title title="Content padding" theme="light" level={2} />
111
+ <ExampleContainer>
112
+ <Title title="Xxsmall" theme="light" level={4} />
113
+ <DxcCard contentPadding="xxsmall">Xxsmall</DxcCard>
114
+ </ExampleContainer>
115
+ <ExampleContainer>
116
+ <Title title="Xsmall" theme="light" level={4} />
117
+ <DxcCard contentPadding="xsmall">Xsmall</DxcCard>
118
+ </ExampleContainer>
119
+ <ExampleContainer>
120
+ <Title title="Small" theme="light" level={4} />
121
+ <DxcCard contentPadding="small">Small</DxcCard>
122
+ </ExampleContainer>
123
+ <ExampleContainer>
124
+ <Title title="Medium" theme="light" level={4} />
125
+ <DxcCard contentPadding="medium">Medium</DxcCard>
126
+ </ExampleContainer>
127
+ <ExampleContainer>
128
+ <Title title="Large" theme="light" level={4} />
129
+ <DxcCard contentPadding="large">Large</DxcCard>
130
+ </ExampleContainer>
131
+ <ExampleContainer>
132
+ <Title title="Xlarge" theme="light" level={4} />
133
+ <DxcCard contentPadding="xlarge">Xlarge</DxcCard>
134
+ </ExampleContainer>
135
+ <ExampleContainer>
136
+ <Title title="Xxlarge" theme="light" level={4} />
137
+ <DxcCard contentPadding="xxlarge">Xxlarge</DxcCard>
138
+ </ExampleContainer>
139
+ <Title title="Margin" theme="light" level={2} />
140
+ <ExampleContainer>
141
+ <Title title="Xxsmall" theme="light" level={4} />
142
+ <DxcCard margin="xxsmall">Xxsmall</DxcCard>
143
+ </ExampleContainer>
144
+ <ExampleContainer>
145
+ <Title title="Xsmall" theme="light" level={4} />
146
+ <DxcCard margin="xsmall">Xsmall</DxcCard>
147
+ </ExampleContainer>
148
+ <ExampleContainer>
149
+ <Title title="Small" theme="light" level={4} />
150
+ <DxcCard margin="small">Small</DxcCard>
151
+ </ExampleContainer>
152
+ <ExampleContainer>
153
+ <Title title="Medium" theme="light" level={4} />
154
+ <DxcCard margin="medium">Medium</DxcCard>
155
+ </ExampleContainer>
156
+ <ExampleContainer>
157
+ <Title title="Large" theme="light" level={4} />
158
+ <DxcCard margin="large">Large</DxcCard>
159
+ </ExampleContainer>
160
+ <ExampleContainer>
161
+ <Title title="Xlarge" theme="light" level={4} />
162
+ <DxcCard margin="xlarge">Xlarge</DxcCard>
163
+ </ExampleContainer>
164
+ <ExampleContainer>
165
+ <Title title="Xxlarge" theme="light" level={4} />
166
+ <DxcCard margin="xxlarge">Xxlarge</DxcCard>
167
+ </ExampleContainer>
168
+ </>
169
+ );
170
+
171
+ const actionCard = () => (
172
+ <>
173
+ <ExampleContainer>
174
+ <Title title="Focused default with action" theme="light" level={4} />
175
+ <DxcCard onClick={() => {}}>Focused default with action</DxcCard>
176
+ </ExampleContainer>
177
+ <ExampleContainer expanded>
178
+ <Title title="Hovered default with action" theme="light" level={4} />
179
+ <DxcCard onClick={() => {}}>Hovered default with action</DxcCard>
180
+ </ExampleContainer>
181
+ </>
182
+ );
183
+
184
+ const linkStates = async (focusCard, hoverCard) => {
185
+ await focusCard.focus();
186
+ await userEvent.hover(hoverCard);
187
+ };
188
+
189
+ export const ActionCardStates = actionCard.bind({});
190
+ ActionCardStates.play = async ({ canvasElement }) => {
191
+ const canvas = within(canvasElement);
192
+ await userEvent.tab();
193
+ await userEvent.hover(canvas.getAllByText("Hovered default with action")[1]);
194
+ };
195
+
196
+ export const Chromatic = Card.bind({});
197
+ Chromatic.play = async ({ canvasElement }) => {
198
+ const canvas = within(canvasElement);
199
+ const linkCards = canvas.getAllByRole("link");
200
+ await linkStates(linkCards[1], linkCards[2]);
201
+ };
Binary file
package/card/types.d.ts CHANGED
@@ -42,15 +42,13 @@ declare type Props = {
42
42
  */
43
43
  imageCover?: boolean;
44
44
  /**
45
- * Size of the margin to be applied to the component. You can pass
46
- * an object with 'top', 'bottom', 'left' and 'right' properties
47
- * in order to specify different margin sizes.
45
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
46
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
48
47
  */
49
48
  margin?: Space | Size;
50
49
  /**
51
- * Size of the padding to be applied to the content area. You can pass
52
- * an object with 'top', 'bottom', 'left' and 'right' properties in
53
- * order to specify different padding sizes.
50
+ * Size of the padding to be applied to the content area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
51
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
54
52
  */
55
53
  contentPadding?: Space | Size;
56
54
  /**
@@ -27,9 +27,9 @@ var _variables = require("../common/variables.js");
27
27
 
28
28
  var _utils = require("../common/utils.js");
29
29
 
30
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
30
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
31
31
 
32
- var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
32
+ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
33
33
 
34
34
  var _templateObject, _templateObject2, _templateObject3;
35
35
 
@@ -19,7 +19,7 @@ declare type Props = {
19
19
  /**
20
20
  * Text to be placed next to the checkbox.
21
21
  */
22
- label: string;
22
+ label?: string;
23
23
  /**
24
24
  * Whether the label should appear after or before the checkbox.
25
25
  */
@@ -49,7 +49,7 @@ declare type Props = {
49
49
  */
50
50
  margin?: Space | Margin;
51
51
  /**
52
- * Size of the component ('small' | 'medium' | 'large' | 'fillParent' | 'fitContent').
52
+ * Size of the component.
53
53
  */
54
54
  size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
55
55
  /**
package/chip/Chip.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import ChipPropsType from "./types";
3
+ declare const DxcChip: ({ label, suffixIcon, prefixIcon, suffixIconSrc, onClickSuffix, prefixIconSrc, onClickPrefix, disabled, margin, tabIndex, }: ChipPropsType) => JSX.Element;
4
+ export default DxcChip;
package/chip/Chip.js CHANGED
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
13
 
16
14
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
@@ -19,13 +17,11 @@ var _react = _interopRequireDefault(require("react"));
19
17
 
20
18
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
19
 
22
- var _propTypes = _interopRequireDefault(require("prop-types"));
23
-
24
20
  var _variables = require("../common/variables.js");
25
21
 
26
22
  var _utils = require("../common/utils.js");
27
23
 
28
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
24
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
29
25
 
30
26
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
31
27
 
@@ -58,7 +54,7 @@ var DxcChip = function DxcChip(_ref) {
58
54
  mode: "prefix",
59
55
  tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
60
56
  onClick: function onClick() {
61
- return onClickPrefix && !disabled && onClickPrefix(label);
57
+ return onClickPrefix && !disabled && onClickPrefix();
62
58
  },
63
59
  interactuable: typeof onClickPrefix === "function" && !disabled
64
60
  }, (0, _typeof2["default"])(prefixIcon) === "object" ? prefixIcon : /*#__PURE__*/_react["default"].createElement(prefixIcon)) : prefixIconSrc && /*#__PURE__*/_react["default"].createElement(PrefixIconContainer, {
@@ -67,7 +63,7 @@ var DxcChip = function DxcChip(_ref) {
67
63
  label: label,
68
64
  tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
69
65
  onClick: function onClick() {
70
- return onClickPrefix && !disabled && onClickPrefix(label);
66
+ return onClickPrefix && !disabled && onClickPrefix();
71
67
  },
72
68
  interactuable: typeof onClickPrefix === "function" && !disabled
73
69
  }), label && /*#__PURE__*/_react["default"].createElement(ChipTextContainer, {
@@ -81,7 +77,7 @@ var DxcChip = function DxcChip(_ref) {
81
77
  label: label,
82
78
  tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
83
79
  onClick: function onClick() {
84
- return onClickSuffix && !disabled && onClickSuffix(label);
80
+ return onClickSuffix && !disabled && onClickSuffix();
85
81
  },
86
82
  interactuable: typeof onClickSuffix === "function" && !disabled
87
83
  }, (0, _typeof2["default"])(suffixIcon) === "object" ? suffixIcon : /*#__PURE__*/_react["default"].createElement(suffixIcon)) : suffixIconSrc && /*#__PURE__*/_react["default"].createElement(SuffixIconContainer, {
@@ -90,7 +86,7 @@ var DxcChip = function DxcChip(_ref) {
90
86
  label: label,
91
87
  tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
92
88
  onClick: function onClick() {
93
- return onClickSuffix && !disabled && onClickSuffix(label);
89
+ return onClickSuffix && !disabled && onClickSuffix();
94
90
  },
95
91
  interactuable: typeof onClickSuffix === "function" && !disabled
96
92
  })));
@@ -199,23 +195,5 @@ var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templ
199
195
  return props.disabled && "outline: none;";
200
196
  });
201
197
 
202
- DxcChip.propTypes = {
203
- label: _propTypes["default"].string,
204
- disabled: _propTypes["default"].bool,
205
- theme: _propTypes["default"].oneOf(["dark", "light"]),
206
- suffixIcon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
207
- prefixIcon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
208
- suffixIconSrc: _propTypes["default"].string,
209
- prefixIconSrc: _propTypes["default"].string,
210
- onClickSuffix: _propTypes["default"].func,
211
- onClickPrefix: _propTypes["default"].func,
212
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
213
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
214
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
215
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
216
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
217
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
218
- tabIndex: _propTypes["default"].number
219
- };
220
198
  var _default = DxcChip;
221
199
  exports["default"] = _default;
@@ -0,0 +1,121 @@
1
+ import React from "react";
2
+ import { userEvent, within } from "@storybook/testing-library";
3
+ import DxcChip from "./Chip";
4
+ import Title from "../../.storybook/components/Title";
5
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
+
7
+ export default {
8
+ title: "Chip",
9
+ component: DxcChip,
10
+ };
11
+
12
+ const iconSVG = () => {
13
+ return (
14
+ <svg viewBox="0 0 24 24" fill="currentColor">
15
+ <path d="M0 0h24v24H0z" fill="none" />
16
+ <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" />
17
+ </svg>
18
+ );
19
+ };
20
+
21
+ export const Chromatic = () => (
22
+ <>
23
+ <ExampleContainer>
24
+ <Title title="Basic chip" theme="light" level={4} />
25
+ <DxcChip label="Default Chip" />
26
+ </ExampleContainer>
27
+ <ExampleContainer>
28
+ <Title title="Chip with prefix" theme="light" level={4} />
29
+ <DxcChip label="Chip with prefix" prefixIcon={iconSVG} />
30
+ </ExampleContainer>
31
+ <ExampleContainer>
32
+ <Title title="Chip with suffix" theme="light" level={4} />
33
+ <DxcChip label="Chip with suffix" suffixIcon={iconSVG} />
34
+ </ExampleContainer>
35
+ <ExampleContainer>
36
+ <Title title="Chip with prefix and suffix" theme="light" level={4} />
37
+ <DxcChip label="Chip with prefix and suffix" prefixIcon={iconSVG} suffixIcon={iconSVG} />
38
+ </ExampleContainer>
39
+ <ExampleContainer>
40
+ <Title title="Disabled chip" theme="light" level={4} />
41
+ <DxcChip label="Disabled" disabled prefixIcon={iconSVG} suffixIcon={iconSVG} />
42
+ </ExampleContainer>
43
+ <ExampleContainer>
44
+ <Title title="Chip with ellipsis" theme="light" level={4} />
45
+ <DxcChip label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fg ssssssssssss ssss" />
46
+ </ExampleContainer>
47
+ <ExampleContainer>
48
+ <Title title="Chip with ellipsis and suffix" theme="light" level={4} />
49
+ <DxcChip
50
+ suffixIcon={iconSVG}
51
+ label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fgsss"
52
+ />
53
+ </ExampleContainer>
54
+ <ExampleContainer>
55
+ <Title title="Chip with ellipsis and prefix" theme="light" level={4} />
56
+ <DxcChip
57
+ prefixIcon={iconSVG}
58
+ label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fgsss"
59
+ />
60
+ </ExampleContainer>
61
+ <ExampleContainer>
62
+ <Title title="Chip with ellipsis, suffix and prefix" theme="light" level={4} />
63
+ <DxcChip
64
+ prefixIcon={iconSVG}
65
+ suffixIcon={iconSVG}
66
+ label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasdf"
67
+ />
68
+ </ExampleContainer>
69
+ <Title title="Margins" theme="light" level={2} />
70
+ <ExampleContainer>
71
+ <Title title="Xxsmall margin" theme="light" level={4} />
72
+ <DxcChip label="xxsmall" margin="xxsmall" />
73
+ </ExampleContainer>
74
+ <ExampleContainer>
75
+ <Title title="Xsmall margin" theme="light" level={4} />
76
+ <DxcChip label="xsmall" margin="xsmall" />
77
+ </ExampleContainer>
78
+ <ExampleContainer>
79
+ <Title title="Small margin" theme="light" level={4} />
80
+ <DxcChip label="small" margin="small" />
81
+ </ExampleContainer>
82
+ <ExampleContainer>
83
+ <Title title="Medium margin" theme="light" level={4} />
84
+ <DxcChip label="medium" margin="medium" />
85
+ </ExampleContainer>
86
+ <ExampleContainer>
87
+ <Title title="Large margin" theme="light" level={4} />
88
+ <DxcChip label="large" margin="large" />
89
+ </ExampleContainer>
90
+ <ExampleContainer>
91
+ <Title title="Xlarge margin" theme="light" level={4} />
92
+ <DxcChip label="xlarge" margin="xlarge" />
93
+ </ExampleContainer>
94
+ <ExampleContainer>
95
+ <Title title="Xxlarge margin" theme="light" level={4} />
96
+ <DxcChip label="xxlarge" margin="xxlarge" />
97
+ </ExampleContainer>
98
+ </>
99
+ );
100
+ const ChipPrefixFocused = () => (
101
+ <ExampleContainer>
102
+ <Title title="Chip with prefix" theme="light" level={4} />
103
+ <DxcChip label="Chip with prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
104
+ </ExampleContainer>
105
+ );
106
+ const ChipSuffixFocused = () => (
107
+ <ExampleContainer>
108
+ <Title title="Chip with suffix" theme="light" level={4} />
109
+ <DxcChip label="Chip with suffix" suffixIcon={iconSVG} onClickSuffix={() => {}} />
110
+ </ExampleContainer>
111
+ );
112
+
113
+ export const PrefixFocused = ChipPrefixFocused.bind({});
114
+ PrefixFocused.play = async ({ canvasElement }) => {
115
+ await userEvent.tab();
116
+ };
117
+
118
+ export const SuffixFocused = ChipSuffixFocused.bind({});
119
+ SuffixFocused.play = async ({ canvasElement }) => {
120
+ await userEvent.tab();
121
+ };
@@ -0,0 +1,53 @@
1
+ /// <reference types="react" />
2
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ declare type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
10
+ declare type Props = {
11
+ /**
12
+ * Text to be placed on the chip.
13
+ */
14
+ label?: string;
15
+ /**
16
+ * Element used as icon to be placed after the chip label.
17
+ */
18
+ suffixIcon?: SVG;
19
+ /**
20
+ * Element used as icon to be placed before the chip label.
21
+ */
22
+ prefixIcon?: SVG;
23
+ /**
24
+ * @deprecated Path of the icon to be placed after the chip label.
25
+ */
26
+ suffixIconSrc?: string;
27
+ /**
28
+ * This function will be called when the suffix is clicked.
29
+ */
30
+ onClickSuffix?: () => void;
31
+ /**
32
+ * @deprecated Path of the icon to be placed before the chip label.
33
+ */
34
+ prefixIconSrc?: string;
35
+ /**
36
+ * This function will be called when the prefix is clicked.
37
+ */
38
+ onClickPrefix?: () => void;
39
+ /**
40
+ * If true, the component will be disabled.
41
+ */
42
+ disabled?: boolean;
43
+ /**
44
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
45
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
46
+ */
47
+ margin?: Space | Margin;
48
+ /**
49
+ * Value of the tabindex attribute.
50
+ */
51
+ tabIndex?: number;
52
+ };
53
+ export default Props;
package/chip/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });