@dxc-technology/halstack-react 0.0.0-dcd93c4 → 0.0.0-dddc3c4

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 (121) hide show
  1. package/accordion/types.d.ts +1 -1
  2. package/accordion-group/types.d.ts +1 -1
  3. package/bleed/Bleed.stories.tsx +63 -63
  4. package/bulleted-list/BulletedList.d.ts +7 -0
  5. package/bulleted-list/BulletedList.js +123 -0
  6. package/bulleted-list/BulletedList.stories.tsx +200 -0
  7. package/bulleted-list/types.d.ts +11 -0
  8. package/{inline → bulleted-list}/types.js +0 -0
  9. package/button/Button.js +43 -61
  10. package/button/Button.stories.tsx +9 -0
  11. package/button/types.d.ts +7 -7
  12. package/chip/types.d.ts +1 -1
  13. package/common/variables.js +52 -14
  14. package/date-input/DateInput.js +3 -3
  15. package/dialog/Dialog.js +52 -28
  16. package/dialog/Dialog.stories.tsx +1 -2
  17. package/dialog/Dialog.test.js +34 -4
  18. package/dialog/types.d.ts +2 -2
  19. package/dropdown/Dropdown.d.ts +1 -1
  20. package/dropdown/Dropdown.js +242 -246
  21. package/dropdown/Dropdown.stories.tsx +126 -63
  22. package/dropdown/Dropdown.test.js +510 -108
  23. package/dropdown/DropdownMenu.d.ts +4 -0
  24. package/dropdown/DropdownMenu.js +80 -0
  25. package/dropdown/DropdownMenuItem.d.ts +4 -0
  26. package/dropdown/DropdownMenuItem.js +92 -0
  27. package/dropdown/types.d.ts +25 -5
  28. package/flex/Flex.d.ts +4 -0
  29. package/flex/Flex.js +57 -0
  30. package/flex/Flex.stories.tsx +103 -0
  31. package/flex/types.d.ts +21 -0
  32. package/{list → flex}/types.js +0 -0
  33. package/footer/types.d.ts +1 -1
  34. package/header/Header.js +74 -72
  35. package/header/Header.stories.tsx +4 -4
  36. package/header/Icons.js +2 -2
  37. package/header/types.d.ts +2 -2
  38. package/inset/Inset.stories.tsx +4 -4
  39. package/layout/ApplicationLayout.d.ts +15 -6
  40. package/layout/ApplicationLayout.js +36 -64
  41. package/layout/ApplicationLayout.stories.tsx +80 -44
  42. package/layout/types.d.ts +17 -27
  43. package/link/Link.js +1 -1
  44. package/link/Link.stories.tsx +12 -5
  45. package/link/types.d.ts +1 -1
  46. package/main.d.ts +5 -9
  47. package/main.js +27 -59
  48. package/package.json +9 -9
  49. package/paragraph/Paragraph.d.ts +6 -0
  50. package/paragraph/Paragraph.js +38 -0
  51. package/paragraph/Paragraph.stories.tsx +44 -0
  52. package/progress-bar/ProgressBar.d.ts +2 -2
  53. package/progress-bar/ProgressBar.js +56 -50
  54. package/progress-bar/ProgressBar.stories.jsx +3 -1
  55. package/progress-bar/ProgressBar.test.js +67 -22
  56. package/progress-bar/types.d.ts +3 -4
  57. package/quick-nav/QuickNav.js +15 -13
  58. package/quick-nav/QuickNav.stories.tsx +41 -14
  59. package/radio-group/RadioGroup.js +11 -13
  60. package/select/Listbox.d.ts +1 -1
  61. package/select/Listbox.js +25 -1
  62. package/select/Select.js +14 -31
  63. package/select/Select.stories.tsx +6 -5
  64. package/select/Select.test.js +63 -50
  65. package/select/types.d.ts +2 -4
  66. package/sidenav/Sidenav.d.ts +6 -5
  67. package/sidenav/Sidenav.js +176 -55
  68. package/sidenav/Sidenav.stories.tsx +154 -156
  69. package/sidenav/Sidenav.test.js +25 -37
  70. package/sidenav/types.d.ts +50 -27
  71. package/slider/Slider.js +112 -97
  72. package/slider/Slider.stories.tsx +7 -1
  73. package/slider/Slider.test.js +121 -21
  74. package/slider/types.d.ts +2 -2
  75. package/switch/Switch.d.ts +1 -1
  76. package/switch/Switch.js +110 -54
  77. package/switch/Switch.stories.tsx +8 -30
  78. package/switch/Switch.test.js +122 -8
  79. package/switch/types.d.ts +3 -4
  80. package/tabs/Tab.d.ts +4 -0
  81. package/tabs/Tab.js +135 -0
  82. package/tabs/Tabs.js +360 -104
  83. package/tabs/Tabs.stories.tsx +74 -0
  84. package/tabs/Tabs.test.js +217 -6
  85. package/tabs/types.d.ts +15 -5
  86. package/tabs-nav/NavTabs.js +5 -5
  87. package/tabs-nav/Tab.js +3 -5
  88. package/tabs-nav/types.d.ts +1 -1
  89. package/tag/types.d.ts +1 -1
  90. package/text-input/TextInput.js +12 -21
  91. package/text-input/TextInput.stories.tsx +1 -2
  92. package/text-input/types.d.ts +1 -1
  93. package/toggle-group/types.d.ts +1 -1
  94. package/typography/Typography.d.ts +4 -0
  95. package/typography/Typography.js +131 -0
  96. package/typography/Typography.stories.tsx +198 -0
  97. package/typography/types.d.ts +18 -0
  98. package/{row → typography}/types.js +0 -0
  99. package/wizard/Wizard.js +9 -16
  100. package/wizard/Wizard.stories.tsx +20 -1
  101. package/wizard/types.d.ts +5 -4
  102. package/inline/Inline.d.ts +0 -4
  103. package/inline/Inline.js +0 -60
  104. package/inline/Inline.stories.tsx +0 -319
  105. package/inline/types.d.ts +0 -36
  106. package/list/List.d.ts +0 -4
  107. package/list/List.js +0 -47
  108. package/list/List.stories.tsx +0 -89
  109. package/list/types.d.ts +0 -7
  110. package/row/Row.d.ts +0 -3
  111. package/row/Row.js +0 -127
  112. package/row/Row.stories.tsx +0 -237
  113. package/row/types.d.ts +0 -28
  114. package/stack/Stack.d.ts +0 -4
  115. package/stack/Stack.js +0 -56
  116. package/stack/Stack.stories.tsx +0 -263
  117. package/stack/types.d.ts +0 -32
  118. package/stack/types.js +0 -5
  119. package/text/Text.d.ts +0 -7
  120. package/text/Text.js +0 -30
  121. package/text/Text.stories.tsx +0 -19
