@dxc-technology/halstack-react 0.0.0-49006fa → 0.0.0-49081f0

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 (211) hide show
  1. package/HalstackContext.d.ts +12 -0
  2. package/HalstackContext.js +295 -0
  3. package/accordion/Accordion.d.ts +1 -1
  4. package/accordion/Accordion.js +121 -123
  5. package/accordion/Accordion.stories.tsx +13 -14
  6. package/accordion/Accordion.test.js +25 -11
  7. package/accordion/types.d.ts +9 -4
  8. package/accordion-group/AccordionGroup.d.ts +1 -1
  9. package/accordion-group/AccordionGroup.js +15 -36
  10. package/accordion-group/AccordionGroup.stories.tsx +28 -2
  11. package/accordion-group/AccordionGroup.test.js +30 -37
  12. package/accordion-group/types.d.ts +14 -3
  13. package/alert/Alert.js +5 -2
  14. package/badge/Badge.d.ts +1 -1
  15. package/badge/Badge.js +5 -3
  16. package/badge/types.d.ts +1 -0
  17. package/bleed/Bleed.js +1 -34
  18. package/bleed/Bleed.stories.tsx +94 -95
  19. package/bleed/types.d.ts +1 -1
  20. package/box/Box.js +23 -33
  21. package/box/types.d.ts +1 -0
  22. package/bulleted-list/BulletedList.d.ts +7 -0
  23. package/bulleted-list/BulletedList.js +123 -0
  24. package/bulleted-list/BulletedList.stories.tsx +200 -0
  25. package/bulleted-list/types.d.ts +11 -0
  26. package/{list → bulleted-list}/types.js +0 -0
  27. package/button/Button.js +53 -68
  28. package/button/Button.stories.tsx +9 -0
  29. package/button/types.d.ts +7 -7
  30. package/card/Card.js +24 -27
  31. package/card/types.d.ts +1 -0
  32. package/checkbox/Checkbox.d.ts +1 -1
  33. package/checkbox/Checkbox.js +99 -97
  34. package/checkbox/Checkbox.stories.tsx +124 -128
  35. package/checkbox/Checkbox.test.js +93 -16
  36. package/checkbox/types.d.ts +5 -5
  37. package/chip/types.d.ts +1 -1
  38. package/common/variables.js +236 -100
  39. package/date-input/DateInput.js +41 -23
  40. package/date-input/DateInput.test.js +9 -22
  41. package/date-input/types.d.ts +12 -9
  42. package/dialog/Dialog.js +46 -50
  43. package/dialog/Dialog.stories.tsx +57 -2
  44. package/dialog/Dialog.test.js +34 -4
  45. package/dialog/types.d.ts +3 -2
  46. package/dropdown/Dropdown.d.ts +1 -1
  47. package/dropdown/Dropdown.js +244 -251
  48. package/dropdown/Dropdown.stories.tsx +126 -63
  49. package/dropdown/Dropdown.test.js +509 -108
  50. package/dropdown/DropdownMenu.d.ts +4 -0
  51. package/dropdown/DropdownMenu.js +80 -0
  52. package/dropdown/DropdownMenuItem.d.ts +4 -0
  53. package/dropdown/DropdownMenuItem.js +92 -0
  54. package/dropdown/types.d.ts +25 -5
  55. package/file-input/FileInput.js +174 -193
  56. package/file-input/FileInput.stories.tsx +38 -6
  57. package/file-input/FileInput.test.js +41 -0
  58. package/file-input/FileItem.d.ts +4 -4
  59. package/file-input/FileItem.js +29 -39
  60. package/flex/Flex.d.ts +4 -0
  61. package/flex/Flex.js +69 -0
  62. package/flex/Flex.stories.tsx +103 -0
  63. package/flex/types.d.ts +32 -0
  64. package/{radio → flex}/types.js +0 -0
  65. package/footer/Footer.js +15 -88
  66. package/footer/Footer.stories.tsx +8 -1
  67. package/footer/Icons.js +1 -1
  68. package/footer/types.d.ts +2 -1
  69. package/header/Header.js +95 -114
  70. package/header/Header.stories.tsx +46 -36
  71. package/header/Header.test.js +18 -2
  72. package/header/Icons.js +2 -2
  73. package/header/types.d.ts +3 -2
  74. package/inset/Inset.js +1 -34
  75. package/inset/Inset.stories.tsx +36 -36
  76. package/inset/types.d.ts +25 -1
  77. package/layout/ApplicationLayout.d.ts +16 -6
  78. package/layout/ApplicationLayout.js +71 -131
  79. package/layout/ApplicationLayout.stories.tsx +84 -93
  80. package/layout/Icons.d.ts +5 -0
  81. package/layout/Icons.js +13 -2
  82. package/layout/SidenavContext.d.ts +5 -0
  83. package/layout/SidenavContext.js +19 -0
  84. package/layout/types.d.ts +18 -33
  85. package/link/Link.d.ts +3 -2
  86. package/link/Link.js +57 -74
  87. package/link/Link.stories.tsx +95 -53
  88. package/link/Link.test.js +7 -15
  89. package/link/types.d.ts +7 -23
  90. package/main.d.ts +8 -10
  91. package/main.js +46 -56
  92. package/number-input/NumberInput.test.js +40 -5
  93. package/number-input/types.d.ts +13 -10
  94. package/package.json +14 -12
  95. package/paginator/Paginator.js +17 -38
  96. package/paginator/Paginator.test.js +43 -1
  97. package/paragraph/Paragraph.d.ts +6 -0
  98. package/paragraph/Paragraph.js +38 -0
  99. package/paragraph/Paragraph.stories.tsx +44 -0
  100. package/password-input/PasswordInput.js +7 -4
  101. package/password-input/PasswordInput.test.js +16 -18
  102. package/password-input/types.d.ts +14 -11
  103. package/progress-bar/ProgressBar.d.ts +2 -2
  104. package/progress-bar/ProgressBar.js +57 -51
  105. package/progress-bar/ProgressBar.stories.jsx +13 -11
  106. package/progress-bar/ProgressBar.test.js +67 -22
  107. package/progress-bar/types.d.ts +3 -4
  108. package/quick-nav/QuickNav.d.ts +4 -0
  109. package/quick-nav/QuickNav.js +117 -0
  110. package/quick-nav/QuickNav.stories.tsx +342 -0
  111. package/quick-nav/types.d.ts +21 -0
  112. package/{row → quick-nav}/types.js +0 -0
  113. package/radio-group/Radio.d.ts +1 -1
  114. package/radio-group/Radio.js +43 -28
  115. package/radio-group/RadioGroup.js +30 -27
  116. package/radio-group/RadioGroup.stories.tsx +1 -0
  117. package/radio-group/RadioGroup.test.js +123 -96
  118. package/radio-group/types.d.ts +2 -2
  119. package/resultsetTable/ResultsetTable.js +1 -3
  120. package/resultsetTable/ResultsetTable.test.js +42 -0
  121. package/select/Listbox.d.ts +4 -0
  122. package/select/Listbox.js +198 -0
  123. package/select/Option.js +1 -1
  124. package/select/Select.js +104 -199
  125. package/select/Select.stories.tsx +145 -100
  126. package/select/Select.test.js +503 -286
  127. package/select/types.d.ts +31 -12
  128. package/sidenav/Sidenav.d.ts +6 -5
  129. package/sidenav/Sidenav.js +184 -52
  130. package/sidenav/Sidenav.stories.tsx +154 -156
  131. package/sidenav/Sidenav.test.js +25 -37
  132. package/sidenav/types.d.ts +50 -27
  133. package/slider/Slider.d.ts +1 -1
  134. package/slider/Slider.js +118 -93
  135. package/slider/Slider.stories.tsx +15 -9
  136. package/slider/Slider.test.js +142 -21
  137. package/slider/types.d.ts +6 -2
  138. package/spinner/Spinner.js +1 -1
  139. package/switch/Switch.d.ts +2 -2
  140. package/switch/Switch.js +133 -64
  141. package/switch/Switch.stories.tsx +16 -38
  142. package/switch/Switch.test.js +144 -17
  143. package/switch/types.d.ts +5 -6
  144. package/table/Table.js +1 -1
  145. package/tabs/Tab.d.ts +4 -0
  146. package/tabs/Tab.js +135 -0
  147. package/tabs/Tabs.d.ts +1 -1
  148. package/tabs/Tabs.js +362 -108
  149. package/tabs/Tabs.stories.tsx +74 -8
  150. package/tabs/Tabs.test.js +241 -13
  151. package/tabs/types.d.ts +19 -5
  152. package/tabs-nav/NavTabs.d.ts +8 -0
  153. package/tabs-nav/NavTabs.js +125 -0
  154. package/tabs-nav/NavTabs.stories.tsx +170 -0
  155. package/tabs-nav/NavTabs.test.js +82 -0
  156. package/tabs-nav/Tab.d.ts +4 -0
  157. package/tabs-nav/Tab.js +130 -0
  158. package/tabs-nav/types.d.ts +53 -0
  159. package/{stack → tabs-nav}/types.js +0 -0
  160. package/tag/Tag.js +6 -9
  161. package/tag/types.d.ts +1 -1
  162. package/text-input/Icons.d.ts +8 -0
  163. package/text-input/Icons.js +60 -0
  164. package/text-input/Suggestion.d.ts +4 -0
  165. package/text-input/Suggestion.js +57 -0
  166. package/text-input/Suggestions.d.ts +4 -0
  167. package/text-input/Suggestions.js +134 -0
  168. package/text-input/TextInput.js +213 -334
  169. package/text-input/TextInput.stories.tsx +189 -182
  170. package/text-input/TextInput.test.js +244 -198
  171. package/text-input/types.d.ts +46 -12
  172. package/textarea/Textarea.js +10 -19
  173. package/textarea/types.d.ts +10 -7
  174. package/toggle-group/ToggleGroup.d.ts +1 -1
  175. package/toggle-group/ToggleGroup.js +5 -4
  176. package/toggle-group/ToggleGroup.stories.tsx +4 -4
  177. package/toggle-group/ToggleGroup.test.js +35 -4
  178. package/toggle-group/types.d.ts +9 -1
  179. package/typography/Typography.d.ts +4 -0
  180. package/typography/Typography.js +131 -0
  181. package/typography/Typography.stories.tsx +198 -0
  182. package/typography/types.d.ts +18 -0
  183. package/typography/types.js +5 -0
  184. package/useTheme.js +2 -2
  185. package/useTranslatedLabels.d.ts +2 -0
  186. package/useTranslatedLabels.js +20 -0
  187. package/wizard/Wizard.js +43 -44
  188. package/wizard/Wizard.stories.tsx +20 -1
  189. package/wizard/types.d.ts +5 -4
  190. package/ThemeContext.d.ts +0 -10
  191. package/ThemeContext.js +0 -243
  192. package/list/List.d.ts +0 -4
  193. package/list/List.js +0 -47
  194. package/list/List.stories.tsx +0 -95
  195. package/list/types.d.ts +0 -7
  196. package/radio/Radio.d.ts +0 -4
  197. package/radio/Radio.js +0 -174
  198. package/radio/Radio.stories.tsx +0 -192
  199. package/radio/Radio.test.js +0 -71
  200. package/radio/types.d.ts +0 -54
  201. package/row/Row.d.ts +0 -3
  202. package/row/Row.js +0 -127
  203. package/row/Row.stories.tsx +0 -237
  204. package/row/types.d.ts +0 -28
  205. package/stack/Stack.d.ts +0 -3
  206. package/stack/Stack.js +0 -97
  207. package/stack/Stack.stories.tsx +0 -164
  208. package/stack/types.d.ts +0 -24
  209. package/text/Text.d.ts +0 -7
  210. package/text/Text.js +0 -30
  211. package/text/Text.stories.tsx +0 -19
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { userEvent, within } from "@storybook/testing-library";
3
2
  import DxcSwitch from "./Switch";
