@dxc-technology/halstack-react 0.0.0-e30cba6 → 0.0.0-e832ef8
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.
- package/dist/ThemeContext.js +69 -61
- package/dist/V3Textarea/V3Textarea.js +264 -0
- package/dist/alert/Alert.js +5 -5
- package/dist/alert/index.d.ts +51 -0
- package/dist/button/Button.js +1 -1
- package/dist/common/variables.js +341 -139
- package/dist/date/Date.js +10 -12
- package/dist/{new-date/NewDate.js → date-input/DateInput.js} +69 -72
- package/dist/date-input/index.d.ts +95 -0
- package/dist/file-input/FileInput.js +644 -0
- package/dist/file-input/FileItem.js +280 -0
- package/dist/file-input/index.d.ts +81 -0
- package/dist/footer/Footer.js +44 -18
- package/dist/footer/Icons.js +77 -0
- package/dist/header/Header.js +80 -49
- package/dist/header/Icons.js +59 -0
- package/dist/input-text/Icons.js +22 -0
- package/dist/input-text/InputText.js +7 -9
- package/dist/layout/ApplicationLayout.js +5 -9
- package/dist/layout/Icons.js +55 -0
- package/dist/link/Link.js +4 -8
- package/dist/main.d.ts +8 -0
- package/dist/main.js +37 -21
- package/dist/new-select/NewSelect.js +836 -0
- package/dist/new-select/index.d.ts +53 -0
- package/dist/{number/Number.js → number-input/NumberInput.js} +9 -11
- package/dist/{number/NumberContext.js → number-input/NumberInputContext.js} +2 -2
- package/dist/number-input/index.d.ts +113 -0
- package/dist/paginator/Icons.js +66 -0
- package/dist/paginator/Paginator.js +5 -11
- package/dist/{password/Password.js → password-input/PasswordInput.js} +11 -13
- package/dist/password-input/index.d.ts +94 -0
- package/dist/progress-bar/ProgressBar.js +1 -1
- package/dist/select/Select.js +122 -158
- package/dist/sidenav/Sidenav.js +6 -4
- package/dist/slider/Slider.js +104 -19
- package/dist/spinner/Spinner.js +217 -54
- package/dist/tag/Tag.js +26 -32
- package/dist/{new-input-text/NewInputText.js → text-input/TextInput.js} +180 -170
- package/dist/text-input/index.d.ts +135 -0
- package/dist/textarea/Textarea.js +227 -122
- package/dist/textarea/index.d.ts +117 -0
- package/dist/toggle-group/ToggleGroup.js +132 -28
- package/dist/upload/Upload.js +3 -3
- package/dist/upload/buttons-upload/ButtonsUpload.js +7 -11
- package/dist/upload/buttons-upload/Icons.js +40 -0
- package/dist/upload/file-upload/FileToUpload.js +26 -21
- package/dist/upload/file-upload/Icons.js +66 -0
- package/dist/upload/readme.md +2 -2
- package/dist/upload/transaction/Icons.js +160 -0
- package/dist/upload/transaction/Transaction.js +11 -38
- package/dist/wizard/Icons.js +65 -0
- package/dist/wizard/Wizard.js +3 -9
- package/package.json +2 -1
- package/test/Date.test.js +48 -44
- package/test/{NewDate.test.js → DateInput.test.js} +66 -27
- package/test/FileInput.test.js +201 -0
- package/test/Footer.test.js +2 -7
- package/test/Header.test.js +5 -10
- package/test/InputText.test.js +24 -16
- package/test/{Number.test.js → NumberInput.test.js} +84 -66
- package/test/Paginator.test.js +1 -1
- package/test/PasswordInput.test.js +83 -0
- package/test/ResultsetTable.test.js +1 -2
- package/test/Select.test.js +40 -17
- package/test/Slider.test.js +9 -17
- package/test/Spinner.test.js +5 -0
- package/test/{NewInputText.test.js → TextInput.test.js} +146 -231
- package/test/Textarea.test.js +193 -0
- package/test/ToggleGroup.test.js +5 -1
- package/test/Upload.test.js +5 -5
- package/test/{TextArea.test.js → V3TextArea.test.js} +6 -7
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/footer/dxc_logo.svg +0 -15
- package/dist/footer/readme.md +0 -41
- package/dist/header/Header.stories.js +0 -176
- package/dist/header/close_icon.svg +0 -1
- package/dist/header/dxc_logo_black.svg +0 -8
- package/dist/header/hamb_menu_black.svg +0 -1
- package/dist/header/hamb_menu_white.svg +0 -1
- package/dist/header/readme.md +0 -33
- package/dist/input-text/InputText.stories.js +0 -209
- package/dist/input-text/error.svg +0 -1
- package/dist/input-text/readme.md +0 -91
- package/dist/layout/facebook.svg +0 -45
- package/dist/layout/linkedin.svg +0 -50
- package/dist/layout/twitter.svg +0 -53
- package/dist/new-textarea/NewTextarea.js +0 -346
- package/dist/paginator/images/next.svg +0 -3
- package/dist/paginator/images/nextPage.svg +0 -3
- package/dist/paginator/images/previous.svg +0 -3
- package/dist/paginator/images/previousPage.svg +0 -3
- package/dist/paginator/readme.md +0 -50
- package/dist/password/styles.css +0 -3
- package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
- package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
- package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
- package/dist/select/Select.stories.js +0 -235
- package/dist/select/readme.md +0 -72
- package/dist/slider/Slider.stories.js +0 -241
- package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
- package/dist/upload/buttons-upload/upload-button.svg +0 -1
- package/dist/upload/file-upload/audio-icon.svg +0 -4
- package/dist/upload/file-upload/close.svg +0 -4
- package/dist/upload/file-upload/file-icon.svg +0 -4
- package/dist/upload/file-upload/video-icon.svg +0 -4
- package/dist/upload/transaction/audio-icon-err.svg +0 -4
- package/dist/upload/transaction/audio-icon.svg +0 -4
- package/dist/upload/transaction/error-icon.svg +0 -4
- package/dist/upload/transaction/file-icon-err.svg +0 -4
- package/dist/upload/transaction/file-icon.svg +0 -4
- package/dist/upload/transaction/image-icon-err.svg +0 -4
- package/dist/upload/transaction/image-icon.svg +0 -4
- package/dist/upload/transaction/success-icon.svg +0 -4
- package/dist/upload/transaction/video-icon-err.svg +0 -4
- package/dist/upload/transaction/video-icon.svg +0 -4
- package/dist/wizard/invalid_icon.svg +0 -5
- package/dist/wizard/valid_icon.svg +0 -5
- package/dist/wizard/validation-wrong.svg +0 -6
- package/test/NewTextarea.test.js +0 -201
- package/test/Password.test.js +0 -76
package/test/Paginator.test.js
CHANGED
|
@@ -62,7 +62,7 @@ describe("Paginator component tests", () => {
|
|
|
62
62
|
act(() => {
|
|
63
63
|
userEvent.click(goToPageSelect);
|
|
64
64
|
});
|
|
65
|
-
const goToPageOption =
|
|
65
|
+
const goToPageOption = getByText("2");
|
|
66
66
|
act(() => {
|
|
67
67
|
userEvent.click(goToPageOption);
|
|
68
68
|
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import DxcPasswordInput from "../src/password-input/PasswordInput";
|
|
5
|
+
|
|
6
|
+
describe("Password input component tests", () => {
|
|
7
|
+
test("Password input renders with label", () => {
|
|
8
|
+
const { getByText } = render(<DxcPasswordInput label="Password input label" />);
|
|
9
|
+
expect(getByText("Password input label")).toBeTruthy();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("Password input renders with helper text", () => {
|
|
13
|
+
const { getByText } = render(<DxcPasswordInput helperText="Helper text" />);
|
|
14
|
+
expect(getByText("Helper text")).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("Password input renders error", () => {
|
|
18
|
+
const { getByText } = render(<DxcPasswordInput error="Error message." />);
|
|
19
|
+
expect(getByText("Error message.")).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("onChange function is called correctly", () => {
|
|
23
|
+
const onChange = jest.fn();
|
|
24
|
+
const { getByRole } = render(<DxcPasswordInput label="Password input" onChange={onChange} />);
|
|
25
|
+
const passwordInput = getByRole("textbox");
|
|
26
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
27
|
+
expect(onChange).toHaveBeenCalledWith({ value: "P", error: null });
|
|
28
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("onBlur function is called correctly", () => {
|
|
32
|
+
const onBlur = jest.fn();
|
|
33
|
+
const { getByRole } = render(<DxcPasswordInput label="Password input" onBlur={onBlur} />);
|
|
34
|
+
const passwordInput = getByRole("textbox");
|
|
35
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
36
|
+
fireEvent.blur(passwordInput);
|
|
37
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "Pa$$w0rd", error: null });
|
|
38
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("Clear password input value", () => {
|
|
42
|
+
const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" clearable />);
|
|
43
|
+
const passwordInput = getByRole("textbox");
|
|
44
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
45
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
46
|
+
const clearButton = getAllByRole("button")[0];
|
|
47
|
+
userEvent.click(clearButton);
|
|
48
|
+
expect(passwordInput.value).toBe("");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("Non clearable password input has no clear icon", () => {
|
|
52
|
+
const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" />);
|
|
53
|
+
const passwordInput = getByRole("textbox");
|
|
54
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
55
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
56
|
+
const buttons = getAllByRole("button");
|
|
57
|
+
expect(buttons.length).toBe(1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("Show/hide password input button works correctly", () => {
|
|
61
|
+
const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" clearable />);
|
|
62
|
+
const passwordInput = getByRole("textbox");
|
|
63
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
64
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
65
|
+
expect(passwordInput.type).toBe("password");
|
|
66
|
+
const showButton = getAllByRole("button")[1];
|
|
67
|
+
userEvent.click(showButton);
|
|
68
|
+
expect(passwordInput.type).toBe("text");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("Password input has correct accesibility attributes", () => {
|
|
72
|
+
const { getByRole } = render(<DxcPasswordInput label="Password input" />);
|
|
73
|
+
const passwordInput = getByRole("textbox");
|
|
74
|
+
expect(passwordInput.getAttribute("aria-autocomplete")).toBeNull();
|
|
75
|
+
expect(passwordInput.getAttribute("aria-controls")).toBeNull();
|
|
76
|
+
const showButton = getByRole("button");
|
|
77
|
+
expect(showButton.getAttribute("aria-expanded")).toBe("false");
|
|
78
|
+
expect(showButton.getAttribute("aria-label")).toBe("Show");
|
|
79
|
+
userEvent.click(showButton);
|
|
80
|
+
expect(showButton.getAttribute("aria-expanded")).toBe("true");
|
|
81
|
+
expect(showButton.getAttribute("aria-label")).toBe("Hide");
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -266,13 +266,12 @@ describe("ResultsetTable component tests", () => {
|
|
|
266
266
|
act(() => {
|
|
267
267
|
userEvent.click(goToPageSelect);
|
|
268
268
|
});
|
|
269
|
-
const goToPageOption =
|
|
269
|
+
const goToPageOption = getByText("2");
|
|
270
270
|
act(() => {
|
|
271
271
|
userEvent.click(goToPageOption);
|
|
272
272
|
});
|
|
273
273
|
|
|
274
274
|
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
275
|
-
// expect(getByText("Page: 2 of 4")).toBeTruthy();
|
|
276
275
|
expect(getByText("Rick")).toBeTruthy();
|
|
277
276
|
expect(getByText("Mark")).toBeTruthy();
|
|
278
277
|
expect(getByText("Cris")).toBeTruthy();
|
package/test/Select.test.js
CHANGED
|
@@ -21,18 +21,43 @@ const optionsWithoutIcon = [
|
|
|
21
21
|
const optionsWithIcons = [
|
|
22
22
|
{
|
|
23
23
|
value: 1,
|
|
24
|
-
label: "
|
|
25
|
-
|
|
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
|
+
),
|
|
26
38
|
},
|
|
27
39
|
{
|
|
28
40
|
value: 2,
|
|
29
|
-
label: "
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
),
|
|
36
61
|
},
|
|
37
62
|
];
|
|
38
63
|
|
|
@@ -60,29 +85,27 @@ describe("Select component tests", () => {
|
|
|
60
85
|
});
|
|
61
86
|
|
|
62
87
|
test("Select renders options with icons before", () => {
|
|
63
|
-
const { getByRole,
|
|
88
|
+
const { getByRole, getByTestId } = render(
|
|
64
89
|
<DxcSelect label="test-select-name" options={optionsWithIcons}></DxcSelect>
|
|
65
90
|
);
|
|
66
91
|
const select = getByRole("button");
|
|
67
92
|
act(() => {
|
|
68
93
|
userEvent.click(select);
|
|
69
94
|
});
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
72
|
-
expect(getAllByRole("img")[2].getAttribute("src")).toEqual("/testIconLinkedin");
|
|
95
|
+
expect(getByTestId("image-1")).toBeTruthy();
|
|
96
|
+
expect(getByTestId("image-2")).toBeTruthy();
|
|
73
97
|
});
|
|
74
98
|
|
|
75
99
|
test("Select renders options with icons after", () => {
|
|
76
|
-
const { getByRole,
|
|
100
|
+
const { getByRole, getByTestId } = render(
|
|
77
101
|
<DxcSelect label="test-select-name" options={optionsWithIcons} iconPosition="after"></DxcSelect>
|
|
78
102
|
);
|
|
79
103
|
const select = getByRole("button");
|
|
80
104
|
act(() => {
|
|
81
105
|
userEvent.click(select);
|
|
82
106
|
});
|
|
83
|
-
expect(
|
|
84
|
-
expect(
|
|
85
|
-
expect(getAllByRole("img")[2].getAttribute("src")).toEqual("/testIconLinkedin");
|
|
107
|
+
expect(getByTestId("image-1")).toBeTruthy();
|
|
108
|
+
expect(getByTestId("image-2")).toBeTruthy();
|
|
86
109
|
});
|
|
87
110
|
|
|
88
111
|
test("Select renders with a default value", () => {
|
package/test/Slider.test.js
CHANGED
|
@@ -4,7 +4,7 @@ import DxcSlider from "../src/slider/Slider";
|
|
|
4
4
|
|
|
5
5
|
describe("Slider component tests", () => {
|
|
6
6
|
test("Slider renders with correct text", () => {
|
|
7
|
-
const { getByText } = render(<DxcSlider minValue={0} maxValue={100} showLimitsValues
|
|
7
|
+
const { getByText } = render(<DxcSlider minValue={0} maxValue={100} showLimitsValues />);
|
|
8
8
|
expect(getByText("0")).toBeTruthy();
|
|
9
9
|
expect(getByText("100")).toBeTruthy();
|
|
10
10
|
});
|
|
@@ -12,37 +12,29 @@ describe("Slider component tests", () => {
|
|
|
12
12
|
test("Calls correct function onChange in controlled slider", () => {
|
|
13
13
|
const onChange = jest.fn();
|
|
14
14
|
const { getByRole } = render(
|
|
15
|
-
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues value={13} showInput
|
|
15
|
+
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues value={13} showInput />
|
|
16
16
|
);
|
|
17
17
|
act(() => {
|
|
18
18
|
fireEvent.change(getByRole("textbox"), { target: { value: 25 } });
|
|
19
19
|
});
|
|
20
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
20
|
+
expect(onChange).toHaveBeenCalledWith(25);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
test("Calls correct function onChange in uncontrolled slider", () => {
|
|
24
24
|
const onChange = jest.fn();
|
|
25
25
|
const { getByRole } = render(
|
|
26
|
-
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues showInput
|
|
26
|
+
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues showInput />
|
|
27
27
|
);
|
|
28
28
|
act(() => {
|
|
29
29
|
fireEvent.change(getByRole("textbox"), { target: { value: 25 } });
|
|
30
30
|
});
|
|
31
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
31
|
+
expect(onChange).toHaveBeenCalledWith(25);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
test("Disabled slider have disabled input", () => {
|
|
35
35
|
const onChange = jest.fn();
|
|
36
36
|
const { getByRole } = render(
|
|
37
|
-
<DxcSlider
|
|
38
|
-
minValue={0}
|
|
39
|
-
maxValue={100}
|
|
40
|
-
onChange={onChange}
|
|
41
|
-
showLimitsValues
|
|
42
|
-
disabled
|
|
43
|
-
showInput
|
|
44
|
-
value={13}
|
|
45
|
-
></DxcSlider>
|
|
37
|
+
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues disabled showInput value={13} />
|
|
46
38
|
);
|
|
47
39
|
act(() => {
|
|
48
40
|
fireEvent.change(getByRole("textbox"), { target: { value: 25 } });
|
|
@@ -54,7 +46,7 @@ describe("Slider component tests", () => {
|
|
|
54
46
|
test("Calls correct function onDragEnd", () => {
|
|
55
47
|
const onDragEnd = jest.fn();
|
|
56
48
|
const { getByRole } = render(
|
|
57
|
-
<DxcSlider minValue={0} maxValue={100} showLimitsValues showInput onDragEnd={onDragEnd} value={25}
|
|
49
|
+
<DxcSlider minValue={0} maxValue={100} showLimitsValues showInput onDragEnd={onDragEnd} value={25} />
|
|
58
50
|
);
|
|
59
51
|
act(() => {
|
|
60
52
|
fireEvent.mouseDown(getByRole("slider"));
|
|
@@ -64,7 +56,7 @@ describe("Slider component tests", () => {
|
|
|
64
56
|
});
|
|
65
57
|
|
|
66
58
|
test("Calls correct function labelFormatCallback", () => {
|
|
67
|
-
const labelFormatCallback = jest.fn(x => `${x}$`);
|
|
59
|
+
const labelFormatCallback = jest.fn((x) => `${x}$`);
|
|
68
60
|
const { getByText } = render(
|
|
69
61
|
<DxcSlider
|
|
70
62
|
minValue={0}
|
|
@@ -73,7 +65,7 @@ describe("Slider component tests", () => {
|
|
|
73
65
|
showInput
|
|
74
66
|
value={25}
|
|
75
67
|
labelFormatCallback={labelFormatCallback}
|
|
76
|
-
|
|
68
|
+
/>
|
|
77
69
|
);
|
|
78
70
|
expect(getByText("0$")).toBeTruthy();
|
|
79
71
|
expect(getByText("100$")).toBeTruthy();
|
package/test/Spinner.test.js
CHANGED
|
@@ -24,4 +24,9 @@ describe("Spinner component tests", () => {
|
|
|
24
24
|
expect(getByText("test-loading")).toBeTruthy();
|
|
25
25
|
expect(getByText("75%")).toBeTruthy();
|
|
26
26
|
});
|
|
27
|
+
|
|
28
|
+
test("Get spinner by role", () => {
|
|
29
|
+
const { getByRole } = render(<DxcSpinner label="test-loading" value={75} showValue></DxcSpinner>);
|
|
30
|
+
expect(getByRole("progressbar")).toBeTruthy();
|
|
31
|
+
});
|
|
27
32
|
});
|