@dxc-technology/halstack-react 0.0.0-011b1bb

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 (130) 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/V3Textarea/V3Textarea.js +264 -0
  6. package/dist/accordion/Accordion.js +353 -0
  7. package/dist/accordion-group/AccordionGroup.js +186 -0
  8. package/dist/alert/Alert.js +403 -0
  9. package/dist/alert/index.d.ts +51 -0
  10. package/dist/badge/Badge.js +63 -0
  11. package/dist/box/Box.js +156 -0
  12. package/dist/button/Button.js +238 -0
  13. package/dist/card/Card.js +254 -0
  14. package/dist/checkbox/Checkbox.js +300 -0
  15. package/dist/chip/Chip.js +265 -0
  16. package/dist/common/OpenSans.css +81 -0
  17. package/dist/common/RequiredComponent.js +40 -0
  18. package/dist/common/fonts/OpenSans-Bold.ttf +0 -0
  19. package/dist/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  20. package/dist/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  21. package/dist/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  22. package/dist/common/fonts/OpenSans-Italic.ttf +0 -0
  23. package/dist/common/fonts/OpenSans-Light.ttf +0 -0
  24. package/dist/common/fonts/OpenSans-LightItalic.ttf +0 -0
  25. package/dist/common/fonts/OpenSans-Regular.ttf +0 -0
  26. package/dist/common/fonts/OpenSans-SemiBold.ttf +0 -0
  27. package/dist/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  28. package/dist/common/utils.js +22 -0
  29. package/dist/common/variables.js +1571 -0
  30. package/dist/date/Date.js +379 -0
  31. package/dist/date-input/DateInput.js +400 -0
  32. package/dist/date-input/index.d.ts +95 -0
  33. package/dist/dialog/Dialog.js +218 -0
  34. package/dist/dropdown/Dropdown.js +544 -0
  35. package/dist/file-input/FileInput.js +644 -0
  36. package/dist/file-input/FileItem.js +280 -0
  37. package/dist/file-input/index.d.ts +81 -0
  38. package/dist/footer/Footer.js +421 -0
  39. package/dist/footer/Icons.js +77 -0
  40. package/dist/header/Header.js +470 -0
  41. package/dist/header/Icons.js +59 -0
  42. package/dist/heading/Heading.js +230 -0
  43. package/dist/input-text/Icons.js +22 -0
  44. package/dist/input-text/InputText.js +705 -0
  45. package/dist/layout/ApplicationLayout.js +327 -0
  46. package/dist/layout/Icons.js +55 -0
  47. package/dist/link/Link.js +237 -0
  48. package/dist/main.d.ts +8 -0
  49. package/dist/main.js +359 -0
  50. package/dist/new-select/NewSelect.js +836 -0
  51. package/dist/new-select/index.d.ts +53 -0
  52. package/dist/number-input/NumberInput.js +136 -0
  53. package/dist/number-input/NumberInputContext.js +16 -0
  54. package/dist/number-input/index.d.ts +113 -0
  55. package/dist/paginator/Icons.js +66 -0
  56. package/dist/paginator/Paginator.js +283 -0
  57. package/dist/password-input/PasswordInput.js +198 -0
  58. package/dist/password-input/index.d.ts +94 -0
  59. package/dist/progress-bar/ProgressBar.js +242 -0
  60. package/dist/radio/Radio.js +209 -0
  61. package/dist/resultsetTable/ResultsetTable.js +358 -0
  62. package/dist/select/Select.js +549 -0
  63. package/dist/sidenav/Sidenav.js +179 -0
  64. package/dist/slider/Slider.js +404 -0
  65. package/dist/spinner/Spinner.js +381 -0
  66. package/dist/switch/Switch.js +222 -0
  67. package/dist/table/Table.js +132 -0
  68. package/dist/tabs/Tabs.js +343 -0
  69. package/dist/tag/Tag.js +282 -0
  70. package/dist/text-input/TextInput.js +971 -0
  71. package/dist/text-input/index.d.ts +135 -0
  72. package/dist/textarea/Textarea.js +369 -0
  73. package/dist/textarea/index.d.ts +117 -0
  74. package/dist/toggle/Toggle.js +220 -0
  75. package/dist/toggle-group/ToggleGroup.js +327 -0
  76. package/dist/upload/Upload.js +205 -0
  77. package/dist/upload/buttons-upload/ButtonsUpload.js +135 -0
  78. package/dist/upload/buttons-upload/Icons.js +40 -0
  79. package/dist/upload/dragAndDropArea/DragAndDropArea.js +329 -0
  80. package/dist/upload/dragAndDropArea/Icons.js +39 -0
  81. package/dist/upload/file-upload/FileToUpload.js +189 -0
  82. package/dist/upload/file-upload/Icons.js +66 -0
  83. package/dist/upload/files-upload/FilesToUpload.js +123 -0
  84. package/dist/upload/transaction/Icons.js +160 -0
  85. package/dist/upload/transaction/Transaction.js +148 -0
  86. package/dist/upload/transactions/Transactions.js +138 -0
  87. package/dist/useTheme.js +22 -0
  88. package/dist/wizard/Icons.js +65 -0
  89. package/dist/wizard/Wizard.js +405 -0
  90. package/package.json +75 -0
  91. package/test/Accordion.test.js +33 -0
  92. package/test/AccordionGroup.test.js +125 -0
  93. package/test/Alert.test.js +53 -0
  94. package/test/Box.test.js +10 -0
  95. package/test/Button.test.js +18 -0
  96. package/test/Card.test.js +30 -0
  97. package/test/Checkbox.test.js +45 -0
  98. package/test/Chip.test.js +25 -0
  99. package/test/Date.test.js +397 -0
  100. package/test/DateInput.test.js +242 -0
  101. package/test/Dialog.test.js +23 -0
  102. package/test/Dropdown.test.js +145 -0
  103. package/test/FileInput.test.js +201 -0
  104. package/test/Footer.test.js +94 -0
  105. package/test/Header.test.js +34 -0
  106. package/test/Heading.test.js +83 -0
  107. package/test/InputText.test.js +248 -0
  108. package/test/Link.test.js +43 -0
  109. package/test/NumberInput.test.js +259 -0
  110. package/test/Paginator.test.js +177 -0
  111. package/test/PasswordInput.test.js +83 -0
  112. package/test/ProgressBar.test.js +35 -0
  113. package/test/Radio.test.js +37 -0
  114. package/test/ResultsetTable.test.js +329 -0
  115. package/test/Select.test.js +212 -0
  116. package/test/Sidenav.test.js +45 -0
  117. package/test/Slider.test.js +74 -0
  118. package/test/Spinner.test.js +32 -0
  119. package/test/Switch.test.js +45 -0
  120. package/test/Table.test.js +36 -0
  121. package/test/Tabs.test.js +109 -0
  122. package/test/Tag.test.js +32 -0
  123. package/test/TextInput.test.js +732 -0
  124. package/test/Textarea.test.js +193 -0
  125. package/test/ToggleGroup.test.js +85 -0
  126. package/test/Upload.test.js +60 -0
  127. package/test/V3TextArea.test.js +51 -0
  128. package/test/Wizard.test.js +130 -0
  129. package/test/mocks/pngMock.js +1 -0
  130. package/test/mocks/svgMock.js +1 -0
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import { render, fireEvent } from "@testing-library/react";
3
+ import DxcSwitch from "../src/switch/Switch";
4
+
5
+ describe("Switch component tests", () => {
6
+ test("Switch renders with correct text", () => {
7
+ const onChange = jest.fn((returnedValue) => {
8
+ expect(returnedValue).toBe(true);
9
+ });
10
+
11
+ const { getByText } = render(<DxcSwitch label={"SwitchComponent"} checked={false} onChange={onChange} />);
12
+ expect(getByText("SwitchComponent")).toBeTruthy();
13
+ });
14
+
15
+ test("Calls correct function on click", () => {
16
+ const onChange = jest.fn();
17
+ const { getByText } = render(<DxcSwitch label={"SwitchComponent"} checked={false} onChange={onChange} />);
18
+
19
+ fireEvent.click(getByText("SwitchComponent"));
20
+ expect(onChange).toHaveBeenCalled();
21
+ });
22
+
23
+ test("Everytime the user clicks the component the onchange function is called with the correct value CONTROLLED COMPONENT", () => {
24
+ const onChange = jest.fn();
25
+
26
+ const { getByText } = render(<DxcSwitch label={"SwitchComponent"} checked={false} onChange={onChange} />);
27
+
28
+ fireEvent.click(getByText("SwitchComponent"));
29
+ fireEvent.click(getByText("SwitchComponent"));
30
+ expect(onChange.mock.calls[0][0]).toBe(true);
31
+ expect(onChange.mock.calls[1][0]).toBe(true);
32
+ });
33
+
34
+
35
+ test("Everytime the user clicks the component the onchange function is called with the correct value UNCONTROLLED COMPONENT", () => {
36
+ const onChange = jest.fn();
37
+
38
+ const { getByText } = render(<DxcSwitch label={"SwitchComponent"} onChange={onChange} />);
39
+
40
+ fireEvent.click(getByText("SwitchComponent"));
41
+ fireEvent.click(getByText("SwitchComponent"));
42
+ expect(onChange.mock.calls[0][0]).toBe(true);
43
+ expect(onChange.mock.calls[1][0]).toBe(false);
44
+ });
45
+ });
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { render, fireEvent } from "@testing-library/react";
3
+ import DxcTable from "../src/table/Table";
4
+
5
+ describe("Table component tests", () => {
6
+ test("Table renders with correct content", () => {
7
+ const { getByText } = render(
8
+ <DxcTable>
9
+ <tr>
10
+ <th>header-1</th>
11
+ <th>header-2</th>
12
+ <th>header-3</th>
13
+ </tr>
14
+ <tr>
15
+ <td>cell-1</td>
16
+ <td>cell-2</td>
17
+ <td>cell-3</td>
18
+ </tr>
19
+ <tr>
20
+ <td>cell-4</td>
21
+ <td>cell-5</td>
22
+ <td>cell-6</td>
23
+ </tr>
24
+ </DxcTable>
25
+ );
26
+ expect(getByText("header-1")).toBeTruthy();
27
+ expect(getByText("header-2")).toBeTruthy();
28
+ expect(getByText("header-3")).toBeTruthy();
29
+ expect(getByText("cell-1")).toBeTruthy();
30
+ expect(getByText("cell-2")).toBeTruthy();
31
+ expect(getByText("cell-3")).toBeTruthy();
32
+ expect(getByText("cell-4")).toBeTruthy();
33
+ expect(getByText("cell-5")).toBeTruthy();
34
+ expect(getByText("cell-6")).toBeTruthy();
35
+ });
36
+ });
@@ -0,0 +1,109 @@
1
+ import React from "react";
2
+ import { render, fireEvent } from "@testing-library/react";
3
+ import DxcTabs from "../src/tabs/Tabs";
4
+
5
+ const sampleTabs = [
6
+ {
7
+ label: "Tab-1",
8
+ },
9
+ {
10
+ label: "Tab-2",
11
+ },
12
+ {
13
+ label: "Tab-3",
14
+ },
15
+ ];
16
+
17
+ const sampleTabsWithBadge = [
18
+ {
19
+ label: "Tab-1",
20
+ notificationNumber: "10",
21
+ },
22
+ {
23
+ label: "Tab-2",
24
+ notificationNumber: "20",
25
+ },
26
+ {
27
+ label: "Tab-3",
28
+ notificationNumber: "101",
29
+ },
30
+ ];
31
+
32
+ describe("Tabs component tests", () => {
33
+ test("Tabs render with correct labels", () => {
34
+ const { getByText } = render(<DxcTabs tabs={sampleTabs}></DxcTabs>);
35
+ expect(getByText("Tab-1")).toBeTruthy();
36
+ expect(getByText("Tab-2")).toBeTruthy();
37
+ expect(getByText("Tab-3")).toBeTruthy();
38
+ });
39
+ test("Tabs render with correct labels and badges", () => {
40
+ const { getByText } = render(<DxcTabs tabs={sampleTabsWithBadge}></DxcTabs>);
41
+ expect(getByText("10")).toBeTruthy();
42
+ expect(getByText("20")).toBeTruthy();
43
+ expect(getByText("+99")).toBeTruthy();
44
+ });
45
+
46
+ test("Tabs render with correct icons", () => {
47
+ const { getAllByRole } = render(
48
+ <DxcTabs
49
+ tabs={[
50
+ {
51
+ label: "Tab-1",
52
+ iconSrc: "/testIcon1.png",
53
+ },
54
+ {
55
+ label: "Tab-2",
56
+ iconSrc: "/testIcon2.png",
57
+ },
58
+ {
59
+ label: "Tab-3",
60
+ iconSrc: "/testIcon3.png",
61
+ },
62
+ ]}
63
+ ></DxcTabs>
64
+ );
65
+ expect(getAllByRole("img")[0].getAttribute("src")).toBe("/testIcon1.png");
66
+ expect(getAllByRole("img")[1].getAttribute("src")).toBe("/testIcon2.png");
67
+ expect(getAllByRole("img")[2].getAttribute("src")).toBe("/testIcon3.png");
68
+ });
69
+
70
+ test("Tabs render with disabled tab", () => {
71
+ const { getAllByRole } = render(
72
+ <DxcTabs
73
+ tabs={[
74
+ {
75
+ label: "Tab-1",
76
+ isDisabled: true,
77
+ },
78
+ {
79
+ label: "Tab-2",
80
+ },
81
+ ]}
82
+ ></DxcTabs>
83
+ );
84
+ expect(getAllByRole("tab")[0].hasAttribute("disabled")).toBeTruthy();
85
+ expect(getAllByRole("tab")[1].hasAttribute("disabled")).toBeFalsy();
86
+ });
87
+
88
+ test("Uncontrolled tabs", () => {
89
+ const onTabClick = jest.fn();
90
+ const { getByText } = render(<DxcTabs tabs={sampleTabs} onTabClick={onTabClick}></DxcTabs>);
91
+ const tab1 = getByText("Tab-1");
92
+ const tab2 = getByText("Tab-2");
93
+ fireEvent.click(tab2);
94
+ expect(onTabClick).toHaveBeenCalledWith(1);
95
+ fireEvent.click(tab1);
96
+ expect(onTabClick).toHaveBeenCalledWith(0);
97
+ });
98
+
99
+ test("Controlled tabs", () => {
100
+ const onTabClick = jest.fn();
101
+ const { getByText } = render(<DxcTabs tabs={sampleTabs} onTabClick={onTabClick} activeTabIndex={0}></DxcTabs>);
102
+ const tab2 = getByText("Tab-2");
103
+ const tab3 = getByText("Tab-3");
104
+ fireEvent.click(tab2);
105
+ expect(onTabClick).toHaveBeenCalledWith(1);
106
+ fireEvent.click(tab3);
107
+ expect(onTabClick).toHaveBeenCalledWith(2);
108
+ });
109
+ });
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import { render, fireEvent } from "@testing-library/react";
3
+ import DxcTag from "../src/tag/Tag";
4
+
5
+ describe("Tag component tests", () => {
6
+ test("Tag renders with correct label", () => {
7
+ const { getByText } = render(<DxcTag label="tag-test"></DxcTag>);
8
+ expect(getByText("tag-test")).toBeTruthy();
9
+ });
10
+
11
+ test("Tag renders with correct label before", () => {
12
+ const { getByText } = render(<DxcTag label="tag-test" labelPosition="before"></DxcTag>);
13
+ expect(getByText("tag-test")).toBeTruthy();
14
+ });
15
+
16
+ test("Tag renders with correct icon", () => {
17
+ const { getByRole } = render(<DxcTag label="tag-test" iconSrc="/test-icon.jpg"></DxcTag>);
18
+ expect(getByRole("img").getAttribute("src")).toBe("/test-icon.jpg");
19
+ });
20
+
21
+ test("Tag renders with link href", () => {
22
+ const { getByRole } = render(<DxcTag label="tag-test" linkHref="/test/page"></DxcTag>);
23
+ expect(getByRole("link").getAttribute("href")).toBe("/test/page");
24
+ });
25
+
26
+ test("Call correct function on click", () => {
27
+ const onClick = jest.fn();
28
+ const { getByText } = render(<DxcTag label="tag-test" onClick={onClick}></DxcTag>);
29
+ fireEvent.click(getByText("tag-test"));
30
+ expect(onClick).toHaveBeenCalled();
31
+ });
32
+ });