4
3
  import { BackgroundColorProvider } from "../BackgroundColorContext";
5
4
  import Title from "../../.storybook/components/Title";
@@ -21,21 +20,25 @@ export const Chromatic = () => (
21
20
  <Title title="Without label" theme="light" level={4} />
22
21
  <DxcSwitch />
23
22
  </ExampleContainer>
23
+ <ExampleContainer pseudoState="pseudo-focus-visible">
24
+ <Title title="Focused" theme="light" level={4} />
25
+ <DxcSwitch label="Switch" labelPosition="after" />
26
+ </ExampleContainer>
24
27
  <ExampleContainer>
25
28
  <Title title="Checked" theme="light" level={4} />
26
29
  <DxcSwitch label="Switch" defaultChecked />
27
30
  </ExampleContainer>
28
31
  <ExampleContainer>
29
- <Title title="Required" theme="light" level={4} />
30
- <DxcSwitch label="Switch" required />
32
+ <Title title="Optional" theme="light" level={4} />
33
+ <DxcSwitch label="Switch" optional />
31
34
  </ExampleContainer>
32
35
  <ExampleContainer>
33
36
  <Title title="Disabled" theme="light" level={4} />
34
37
  <DxcSwitch label="Switch" disabled />
35
38
  </ExampleContainer>
36
39
  <ExampleContainer>
37
- <Title title="Disabled required" theme="light" level={4} />
38
- <DxcSwitch label="Switch" disabled required labelPosition="after" />
40
+ <Title title="Disabled optional" theme="light" level={4} />
41
+ <DxcSwitch label="Switch" disabled optional labelPosition="after" />
39
42
  </ExampleContainer>
40
43
  <ExampleContainer>
41
44
  <Title title="Disabled checked" theme="light" level={4} />
@@ -47,21 +50,25 @@ export const Chromatic = () => (
47
50
  <Title title="With label" theme="dark" level={4} />
48
51
  <DxcSwitch label="Switch" />
49
52
  </ExampleContainer>
53
+ <ExampleContainer pseudoState="pseudo-focus-visible">
54
+ <Title title="Focused" theme="dark" level={4} />
55
+ <DxcSwitch label="Switch" labelPosition="after" />
56
+ </ExampleContainer>
50
57
  <ExampleContainer>
51
58
  <Title title="Checked" theme="dark" level={4} />
52
59
  <DxcSwitch label="Switch" defaultChecked />
53
60
  </ExampleContainer>
54
61
  <ExampleContainer>
55
- <Title title="Required" theme="dark" level={4} />
56
- <DxcSwitch label="Switch" required />
62
+ <Title title="Optional" theme="dark" level={4} />
63
+ <DxcSwitch label="Switch" optional />
57
64
  </ExampleContainer>
58
65
  <ExampleContainer>
59
66
  <Title title="Disabled" theme="dark" level={4} />
60
67
  <DxcSwitch label="Switch" disabled />
61
68
  </ExampleContainer>
62
69
  <ExampleContainer>
63
- <Title title="Disabled required" theme="dark" level={4} />
64
- <DxcSwitch label="Switch" disabled required labelPosition="after" />
70
+ <Title title="Disabled optional" theme="dark" level={4} />
71
+ <DxcSwitch label="Switch" disabled optional labelPosition="after" />
65
72
  </ExampleContainer>
66
73
  <ExampleContainer>
67
74
  <Title title="Disabled checked" theme="dark" level={4} />
@@ -129,32 +136,3 @@ export const Chromatic = () => (
129
136
  </ExampleContainer>
130
137
  </>
131
138
  );
132
-
133
- const Switch = () => (
134
- <ExampleContainer>
135
- <Title title="Focused" theme="light" level={4} />
136
- <DxcSwitch label="Switch" />
137
- </ExampleContainer>
138
- );
139
- export const FocusedSwitch = Switch.bind({});
140
- FocusedSwitch.play = async ({ canvasElement }) => {
141
- const canvas = within(canvasElement);
142
- canvas.getByRole("switch").focus();
143
- };
144
-
145
- const DarkSwitch = () => (
146
- <BackgroundColorProvider color="#333333">
147
- <DarkContainer>
148
- <ExampleContainer>
149
- <Title title="Focused" theme="dark" level={4} />
150
- <DxcSwitch label="Switch" />
151
- </ExampleContainer>
152
- </DarkContainer>
153
- </BackgroundColorProvider>
154
- );
155
-
156
- export const FocusedSwitchOnDark = DarkSwitch.bind({});
157
- FocusedSwitchOnDark.play = async ({ canvasElement }) => {
158
- const canvas = within(canvasElement);
159
- canvas.getByRole("switch").focus();
160
- };
@@ -37,7 +37,7 @@ describe("Switch component tests", function () {
37
37
 
38
38
  expect(onChange).toHaveBeenCalled();
39
39
  });
40
- test("Everytime the user clicks the component the onchange function is called with the correct value CONTROLLED COMPONENT", function () {
40
+ test("Calls correct function on key down", function () {
41
41
  var onChange = jest.fn();
42
42
 
43
43
  var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
@@ -47,6 +47,30 @@ describe("Switch component tests", function () {
47
47
  })),
48
48
  getByText = _render3.getByText;
49
49
 
50
+ _react2.fireEvent.focus(getByText("SwitchComponent"));
51
+
52
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
53
+ key: "Enter"
54
+ });
55
+
56
+ expect(onChange).toHaveBeenCalled();
57
+
58
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
59
+ key: " "
60
+ });
61
+
62
+ expect(onChange).toHaveBeenCalled();
63
+ });
64
+ test("Everytime the user clicks the component the onchange function is called with the correct value CONTROLLED COMPONENT", function () {
65
+ var onChange = jest.fn();
66
+
67
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
68
+ label: "SwitchComponent",
69
+ checked: false,
70
+ onChange: onChange
71
+ })),
72
+ getByText = _render4.getByText;
73
+
50
74
  _react2.fireEvent.click(getByText("SwitchComponent"));
