@dxc-technology/halstack-react 0.0.0-6c89958 → 0.0.0-6c8ea9f

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 (223) hide show
  1. package/BackgroundColorContext.js +0 -1
  2. package/HalstackContext.d.ts +12 -0
  3. package/HalstackContext.js +298 -0
  4. package/accordion/Accordion.d.ts +1 -1
  5. package/accordion/Accordion.js +13 -45
  6. package/accordion/Accordion.stories.tsx +307 -0
  7. package/accordion/Accordion.test.js +72 -0
  8. package/accordion/types.d.ts +8 -8
  9. package/accordion-group/AccordionGroup.d.ts +1 -1
  10. package/accordion-group/AccordionGroup.js +13 -15
  11. package/accordion-group/AccordionGroup.stories.tsx +1 -1
  12. package/accordion-group/AccordionGroup.test.js +151 -0
  13. package/accordion-group/types.d.ts +8 -8
  14. package/alert/Alert.js +4 -1
  15. package/alert/Alert.test.js +92 -0
  16. package/badge/Badge.d.ts +4 -0
  17. package/badge/types.d.ts +4 -0
  18. package/badge/types.js +5 -0
  19. package/bleed/Bleed.d.ts +3 -0
  20. package/bleed/Bleed.js +84 -0
  21. package/bleed/Bleed.stories.tsx +342 -0
  22. package/bleed/types.d.ts +37 -0
  23. package/bleed/types.js +5 -0
  24. package/box/Box.test.js +18 -0
  25. package/button/Button.d.ts +1 -1
  26. package/button/Button.js +19 -24
  27. package/button/Button.stories.tsx +6 -8
  28. package/button/Button.test.js +35 -0
  29. package/button/types.d.ts +3 -7
  30. package/card/Card.js +27 -28
  31. package/card/Card.stories.tsx +1 -1
  32. package/card/Card.test.js +50 -0
  33. package/checkbox/Checkbox.d.ts +1 -1
  34. package/checkbox/Checkbox.js +43 -39
  35. package/checkbox/Checkbox.stories.tsx +124 -128
  36. package/checkbox/Checkbox.test.js +78 -0
  37. package/checkbox/types.d.ts +8 -4
  38. package/chip/Chip.d.ts +1 -1
  39. package/chip/Chip.js +16 -54
  40. package/chip/Chip.stories.tsx +6 -8
  41. package/chip/Chip.test.js +56 -0
  42. package/chip/types.d.ts +7 -15
  43. package/common/variables.js +233 -325
  44. package/date-input/DateInput.js +59 -45
  45. package/date-input/DateInput.stories.tsx +7 -7
  46. package/date-input/DateInput.test.js +479 -0
  47. package/date-input/types.d.ts +16 -9
  48. package/dialog/Dialog.js +6 -33
  49. package/dialog/Dialog.test.js +40 -0
  50. package/dropdown/Dropdown.d.ts +1 -1
  51. package/dropdown/Dropdown.js +21 -47
  52. package/dropdown/Dropdown.stories.tsx +249 -0
  53. package/dropdown/Dropdown.test.js +189 -0
  54. package/dropdown/types.d.ts +5 -14
  55. package/file-input/FileInput.js +111 -39
  56. package/file-input/FileInput.stories.tsx +507 -0
  57. package/file-input/FileInput.test.js +457 -0
  58. package/file-input/FileItem.js +7 -5
  59. package/footer/Footer.js +28 -109
  60. package/footer/Footer.stories.tsx +1 -22
  61. package/footer/Footer.test.js +109 -0
  62. package/footer/Icons.d.ts +2 -0
  63. package/footer/Icons.js +3 -3
  64. package/footer/types.d.ts +1 -1
  65. package/header/Header.js +27 -48
  66. package/header/Header.stories.tsx +46 -36
  67. package/header/Header.test.js +79 -0
  68. package/header/Icons.d.ts +2 -0
  69. package/heading/Heading.stories.tsx +3 -2
  70. package/heading/Heading.test.js +186 -0
  71. package/inset/Inset.d.ts +3 -0
  72. package/inset/Inset.js +84 -0
  73. package/inset/Inset.stories.tsx +229 -0
  74. package/inset/types.d.ts +37 -0
  75. package/inset/types.js +5 -0
  76. package/layout/ApplicationLayout.js +7 -14
  77. package/link/Link.d.ts +3 -2
  78. package/link/Link.js +70 -69
  79. package/link/Link.stories.tsx +91 -51
  80. package/link/Link.test.js +83 -0
  81. package/link/types.d.ts +10 -29
  82. package/list/List.d.ts +3 -6
  83. package/list/List.js +17 -7
  84. package/list/List.stories.tsx +25 -0
  85. package/list/types.d.ts +7 -0
  86. package/list/types.js +5 -0
  87. package/main.d.ts +6 -7
  88. package/main.js +35 -37
  89. package/number-input/NumberInput.js +11 -18
  90. package/number-input/NumberInput.stories.tsx +5 -5
  91. package/number-input/NumberInput.test.js +506 -0
  92. package/number-input/types.d.ts +17 -10
  93. package/package.json +9 -6
  94. package/paginator/Paginator.js +17 -38
  95. package/paginator/Paginator.test.js +266 -0
  96. package/password-input/PasswordInput.js +7 -4
  97. package/password-input/PasswordInput.stories.tsx +3 -3
  98. package/password-input/PasswordInput.test.js +180 -0
  99. package/password-input/types.d.ts +14 -11
  100. package/progress-bar/ProgressBar.js +2 -2
  101. package/progress-bar/ProgressBar.test.js +65 -0
  102. package/quick-nav/QuickNav.d.ts +4 -0
  103. package/quick-nav/QuickNav.js +110 -0
  104. package/quick-nav/QuickNav.stories.tsx +237 -0
  105. package/quick-nav/types.d.ts +21 -0
  106. package/quick-nav/types.js +5 -0
  107. package/radio/Radio.js +10 -11
  108. package/radio/Radio.test.js +71 -0
  109. package/radio-group/Radio.d.ts +4 -0
  110. package/radio-group/Radio.js +141 -0
  111. package/radio-group/RadioGroup.d.ts +4 -0
  112. package/radio-group/RadioGroup.js +282 -0
  113. package/radio-group/RadioGroup.stories.tsx +100 -0
  114. package/radio-group/RadioGroup.test.js +695 -0
  115. package/radio-group/types.d.ts +114 -0
  116. package/radio-group/types.js +5 -0
  117. package/resultsetTable/ResultsetTable.js +5 -2
  118. package/resultsetTable/ResultsetTable.stories.tsx +275 -0
  119. package/resultsetTable/ResultsetTable.test.js +306 -0
  120. package/resultsetTable/types.d.ts +1 -1
  121. package/row/Row.d.ts +3 -11
  122. package/row/Row.js +12 -9
  123. package/row/Row.stories.tsx +20 -6
  124. package/row/types.d.ts +28 -0
  125. package/row/types.js +5 -0
  126. package/select/Icons.d.ts +10 -0
  127. package/select/Icons.js +93 -0
  128. package/select/Listbox.d.ts +4 -0
  129. package/select/Listbox.js +152 -0
  130. package/select/Option.d.ts +4 -0
  131. package/select/Option.js +110 -0
  132. package/select/Select.d.ts +4 -0
  133. package/select/Select.js +98 -307
  134. package/select/Select.stories.tsx +103 -81
  135. package/select/Select.test.js +2057 -0
  136. package/select/types.d.ts +213 -0
  137. package/select/types.js +5 -0
  138. package/sidenav/Sidenav.stories.tsx +18 -1
  139. package/sidenav/Sidenav.test.js +56 -0
  140. package/slider/Slider.d.ts +1 -1
  141. package/slider/Slider.js +2 -1
  142. package/slider/Slider.stories.tsx +8 -8
  143. package/slider/Slider.test.js +150 -0
  144. package/slider/types.d.ts +4 -0
  145. package/spinner/Spinner.js +1 -1
  146. package/spinner/Spinner.stories.jsx +1 -0
  147. package/spinner/Spinner.test.js +64 -0
  148. package/stack/Stack.d.ts +3 -10
  149. package/stack/Stack.js +12 -9
  150. package/stack/Stack.stories.tsx +20 -6
  151. package/stack/types.d.ts +24 -0
  152. package/stack/types.js +5 -0
  153. package/switch/Switch.d.ts +1 -1
  154. package/switch/Switch.js +35 -19
  155. package/switch/Switch.stories.tsx +15 -15
  156. package/switch/Switch.test.js +98 -0
  157. package/switch/types.d.ts +6 -2
  158. package/table/Table.stories.jsx +2 -1
  159. package/table/Table.test.js +26 -0
  160. package/tabs/Tabs.d.ts +1 -1
  161. package/tabs/Tabs.js +16 -18
  162. package/tabs/Tabs.stories.tsx +7 -16
  163. package/tabs/Tabs.test.js +140 -0
  164. package/tabs/types.d.ts +27 -15
  165. package/tag/Tag.d.ts +1 -1
  166. package/tag/Tag.js +17 -27
  167. package/tag/Tag.stories.tsx +26 -29
  168. package/tag/Tag.test.js +60 -0
  169. package/tag/types.d.ts +23 -14
  170. package/text/Text.js +1 -1
  171. package/text-input/Suggestion.d.ts +4 -0
  172. package/text-input/Suggestion.js +55 -0
  173. package/text-input/TextInput.js +68 -84
  174. package/text-input/TextInput.stories.tsx +34 -16
  175. package/text-input/TextInput.test.js +1712 -0
  176. package/text-input/types.d.ts +32 -13
  177. package/textarea/Textarea.d.ts +4 -0
  178. package/textarea/Textarea.js +19 -56
  179. package/textarea/Textarea.stories.jsx +37 -15
  180. package/textarea/Textarea.test.js +437 -0
  181. package/textarea/types.d.ts +137 -0
  182. package/textarea/types.js +5 -0
  183. package/toggle-group/ToggleGroup.d.ts +1 -1
  184. package/toggle-group/ToggleGroup.js +12 -14
  185. package/toggle-group/ToggleGroup.stories.tsx +27 -32
  186. package/toggle-group/ToggleGroup.test.js +156 -0
  187. package/toggle-group/types.d.ts +46 -25
  188. package/useTheme.js +2 -2
  189. package/useTranslatedLabels.d.ts +2 -0
  190. package/useTranslatedLabels.js +20 -0
  191. package/wizard/Wizard.d.ts +1 -1
  192. package/wizard/Wizard.js +106 -45
  193. package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +13 -23
  194. package/wizard/Wizard.test.js +141 -0
  195. package/wizard/types.d.ts +8 -8
  196. package/ThemeContext.d.ts +0 -15
  197. package/ThemeContext.js +0 -243
  198. package/V3Select/V3Select.js +0 -455
  199. package/V3Select/index.d.ts +0 -27
  200. package/V3Textarea/V3Textarea.js +0 -260
  201. package/V3Textarea/index.d.ts +0 -27
  202. package/date/Date.js +0 -373
  203. package/date/index.d.ts +0 -27
  204. package/input-text/Icons.js +0 -22
  205. package/input-text/InputText.js +0 -611
  206. package/input-text/index.d.ts +0 -36
  207. package/select/index.d.ts +0 -131
  208. package/textarea/index.d.ts +0 -127
  209. package/toggle/Toggle.js +0 -186
  210. package/toggle/index.d.ts +0 -21
  211. package/upload/Upload.js +0 -201
  212. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  213. package/upload/buttons-upload/Icons.js +0 -40
  214. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  215. package/upload/dragAndDropArea/Icons.js +0 -39
  216. package/upload/file-upload/FileToUpload.js +0 -115
  217. package/upload/file-upload/Icons.js +0 -66
  218. package/upload/files-upload/FilesToUpload.js +0 -109
  219. package/upload/index.d.ts +0 -15
  220. package/upload/transaction/Icons.js +0 -160
  221. package/upload/transaction/Transaction.js +0 -104
  222. package/upload/transactions/Transactions.js +0 -94
  223. package/wizard/Icons.js +0 -65