package/tabs/Tabs.test.js CHANGED
@@ -25,6 +25,23 @@ var sampleTabsWithBadge = [{
25
25
  label: "Tab-3",
26
26
  notificationNumber: "101"
27
27
  }];
28
+ var sampleTabsMiddleDisabled = [{
29
+ label: "Tab-1"
30
+ }, {
31
+ label: "Tab-2",
32
+ isDisabled: true
33
+ }, {
34
+ label: "Tab-3"
35
+ }];
36
+ var sampleTabsLastTabNonDisabled = [{
37
+ label: "Tab-1",
38
+ isDisabled: true
39
+ }, {
40
+ label: "Tab-2",
41
+ isDisabled: true
42
+ }, {
43
+ label: "Tab-3"
44
+ }];
28
45
  describe("Tabs component tests", function () {
29
46
  test("Tabs render with correct labels", function () {
30
47
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
@@ -103,18 +120,26 @@ describe("Tabs component tests", function () {
103
120
  tabs: sampleTabs,
104
121
  onTabClick: onTabClick
105
122
  })),
106
- getByText = _render6.getByText;
123
+ getByText = _render6.getByText,
124
+ getAllByRole = _render6.getAllByRole;
107
125
 
126
+ var tabs = getAllByRole("tab");
108
127
  var tab1 = getByText("Tab-1");
109
128
  var tab2 = getByText("Tab-2");
110
129
 
111
130
  _react2.fireEvent.click(tab2);
112
131
 
113
132
  expect(onTabClick).toHaveBeenCalledWith(1);
133
+ expect(tabs[0].getAttribute("aria-selected")).toBe("false");
134
+ expect(tabs[1].getAttribute("aria-selected")).toBe("true");
135
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
114
136
 
115
137
  _react2.fireEvent.click(tab1);
116
138
 
117
139
  expect(onTabClick).toHaveBeenCalledWith(0);
140
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
141
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
142
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
118
143
  });
119
144
  test("Controlled tabs", function () {
120
145
  var onTabClick = jest.fn();
@@ -124,17 +149,203 @@ describe("Tabs component tests", function () {
124
149
  onTabClick: onTabClick,
125
150
  activeTabIndex: 0
126
151
  })),
127
- getByText = _render7.getByText;
152
+ getByText = _render7.getByText,
153
+ getAllByRole = _render7.getAllByRole;
128
154
 
129
- var tab2 = getByText("Tab-2");
130
- var tab3 = getByText("Tab-3");
155
+ var tabs = getAllByRole("tab");
131
156
 
132
- _react2.fireEvent.click(tab2);
157
+ _react2.fireEvent.click(tabs[1]);
158
+
159
+ expect(onTabClick).toHaveBeenCalledWith(1);
160
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
161
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
162
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
163
+
164
+ _react2.fireEvent.click(tabs[2]);
165
+
166
+ expect(onTabClick).toHaveBeenCalledWith(2);
167
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
168
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
169
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
170
+ });
171
+ test("Uncontrolled tabs should have focus in the first non-disabled tab", function () {
172
+ var onTabClick = jest.fn();
173
+
174
+ var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
175
+ tabs: sampleTabsLastTabNonDisabled,
176
+ onTabClick: onTabClick
177
+ })),
178
+ getAllByRole = _render8.getAllByRole;
179
+
180
+ var tabs = getAllByRole("tab");
181
+ expect(tabs[0].hasAttribute("disabled")).toBeTruthy();
182
+ expect(tabs[1].hasAttribute("disabled")).toBeTruthy();
183
+ expect(tabs[2].hasAttribute("disabled")).toBeFalsy();
184
+ expect(tabs[0].getAttribute("aria-selected")).toBe("false");
185
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
186
+ expect(tabs[2].getAttribute("aria-selected")).toBe("true");
187
+ });
188
+ test("Controlled tabs with active index in disabled tab should not change focus to the first available tab", function () {
189
+ var onTabClick = jest.fn();
190
+
191
+ var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
192
+ tabs: sampleTabsLastTabNonDisabled,
193
+ onTabClick: onTabClick,
194
+ activeTabIndex: 0
195
+ })),
196
+ getAllByRole = _render9.getAllByRole;
197
+
198
+ var tabs = getAllByRole("tab");
199
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
200
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
201
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
202
+ expect(tabs[0].hasAttribute("disabled")).toBeTruthy();
203
+ expect(tabs[1].hasAttribute("disabled")).toBeTruthy();
204
+ expect(tabs[2].hasAttribute("disabled")).toBeFalsy();
205
+
206
+ _react2.fireEvent.click(tabs[2]);
207
+
208
+ expect(onTabClick).toHaveBeenCalledWith(2);
209
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
210
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
211
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
212
+ expect(tabs[0].hasAttribute("disabled")).toBeTruthy();
213
+ expect(tabs[1].hasAttribute("disabled")).toBeTruthy();
214
+ expect(tabs[2].hasAttribute("disabled")).toBeFalsy();
215
+ });
216
+ test("Select tabs with keyboard event arrows", function () {
217
+ var onTabClick = jest.fn();
218
+
219
+ var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
220
+ tabs: sampleTabs,
221
+ onTabClick: onTabClick
222
+ })),
223
+ getByText = _render10.getByText,
224
+ getByRole = _render10.getByRole,
225
+ getAllByRole = _render10.getAllByRole;
226
+
227
+ var tabList = getByRole("tablist");
228
+ var tab1 = getByText("Tab-1");
229
+ var tabs = getAllByRole("tab");
230
+
231
+ _react2.fireEvent.click(tab1);
232
+
233
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
234
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
235
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
236
+ expect(onTabClick).toHaveBeenCalledWith(0);
133
237
 