51
75
 
52
76
  _react2.fireEvent.click(getByText("SwitchComponent"));
@@ -54,14 +78,60 @@ describe("Switch component tests", function () {
54
78
  expect(onChange.mock.calls[0][0]).toBe(true);
55
79
  expect(onChange.mock.calls[1][0]).toBe(true);
56
80
  });
81
+ test("Everytime the user use enter in the component, the onchange function is called with the correct value CONTROLLED COMPONENT", function () {
82
+ var onChange = jest.fn();
83
+
84
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
85
+ label: "SwitchComponent",
86
+ checked: false,
87
+ onChange: onChange
88
+ })),
89
+ getByText = _render5.getByText;
90
+
91
+ _react2.fireEvent.focus(getByText("SwitchComponent"));
92
+
93
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
94
+ key: "Enter"
95
+ });
96
+
97
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
98
+ key: "Enter"
99
+ });
100
+
101
+ expect(onChange.mock.calls[0][0]).toBe(true);
102
+ expect(onChange.mock.calls[1][0]).toBe(true);
103
+ });
104
+ test("Everytime the user use space in the component, the onchange function is called with the correct value CONTROLLED COMPONENT", function () {
105
+ var onChange = jest.fn();
106
+
107
+ var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
108
+ label: "SwitchComponent",
109
+ checked: false,
110
+ onChange: onChange
111
+ })),
112
+ getByText = _render6.getByText;
113
+
114
+ _react2.fireEvent.focus(getByText("SwitchComponent"));
115
+
116
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
117
+ key: " "
118
+ });
119
+
120
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
121
+ key: " "
122
+ });
123
+
124
+ expect(onChange.mock.calls[0][0]).toBe(true);
125
+ expect(onChange.mock.calls[1][0]).toBe(true);
126
+ });
57
127
  test("Everytime the user clicks the component the onchange function is called with the correct value UNCONTROLLED COMPONENT", function () {
58
128
  var onChange = jest.fn();
59
129
 
60
- var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
130
+ var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
61
131
  label: "SwitchComponent",
62
132
  onChange: onChange
63
133
  })),