@@ -0,0 +1,229 @@
1
+ import React from "react";
2
+ import Title from "../../.storybook/components/Title";
3
+ import styled from "styled-components";
4
+ import DxcStack from "./../stack/Stack";
5
+ import DxcInset from "./Inset";
6
+
7
+ export default {
8
+ title: "Inset",
9
+ component: DxcInset,
10
+ };
11
+
12
+ export const Chromatic = () => (
13
+ <>
14
+ <Title title="Default" level={4} />
15
+ <Container>
16
+ <DxcInset>
17
+ <Placeholder></Placeholder>
18
+ </DxcInset>
19
+ </Container>
20
+ <Title title="space = none" level={4} />
21
+ <Container>
22
+ <DxcInset space="none">
23
+ <Placeholder></Placeholder>
24
+ </DxcInset>
25
+ </Container>
26
+ <Title title="space = xxxsmall" level={4} />
27
+ <Container>
28
+ <DxcInset space="xxxsmall">
29
+ <Placeholder></Placeholder>
30
+ </DxcInset>
31
+ </Container>
32
+ <Title title="space = xxsmall" level={4} />
33
+ <Container>
34
+ <DxcInset space="xxsmall">
35
+ <Placeholder></Placeholder>
36
+ </DxcInset>
37
+ </Container>
38
+ <Title title="space = xsmall" level={4} />
39
+ <Container>
40
+ <DxcInset space="xsmall">
41
+ <Placeholder></Placeholder>
42
+ </DxcInset>
43
+ </Container>
44
+ <Title title="space = small" level={4} />
45
+ <Container>
46
+ <DxcInset space="small">
47
+ <Placeholder></Placeholder>
48
+ </DxcInset>
49
+ </Container>
50
+ <Title title="space = medium" level={4} />
51
+ <Container>
52
+ <DxcInset space="medium">
53
+ <Placeholder></Placeholder>
54
+ </DxcInset>
55
+ </Container>
56
+ <Title title="space = large" level={4} />
57
+ <Container>
58
+ <DxcInset space="large">
59
+ <Placeholder></Placeholder>
60
+ </DxcInset>
61
+ </Container>
62
+ <Title title="space = xlarge" level={4} />
63
+ <Container>
64
+ <DxcInset space="xlarge">
65
+ <Placeholder></Placeholder>
66
+ </DxcInset>
67
+ </Container>
68
+ <Title title="space = xxlarge" level={4} />
69
+ <Container>
70
+ <DxcInset space="xxlarge">
71
+ <Placeholder></Placeholder>
72
+ </DxcInset>
73
+ </Container>
74
+ <Title title="space = xxxlarge" level={4} />
75
+ <Container>
76
+ <DxcInset space="xxxlarge">
77
+ <Placeholder></Placeholder>
78
+ </DxcInset>
79
+ </Container>
80
+ <Title title="horizontal = none" level={4} />
81
+ <Container>
82
+ <DxcInset horizontal="none">
83
+ <Placeholder></Placeholder>
84
+ </DxcInset>
85
+ </Container>
86
+ <Title title="horizontal = xxxsmall" level={4} />
87
+ <Container>
88
+ <DxcInset horizontal="xxxsmall">
89
+ <Placeholder></Placeholder>
90
+ </DxcInset>
91
+ </Container>
92
+ <Title title="horizontal = xxsmall" level={4} />
93
+ <Container>
94
+ <DxcInset horizontal="xxsmall">
95
+ <Placeholder></Placeholder>
96
+ </DxcInset>
97
+ </Container>
98
+ <Title title="horizontal = xsmall" level={4} />
99
+ <Container>
100
+ <DxcInset horizontal="xsmall">
101
+ <Placeholder></Placeholder>
102
+ </DxcInset>
103
+ </Container>
104
+ <Title title="horizontal = small" level={4} />
105
+ <Container>
106
+ <DxcInset horizontal="small">
107
+ <Placeholder></Placeholder>
108
+ </DxcInset>
109
+ </Container>
110
+ <Title title="horizontal = medium" level={4} />
111
+ <Container>
112
+ <DxcInset horizontal="medium">
113
+ <Placeholder></Placeholder>
114
+ </DxcInset>
115
+ </Container>
116
+ <Title title="horizontal = large" level={4} />
117
+ <Container>
118
+ <DxcInset horizontal="large">
119
+ <Placeholder></Placeholder>
120
+ </DxcInset>
121
+ </Container>
122
+ <Title title="horizontal = xlarge" level={4} />
123
+ <Container>
124
+ <DxcInset horizontal="xlarge">
125
+ <Placeholder></Placeholder>
126
+ </DxcInset>
127
+ </Container>
128
+ <Title title="horizontal = xxlarge" level={4} />
129
+ <Container>
130
+ <DxcInset horizontal="xxlarge">
131
+ <Placeholder></Placeholder>
132
+ </DxcInset>
133
+ </Container>
134
+ <Title title="horizontal = xxxlarge" level={4} />
135
+ <Container>
136
+ <DxcInset horizontal="xxxlarge">
137
+ <Placeholder></Placeholder>
138
+ </DxcInset>
139
+ </Container>
140
+ <Title title="vertical = none" level={4} />
141
+ <Container>
142
+ <DxcInset vertical="none">
143
+ <Placeholder></Placeholder>
144
+ </DxcInset>
145
+ </Container>
146
+ <Title title="vertical = xxxsmall" level={4} />
147
+ <Container>
148
+ <DxcInset vertical="xxxsmall">
149
+ <Placeholder></Placeholder>
150
+ </DxcInset>
151
+ </Container>
152
+ <Title title="vertical = xxsmall" level={4} />
153
+ <Container>
154
+ <DxcInset vertical="xxsmall">
155
+ <Placeholder></Placeholder>
156
+ </DxcInset>
157
+ </Container>
158
+ <Title title="vertical = xsmall" level={4} />
159
+ <Container>
160
+ <DxcInset vertical="xsmall">
161
+ <Placeholder></Placeholder>
162
+ </DxcInset>
163
+ </Container>
164
+ <Title title="vertical = small" level={4} />
165
+ <Container>
166
+ <DxcInset vertical="small">
167
+ <Placeholder></Placeholder>
168
+ </DxcInset>
169
+ </Container>
170
+ <Title title="vertical = medium" level={4} />
171
+ <Container>
172
+ <DxcInset vertical="medium">
173
+ <Placeholder></Placeholder>
174
+ </DxcInset>
175
+ </Container>
176
+ <Title title="vertical = large" level={4} />
177
+ <Container>
178
+ <DxcInset vertical="large">
179
+ <Placeholder></Placeholder>
180
+ </DxcInset>
181
+ </Container>
182
+ <Title title="vertical = xlarge" level={4} />
183
+ <Container>
184
+ <DxcInset vertical="xlarge">
185
+ <Placeholder></Placeholder>
186
+ </DxcInset>
187
+ </Container>
188
+ <Title title="vertical = xxlarge" level={4} />
189
+ <Container>
190
+ <DxcInset vertical="xxlarge">
191
+ <Placeholder></Placeholder>
192
+ </DxcInset>
193
+ </Container>
194
+ <Title title="vertical = xxxlarge" level={4} />
195
+ <Container>
196
+ <DxcInset vertical="xxxlarge">
197
+ <Placeholder></Placeholder>
198
+ </DxcInset>
199
+ </Container>
200
+ <Title title="top = xxsmall, right= medium, bottom = large and left = xxlarge" level={4} />
201
+ <Container>
202
+ <DxcInset top="xxsmall" right="medium" bottom="large" left="xxlarge">
203
+ <Placeholder></Placeholder>
204
+ </DxcInset>
205
+ </Container>
206
+ <Title title="Inside a stack" level={4} />
207
+ <Container>
208
+ <DxcStack gutter="medium" divider>
209
+ <Placeholder></Placeholder>
210
+ <DxcInset top="xxsmall" right="medium" bottom="large" left="xxlarge">
211
+ <Placeholder></Placeholder>
212
+ </DxcInset>
213
+ <Placeholder></Placeholder>
214
+ </DxcStack>
215
+ </Container>
216
+ </>
217
+ );
218
+
219
+ const Container = styled.div`
220
+ background: #f2eafa;
221
+ margin: 2.5rem;
222
+ `;
223
+
224
+ const Placeholder = styled.div`
225
+ min-height: 40px;
226
+ min-width: 120px;
227
+ border: 1px solid #a46ede;
228
+ background-color: #e5d5f6;
229
+ `;
@@ -0,0 +1,37 @@
1
+ /// <reference types="react" />
2
+ declare type Spacing = "none" | "xxxsmall" | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge";
3
+ declare type Props = {
4
+ /**
5
+ * Applies the spacing scale to all sides.
6
+ */
7
+ space?: Spacing;
8
+ /**
9
+ * Applies the spacing scale to the left and right sides.
10
+ */
11
+ horizontal?: Spacing;
12
+ /**
13
+ * Applies the spacing scale to the top and bottom sides.
14
+ */
15
+ vertical?: Spacing;
16
+ /**
17
+ * Applies the spacing scale to the top side.
18
+ */
19
+ top?: Spacing;
20
+ /**
21
+ * Applies the spacing scale to the right side.
22
+ */
23
+ right?: Spacing;
24
+ /**
25
+ * Applies the spacing scale to the bottom side.
26
+ */
27
+ bottom?: Spacing;
28
+ /**
29
+ * Applies the spacing scale to the left side.
30
+ */
31
+ left?: Spacing;
32
+ /**
33
+ * Custom content inside the inset.
34
+ */
35
+ children: React.ReactNode;
36
+ };
37
+ export default Props;
package/inset/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -136,27 +136,20 @@ var DxcApplicationLayout = function DxcApplicationLayout(_ref4) {
136
136
  }));
