@dxc-technology/halstack-react 0.0.0-4a5e7d8 → 0.0.0-4b95ba0

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 (120) hide show
  1. package/BackgroundColorContext.js +0 -1
  2. package/ThemeContext.js +23 -31
  3. package/accordion/Accordion.d.ts +1 -1
  4. package/accordion/Accordion.js +9 -20
  5. package/accordion/Accordion.stories.tsx +9 -2
  6. package/accordion/types.d.ts +3 -7
  7. package/accordion-group/types.d.ts +3 -7
  8. package/badge/Badge.d.ts +4 -0
  9. package/badge/types.d.ts +4 -0
  10. package/badge/types.js +5 -0
  11. package/bleed/Bleed.d.ts +3 -0
  12. package/bleed/Bleed.js +84 -0
  13. package/bleed/Bleed.stories.tsx +342 -0
  14. package/bleed/types.d.ts +13 -0
  15. package/bleed/types.js +5 -0
  16. package/button/Button.d.ts +1 -1
  17. package/button/Button.js +7 -15
  18. package/button/Button.stories.tsx +6 -8
  19. package/button/types.d.ts +3 -7
  20. package/card/Card.stories.tsx +1 -1
  21. package/checkbox/types.d.ts +1 -1
  22. package/chip/Chip.d.ts +1 -1
  23. package/chip/Chip.js +14 -52
  24. package/chip/Chip.stories.tsx +6 -8
  25. package/chip/types.d.ts +5 -13
  26. package/common/variables.js +38 -234
  27. package/date-input/DateInput.js +6 -6
  28. package/dialog/Dialog.js +2 -1
  29. package/dropdown/Dropdown.d.ts +1 -1
  30. package/dropdown/Dropdown.js +12 -34
  31. package/dropdown/Dropdown.stories.tsx +25 -23
  32. package/dropdown/types.d.ts +5 -14
  33. package/file-input/FileInput.js +102 -33
  34. package/file-input/FileInput.stories.tsx +507 -0
  35. package/footer/Footer.js +18 -20
  36. package/heading/Heading.stories.tsx +3 -2
  37. package/inset/Inset.d.ts +3 -0
  38. package/inset/Inset.js +84 -0
  39. package/inset/Inset.stories.tsx +229 -0
  40. package/inset/types.d.ts +13 -0
  41. package/inset/types.js +5 -0
  42. package/layout/ApplicationLayout.js +9 -3
  43. package/link/Link.js +7 -15
  44. package/link/Link.stories.tsx +6 -1
  45. package/link/types.d.ts +5 -9
  46. package/list/List.d.ts +3 -7
  47. package/list/List.js +4 -4
  48. package/list/List.stories.tsx +10 -0
  49. package/list/types.d.ts +7 -0
  50. package/list/types.js +5 -0
  51. package/main.d.ts +4 -6
  52. package/main.js +20 -36
  53. package/package.json +4 -2
  54. package/password-input/PasswordInput.stories.tsx +3 -3
  55. package/progress-bar/ProgressBar.js +2 -2
  56. package/radio-group/Radio.d.ts +4 -0
  57. package/radio-group/Radio.js +140 -0
  58. package/radio-group/RadioGroup.d.ts +4 -0
  59. package/radio-group/RadioGroup.js +273 -0
  60. package/radio-group/RadioGroup.stories.tsx +79 -0
  61. package/radio-group/RadioGroup.test.js +248 -0
  62. package/radio-group/types.d.ts +36 -0
  63. package/radio-group/types.js +5 -0
  64. package/resultsetTable/ResultsetTable.js +5 -2
  65. package/resultsetTable/ResultsetTable.stories.tsx +7 -8
  66. package/row/Row.d.ts +3 -11
  67. package/row/Row.js +12 -9
  68. package/row/Row.stories.tsx +20 -6
  69. package/row/types.d.ts +10 -0
  70. package/row/types.js +5 -0
  71. package/select/Select.d.ts +4 -0
  72. package/select/Select.js +12 -6
  73. package/select/types.d.ts +170 -0
  74. package/select/types.js +5 -0
  75. package/sidenav/Sidenav.stories.tsx +18 -1
  76. package/spinner/Spinner.stories.jsx +1 -0
  77. package/stack/Stack.d.ts +3 -10
  78. package/stack/Stack.js +12 -9
  79. package/stack/Stack.stories.tsx +20 -6
  80. package/stack/types.d.ts +9 -0
  81. package/stack/types.js +5 -0
  82. package/switch/Switch.stories.tsx +1 -1
  83. package/table/Table.stories.jsx +2 -1
  84. package/tabs/Tabs.js +7 -7
  85. package/tabs/Tabs.stories.tsx +7 -8
  86. package/tabs/types.d.ts +23 -15
  87. package/tag/Tag.d.ts +1 -1
  88. package/tag/Tag.js +6 -11
  89. package/tag/Tag.stories.tsx +15 -22
  90. package/tag/types.d.ts +23 -14
  91. package/text/Text.js +1 -1
  92. package/text-input/TextInput.js +17 -7
  93. package/text-input/TextInput.stories.tsx +4 -4
  94. package/text-input/types.d.ts +1 -1
  95. package/textarea/Textarea.js +5 -3
  96. package/textarea/Textarea.stories.jsx +4 -3
  97. package/V3Select/V3Select.js +0 -455
  98. package/V3Select/index.d.ts +0 -27
  99. package/V3Textarea/V3Textarea.js +0 -260
  100. package/V3Textarea/index.d.ts +0 -27
  101. package/date/Date.js +0 -373
  102. package/date/index.d.ts +0 -27
  103. package/input-text/Icons.js +0 -22
  104. package/input-text/InputText.js +0 -611
  105. package/input-text/index.d.ts +0 -36
  106. package/select/index.d.ts +0 -131
  107. package/toggle/Toggle.js +0 -186
  108. package/toggle/index.d.ts +0 -21
  109. package/upload/Upload.js +0 -201
  110. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  111. package/upload/buttons-upload/Icons.js +0 -40
  112. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  113. package/upload/dragAndDropArea/Icons.js +0 -39
  114. package/upload/file-upload/FileToUpload.js +0 -115
  115. package/upload/file-upload/Icons.js +0 -66
  116. package/upload/files-upload/FilesToUpload.js +0 -109
  117. package/upload/index.d.ts +0 -15
  118. package/upload/transaction/Icons.js +0 -160
  119. package/upload/transaction/Transaction.js +0 -104
  120. package/upload/transactions/Transactions.js +0 -94