64
- getByText = _render4.getByText;
134
+ getByText = _render7.getByText;
65
135
 
66
136
  _react2.fireEvent.click(getByText("SwitchComponent"));
67
137
 
@@ -70,29 +140,86 @@ describe("Switch component tests", function () {
70
140
  expect(onChange.mock.calls[0][0]).toBe(true);
71
141
  expect(onChange.mock.calls[1][0]).toBe(false);
72
142
  });
143
+ test("Everytime the user use enter in the component, the onchange function is called with the correct value UNCONTROLLED COMPONENT", function () {
144
+ var onChange = jest.fn();
145
+
146
+ var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
147
+ label: "SwitchComponent",
148
+ onChange: onChange
149
+ })),
150
+ getByText = _render8.getByText;
151
+
152
+ _react2.fireEvent.focus(getByText("SwitchComponent"));
153
+
154
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
155
+ key: "Enter"
156
+ });
157
+
158
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
159
+ key: "Enter"
160
+ });
161
+
162
+ expect(onChange.mock.calls[0][0]).toBe(true);
163
+ expect(onChange.mock.calls[1][0]).toBe(false);
164
+ });
165
+ test("Everytime the user use space in the component, the onchange function is called with the correct value UNCONTROLLED COMPONENT", function () {
166
+ var onChange = jest.fn();
167
+
168
+ var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
169
+ label: "SwitchComponent",
170
+ onChange: onChange
171
+ })),
172
+ getByText = _render9.getByText;
173
+
174
+ _react2.fireEvent.focus(getByText("SwitchComponent"));
175
+
176
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
177
+ key: " "
178
+ });
179
+
180
+ _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
181
+ key: " "
182
+ });
183
+
184
+ expect(onChange.mock.calls[0][0]).toBe(true);
185
+ expect(onChange.mock.calls[1][0]).toBe(false);
186
+ });
73
187
  test("Renders with correct initial value and initial state when it is uncontrolled", function () {
74
- var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
188
+ var component = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
75
189
  label: "Default label",
76
190
  defaultChecked: true,
77
- value: "test-defaultChecked"
78
- })),
79
- getByRole = _render5.getByRole;
80
-
81
- var inputEl = getByRole("switch");
82
- expect(inputEl.checked).toBe(true);
191
+ value: "test-defaultChecked",
192
+ name: "test"
193
+ }));
194
+ var switchEl = component.getByRole("switch");
195
+ var inputEl = component.container.querySelector("input[name=\"test\"]");
83
196
  expect(inputEl.value).toBe("test-defaultChecked");