238
+ _react2.fireEvent.keyDown(tabList, {
239
+ key: "ArrowRight"
240
+ });
241
+
242
+ _react2.fireEvent.keyDown(tabList, {
243
+ key: "Enter"
244
+ });
245
+
246
+ expect(tabs[0].getAttribute("aria-selected")).toBe("false");
247
+ expect(tabs[1].getAttribute("aria-selected")).toBe("true");
248
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
134
249
  expect(onTabClick).toHaveBeenCalledWith(1);
135
250
 
136
- _react2.fireEvent.click(tab3);
251
+ _react2.fireEvent.keyDown(tabList, {
252
+ key: "ArrowRight"
253
+ });
254
+
255
+ _react2.fireEvent.keyDown(tabList, {
256
+ key: "Enter"
257
+ });
258
+
259
+ expect(tabs[0].getAttribute("aria-selected")).toBe("false");
260
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
261
+ expect(tabs[2].getAttribute("aria-selected")).toBe("true");
262
+ expect(onTabClick).toHaveBeenCalledWith(2);
263
+
264
+ _react2.fireEvent.keyDown(tabList, {
265
+ key: "ArrowLeft"
266
+ });
267
+
268
+ _react2.fireEvent.keyDown(tabList, {
269
+ key: "Enter"
270
+ });
271
+
272
+ expect(tabs[0].getAttribute("aria-selected")).toBe("false");
273
+ expect(tabs[1].getAttribute("aria-selected")).toBe("true");
274
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
275
+ expect(onTabClick).toHaveBeenCalledWith(1);
276
+
277
+ _react2.fireEvent.keyDown(tabList, {
278
+ key: "ArrowLeft"
279
+ });
280
+
281
+ _react2.fireEvent.keyDown(tabList, {
282
+ key: "Enter"
283
+ });
284
+
285
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
286
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
287
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
288
+ expect(onTabClick).toHaveBeenCalledWith(0);
289
+
290
+ _react2.fireEvent.keyDown(tabList, {
291
+ key: "ArrowLeft"
292
+ });
137
293
 