@@ -0,0 +1,170 @@
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>;
10
+ declare type OptionGroup = {
11
+ /**
12
+ * Label of the group to be shown in the select's listbox.
13
+ */
14
+ label: string;
15
+ /**
16
+ * List of the grouped options.
17
+ */
18
+ options: Option[];
19
+ };
20
+ declare type Option = {
21
+ /**
22
+ * Element used as the icon that will be placed before the option label.
23
+ * It can be a url of an image or an inline SVG. If the url option
24
+ * is the chosen one, take into account that the component's
25
+ * color styling tokens will not be applied to the image.
26
+ */
27
+ icon?: string | SVG;
28
+ /**
29
+ * Label of the option to be shown in the select's listbox.
30
+ */
31
+ label: string;
32
+ /**
33
+ * Value of the option. It should be unique and
34
+ * not an empty string, which is reserved to the empty option added
35
+ * by optional prop.
36
+ */
37
+ value: string;
38
+ };
39
+ declare type CommonProps = {
40
+ /**
41
+ * Text to be placed above the select.
42
+ */
43
+ label?: string;
44
+ /**
45
+ * Name attribute of the input element. This attribute will allow users
46
+ * to find the component's value during the submit event. In this event,
47
+ * the component's value will always be a regular string, for both single
48
+ * and multiple selection modes, been in the first one a single option
49
+ * value and in the multiple variant more than one option value,
50
+ * separated by commas.
51
+ */
52
+ name?: string;
53
+ /**
54
+ * An array of objects representing the selectable options.
55
+ */
56
+ options?: Option[] | OptionGroup[];
57
+ /**
58
+ * Helper text to be placed above the select.
59
+ */
60
+ helperText?: string;
61
+ /**
62
+ * Text to be put as placeholder of the select.
63
+ */
64
+ placeholder?: string;
65
+ /**
66
+ * If true, the component will be disabled.
67
+ */
68
+ disabled?: boolean;
69
+ /**
70
+ * If true, the select will be optional, showing '(Optional)'
71
+ * next to the label and adding a default first option with an empty string as value,
72
+ * been the placeholder (if defined) its label. Otherwise, the field will be
73
+ * considered required and an error will be passed as a parameter to the
74
+ * OnBlur and onChange functions if an option wasn't selected.
75
+ */
76
+ optional?: boolean;
77
+ /**
78
+ * If true, enables search functionality.
79
+ */
80
+ searchable?: boolean;
81
+ /**
82
+ * If it is defined, the component will change its appearance, showing
83
+ * the error below the select component. If it is not defined, the error
84
+ * messages will be managed internally, but never displayed on its own.
85
+ */
86
+ error?: string;
87
+ /**
88
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
89
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
90
+ */
91
+ margin?: Space | Margin;
92
+ /**
93
+ * Size of the component.
94
+ */
95
+ size?: "small" | "medium" | "large" | "fillParent";
96
+ /**
97
+ * Value of the tabindex attribute.
98
+ */
99
+ tabIndex?: number;
100
+ };
101
+ declare type SingleSelect = CommonProps & {
102
+ /**
103
+ * If true, the select component will support multiple selected options.
104
+ * In that case, value will be an array of strings with each selected
105
+ * option value.
106
+ */
107
+ multiple?: false;
108
+ /**
109
+ * Value of the select. If undefined, the component will be uncontrolled
110
+ * and the value will be managed internally by the component.
111
+ */
112
+ value?: string;
113
+ /**
114
+ * This function will be called when the user selects an option.
115
+ * An object including the current value and the error (if the value entered is not valid)
116
+ * will be passed to this function. If there is no error, error will be null.
117
+ */
118
+ onChange?: (val: {
119
+ value: string;
120
+ error: string;
121
+ }) => void;
122
+ /**
123
+ * This function will be called when the select loses the focus. An
124
+ * object including the value and the error (if the value
125
+ * selected is not valid) will be passed to this function. If there is no error,
126
+ * error will be null.
127
+ */
128
+ onBlur?: (val: {
129
+ value: string;
130
+ error: string;
131
+ }) => void;
132
+ };
133
+ declare type MultipleSelect = CommonProps & {
134
+ /**
135
+ * If true, the select component will support multiple selected options.
136
+ * In that case, value will be an array of strings with each selected
137
+ * option value.
138
+ */
139
+ multiple: true;
140
+ /**
141
+ * Value of the select. If undefined, the component will be uncontrolled
142
+ * and the value will be managed internally by the component.
143
+ */
144
+ value?: string[];
145
+ /**
146
+ * This function will be called when the user selects an option.
147
+ * An object including the current selected values and the error (if the value entered is not valid)
148
+ * will be passed to this function. If there is no error, error will be null.
149
+ */
150
+ onChange?: (val: {
151
+ value: string[];
152
+ error: string;
153
+ }) => void;
154
+ /**
155
+ * This function will be called when the select loses the focus. An
156
+ * object including the selected values and the error (if the value
157
+ * selected is not valid) will be passed to this function. If there is no error,
158
+ * error will be null.
159
+ */
160
+ onBlur?: (val: {
161
+ value: string[];
162
+ error: string;
163
+ }) => void;
164
+ };
165
+ declare type Props = SingleSelect | MultipleSelect;
166
+ /**
167
+ * Reference to the component.
168
+ */
169
+ export declare type RefType = HTMLDivElement;
170
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -143,7 +143,24 @@ export const Chromatic = () => (
143
143
  gravida enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare,
144
144
  malesuada urna eu, fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam
145
145
  sit amet maximus augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo.
146
- Praesent quis nunc dignissim, pharetra neque molestie, molestie lectus.
146
+ Praesent quis nunc dignissim, pharetra neque molestie, molestie lectus. Lorem ipsum dolor sit amet,
147
+ consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna, placerat sit amet felis
148
+ eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec congue
149
+ laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus tincidunt. Vestibulum
150
+ cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus eros aliquam erat, ut
151
+ efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida enim. Donec rhoncus
152
+ aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu, fringilla mauris.
153
+ Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus augue. Vivamus erat
154
+ sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc dignissim, pharetra
155
+ neque molestie, molestie lectus.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas
156
+ luctus porttitor. Donec massa magna, placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum
157
+ dolor sit amet, consectetur adipiscing elit. Donec congue laoreet orci, nec elementum dolor consequat quis.
158
+ Curabitur rhoncus justo sed dapibus tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna
159
+ ullamcorper facilisis Jia Le, risus eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo,
160
+ dignissim sit amet dolor ut, congue gravida enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae.
161
+ Nunc sit amet elit ornare, malesuada urna eu, fringilla mauris. Vivamus bibendum turpis est, id elementum
162
+ purus euismod sit amet. Etiam sit amet maximus augue. Vivamus erat sapien, ultricies fringilla tellus id,
163
+ condimentum blandit justo. Praesent quis nunc dignissim, pharetra neque molestie, molestie lectus.
147
164
  </p>
148
165
  </DxcSidenav>
149
166
  </StyledContainer>
@@ -62,6 +62,7 @@ export const Chromatic = () => (
62
62
  <DxcSpinner margin="xlarge" mode="small" value="75"></DxcSpinner>
63
63
  <Title title="Xxlarge margin" theme="light" level={4} />
64
64
  <DxcSpinner margin="xxlarge" mode="small" value="75"></DxcSpinner>
65
+ <hr />
65
66
  </ExampleContainer>
66
67
  </>
67
68
  );
package/stack/Stack.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- import React from "react";
2
- declare type StackProps = {
3
- gutter?: "none" | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge";
4
- divider?: boolean;
5
- align?: "start" | "center" | "end" | "baseline" | "stretch";
6
- as?: React.ElementType;
7
- children: React.ReactNode;
8
- };
9
- export default function Stack({ gutter, divider, align, as, children }: StackProps): JSX.Element;
10
- export {};
1
+ /// <reference types="react" />
2
+ import StackPropsType from "./types";
3
+ export default function Stack({ gutter, divider, align, as, children }: StackPropsType): JSX.Element;
package/stack/Stack.js CHANGED
@@ -34,7 +34,7 @@ function Stack(_ref) {
34
34
 
35
35
  var Divider = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n height: 1px;\n background-color: #999999;\n"])));
36
36
 
37
- var StyledStack = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n align-items: ", "};\n gap: ", ";\n margin: 0;\n padding: 0;\n"])), function (_ref2) {
37
+ var StyledStack = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n align-items: ", ";\n gap: ", ";\n margin: 0;\n padding: 0;\n"])), function (_ref2) {
38
38
  var align = _ref2.align;
39
39
 
40
40
  switch (align) {
@@ -64,30 +64,33 @@ var StyledStack = _styledComponents["default"].div(_templateObject2 || (_templat
64
64
  case "none":
65
65
  return "0";
66
66
 
67
- case "xxsmall":
67
+ case "xxxsmall":
68
68
  return "calc(0.125rem / ".concat(divider ? 2 : 1, ")");
69
69
 
70
- case "xsmall":
70
+ case "xxsmall":
71
71
  return "calc(0.25rem / ".concat(divider ? 2 : 1, ")");
72
72
 
73
- case "small":
73
+ case "xsmall":
74
74
  return "calc(0.5rem / ".concat(divider ? 2 : 1, ")");
75
75
 
76
- case "medium":
76
+ case "small":
77
77
  return "calc(1rem / ".concat(divider ? 2 : 1, ")");
78
78
 
79
- case "large":
79
+ case "medium":
80
80
  return "calc(1.5rem / ".concat(divider ? 2 : 1, ")");
81
81
 
82
- case "xlarge":
82
+ case "large":
83
83
  return "calc(2rem / ".concat(divider ? 2 : 1, ")");
84
84
 
85
- case "xxlarge":
85
+ case "xlarge":
86
86
  return "calc(3rem / ".concat(divider ? 2 : 1, ")");
87
87
 
88
- case "xxxlarge":
88
+ case "xxlarge":
89
89
  return "calc(4rem / ".concat(divider ? 2 : 1, ")");
90
90
 
91
+ case "xxxlarge":
92
+ return "calc(5rem / ".concat(divider ? 2 : 1, ")");
93
+
91
94
  default:
92
95
  return "0";
93
96
  }
@@ -58,6 +58,14 @@ export const Chromatic = () => (
58
58
  <Placeholder paddingLeft={60}></Placeholder>
59
59
  </DxcStack>
60
60
  </Container>
61
+ <Title title="gutter = xxxsmall" theme="light" level={4} />
62
+ <Container>
63
+ <DxcStack gutter="xxxsmall">
64
+ <Placeholder></Placeholder>
65
+ <Placeholder></Placeholder>
66
+ <Placeholder></Placeholder>
67
+ </DxcStack>
68
+ </Container>
61
69
  <Title title="gutter = xxsmall" theme="light" level={4} />
62
70
  <Container>
63
71
  <DxcStack gutter="xxsmall">
@@ -114,6 +122,14 @@ export const Chromatic = () => (
114
122
  <Placeholder></Placeholder>
115
123
  </DxcStack>
116
124
  </Container>
125
+ <Title title="gutter = xxxlarge" theme="light" level={4} />
126
+ <Container>
127
+ <DxcStack gutter="xxxlarge">
128
+ <Placeholder></Placeholder>
129
+ <Placeholder></Placeholder>
130
+ <Placeholder></Placeholder>
131
+ </DxcStack>
132
+ </Container>
117
133
  <Title title="gutter = xxlarge && divider" theme="light" level={4} />
118
134
  <Container>
119
135
  <DxcStack gutter="xxlarge" divider>
@@ -134,17 +150,15 @@ export const Chromatic = () => (
134
150
  );
135
151
 
136
152
  const Container = styled.div`
137
- background: #d0d0d0;
153
+ background: #f2eafa;
138
154
  padding: 10px;
139
- border-radius: 10px;
140
155
  `;
141
156
 
142
157
  const Placeholder = styled.div`
143
- min-height: 80px;
158
+ min-height: 40px;
144
159
  min-width: 120px;
145
- border: 1px solid #fabada;
146
- background-color: #fff7fb;
147
- border-radius: 5px;
160
+ border: 1px solid #a46ede;
161
+ background-color: #e5d5f6;
148
162
  padding-left: ${({ paddingLeft }) => `${paddingLeft ?? 0}px`};
149
163
  padding-right: ${({ paddingRight }) => `${paddingRight ?? 0}px`};
150
164
  `;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ gutter?: "none" | "xxxsmall" | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge";
4
+ divider?: boolean;
5
+ align?: "start" | "center" | "end" | "baseline" | "stretch";
6
+ as?: React.ElementType;
7
+ children: React.ReactNode;
8
+ };
9
+ export default Props;
package/stack/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -72,7 +72,7 @@ export const Chromatic = () => (
72
72
  <Title title="Margins" theme="light" level={2} />
73
73
  <ExampleContainer>
74
74
  <Title title="Xxsmall margin" theme="light" level={4} />
75
- <DxcSwitch label="Xxsmmall" margin="xxsmall" />
75
+ <DxcSwitch label="Xxsmall" margin="xxsmall" />
76
76
  </ExampleContainer>
77
77
  <ExampleContainer>
78
78
  <Title title="Xsmall margin" theme="light" level={4} />
@@ -271,6 +271,7 @@ export const Chromatic = () => (
271
271
  <td>Cell 9</td>
272
272
  </tr>
273
273
  </DxcTable>
274
+ <hr />
274
275
  </ExampleContainer>
275
276
  </>
276
- );
277
+ );
package/tabs/Tabs.js CHANGED
@@ -9,10 +9,10 @@ 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
 
14
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
+
16
16
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
17
 
18
18
  var _react = _interopRequireDefault(require("react"));
@@ -70,12 +70,12 @@ var DxcTabs = function DxcTabs(_ref) {
70
70
  }, /*#__PURE__*/_react["default"].createElement(TabLabelContainer, {
71
71
  hasLabelAndIcon: hasLabelAndIcon,
72
72
  iconPosition: iconPosition
73
- }, tab.icon ? /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
73
+ }, tab.icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
74
74
  hasLabelAndIcon: hasLabelAndIcon,
75
75
  iconPosition: iconPosition
76
- }, (0, _typeof2["default"])(tab.icon) === "object" ? tab.icon : /*#__PURE__*/_react["default"].createElement(tab.icon)) : tab.iconSrc && /*#__PURE__*/_react["default"].createElement(TabIcon, {
77
- src: tab.iconSrc
78
- }), /*#__PURE__*/_react["default"].createElement(LabelTextContainer, null, tab.label))), tab.notificationNumber && tab.notificationNumber !== false && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
76
+ }, typeof tab.icon === "string" ? /*#__PURE__*/_react["default"].createElement(TabIcon, {
77
+ src: tab.icon
78
+ }) : tab.icon), /*#__PURE__*/_react["default"].createElement(LabelTextContainer, null, tab.label))), tab.notificationNumber && tab.notificationNumber !== false && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
79
79
  hasLabelAndIcon: hasLabelAndIcon,