84
- expect(inputEl.getAttribute("aria-checked")).toBe("true");
197
+ expect(switchEl.getAttribute("aria-checked")).toBe("true");
85
198
  });
86
199
  test("Renders with correct aria attributes", function () {
87
- var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
200
+ var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
88
201
  label: "Default label"
89
202
  })),
90
- getByRole = _render6.getByRole,
91
- getByText = _render6.getByText;
203
+ getByText = _render10.getByText,
204
+ getByRole = _render10.getByRole;
205
+
206
+ var switchEl = getByRole("switch");
207
+ var label = getByText("Default label");
208
+ expect(switchEl.getAttribute("aria-labelledby")).toBe(label.id);
209
+ expect(switchEl.getAttribute("aria-checked")).toBe("false");
210
+ });
211
+ test("Renders disabled switch correctly", function () {
212
+ var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
213
+ label: "Default label",
214
+ disabled: true
215
+ })),
216
+ getByText = _render11.getByText,
217
+ getByRole = _render11.getByRole;
92
218
 
93
- var inputEl = getByRole("switch");
219
+ var switchEl = getByRole("switch");
94
220
  var label = getByText("Default label");
95
- expect(inputEl.getAttribute("aria-labelledby")).toBe(label.id);
96
- expect(inputEl.getAttribute("aria-checked")).toBe("false");
221
+ expect(switchEl.getAttribute("aria-labelledby")).toBe(label.id);
222
+ expect(switchEl.getAttribute("aria-checked")).toBe("false");
223
+ expect(switchEl.getAttribute("aria-disabled")).toBe("true");
97
224
  });