294
+ _react2.fireEvent.keyDown(tabList, {
295
+ key: "Enter"
296
+ });
297
+
298
+ expect(tabs[0].getAttribute("aria-selected")).toBe("false");
299
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
300
+ expect(tabs[2].getAttribute("aria-selected")).toBe("true");
301
+ expect(onTabClick).toHaveBeenCalledWith(2);
302
+
303
+ _react2.fireEvent.keyDown(tabList, {
304
+ key: "ArrowRight"
305
+ });
306
+
307
+ _react2.fireEvent.keyDown(tabList, {
308
+ key: "Enter"
309
+ });
310
+
311
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
312
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
313
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
314
+ expect(onTabClick).toHaveBeenCalledWith(0);
315
+ });
316
+ test("Skip disabled tab with keyboard event arrows", function () {
317
+ var onTabClick = jest.fn();
318
+
319
+ var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
320
+ tabs: sampleTabsMiddleDisabled,
321
+ onTabClick: onTabClick
322
+ })),
323
+ getByText = _render11.getByText,
324
+ getByRole = _render11.getByRole,
325
+ getAllByRole = _render11.getAllByRole;
326
+
327
+ var tabList = getByRole("tablist");
328
+ var tab1 = getByText("Tab-1");
329
+ var tabs = getAllByRole("tab");
330
+
331
+ _react2.fireEvent.click(tab1);
332
+
333
+ expect(tabs[0].getAttribute("aria-selected")).toBe("true");
334
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
335
+ expect(tabs[2].getAttribute("aria-selected")).toBe("false");
336
+ expect(onTabClick).toHaveBeenCalledWith(0);
337
+
338
+ _react2.fireEvent.keyDown(tabList, {
339
+ key: "ArrowRight"
340
+ });
341
+
342
+ _react2.fireEvent.keyDown(tabList, {
343
+ key: " "
344
+ });
345
+
346
+ expect(tabs[0].getAttribute("aria-selected")).toBe("false");
347
+ expect(tabs[1].getAttribute("aria-selected")).toBe("false");
348
+ expect(tabs[2].getAttribute("aria-selected")).toBe("true");
138
349
  expect(onTabClick).toHaveBeenCalledWith(2);
139
350
  });
140
351
  });
