@dxc-technology/halstack-react 0.0.0-e628009 → 0.0.0-e961efe

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 (82) hide show
  1. package/README.md +1 -1
  2. package/babel.config.js +0 -1
  3. package/dist/ThemeContext.js +40 -38
  4. package/dist/V3Select/V3Select.js +549 -0
  5. package/dist/V3Select/index.d.ts +27 -0
  6. package/dist/V3Textarea/index.d.ts +27 -0
  7. package/dist/accordion/index.d.ts +28 -0
  8. package/dist/accordion-group/index.d.ts +16 -0
  9. package/dist/alert/Alert.js +1 -1
  10. package/dist/box/index.d.ts +25 -0
  11. package/dist/button/index.d.ts +24 -0
  12. package/dist/card/index.d.ts +22 -0
  13. package/dist/checkbox/Checkbox.js +4 -5
  14. package/dist/checkbox/index.d.ts +24 -0
  15. package/dist/chip/index.d.ts +22 -0
  16. package/dist/common/variables.js +128 -123
  17. package/dist/date/Date.js +6 -6
  18. package/dist/date/index.d.ts +27 -0
  19. package/dist/dialog/index.d.ts +18 -0
  20. package/dist/dropdown/index.d.ts +26 -0
  21. package/dist/file-input/FileItem.js +8 -1
  22. package/dist/file-input/index.d.ts +1 -1
  23. package/dist/footer/index.d.ts +25 -0
  24. package/dist/header/Header.js +59 -23
  25. package/dist/header/index.d.ts +25 -0
  26. package/dist/heading/index.d.ts +17 -0
  27. package/dist/input-text/InputText.js +4 -4
  28. package/dist/input-text/index.d.ts +36 -0
  29. package/dist/link/index.d.ts +23 -0
  30. package/dist/main.d.ts +36 -4
  31. package/dist/main.js +9 -17
  32. package/dist/paginator/Paginator.js +50 -28
  33. package/dist/paginator/index.d.ts +20 -0
  34. package/dist/password-input/PasswordInput.js +6 -1
  35. package/dist/progress-bar/index.d.ts +18 -0
  36. package/dist/radio/index.d.ts +23 -0
  37. package/dist/resultsetTable/index.d.ts +19 -0
  38. package/dist/select/Select.js +848 -301
  39. package/dist/{new-select → select}/index.d.ts +1 -1
  40. package/dist/sidenav/index.d.ts +13 -0
  41. package/dist/slider/index.d.ts +29 -0
  42. package/dist/spinner/index.d.ts +17 -0
  43. package/dist/stories/Button.js +71 -0
  44. package/dist/stories/Button.stories.js +55 -0
  45. package/dist/stories/Header.js +67 -0
  46. package/dist/stories/Header.stories.js +31 -0
  47. package/dist/stories/Introduction.stories.mdx +211 -0
  48. package/dist/stories/Page.js +68 -0
  49. package/dist/stories/Page.stories.js +39 -0
  50. package/dist/stories/assets/code-brackets.svg +1 -0
  51. package/dist/stories/assets/colors.svg +1 -0
  52. package/dist/stories/assets/comments.svg +1 -0
  53. package/dist/stories/assets/direction.svg +1 -0
  54. package/dist/stories/assets/flow.svg +1 -0
  55. package/dist/stories/assets/plugin.svg +1 -0
  56. package/dist/stories/assets/repo.svg +1 -0
  57. package/dist/stories/assets/stackalt.svg +1 -0
  58. package/dist/stories/button.css +30 -0
  59. package/dist/stories/header.css +26 -0
  60. package/dist/stories/page.css +69 -0
  61. package/dist/switch/index.d.ts +24 -0
  62. package/dist/table/index.d.ts +13 -0
  63. package/dist/tabs/index.d.ts +19 -0
  64. package/dist/tag/index.d.ts +24 -0
  65. package/dist/text-input/TextInput.js +8 -5
  66. package/dist/toggle/index.d.ts +21 -0
  67. package/dist/toggle-group/index.d.ts +21 -0
  68. package/dist/upload/Upload.js +3 -3
  69. package/dist/upload/index.d.ts +15 -0
  70. package/dist/wizard/index.d.ts +18 -0
  71. package/package.json +14 -10
  72. package/test/Date.test.js +34 -36
  73. package/test/InputText.test.js +17 -26
  74. package/test/Paginator.test.js +5 -1
  75. package/test/ResultsetTable.test.js +5 -4
  76. package/test/Select.test.js +374 -171
  77. package/test/TextInput.test.js +5 -5
  78. package/test/Upload.test.js +4 -4
  79. package/test/V3Select.test.js +212 -0
  80. package/dist/new-select/NewSelect.js +0 -836
  81. package/dist/tabs-for-sections/TabsForSections.js +0 -92
  82. package/test/TabsForSections.test.js +0 -34
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import { render, fireEvent, act, createEvent } from "@testing-library/react";
3
- import V3DxcUpload from "../src/upload/Upload";
3
+ import DxcUpload from "../src/upload/Upload";
4
4
 