98
225
  });
package/switch/types.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
- declare type Margin = {
1
+ export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
+ export declare type Margin = {
3
3
  top?: Space;
4
4
  bottom?: Space;
5
5
  left?: Space;
6
6
  right?: Space;
7
7
  };
8
- declare type Props = {
8
+ export declare type SwitchPropsType = {
9
9
  /**
10
10
  * Initial state of the switch, only when it is uncontrolled.
11
11
  */
@@ -42,9 +42,9 @@ declare type Props = {
42
42
  */
43
43
  onChange?: (checked: boolean) => void;
44
44
  /**
45
- * If true, the switch will change its appearence, showing that the value is required.
45
+ * If true, the component will display '(Optional)' next to the label.
46
46
  */
47
- required?: boolean;
47
+ optional?: boolean;
48
48
  /**
49
49
  * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
50
50
  * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
@@ -59,4 +59,3 @@ declare type Props = {
59
59
  */
60
60
  tabIndex?: number;
61
61
  };
62
- export default Props;
package/table/Table.js CHANGED
@@ -66,7 +66,7 @@ var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_te
66
66
  return props.theme.scrollBarTrackColor;
67
67
  });
68
68
 
69
- var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n }\n"])), function (props) {
69
+ var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n height: 60px;\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n }\n & td:last-child {\n padding-right: 40px;\n }\n"])), function (props) {
70
70
  return "".concat(props.theme.rowSeparatorThickness, " ").concat(props.theme.rowSeparatorStyle, " ").concat(props.theme.rowSeparatorColor);