package/tabs/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- declare type Margin = {
2
+ export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ export declare type Margin = {
4
4
  top?: Space;
5
5
  bottom?: Space;
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement>;
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type TabCommonProps = {
11
11
  /**
12
12
  * Whether the tab is disabled or not.
@@ -21,7 +21,7 @@ declare type TabCommonProps = {
21
21
  */
22
22
  notificationNumber?: boolean | number;
23
23
  };
24
- declare type TabLabelProps = TabCommonProps & {
24
+ export declare type TabLabelProps = TabCommonProps & {
25
25
  /**
26
26
  * Tab label.
27
27
  */
@@ -31,7 +31,7 @@ declare type TabLabelProps = TabCommonProps & {
31
31
  */
32
32
  icon?: string | SVG;
33
33
  };
34
- declare type TabIconProps = TabCommonProps & {
34
+ export declare type TabIconProps = TabCommonProps & {
35
35
  /**
36
36
  * Tab label.
37
37
  */
@@ -41,6 +41,16 @@ declare type TabIconProps = TabCommonProps & {
41
41
  */
42
42
  icon: string | SVG;
43
43
  };
44
+ export declare type TabProps = {
45
+ tab: TabLabelProps | TabIconProps;
46
+ active: boolean;
47
+ tabIndex: number;
48
+ hasLabelAndIcon: boolean;
49
+ iconPosition: "top" | "left";
50
+ onClick: () => void;
51
+ onMouseEnter: () => void;
52
+ onMouseLeave: () => void;
53
+ };
44
54
  declare type Props = {
45
55
  /**
46
56
  * An array of objects representing the tabs.
@@ -91,15 +91,15 @@ var DxcNavTabs = function DxcNavTabs(_ref) {
91
91
  return getPropInChild(child, "active");
92
92
  });
93
93
 
94
- switch (event.keyCode) {
95
- case 37:
96
- // arrow left
94
+ switch (event.key) {
95
+ case "Left":
96
+ case "ArrowLeft":
97
97
  event.preventDefault();
98
98
  setInnerFocus(getPreviousTabIndex(children, innerFocus === null ? activeTab : innerFocus));
99
99
  break;
100
100
 
101
- case 39:
102
- // arrow right
101
+ case "Right":
102
+ case "ArrowRight":
103
103
  event.preventDefault();
104
104
  setInnerFocus(getNextTabIndex(children, innerFocus === null ? activeTab : innerFocus));
105
105
  break;
package/tabs-nav/Tab.js CHANGED
@@ -59,11 +59,9 @@ var DxcTab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, _ref2) {
59
59
  var handleOnKeyDown = function handleOnKeyDown(event) {
60
60
  var _tabRef$current2;
61
61
 
62
- switch (event.keyCode) {
63
- case 13: // enter
64
-
65
- case 32:
66
- // space
62
+ switch (event.key) {
63
+ case "Enter":
64
+ case "Space":
67
65
  tabRef === null || tabRef === void 0 ? void 0 : (_tabRef$current2 = tabRef.current) === null || _tabRef$current2 === void 0 ? void 0 : _tabRef$current2.click();
68
66
  event.preventDefault();
69
67
  break;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare type SVG = React.SVGProps<SVGSVGElement>;
2
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
3
3
  export declare type TabProps = {
4
4
  /**
5
5
  * Whether the tab is active or not.
package/tag/types.d.ts CHANGED
@@ -6,7 +6,7 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement>;
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type TagCommonProps = {
11
11
  /**
12
12
  * If defined, the tag will be displayed as an anchor, using this prop as "href".
@@ -110,14 +110,6 @@ var makeCancelable = function makeCancelable(promise) {
110
110
  };
111
111
  };
112
112
 
113
- var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
114
- return "This field is required. Please, enter a value.";
115
- };
116
-
117
- var getPatternErrorMessage = function getPatternErrorMessage() {
118
- return "Please match the format requested.";
119
- };
120
-
121
113
  var patternMatch = function patternMatch(pattern, value) {
122
114
  return new RegExp(pattern).test(value);
123
115
  };
@@ -307,14 +299,14 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
307
299
  };
308
300
 
309
301
  var handleIOnKeyDown = function handleIOnKeyDown(event) {
310
- switch (event.keyCode) {
311
- case 40:
312
- // Arrow Down
302
+ switch (event.key) {
303
+ case "Down":
304
+ case "ArrowDown":
305
+ event.preventDefault();
306
+
313
307
  if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
314
308
  decrementNumber();
315
- event.preventDefault();
316
309
  } else {
317
- event.preventDefault();
318
310
  openSuggestions();
319
311
 
320
312
  if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
@@ -326,13 +318,13 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
326
318
 
327
319
  break;
328
320
 
329
- case 38:
330
- // Arrow Up
321
+ case "Up":
322
+ case "ArrowUp":
323
+ event.preventDefault();
324
+
331
325
  if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
332
326
  incrementNumber();
333
- event.preventDefault();
334
327
  } else {
335
- event.preventDefault();
336
328
  openSuggestions();
337
329
 
338
330
  if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
@@ -344,8 +336,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
344
336
 
345
337
  break;
346
338
 
347
- case 27:
348
- // Esc
339
+ case "Esc":
340
+ case "Escape":
349
341
  event.preventDefault();
350
342
 
351
343
  if (hasSuggestions()) {
@@ -355,8 +347,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
355
347
 
356
348
  break;
357
349
 
358
- case 13:
359
- // Enter
350
+ case "Enter":
360
351
  if (hasSuggestions() && !isSearching) {
361
352
  var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusedSuggIndex >= 0 && visualFocusedSuggIndex < filteredSuggestions.length;
362
353
  validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusedSuggIndex]);
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { userEvent, within, waitFor } from "@storybook/testing-library";
3
- import { fireEvent } from "@testing-library/react";
2
+ import { userEvent, within, fireEvent } from "@storybook/testing-library";
4
3
  import { BackgroundColorProvider } from "../BackgroundColorContext";
5
4
  import Title from "../../.storybook/components/Title";
6
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
@@ -6,7 +6,7 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement>;
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type Action = {
11
11
  /**
12
12
  * This function will be called when the user clicks the action.
@@ -6,7 +6,7 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement>;
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type OptionCommons = {
11
11
  /**
12
12
  * Number with the option inner value.
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import TypographyPropsTypes from "./types";
3
+ declare const Typography: ({ as, display, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign, color, textDecoration, textOverflow, whiteSpace, children, }: TypographyPropsTypes) => JSX.Element;
4
+ export default Typography;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
+
14
+ var _react = _interopRequireWildcard(require("react"));
15
+
16
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
17
+
18
+ var _templateObject;
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
23
+
24
+ var TypographyContext = /*#__PURE__*/_react["default"].createContext(null);
25
+
26
+ var Typography = function Typography(_ref) {
27
+ var as = _ref.as,
28
+ display = _ref.display,
29
+ fontFamily = _ref.fontFamily,
30
+ fontSize = _ref.fontSize,
31
+ fontStyle = _ref.fontStyle,
32
+ fontWeight = _ref.fontWeight,
33
+ letterSpacing = _ref.letterSpacing,
34
+ lineHeight = _ref.lineHeight,
35
+ textAlign = _ref.textAlign,
36
+ color = _ref.color,
37
+ textDecoration = _ref.textDecoration,
38
+ textOverflow = _ref.textOverflow,
39
+ whiteSpace = _ref.whiteSpace,
40
+ children = _ref.children;
41
+ var componentContext = (0, _react.useContext)(TypographyContext);
42
+ var asValue = as !== null && as !== void 0 ? as : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.as) || "span";
43
+ var displayValue = display !== null && display !== void 0 ? display : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.display) || "inline";
44
+ var fontFamilyValue = fontFamily !== null && fontFamily !== void 0 ? fontFamily : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.fontFamily) || "Open Sans, sans-serif";
45
+ var fontSizeValue = fontSize !== null && fontSize !== void 0 ? fontSize : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.fontSize) || "1rem";
46
+ var fontStyleValue = fontStyle !== null && fontStyle !== void 0 ? fontStyle : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.fontStyle) || "normal";
47
+ var fontWeightValue = fontWeight !== null && fontWeight !== void 0 ? fontWeight : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.fontWeight) || "400";
48
+ var letterSpacingValue = letterSpacing !== null && letterSpacing !== void 0 ? letterSpacing : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.letterSpacing) || "0em";
49
+ var lineHeightValue = lineHeight !== null && lineHeight !== void 0 ? lineHeight : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.lineHeight) || "1.5em";
50
+ var textAlignValue = textAlign !== null && textAlign !== void 0 ? textAlign : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.textAlign) || "left";
51
+ var colorValue = color !== null && color !== void 0 ? color : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.color) || "#000000";
52
+ var textDecorationValue = textDecoration !== null && textDecoration !== void 0 ? textDecoration : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.textDecoration) || "none";
53
+ var textOverflowValue = textOverflow !== null && textOverflow !== void 0 ? textOverflow : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.textOverflow) || "unset";
54
+ var whiteSpaceValue = whiteSpace !== null && whiteSpace !== void 0 ? whiteSpace : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.whiteSpace) || "normal";
55
+ return /*#__PURE__*/_react["default"].createElement(TypographyContext.Provider, {
56
+ value: {
57
+ as: asValue,
58
+ display: displayValue,
59
+ fontFamily: fontFamilyValue,
60
+ fontSize: fontSizeValue,
61
+ fontStyle: fontStyleValue,
62
+ fontWeight: fontWeightValue,
63
+ letterSpacing: letterSpacingValue,
64
+ lineHeight: lineHeightValue,
65
+ textAlign: textAlignValue,
66
+ color: colorValue,
67
+ textDecoration: textDecorationValue,
68
+ textOverflow: textOverflowValue,
69
+ whiteSpace: whiteSpaceValue
70
+ }
71
+ }, /*#__PURE__*/_react["default"].createElement(StyledTypography, {
72
+ as: asValue,
73
+ display: displayValue,
74
+ fontFamily: fontFamilyValue,
75
+ fontSize: fontSizeValue,
76
+ fontStyle: fontStyleValue,
77
+ fontWeight: fontWeightValue,
78
+ letterSpacing: letterSpacingValue,
79
+ lineHeight: lineHeightValue,
80
+ textAlign: textAlignValue,
81
+ color: colorValue,
82
+ textDecoration: textDecorationValue,
83
+ textOverflow: textOverflowValue,
84
+ whiteSpace: whiteSpaceValue
85
+ }, children));
86
+ };
87
+
88
+ var StyledTypography = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n margin: 0px;\n display: ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n text-align: ", ";\n line-height: ", ";\n text-decoration: ", ";\n text-overflow: ", ";\n white-space: ", ";\n overflow: ", ";\n"])), function (_ref2) {
89
+ var display = _ref2.display;
90
+ return display;
91
+ }, function (_ref3) {
92
+ var color = _ref3.color;
93
+ return color;
94
+ }, function (_ref4) {
95
+ var fontFamily = _ref4.fontFamily;
96
+ return fontFamily;
97
+ }, function (_ref5) {
98
+ var fontSize = _ref5.fontSize;
99
+ return fontSize;
100
+ }, function (_ref6) {
101
+ var fontStyle = _ref6.fontStyle;
102
+ return fontStyle;
103
+ }, function (_ref7) {
104
+ var fontWeight = _ref7.fontWeight;
105
+ return fontWeight;
106
+ }, function (_ref8) {
107
+ var letterSpacing = _ref8.letterSpacing;
108
+ return letterSpacing;
109
+ }, function (_ref9) {
110
+ var textAlign = _ref9.textAlign;
111
+ return textAlign;
112
+ }, function (_ref10) {
113
+ var lineHeight = _ref10.lineHeight;
114
+ return lineHeight;
115
+ }, function (_ref11) {
116
+ var textDecoration = _ref11.textDecoration;
117
+ return textDecoration;
118
+ }, function (_ref12) {
119
+ var textOverflow = _ref12.textOverflow;
120
+ return textOverflow;
121
+ }, function (_ref13) {
122
+ var whiteSpace = _ref13.whiteSpace,
123
+ textOverflow = _ref13.textOverflow;
124
+ return whiteSpace !== "normal" ? whiteSpace : textOverflow !== "unset" ? "nowrap" : "normal";
125
+ }, function (_ref14) {
126
+ var textOverflow = _ref14.textOverflow;
127
+ return textOverflow !== "unset" ? "hidden" : "visible";
128
+ });
129
+
130
+ var _default = Typography;
131
+ exports["default"] = _default;