5
5
  describe("Upload component tests", () => {
6
6
  test("Upload renders with correct text", () => {
7
- const { getByText } = render(<V3DxcUpload margin="small"></V3DxcUpload>);
7
+ const { getByText } = render(<DxcUpload margin="small"></DxcUpload>);
8
8
  expect(getByText("There are no files to upload")).toBeTruthy();
9
9
  expect(getByText("Drag and drop your files here or choose one from your computer")).toBeTruthy();
10
10
  expect(getByText("CHOOSE FILES")).toBeTruthy();
@@ -12,7 +12,7 @@ describe("Upload component tests", () => {
12
12
 
13
13
  test("Upload shows file information", () => {
14
14
  const myfunction = jest.fn();
15
- const { getByText } = render(<V3DxcUpload margin="small"></V3DxcUpload>);
15
+ const { getByText } = render(<DxcUpload margin="small"></DxcUpload>);
16
16
 
17
17
  const dropZone = getByText("There are no files to upload");
18
18
  const dropEvent = createEvent.drop(dropZone);
@@ -36,7 +36,7 @@ describe("Upload component tests", () => {
36
36
  test("Calls correct function callbackUpload", () => {
37
37
  const onCallbackUpload = jest.fn(() => new Promise((resolve) => setTimeout(resolve, 1000)));
38
38
  const myfunction = jest.fn();
39
- const { getByText } = render(<V3DxcUpload margin="small" callbackUpload={onCallbackUpload}></V3DxcUpload>);
39
+ const { getByText } = render(<DxcUpload margin="small" callbackUpload={onCallbackUpload}></DxcUpload>);
40
40
 
41
41
  const dropZone = getByText("There are no files to upload");
42
42
  const dropEvent = createEvent.drop(dropZone);
@@ -0,0 +1,212 @@
1
+ import React from "react";
2
+ import { render, act } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import V3DxcSelect from "../src/V3Select/V3Select";
5
+
6
+ const optionsWithoutIcon = [
7
+ {
8
+ value: 1,
9
+ label: "Amazon",
10
+ },
11
+ {
12
+ value: 2,
13
+ label: "Ebay",
14
+ },
15
+ {
16
+ value: 3,
17
+ label: "Apple",
18
+ },
19
+ ];
20
+
21
+ const optionsWithIcons = [
22
+ {
23
+ value: 1,
24
+ label: "Image 1",
25
+ icon: (
26
+ <svg
27
+ data-testid="image-1"
28
+ xmlns="http://www.w3.org/2000/svg"
29
+ height="24px"
30
+ viewBox="0 0 24 24"
31
+ width="24px"
32
+ fill="currentColor"
33
+ >
34
+ <path d="M0 0h24v24H0V0z" fill="none" />
35
+ <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
36
+ </svg>
37
+ ),
38
+ },
39
+ {
40
+ value: 2,
41
+ label: "Image 2",
42
+ icon: (
43
+ <svg
44
+ data-testid="image-2"
45
+ version="1.1"
46
+ x="0px"
47
+ y="0px"
48
+ width="24px"
49
+ height="24px"
50
+ viewBox="0 0 24 24"
51
+ enable-background="new 0 0 24 24"
52
+ >
53
+ <g id="Bounding_Box">
54
+ <rect fill="none" width="24" height="24" />
55
+ </g>
56
+ <g id="Master">
57
+ <path d="M19,9.3V4h-3v2.6L12,3L2,12h3v8h5v-6h4v6h5v-8h3L19,9.3z M10,10c0-1.1,0.9-2,2-2s2,0.9,2,2H10z" />
58
+ </g>
59
+ </svg>
60
+ ),
61
+ },
62
+ ];
63
+
64
+ describe("Select component tests", () => {
65
+ test("Select renders with correct label", () => {
66
+ const { getByText } = render(<V3DxcSelect label="test-select-label"></V3DxcSelect>);
67
+ expect(getByText("test-select-label")).toBeTruthy();
68
+ });
69
+
70
+ test("Select renders options when select is clicked", () => {
71
+ const { getByText, getByRole, queryByText } = render(
72
+ <V3DxcSelect label="test-select-name" options={optionsWithoutIcon}></V3DxcSelect>
73
+ );
74
+ //Before are not shown
75
+ expect(queryByText("Amazon")).toBeFalsy();
76
+ expect(queryByText("Ebay")).toBeFalsy();
77
+ expect(queryByText("Apple")).toBeFalsy();
78
+ const select = getByRole("button");
79
+ act(() => {
80
+ userEvent.click(select);
81
+ });
82
+ expect(getByText("Amazon")).toBeTruthy();
83
+ expect(getByText("Ebay")).toBeTruthy();
84
+ expect(getByText("Apple")).toBeTruthy();
85
+ });
86
+
87
+ test("Select renders options with icons before", () => {
88
+ const { getByRole, getByTestId } = render(
89
+ <V3DxcSelect label="test-select-name" options={optionsWithIcons}></V3DxcSelect>
90
+ );
91
+ const select = getByRole("button");
92
+ act(() => {
93
+ userEvent.click(select);
94
+ });
95
+ expect(getByTestId("image-1")).toBeTruthy();
96
+ expect(getByTestId("image-2")).toBeTruthy();
97
+ });
98
+
99
+ test("Select renders options with icons after", () => {
100
+ const { getByRole, getByTestId } = render(
101
+ <V3DxcSelect label="test-select-name" options={optionsWithIcons} iconPosition="after"></V3DxcSelect>
102
+ );
103
+ const select = getByRole("button");
104
+ act(() => {
105
+ userEvent.click(select);
106
+ });
107
+ expect(getByTestId("image-1")).toBeTruthy();
108
+ expect(getByTestId("image-2")).toBeTruthy();
109
+ });
110
+
111
+ test("Select renders with a default value", () => {
112
+ const { getByText } = render(
113
+ <V3DxcSelect label="test-select-name" options={optionsWithoutIcon} value={1}></V3DxcSelect>
114
+ );
115
+ expect(getByText("Amazon")).toBeTruthy();
116
+ });
117
+
118
+ test("Select renders with multiple default values", () => {
119
+ const { getByText } = render(
120
+ <V3DxcSelect label="test-select-name" options={optionsWithoutIcon} value={[1, 2]} multiple></V3DxcSelect>
121
+ );
122
+ expect(getByText("Amazon, Ebay")).toBeTruthy();
123
+ });
124
+
125
+ test("Disabled select is not clickable", () => {
126
+ const { getByText, queryByText } = render(
127
+ <V3DxcSelect label="test-select-name" options={optionsWithoutIcon} disabled></V3DxcSelect>
128
+ );
129
+ expect(queryByText("Amazon")).toBeFalsy();
130
+ expect(queryByText("Ebay")).toBeFalsy();
131
+ expect(queryByText("Apple")).toBeFalsy();
132
+ const select = getByText("test-select-name");
133
+ act(() => {
134
+ userEvent.click(select);
135
+ });
136
+ expect(queryByText("Amazon")).toBeFalsy();
137
+ expect(queryByText("Ebay")).toBeFalsy();
138
+ expect(queryByText("Apple")).toBeFalsy();
139
+ });
140
+
141
+ test("Controlled select with unique value", () => {
142
+ const onChange = jest.fn();
143
+ const { getByText, getAllByText } = render(
144
+ <V3DxcSelect label="test-select-name" options={optionsWithoutIcon} value={1} onChange={onChange}></V3DxcSelect>
145
+ );
146
+ const select = getByText("Amazon");
147
+ act(() => {
148
+ userEvent.click(select);
149
+ });
150
+ const option2 = getByText("Ebay");
151
+ act(() => {
152
+ userEvent.click(option2);
153
+ });
154
+ expect(onChange).toHaveBeenCalledWith(2);
155
+ //The value is not changed
156
+ expect(getAllByText("Amazon").length).toBe(2);
157
+ });
158
+
159
+ test("Controlled select with multiple values", () => {
160
+ const onChange = jest.fn();
161
+ const { getByText } = render(
162
+ <V3DxcSelect
163
+ label="test-select-name"
164
+ options={optionsWithoutIcon}
165
+ value={[1, 2]}
166
+ multiple
167
+ onChange={onChange}
168
+ ></V3DxcSelect>
169
+ );
170
+ const select = getByText("Amazon, Ebay");
171
+ act(() => {
172
+ userEvent.click(select);
173
+ });
174
+ const option3 = getByText("Apple");
175
+ act(() => {
176
+ userEvent.click(option3);
177
+ });
178
+ expect(onChange).toHaveBeenCalledWith([1, 2, 3]);
179
+ //The value is not changed
180
+ expect(getByText("Amazon, Ebay")).toBeTruthy();
181
+ });
182
+
183
+ test("Uncontrolled select with multiple values", () => {
184
+ const onChange = jest.fn();
185
+ const { getByText, getByRole } = render(
186
+ <V3DxcSelect label="test-select-name" options={optionsWithoutIcon} multiple onChange={onChange}></V3DxcSelect>
187
+ );
188
+ const select = getByRole("button");
189
+ act(() => {
190
+ userEvent.click(select);
191
+ });
192
+ act(() => {
193
+ userEvent.click(getByText("Amazon"));
194
+ });
195
+ expect(onChange).toHaveBeenCalledWith([1]);
196
+ act(() => {
197
+ userEvent.click(getByText("Ebay"));
198
+ });
199
+ expect(onChange).toHaveBeenCalledWith([1, 2]);
200
+ expect(getByText("Amazon, Ebay")).toBeTruthy();
201
+ act(() => {
202
+ userEvent.click(getByText("Apple"));
203
+ });
204
+ expect(onChange).toHaveBeenCalledWith([1, 2, 3]);
205
+ expect(getByText("Amazon, Ebay, Apple")).toBeTruthy();
206
+ act(() => {
207
+ userEvent.click(getByText("Amazon"));
208
+ });
209
+ expect(onChange).toHaveBeenCalledWith([2, 3]);
210
+ expect(getByText("Ebay, Apple")).toBeTruthy();
211
+ });
212
+ });