137
137
  };
138
138
 
139
- var handleResize = function handleResize(width) {
140
- if (width) {
141
- setIsResponsive(width <= _variables.responsiveSizes.tablet);
142
- setIsSideNavVisible(true);
143
- }
144
- };
145
-
146
- var handleEventListener = function handleEventListener() {
147
- handleResize(ref.current.offsetWidth);
139
+ var handleResize = function handleResize() {
140
+ setIsResponsive(window.matchMedia("(max-width: ".concat(_variables.responsiveSizes.medium, "rem)")).matches);
141
+ setIsSideNavVisible(true);
148
142
  };
149
143
 
150
144
  (0, _react.useEffect)(function () {
151
145
  if (ref.current) {
152
- window.addEventListener("resize", handleEventListener);
153
- handleResize(ref.current.offsetWidth);
146
+ window.addEventListener("resize", handleResize);
154
147
  }
155
148
 
156
149
  return function () {
157
- window.removeEventListener("resize", handleEventListener);
150
+ window.removeEventListener("resize", handleResize);
158
151
  };
159
- }, []);
152
+ }, [ref.current]);
160
153
 
161
154
  var handleSidenav = function handleSidenav() {
162
155
  setIsSideNavVisible(!isSideNavVisible);
@@ -213,7 +206,7 @@ var SideNavArrowContainer = _styledComponents["default"].div(_templateObject8 ||
213
206
 
214
207
  var ArrowContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n height: calc(100vh - 64px);\n left: 279px;\n"])));
215
208
 
216
- var ArrowTrigger = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n position: sticky;\n top: 45vh;\n width: 42px;\n min-height: 42px;\n background-color: ", ";\n border-radius: 50%;\n transform: ", ";\n transition: transform 0.4s ease-in-out;\n z-index: 1250;\n cursor: pointer;\n & > svg {\n fill: ", ";\n }\n"])), function (props) {
209
+ var ArrowTrigger = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n position: sticky;\n top: 45vh;\n width: 42px;\n min-height: 42px;\n background-color: ", ";\n border-radius: 50%;\n transform: ", ";\n transition: transform 0.4s ease-in-out;\n z-index: 1250;\n cursor: pointer;\n & > svg {\n fill: ", ";\n }\n :focus {\n outline: #0095ff auto 1px;\n }\n"])), function (props) {
217
210
  return "".concat(props.theme.arrowContainerColor);
218
211
  }, function (props) {
219
212
  return props.isSideNavVisible ? "rotate(-180deg)" : "rotate(0deg)";
package/link/Link.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import Overload from "./types";
2
- declare const DxcLink: Overload;
1
+ /// <reference types="react" />
2
+ import { LinkProps } from "./types";
3
+ declare const DxcLink: ({ inheritColor, disabled, icon, iconPosition, href, newWindow, onClick, margin, tabIndex, children, }: LinkProps) => JSX.Element;
3
4
  export default DxcLink;
package/link/Link.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 _react = _interopRequireDefault(require("react"));
17
17
 
18
18
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
@@ -27,57 +27,62 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
27
27
 
28
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
29
 
30
- var DxcLink = function DxcLink(_ref) {
31
- var _ref$inheritColor = _ref.inheritColor,
32
- inheritColor = _ref$inheritColor === void 0 ? false : _ref$inheritColor,
33
- _ref$disabled = _ref.disabled,
34
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
35
- iconSrc = _ref.iconSrc,
30
+ var LinkContent = /*#__PURE__*/_react["default"].memo(function (_ref) {
31
+ var iconPosition = _ref.iconPosition,
36
32
  icon = _ref.icon,
37
- _ref$iconPosition = _ref.iconPosition,
38
- iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
39
- _ref$href = _ref.href,
40
- href = _ref$href === void 0 ? "" : _ref$href,
41
- _ref$newWindow = _ref.newWindow,
42
- newWindow = _ref$newWindow === void 0 ? false : _ref$newWindow,
43
- onClick = _ref.onClick,
44
- _ref$text = _ref.text,
45
- text = _ref$text === void 0 ? "" : _ref$text,
46
- margin = _ref.margin,
47
- _ref$tabIndex = _ref.tabIndex,
48
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
49
- var colorsTheme = (0, _useTheme["default"])();
50
-
51
- var linkContent = /*#__PURE__*/_react["default"].createElement(LinkText, {
33
+ children = _ref.children;
34
+ return /*#__PURE__*/_react["default"].createElement(LinkText, null, iconPosition === "after" && children, icon && /*#__PURE__*/_react["default"].createElement(LinkIconContainer, {
52
35
  iconPosition: iconPosition
53
- }, text, icon ? /*#__PURE__*/_react["default"].createElement(LinkIconContainer, {
54
- iconPosition: iconPosition
55
- }, (0, _typeof2["default"])(icon) === "object" ? icon : /*#__PURE__*/_react["default"].createElement(icon)) : iconSrc && /*#__PURE__*/_react["default"].createElement(LinkIcon, {
56
- src: iconSrc,
57
- iconPosition: iconPosition
58
- }));
36
+ }, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(LinkIcon, {
37
+ src: icon
38
+ }) : icon), iconPosition === "before" && children);
39
+ });
59
40
 
41
+ var DxcLink = function DxcLink(_ref2) {
42
+ var _ref2$inheritColor = _ref2.inheritColor,
43
+ inheritColor = _ref2$inheritColor === void 0 ? false : _ref2$inheritColor,
44
+ _ref2$disabled = _ref2.disabled,
45
+ disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
46
+ icon = _ref2.icon,
47
+ _ref2$iconPosition = _ref2.iconPosition,
48
+ iconPosition = _ref2$iconPosition === void 0 ? "before" : _ref2$iconPosition,
49
+ _ref2$href = _ref2.href,
50
+ href = _ref2$href === void 0 ? "" : _ref2$href,
51
+ _ref2$newWindow = _ref2.newWindow,
52
+ newWindow = _ref2$newWindow === void 0 ? false : _ref2$newWindow,
53
+ onClick = _ref2.onClick,
54
+ margin = _ref2.margin,
55
+ _ref2$tabIndex = _ref2.tabIndex,
56
+ tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex,
57
+ children = _ref2.children;
58
+ var colorsTheme = (0, _useTheme["default"])();
60
59
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
61
60
  theme: colorsTheme.link
62
- }, /*#__PURE__*/_react["default"].createElement(DxcLinkContainer, {
61
+ }, /*#__PURE__*/_react["default"].createElement(LinkContainer, {
63
62
  margin: margin
64
- }, onClick ? /*#__PURE__*/_react["default"].createElement(StyledButton, {
65
- type: "button",
63
+ }, typeof children === "string" && (href || onClick) ? /*#__PURE__*/_react["default"].createElement(StyledLink, {
64
+ as: href ? "a" : "button",
65
+ tabIndex: tabIndex,
66
66
  onClick: !disabled && onClick,
67
- margin: margin,
67
+ href: !disabled && href ? href : undefined,
68
+ target: href ? newWindow ? "_blank" : "_self" : undefined,
68
69
  disabled: disabled,
69
70
  inheritColor: inheritColor
70
- }, linkContent) : /*#__PURE__*/_react["default"].createElement(StyledLink, {
71
- tabIndex: tabIndex,
72
- href: !disabled && href,
73
- target: newWindow ? "_blank" : "_self",
74
- margin: margin,
71
+ }, /*#__PURE__*/_react["default"].createElement(LinkContent, {
72
+ iconPosition: iconPosition,
73
+ icon: icon,
74
+ children: children
75
+ })) : /*#__PURE__*/_react["default"].createElement(CustomLinkContainer, {
75
76
  disabled: disabled,
76
77
  inheritColor: inheritColor
77
- }, linkContent)));
78
+ }, /*#__PURE__*/_react["default"].createElement(LinkContent, {
79
+ iconPosition: iconPosition,
80
+ icon: icon,
81
+ children: children
82
+ }))));
78
83
  };