71
71
  }, function (props) {
72
72
  return props.theme.dataBackgroundColor;
package/tabs/Tab.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { TabProps } from "./types";
3
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLButtonElement>>>;
4
+ export default _default;
package/tabs/Tab.js ADDED
@@ -0,0 +1,135 @@
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 _Badge = _interopRequireDefault(require("../badge/Badge"));
19
+
20
+ var _Typography = _interopRequireDefault(require("../typography/Typography"));
21
+
22
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
23
+
24
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
25
+
26
+ 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); }
27
+
28
+ 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; }
29
+
30
+ var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
31
+ var active = _ref.active,
32
+ tab = _ref.tab,
33
+ tabIndex = _ref.tabIndex,
34
+ hasLabelAndIcon = _ref.hasLabelAndIcon,
35
+ iconPosition = _ref.iconPosition,
36
+ _onClick = _ref.onClick,
37
+ _onMouseEnter = _ref.onMouseEnter,
38
+ _onMouseLeave = _ref.onMouseLeave;
39
+ var colorsTheme = (0, _useTheme["default"])();
40
+ return /*#__PURE__*/_react["default"].createElement(TabContainer, {
41
+ role: "tab",
42
+ type: "button",
43
+ tabIndex: tabIndex,
44
+ disabled: tab.isDisabled,
45
+ "aria-disabled": tab.isDisabled,
46
+ "aria-selected": active,
47
+ hasLabelAndIcon: hasLabelAndIcon,
48
+ iconPosition: iconPosition,
49
+ ref: ref,
50
+ onClick: function onClick() {
51
+ _onClick();
52
+ },
53
+ onMouseEnter: function onMouseEnter() {
54
+ _onMouseEnter();
55
+ },
56
+ onMouseLeave: function onMouseLeave() {
57
+ _onMouseLeave();
58
+ }
59
+ }, /*#__PURE__*/_react["default"].createElement(MainLabelContainer, {
60
+ hasBadge: tab.notificationNumber,
61
+ hasLabelAndIcon: hasLabelAndIcon,
62
+ iconPosition: iconPosition
63
+ }, tab.icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
64
+ hasLabelAndIcon: hasLabelAndIcon,
65
+ iconPosition: iconPosition
66
+ }, typeof tab.icon === "string" ? /*#__PURE__*/_react["default"].createElement(TabIcon, {
67
+ src: tab.icon
68
+ }) : tab.icon), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
69
+ color: tab.isDisabled ? colorsTheme.tabs.disabledFontColor : active ? colorsTheme.tabs.selectedFontColor : colorsTheme.tabs.unselectedFontColor,
70
+ fontFamily: colorsTheme.tabs.fontFamily,
71
+ fontSize: colorsTheme.tabs.fontSize,
72
+ fontStyle: tab.isDisabled ? colorsTheme.tabs.disabledFontStyle : colorsTheme.tabs.fontStyle,
73
+ fontWeight: active ? colorsTheme.tabs.pressedFontWeight : colorsTheme.tabs.fontWeight,
74
+ textAlign: "center",
75
+ letterSpacing: "0.025em",
76
+ lineHeight: "1.715em"
77
+ }, tab.label)), tab.notificationNumber && tab.notificationNumber && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
78
+ hasLabelAndIcon: hasLabelAndIcon,
79
+ iconPosition: iconPosition
80
+ }, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
81
+ notificationText: tab.notificationNumber > 99 ? "+99" : tab.notificationNumber
82
+ })));
83
+ });
84
+
85
+ var TabContainer = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n text-transform: ", ";\n overflow: hidden;\n flex-shrink: 0;\n border: 0;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n user-select: none;\n vertical-align: middle;\n justify-content: center;\n min-width: 90px;\n max-width: 360px;\n padding: ", ";\n height: ", ";\n min-height: ", ";\n background-color: ", ";\n svg {\n color: ", ";\n }\n\n &:hover {\n background-color: ", ";\n }\n\n &:active {\n background-color: ", ";\n }\n\n &:focus {\n outline: ", " solid 1px;\n outline-offset: -1px;\n }\n\n &[aria-selected=\"true\"] {\n background-color: ", ";\n svg {\n color: ", ";\n }\n opacity: 1;\n }\n\n &[aria-disabled=\"true\"] {\n background-color: ", " !important;\n cursor: not-allowed !important;\n pointer-events: all;\n font-style: ", ";\n svg {\n color: ", ";\n }\n outline: none !important;\n > div {\n opacity: 0.5;\n }\n }\n"])), function (props) {
86
+ return props.theme.fontTextTransform;
87
+ }, function (props) {
88
+ return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "12px 16px" || "8px 16px";
89
+ }, function (props) {
90
+ return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "47px" || "71px";
91
+ }, function (props) {
92
+ return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "47px" || "71px";
93
+ }, function (props) {
94
+ return props.theme.unselectedBackgroundColor;
95
+ }, function (props) {
96
+ return props.theme.unselectedIconColor;
97
+ }, function (props) {
98
+ return "".concat(props.theme.hoverBackgroundColor, " !important");
99
+ }, function (props) {
100
+ return "".concat(props.theme.pressedBackgroundColor, " !important");
101
+ }, function (props) {
102
+ return props.theme.focusOutline;
103
+ }, function (props) {
104
+ return props.theme.selectedBackgroundColor;
105
+ }, function (props) {
106
+ return props.theme.selectedIconColor;
107
+ }, function (props) {
108
+ return props.theme.unselectedBackgroundColor;
109
+ }, function (props) {
110
+ return props.theme.disabledFontStyle;
111
+ }, function (props) {
112
+ return props.theme.disabledIconColor;
113
+ });
114
+
115
+ var BadgeContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 12px;\n height: 100%;\n display: flex;\n align-items: ", ";\n"])), function (props) {
116
+ return props.hasLabelAndIcon && props.iconPosition === "top" ? "flex-start" : "center";
117
+ });
118
+
119
+ var MainLabelContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n align-items: center;\n margin-left: ", ";\n"])), function (props) {
120
+ return props.hasLabelAndIcon && props.iconPosition === "top" && "column" || "row";
121
+ }, function (props) {
122
+ return props.hasBadge ? typeof props.hasBadge === "number" ? "calc(".concat(props.theme.badgeWidthWithNotificationNumber, " + 12px)") : "calc(".concat(props.theme.badgeWidth, " + 12px)") : "unset";
123
+ });
124
+
125
+ var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (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) {
126
+ return props.hasLabelAndIcon && props.iconPosition === "top" && "8px" || "";
127
+ }, function (props) {
128
+ return props.hasLabelAndIcon && props.iconPosition === "left" && "12px" || "";
129
+ });
130
+
131
+ var TabIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n display: inline-flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n"])));
132
+
133
+ var _default = /*#__PURE__*/_react["default"].memo(Tab);
134
+
135
+ exports["default"] = _default;
package/tabs/Tabs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import TabsPropsType from "./types";
3
- declare const DxcTabs: ({ activeTabIndex, tabs, onTabClick, onTabHover, margin, iconPosition, tabIndex, }: TabsPropsType) => JSX.Element;
3
+ declare const DxcTabs: ({ defaultActiveTabIndex, activeTabIndex, tabs, onTabClick, onTabHover, margin, iconPosition, tabIndex, }: TabsPropsType) => JSX.Element;
4
4
  export default DxcTabs;