80
80
  iconPosition: iconPosition
81
81
  }, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
@@ -201,7 +201,7 @@ var DxCTabs = _styledComponents["default"].div(_templateObject7 || (_templateObj
201
201
  return props.theme.scrollButtonsWidth;
202
202
  });
203
203
 
204
- var TabIcon = _styledComponents["default"].img(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 22px;\n max-width: 22px;\n"])));
204
+ var TabIcon = _styledComponents["default"].img(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])([""])));
205
205
 
206
206
  var TabIconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 22px;\n max-width: 22px;\n margin-bottom: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n align-items: center;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
207
207
  return props.hasLabelAndIcon && props.iconPosition === "top" && "8px" || "";
@@ -9,14 +9,12 @@ export default {
9
9
  component: DxcTabs,
10
10
  };
11
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
- };
12
+ const iconSVG = (
13
+ <svg viewBox="0 0 24 24" fill="currentColor">
14
+ <path d="M0 0h24v24H0z" fill="none" />
15
+ <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" />
16
+ </svg>
17
+ );
20
18
 
21
19
  const tabs: any = [
22
20
  {
@@ -116,6 +114,7 @@ export const Chromatic = () => (
116
114
  <ExampleContainer>
117
115
  <Title title="Xxlarge margin" theme="light" level={4} />
118
116
  <DxcTabs tabs={tabs} margin="xxlarge" />
117
+ <hr />
119
118
  </ExampleContainer>
120
119
  </>
121
120
  );
package/tabs/types.d.ts CHANGED
@@ -6,20 +6,8 @@ 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>>;
10
- declare type Tab = {
11
- /**
12
- * Tab label.
13
- */
14
- label?: string;
15
- /**
16
- * Element used as the icon that will be displayed in the tab.
17
- */
18
- icon?: SVG;
19
- /**
20
- * @deprecated URL of the icon to be displayed in the tab.
21
- */
22
- iconSrc?: string;
9
+ declare type SVG = React.SVGProps<SVGSVGElement>;
10
+ declare type TabCommonProps = {
23
11
  /**
24
12
  * Whether the tab is disabled or not.
25
13
  */
@@ -33,11 +21,31 @@ declare type Tab = {
33
21
  */
34
22
  notificationNumber?: boolean | number;
35
23
  };
24
+ declare type TabLabelProps = TabCommonProps & {
25
+ /**
26
+ * Tab label.
27
+ */
28
+ label: string;
29
+ /**
30
+ * Element or path used as the icon that will be displayed in the tab.
31
+ */
32
+ icon?: string | SVG;
33
+ };
34
+ declare type TabIconProps = TabCommonProps & {
35
+ /**
36
+ * Tab label.
37
+ */
38
+ label?: string;
39
+ /**
40
+ * Element or path used as the icon that will be displayed in the tab.
41
+ */
42
+ icon: string | SVG;
43
+ };
36
44
  declare type Props = {
37
45
  /**
38
46
  * An array of objects representing the tabs.
39
47
  */
40
- tabs: Tab[];
48
+ tabs: (TabLabelProps | TabIconProps)[];
41
49
  /**
42
50
  * Whether the icon should appear above or to the left of the label.
43
51
  */
package/tag/Tag.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import TagPropsType from "./types";
3
- declare const DxcTag: ({ icon, iconSrc, label, linkHref, onClick, iconBgColor, labelPosition, newWindow, margin, size, tabIndex, }: TagPropsType) => JSX.Element;
3
+ declare const DxcTag: ({ icon, label, linkHref, onClick, iconBgColor, labelPosition, newWindow, margin, size, tabIndex, }: TagPropsType) => JSX.Element;
4
4
  export default DxcTag;
package/tag/Tag.js CHANGED
@@ -9,10 +9,10 @@ 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
 
14
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
+
16
16
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
17
 
18
18
  var _react = _interopRequireWildcard(require("react"));
@@ -35,7 +35,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
35
35
 
36
36
  var DxcTag = function DxcTag(_ref) {
37
37
  var icon = _ref.icon,
38
- iconSrc = _ref.iconSrc,
39
38
  _ref$label = _ref.label,
40
39
  label = _ref$label === void 0 ? "" : _ref$label,
41
40
  linkHref = _ref.linkHref,
@@ -69,9 +68,9 @@ var DxcTag = function DxcTag(_ref) {
69
68
  labelPosition: labelPosition
70
69
  }, /*#__PURE__*/_react["default"].createElement(IconContainer, {
71
70
  iconBgColor: iconBgColor
72
- }, icon ? /*#__PURE__*/_react["default"].createElement(TagIconContainer, null, (0, _typeof2["default"])(icon) === "object" ? icon : /*#__PURE__*/_react["default"].createElement(icon)) : /*#__PURE__*/_react["default"].createElement(TagIcon, {
73
- src: iconSrc
74
- })), size !== "small" && /*#__PURE__*/_react["default"].createElement(TagLabel, null, label)));
71
+ }, icon && /*#__PURE__*/_react["default"].createElement(TagIconContainer, null, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(TagIcon, {
72
+ src: icon
73
+ }) : icon)), size !== "small" && /*#__PURE__*/_react["default"].createElement(TagLabel, null, label)));
75
74
 
