@dxc-technology/halstack-react 0.0.0-0085b72

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 (163) hide show
  1. package/README.md +66 -0
  2. package/babel.config.js +8 -0
  3. package/dist/BackgroundColorContext.js +46 -0
  4. package/dist/ThemeContext.js +250 -0
  5. package/dist/V3Select/V3Select.js +549 -0
  6. package/dist/V3Select/index.d.ts +27 -0
  7. package/dist/V3Textarea/V3Textarea.js +264 -0
  8. package/dist/V3Textarea/index.d.ts +27 -0
  9. package/dist/accordion/Accordion.js +353 -0
  10. package/dist/accordion/index.d.ts +28 -0
  11. package/dist/accordion-group/AccordionGroup.js +186 -0
  12. package/dist/accordion-group/index.d.ts +16 -0
  13. package/dist/alert/Alert.js +403 -0
  14. package/dist/alert/index.d.ts +51 -0
  15. package/dist/badge/Badge.js +63 -0
  16. package/dist/box/Box.js +156 -0
  17. package/dist/box/index.d.ts +25 -0
  18. package/dist/button/Button.js +238 -0
  19. package/dist/button/index.d.ts +24 -0
  20. package/dist/card/Card.js +254 -0
  21. package/dist/card/index.d.ts +22 -0
  22. package/dist/checkbox/Checkbox.js +299 -0
  23. package/dist/checkbox/index.d.ts +24 -0
  24. package/dist/chip/Chip.js +265 -0
  25. package/dist/chip/index.d.ts +22 -0
  26. package/dist/common/OpenSans.css +81 -0
  27. package/dist/common/RequiredComponent.js +40 -0
  28. package/dist/common/fonts/OpenSans-Bold.ttf +0 -0
  29. package/dist/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  30. package/dist/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  31. package/dist/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  32. package/dist/common/fonts/OpenSans-Italic.ttf +0 -0
  33. package/dist/common/fonts/OpenSans-Light.ttf +0 -0
  34. package/dist/common/fonts/OpenSans-LightItalic.ttf +0 -0
  35. package/dist/common/fonts/OpenSans-Regular.ttf +0 -0
  36. package/dist/common/fonts/OpenSans-SemiBold.ttf +0 -0
  37. package/dist/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  38. package/dist/common/utils.js +22 -0
  39. package/dist/common/variables.js +1574 -0
  40. package/dist/date/Date.js +379 -0
  41. package/dist/date/index.d.ts +27 -0
  42. package/dist/date-input/DateInput.js +400 -0
  43. package/dist/date-input/index.d.ts +95 -0
  44. package/dist/dialog/Dialog.js +218 -0
  45. package/dist/dialog/index.d.ts +18 -0
  46. package/dist/dropdown/Dropdown.js +544 -0
  47. package/dist/dropdown/index.d.ts +26 -0
  48. package/dist/file-input/FileInput.js +644 -0
  49. package/dist/file-input/FileItem.js +287 -0
  50. package/dist/file-input/index.d.ts +81 -0
  51. package/dist/footer/Footer.js +421 -0
  52. package/dist/footer/Icons.js +77 -0
  53. package/dist/footer/index.d.ts +25 -0
  54. package/dist/header/Header.js +470 -0
  55. package/dist/header/Icons.js +59 -0
  56. package/dist/header/index.d.ts +25 -0
  57. package/dist/heading/Heading.js +230 -0
  58. package/dist/heading/index.d.ts +17 -0
  59. package/dist/input-text/Icons.js +22 -0
  60. package/dist/input-text/InputText.js +705 -0
  61. package/dist/input-text/index.d.ts +36 -0
  62. package/dist/layout/ApplicationLayout.js +327 -0
  63. package/dist/layout/Icons.js +55 -0
  64. package/dist/link/Link.js +237 -0
  65. package/dist/link/index.d.ts +23 -0
  66. package/dist/main.d.ts +40 -0
  67. package/dist/main.js +359 -0
  68. package/dist/number-input/NumberInput.js +136 -0
  69. package/dist/number-input/NumberInputContext.js +16 -0
  70. package/dist/number-input/index.d.ts +113 -0
  71. package/dist/paginator/Icons.js +66 -0
  72. package/dist/paginator/Paginator.js +305 -0
  73. package/dist/paginator/index.d.ts +20 -0
  74. package/dist/password-input/PasswordInput.js +203 -0
  75. package/dist/password-input/index.d.ts +94 -0
  76. package/dist/progress-bar/ProgressBar.js +242 -0
  77. package/dist/progress-bar/index.d.ts +18 -0
  78. package/dist/radio/Radio.js +209 -0
  79. package/dist/radio/index.d.ts +23 -0
  80. package/dist/resultsetTable/ResultsetTable.js +358 -0
  81. package/dist/resultsetTable/index.d.ts +19 -0
  82. package/dist/select/Select.js +1096 -0
  83. package/dist/select/index.d.ts +53 -0
  84. package/dist/sidenav/Sidenav.js +179 -0
  85. package/dist/sidenav/index.d.ts +13 -0
  86. package/dist/slider/Slider.js +404 -0
  87. package/dist/slider/index.d.ts +29 -0
  88. package/dist/spinner/Spinner.js +381 -0
  89. package/dist/spinner/index.d.ts +17 -0
  90. package/dist/switch/Switch.js +222 -0
  91. package/dist/switch/index.d.ts +24 -0
  92. package/dist/table/Table.js +132 -0
  93. package/dist/table/index.d.ts +13 -0
  94. package/dist/tabs/Tabs.js +343 -0
  95. package/dist/tabs/index.d.ts +19 -0
  96. package/dist/tag/Tag.js +282 -0
  97. package/dist/tag/index.d.ts +24 -0
  98. package/dist/text-input/TextInput.js +974 -0
  99. package/dist/text-input/index.d.ts +135 -0
  100. package/dist/textarea/Textarea.js +369 -0
  101. package/dist/textarea/index.d.ts +117 -0
  102. package/dist/toggle/Toggle.js +220 -0
  103. package/dist/toggle/index.d.ts +21 -0
  104. package/dist/toggle-group/ToggleGroup.js +327 -0
  105. package/dist/toggle-group/index.d.ts +21 -0
  106. package/dist/upload/Upload.js +205 -0
  107. package/dist/upload/buttons-upload/ButtonsUpload.js +135 -0
  108. package/dist/upload/buttons-upload/Icons.js +40 -0
  109. package/dist/upload/dragAndDropArea/DragAndDropArea.js +329 -0
  110. package/dist/upload/dragAndDropArea/Icons.js +39 -0
  111. package/dist/upload/file-upload/FileToUpload.js +189 -0
  112. package/dist/upload/file-upload/Icons.js +66 -0
  113. package/dist/upload/files-upload/FilesToUpload.js +123 -0
  114. package/dist/upload/index.d.ts +15 -0
  115. package/dist/upload/transaction/Icons.js +160 -0
  116. package/dist/upload/transaction/Transaction.js +148 -0
  117. package/dist/upload/transactions/Transactions.js +138 -0
  118. package/dist/useTheme.js +22 -0
  119. package/dist/wizard/Icons.js +65 -0
  120. package/dist/wizard/Wizard.js +405 -0
  121. package/dist/wizard/index.d.ts +18 -0
  122. package/package.json +75 -0
  123. package/test/Accordion.test.js +33 -0
  124. package/test/AccordionGroup.test.js +125 -0
  125. package/test/Alert.test.js +53 -0
  126. package/test/Box.test.js +10 -0
  127. package/test/Button.test.js +18 -0
  128. package/test/Card.test.js +30 -0
  129. package/test/Checkbox.test.js +45 -0
  130. package/test/Chip.test.js +25 -0
  131. package/test/Date.test.js +395 -0
  132. package/test/DateInput.test.js +242 -0
  133. package/test/Dialog.test.js +23 -0
  134. package/test/Dropdown.test.js +145 -0
  135. package/test/FileInput.test.js +201 -0
  136. package/test/Footer.test.js +94 -0
  137. package/test/Header.test.js +34 -0
  138. package/test/Heading.test.js +83 -0
  139. package/test/InputText.test.js +240 -0
  140. package/test/Link.test.js +43 -0
  141. package/test/NumberInput.test.js +259 -0
  142. package/test/Paginator.test.js +181 -0
  143. package/test/PasswordInput.test.js +83 -0
  144. package/test/ProgressBar.test.js +35 -0
  145. package/test/Radio.test.js +37 -0
  146. package/test/ResultsetTable.test.js +330 -0
  147. package/test/Select.test.js +415 -0
  148. package/test/Sidenav.test.js +45 -0
  149. package/test/Slider.test.js +74 -0
  150. package/test/Spinner.test.js +32 -0
  151. package/test/Switch.test.js +45 -0
  152. package/test/Table.test.js +36 -0
  153. package/test/Tabs.test.js +109 -0
  154. package/test/Tag.test.js +32 -0
  155. package/test/TextInput.test.js +732 -0
  156. package/test/Textarea.test.js +193 -0
  157. package/test/ToggleGroup.test.js +85 -0
  158. package/test/Upload.test.js +60 -0
  159. package/test/V3Select.test.js +212 -0
  160. package/test/V3TextArea.test.js +51 -0
  161. package/test/Wizard.test.js +130 -0
  162. package/test/mocks/pngMock.js +1 -0
  163. package/test/mocks/svgMock.js +1 -0