79
84
 
80
- var DxcLinkContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
85
+ var LinkContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n * {\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n font-size: ", ";\n font-weight: ", ";\n font-style: ", ";\n font-family: ", ";\n text-decoration-color: transparent;\n }\n"])), function (props) {
81
86
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
82
87
  }, function (props) {
83
88
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
@@ -87,16 +92,26 @@ var DxcLinkContainer = _styledComponents["default"].div(_templateObject || (_tem
87
92
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
88
93
  }, function (props) {
89
94
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
95
+ }, function (props) {
96
+ return props.theme.fontSize;
97
+ }, function (props) {
98
+ return props.theme.fontWeight;
99
+ }, function (props) {
100
+ return props.theme.fontStyle;
101
+ }, function (props) {
102
+ return props.theme.fontFamily;
90
103
  });
91
104
 
92
- var StyledLink = _styledComponents["default"].a(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n ", "\n\n text-decoration-color: transparent;\n ", "\n\n &:visited {\n color: ", ";\n &:hover {\n ", "\n }\n }\n &:hover {\n ", "\n }\n &:focus {\n border-radius: 2px;\n outline: 2px solid ", ";\n ", "\n }\n &:active {\n ", "\n }\n"])), function (props) {
105
+ var StyledLink = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n ", "\n ", "\n color: ", ";\n ", "\n\n &:visited {\n color: ", ";\n &:hover {\n ", "\n }\n }\n &:hover {\n ", "\n }\n &:focus {\n border-radius: 2px;\n outline: 2px solid ", ";\n ", "\n }\n &:active {\n ", "\n }\n"])), function (props) {
106
+ return "padding-bottom: ".concat(props.theme.underlineSpacing, ";\n border-bottom: ").concat(props.theme.underlineThickness, " ").concat(props.theme.underlineStyle, " transparent;");
107
+ }, function (props) {
108
+ return props.disabled && "cursor: default;";
109
+ }, function (props) {
93
110
  return props.inheritColor ? "inherit" : !props.disabled ? props.theme.fontColor : props.theme.disabledColor;
94
111
  }, function (props) {
95
112
  return props.disabled ? "pointer-events: none;" : "";
96
113
  }, function (props) {
97
- return "padding-bottom: ".concat(props.theme.underlineSpacing, ";\n border-bottom: ").concat(props.theme.underlineThickness, " ").concat(props.theme.underlineStyle, " transparent;");
98
- }, function (props) {
99
- return !props.inheritColor ? props.theme.visitedFontColor : "";
114
+ return !props.inheritColor && !props.disabled ? props.theme.visitedFontColor : "";
100
115
  }, function (props) {
101
116
  return "color: ".concat(props.theme.visitedFontColor, ";\n border-bottom-color: ").concat(props.theme.visitedUnderlineColor, ";");
102
117
  }, function (props) {
@@ -109,47 +124,33 @@ var StyledLink = _styledComponents["default"].a(_templateObject2 || (_templateOb
109
124
  return "color: ".concat(props.theme.activeFontColor, " !important;\n border-bottom-color: ").concat(props.theme.activeUnderlineColor, " !important;");
110
125
  });
111
126
 
112
- var StyledButton = _styledComponents["default"].button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n font-family: inherit;\n text-decoration-color: transparent;\n\n ", "\n ", "\n color: ", ";\n ", "\n\n &:hover {\n ", "\n }\n &:focus {\n border-radius: 2px;\n outline: 2px solid ", ";\n ", "\n }\n &:active {\n ", "\n }\n"])), function (props) {
127
+ var CustomLinkContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n ", "\n ", "\n ", "\n\n * {\n color: ", ";\n }\n\n &:hover {\n * {\n color: ", ";\n }\n ", "\n }\n &:focus-within {\n * {\n outline: none;\n }\n border-radius: 2px;\n outline: 2px solid ", ";\n ", "\n }\n &:active {\n * {\n color: ", " !important;\n }\n ", "\n }\n"])), function (props) {
113
128
  return "padding-bottom: ".concat(props.theme.underlineSpacing, ";\n border-bottom: ").concat(props.theme.underlineThickness, " ").concat(props.theme.underlineStyle, " transparent;");
114
129
  }, function (props) {
115
130
  return props.disabled && "cursor: default;";
131
+ }, function (props) {
132
+ return props.disabled ? "pointer-events: none;" : "";
116
133
  }, function (props) {
117
134
  return props.inheritColor ? "inherit" : !props.disabled ? props.theme.fontColor : props.theme.disabledColor;
118
135
  }, function (props) {
119
- return props.disabled ? "pointer-events: none;" : "";
136
+ return props.theme.hoverFontColor;
120
137
  }, function (props) {
121
- return "color: ".concat(props.theme.hoverFontColor, ";\n border-bottom-color: ").concat(props.theme.hoverUnderlineColor, ";\n cursor: pointer;");
138
+ return "border-bottom-color: ".concat(props.theme.hoverUnderlineColor, ";\n cursor: pointer;");
122
139
  }, function (props) {
123
140
  return props.theme.focusColor;
124
141
  }, function (props) {
125
142
  return props.disabled && "outline: none";
126
143
  }, function (props) {
127
- return "color: ".concat(props.theme.activeFontColor, " !important;\n border-bottom-color: ").concat(props.theme.activeUnderlineColor, " !important;");
128
- });
129
-
130
- var LinkText = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-weight: ", ";\n font-style: ", ";\n font-family: ", ";\n display: inline-flex;\n flex-direction: ", ";\n justify-content: ", ";\n align-items: center;\n max-width: 100%;\n"])), function (props) {
131
- return props.theme.fontSize;
132
- }, function (props) {
133
- return props.theme.fontWeight;
134
- }, function (props) {
135
- return props.theme.fontStyle;
136
- }, function (props) {
137
- return props.theme.fontFamily;
138
- }, function (props) {
139
- return props.iconPosition === "after" ? "row" : "row-reverse";
144
+ return props.theme.activeFontColor;
140
145
  }, function (props) {
141
- return props.iconPosition === "after" ? "flex-start" : "flex-end";
146
+ return "border-bottom-color: ".concat(props.theme.activeUnderlineColor, " !important;");
142
147
  });
143
148
 
144
- var LinkIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", ";\n"])), function (props) {
145
- return props.theme.iconSize;
146
- }, function (props) {
147
- return props.theme.iconSize;
148
- }, function (props) {
149
- return "".concat(props.iconPosition === "before" ? "margin-right" : "margin-left", ": ").concat(props.theme.iconSpacing);
150
- });
149
+ var LinkText = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: baseline;\n max-width: 100%;\n"])));
150
+
151
+ var LinkIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])([""])));
151
152
 
152
- var LinkIconContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
153
+ var LinkIconContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", ";\n overflow: hidden;\n align-self: center;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
153
154
  return props.theme.iconSize;
154
155
  }, function (props) {
155
156
  return props.theme.iconSize;