76
75
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
77
76
  theme: colorsTheme.tag
@@ -146,11 +145,7 @@ var StyledButton = _styledComponents["default"].button(_templateObject4 || (_tem
146
145
  return props.theme.focusColor;
147
146
  });
148
147
 
149
- var TagIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n overflow: hidden;\n width: ", ";\n height: ", ";\n"])), function (props) {
150
- return props.theme.iconWidth;
151
- }, function (props) {
152
- return props.theme.iconHeight;
153
- });
148
+ var TagIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])([""])));
154
149
 
155
150
  var TagIconContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n overflow: hidden;\n\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
156
151
  return props.theme.iconWidth;
@@ -9,29 +9,22 @@ export default {
9
9
  component: DxcTag,
10
10
  };
11
11
 
12
- const icon = () => {
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
- const largeIcon = () => {
21
- return (
22
- <svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
23
- <path d="M0 0h24v24H0V0z" fill="none" />
24
- <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" />
25
- </svg>
26
- );
27
- };
12
+ const icon = (
13
+ <svg viewBox="0 0 24 24" fill="currentColor">
14
+ <path d="M0 0h24v24H0z" fill="none" />
15
+ <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" />
16
+ </svg>
17
+ );
18
+
19
+ const largeIcon = (
20
+ <svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
21
+ <path d="M0 0h24v24H0V0z" fill="none" />
22
+ <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" />
23
+ </svg>
24
+ );
28
25
 
29
26
  export const Chromatic = () => (
30
27
  <>
31
- <ExampleContainer>
32
- <Title title="Without label" theme="light" level={4} />
33
- <DxcTag />
34
- </ExampleContainer>
35
28
  <ExampleContainer>
36
29
  <Title title="With icon" theme="light" level={4} />
37
30
  <DxcTag icon={icon} />
@@ -46,7 +39,7 @@ export const Chromatic = () => (
46
39
  </ExampleContainer>
47
40
  <ExampleContainer>
48
41
  <Title title="With label and icon" theme="light" level={4} />
49
- <DxcTag label="Tag" icon={icon} />
42
+ <DxcTag label="Tag" icon="https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png" />
50
43
  </ExampleContainer>
51
44
  <ExampleContainer>
52
45
  <Title title="With right icon" theme="light" level={4} />
@@ -132,7 +125,7 @@ export const Chromatic = () => (
132
125
  );
133
126
 
134
127
  const LinkTag = () => (
135
- <ExampleContainer>
128
+ <ExampleContainer expanded>
136
129
  <Title title="Hover link tag" theme="light" level={4} />
137
130
  <DxcTag label="Tag" icon={icon} linkHref="https://www.dxc.com" />
138
131
  </ExampleContainer>
package/tag/types.d.ts CHANGED
@@ -6,20 +6,8 @@ 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>>;
10
- declare type Props = {
11
- /**
12
- * Element used as the icon that will be placed next to the label.
13
- */
14
- icon?: SVG;
15
- /**
16
- * @deprecated URL of the icon.
17
- */
18
- iconSrc?: string;
19
- /**
20
- * Text to be placed next inside the tag.
21
- */
22
- label?: string;
9
+ declare type SVG = React.SVGProps<SVGSVGElement>;
10
+ declare type TagCommonProps = {
23
11
  /**
24
12
  * If defined, the tag will be displayed as an anchor, using this prop as "href".
25
13
  * Component will show some visual feedback on hover.
@@ -57,4 +45,25 @@ declare type Props = {
57
45
  */
58
46
  tabIndex?: number;
59
47
  };
48
+ declare type TagLabelProps = TagCommonProps & {
49
+ /**
50
+ * Element or path used as the icon that will be placed next to the label.
51
+ */
52
+ icon?: string | SVG;
53
+ /**
54
+ * Text to be placed next inside the tag.
55
+ */
56
+ label: string;
57
+ };
58
+ declare type TagIconProps = TagCommonProps & {
59
+ /**
60
+ * Element or path used as the icon that will be placed next to the label.
61
+ */
62
+ icon: string | SVG;
63
+ /**
64
+ * Text to be placed next inside the tag.
65
+ */
66
+ label?: string;
67
+ };
68
+ declare type Props = TagLabelProps | TagIconProps;
60
69
  export default Props;