@@ -0,0 +1,330 @@
1
+ import React from "react";
2
+ import { render, fireEvent, act } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+
5
+ import DxcResultsetTable from "../src/resultsetTable/ResultsetTable";
6
+
7
+ const columns = [
8
+ {
9
+ displayValue: "Id",
10
+ isSortable: false,
11
+ },
12
+ {
13
+ displayValue: "Name",
14
+ isSortable: true,
15
+ },
16
+ {
17
+ displayValue: "City",
18
+ isSortable: false,
19
+ },
20
+ ];
21
+
22
+ const rows = [
23
+ [
24
+ {
25
+ displayValue: "001",
26
+ sortValue: "001",
27
+ },
28
+ {
29
+ displayValue: "Peter",
30
+ sortValue: "Peter",
31
+ },
32
+ {
33
+ displayValue: "Oviedo",
34
+ sortValue: "Oviedo",
35
+ },
36
+ ],
37
+ [
38
+ {
39
+ displayValue: "002",
40
+ sortValue: "002",
41
+ },
42
+ {
43
+ displayValue: "Louis",
44
+ sortValue: "Louis",
45
+ },
46
+ {
47
+ displayValue: "Oviedo",
48
+ sortValue: "Oviedo",
49
+ },
50
+ {
51
+ displayValue: "",
52
+ },
53
+ ],
54
+ [
55
+ {
56
+ displayValue: "003",
57
+ sortValue: "003",
58
+ },
59
+ {
60
+ displayValue: "Lana",
61
+ sortValue: "Lana",
62
+ },
63
+ {
64
+ displayValue: "Albacete",
65
+ sortValue: "Albacete",
66
+ },
67
+ ],
68
+ [
69
+ {
70
+ displayValue: "004",
71
+ sortValue: "004",
72
+ },
73
+ {
74
+ displayValue: "Rick",
75
+ sortValue: "Rick",
76
+ },
77
+ {
78
+ displayValue: "Albacete",
79
+ sortValue: "Albacete",
80
+ },
81
+ ],
82
+ [
83
+ {
84
+ displayValue: "005",
85
+ sortValue: "005",
86
+ },
87
+ {
88
+ displayValue: "Mark",
89
+ sortValue: "Mark",
90
+ },
91
+ {
92
+ displayValue: "Madrid",
93
+ sortValue: "Madrid",
94
+ },
95
+ ],
96
+ [
97
+ {
98
+ displayValue: "006",
99
+ sortValue: "006",
100
+ },
101
+ {
102
+ displayValue: "Cris",
103
+ sortValue: "Cris",
104
+ },
105
+ {
106
+ displayValue: "Barcelona",
107
+ sortValue: "Barcelona",
108
+ },
109
+ {
110
+ displayValue: "",
111
+ },
112
+ ],
113
+ [
114
+ {
115
+ displayValue: "007",
116
+ sortValue: "007",
117
+ },
118
+ {
119
+ displayValue: "Susan",
120
+ sortValue: "Susan",
121
+ },
122
+ {
123
+ displayValue: "Madrid",
124
+ sortValue: "Madrid",
125
+ },
126
+ ],
127
+ [
128
+ {
129
+ displayValue: "008",
130
+ sortValue: "008",
131
+ },
132
+ {
133
+ displayValue: "Tina",
134
+ sortValue: "Tina",
135
+ },
136
+ {
137
+ displayValue: "Barcelona",
138
+ sortValue: "Barcelona",
139
+ },
140
+ ],
141
+ [
142
+ {
143
+ displayValue: "009",
144
+ sortValue: "009",
145
+ },
146
+ {
147
+ displayValue: "Kevin",
148
+ sortValue: "Kevin",
149
+ },
150
+ {
151
+ displayValue: "Oviedo",
152
+ sortValue: "Oviedo",
153
+ },
154
+ {
155
+ displayValue: "",
156
+ },
157
+ ],
158
+ [
159
+ {
160
+ displayValue: "010",
161
+ sortValue: "010",
162
+ },
163
+ {
164
+ displayValue: "Cosmin",
165
+ sortValue: "Cosmin",
166
+ },
167
+ {
168
+ displayValue: "Barcelona",
169
+ sortValue: "Barcelona",
170
+ },
171
+ {
172
+ displayValue: "",
173
+ },
174
+ ],
175
+ ];
176
+
177
+ const rows2 = [
178
+ [
179
+ {
180
+ displayValue: "546",
181
+ sortValue: "465",
182
+ },
183
+ {
184
+ displayValue: "OtherValue",
185
+ sortValue: "OtherValue",
186
+ },
187
+ {
188
+ displayValue: "OtherValue",
189
+ sortValue: "OtherValue",
190
+ },
191
+ ],
192
+ [
193
+ {
194
+ displayValue: "978",
195
+ sortValue: "465",
196
+ },
197
+ {
198
+ displayValue: "OtherValue",
199
+ sortValue: "OtherValue",
200
+ },
201
+ {
202
+ displayValue: "OtherValue",
203
+ sortValue: "OtherValue",
204
+ },
205
+ {
206
+ displayValue: "",
207
+ },
208
+ ],
209
+ [
210
+ {
211
+ displayValue: "678",
212
+ sortValue: "344",
213
+ },
214
+ {
215
+ displayValue: "OtherValue",
216
+ sortValue: "OtherValue",
217
+ },
218
+ {
219
+ displayValue: "OtherValue",
220
+ sortValue: "OtherValue",
221
+ },
222
+ ],
223
+ ];
224
+
225
+ describe("ResultsetTable component tests", () => {
226
+ test("ResultsetTable rendered correctly", () => {
227
+ const { getByText } = render(
228
+ <DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
229
+ );
230
+ expect(getByText("Peter")).toBeTruthy();
231
+ });
232
+ test("Resultsettable shows as many rows as itemsPerPage", () => {
233
+ const { getAllByRole } = render(
234
+ <DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
235
+ );
236
+ expect(getAllByRole("row").length - 1).toEqual(3);
237
+ });
238
+
239
+ test("Resultsettable shows rows on second page", () => {
240
+ const { getByText, getAllByRole } = render(
241
+ <DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
242
+ );
243
+ expect(getByText("Peter")).toBeTruthy();
244
+ expect(getByText("Louis")).toBeTruthy();
245
+ expect(getByText("Lana")).toBeTruthy();
246
+ expect(getAllByRole("row").length - 1).toEqual(3);
247
+ const nextButton = getAllByRole("button")[2];
248
+ fireEvent.click(nextButton);
249
+ expect(getByText("4 to 6 of 10")).toBeTruthy();
250
+ // expect(getByText("Page: 2 of 4")).toBeTruthy();
251
+ expect(getByText("Rick")).toBeTruthy();
252
+ expect(getByText("Mark")).toBeTruthy();
253
+ expect(getByText("Cris")).toBeTruthy();
254
+ expect(getAllByRole("row").length - 1).toEqual(3);
255
+ });
256
+
257
+ test("Resultsettable goToPage works as expected", () => {
258
+ window.HTMLElement.prototype.scrollIntoView = () => {};
259
+ window.HTMLElement.prototype.scrollTo = () => {};
260
+ const { getByText, getAllByRole, getByRole } = render(
261
+ <DxcResultsetTable columns={columns} showGoToPage={true} rows={rows} itemsPerPage={3}></DxcResultsetTable>
262
+ );
263
+ expect(getByText("Peter")).toBeTruthy();
264
+ expect(getByText("Louis")).toBeTruthy();
265
+ expect(getByText("Lana")).toBeTruthy();
266
+ expect(getAllByRole("row").length - 1).toEqual(3);
267
+ const goToPageSelect = getAllByRole("button")[2];
268
+ act(() => {
269
+ userEvent.click(goToPageSelect);
270
+ });
271
+ const goToPageOption = getByText("2");
272
+ act(() => {
273
+ userEvent.click(goToPageOption);
274
+ });
275
+
276
+ expect(getByText("4 to 6 of 10")).toBeTruthy();
277
+ expect(getByText("Rick")).toBeTruthy();
278
+ expect(getByText("Mark")).toBeTruthy();
279
+ expect(getByText("Cris")).toBeTruthy();
280
+ expect(getAllByRole("row").length - 1).toEqual(3);
281
+ });
282
+
283
+ test("Resultsettable going to the last page shows only one row", () => {
284
+ const { getByText, getAllByRole } = render(
285
+ <DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
286
+ );
287
+ const lastButton = getAllByRole("button")[3];
288
+ fireEvent.click(lastButton);
289
+ expect(getByText("10 to 10 of 10")).toBeTruthy();
290
+ expect(getAllByRole("row")).toHaveLength(2);
291
+ expect(getByText("Cosmin")).toBeTruthy();
292
+ });
293
+
294
+ test("Resultsettable sort rows by column", () => {
295
+ const component = render(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>);
296
+ expect(component.queryByText("Peter")).toBeTruthy();
297
+ fireEvent.click(component.queryByText("Name"));
298
+ expect(component.queryByText("Tina")).not.toBeTruthy();
299
+ expect(component.queryByText("Cosmin")).toBeTruthy();
300
+
301
+ fireEvent.click(component.queryByText("Name"));
302
+ expect(component.queryByText("Tina")).toBeTruthy();
303
+ expect(component.queryByText("Cosmin")).not.toBeTruthy();
304
+ });
305
+ test("Resultsettable change rows should go to first page", () => {
306
+ const { queryByText, rerender } = render(
307
+ <DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
308
+ );
309
+ expect(queryByText("Peter")).toBeTruthy();
310
+ rerender(<DxcResultsetTable columns={columns} rows={rows2} itemsPerPage={3}></DxcResultsetTable>);
311
+ expect(queryByText("1 to 3 of 3")).toBeTruthy();
312
+ });
313
+
314
+ test("Resultsettable change itemsPerPage should go to first page", () => {
315
+ const { getAllByRole, queryByText, rerender } = render(
316
+ <DxcResultsetTable
317
+ columns={columns}
318
+ rows={rows}
319
+ itemsPerPage={3}
320
+ itemsPerPageOptions={[2, 3]}
321
+ ></DxcResultsetTable>
322
+ );
323
+ const lastButton = getAllByRole("button")[3];
324
+ fireEvent.click(lastButton);
325
+ expect(getAllByRole("row").length - 1).toEqual(1);
326
+ rerender(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={6}></DxcResultsetTable>);
327
+ expect(getAllByRole("row").length - 1).toEqual(6);
328
+ expect(queryByText("Peter")).toBeTruthy();
329
+ });
330
+ });