@dxc-technology/halstack-react 0.0.0-a7970fd → 0.0.0-a7fec42
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/HalstackContext.d.ts +4 -2
- package/HalstackContext.js +110 -58
- package/accordion/Accordion.js +122 -103
- package/accordion/Accordion.stories.tsx +2 -3
- package/accordion/Accordion.test.js +9 -10
- package/accordion/types.d.ts +5 -4
- package/accordion-group/AccordionGroup.js +2 -21
- package/accordion-group/AccordionGroup.stories.tsx +27 -1
- package/accordion-group/AccordionGroup.test.js +20 -45
- package/accordion-group/types.d.ts +10 -3
- package/alert/Alert.js +5 -2
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +23 -33
- package/box/types.d.ts +1 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +43 -61
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +34 -36
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.js +90 -95
- package/checkbox/Checkbox.test.js +93 -16
- package/checkbox/types.d.ts +2 -2
- package/chip/types.d.ts +1 -1
- package/common/variables.js +232 -96
- package/date-input/DateInput.js +8 -5
- package/dialog/Dialog.js +52 -28
- package/dialog/Dialog.stories.tsx +57 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +3 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +244 -247
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +509 -108
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +25 -5
- package/file-input/FileInput.js +9 -6
- package/file-input/FileItem.js +7 -5
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +69 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/{quick-nav-container → flex}/types.js +0 -0
- package/footer/Footer.js +7 -5
- package/footer/Footer.stories.tsx +8 -1
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +2 -1
- package/header/Header.js +80 -75
- package/header/Header.stories.tsx +4 -4
- package/header/Icons.js +2 -2
- package/header/types.d.ts +3 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +70 -117
- package/layout/ApplicationLayout.stories.tsx +84 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +57 -70
- package/link/Link.stories.tsx +95 -53
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +8 -11
- package/main.js +40 -58
- package/number-input/NumberInput.test.js +1 -1
- package/number-input/types.d.ts +1 -1
- package/package.json +10 -9
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +42 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +11 -6
- package/password-input/PasswordInput.test.js +14 -14
- package/password-input/types.d.ts +1 -1
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +57 -51
- package/progress-bar/ProgressBar.stories.jsx +13 -11
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.js +75 -22
- package/quick-nav/QuickNav.stories.tsx +131 -26
- package/quick-nav/types.d.ts +1 -1
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +30 -27
- package/radio-group/RadioGroup.stories.tsx +1 -0
- package/radio-group/RadioGroup.test.js +123 -96
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +58 -8
- package/select/Select.js +80 -90
- package/select/Select.stories.tsx +145 -100
- package/select/Select.test.js +425 -249
- package/select/types.d.ts +2 -5
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.js +116 -92
- package/slider/Slider.stories.tsx +7 -1
- package/slider/Slider.test.js +121 -21
- package/slider/types.d.ts +2 -2
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +135 -66
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +144 -17
- package/switch/types.d.ts +3 -4
- package/table/Table.js +1 -1
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +135 -0
- package/tabs/Tabs.js +360 -104
- package/tabs/Tabs.stories.tsx +74 -0
- package/tabs/Tabs.test.js +217 -6
- package/tabs/types.d.ts +15 -5
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +130 -0
- package/tabs-nav/types.d.ts +53 -0
- package/{radio → tabs-nav}/types.js +0 -0
- package/tag/Tag.js +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +57 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +206 -329
- package/text-input/TextInput.stories.tsx +189 -182
- package/text-input/TextInput.test.js +166 -164
- package/text-input/types.d.ts +35 -4
- package/textarea/Textarea.js +10 -19
- package/textarea/types.d.ts +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/{row → typography}/types.js +0 -0
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +36 -41
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/types.d.ts +5 -4
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/quick-nav-container/HeadingLink.d.ts +0 -8
- package/quick-nav-container/HeadingLink.js +0 -58
- package/quick-nav-container/QuickNavContainer.d.ts +0 -4
- package/quick-nav-container/QuickNavContainer.js +0 -69
- package/quick-nav-container/Section.d.ts +0 -9
- package/quick-nav-container/Section.js +0 -37
- package/quick-nav-container/types.d.ts +0 -34
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -173
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -24
- package/stack/types.js +0 -5
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
|
@@ -6,25 +6,39 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
6
6
|
|
|
7
7
|
var _react2 = require("@testing-library/react");
|
|
8
8
|
|
|
9
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
|
+
|
|
9
11
|
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
|
|
10
12
|
|
|
11
13
|
describe("Checkbox component tests", function () {
|
|
12
|
-
test("Checkbox renders with correct
|
|
14
|
+
test("Checkbox renders with correct aria-labelledby and aria-required", function () {
|
|
13
15
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
14
16
|
label: "Checkbox"
|
|
15
17
|
})),
|
|
16
|
-
getByText = _render.getByText
|
|
18
|
+
getByText = _render.getByText,
|
|
19
|
+
getByRole = _render.getByRole;
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
var labelId = getByText("Checkbox").getAttribute("id");
|
|
22
|
+
expect(getByRole("checkbox").getAttribute("aria-labelledby")).toBe(labelId);
|
|
23
|
+
expect(getByRole("checkbox").getAttribute("aria-required")).toBe("true");
|
|
24
|
+
});
|
|
25
|
+
test("Optional checkbox renders with correct aria-required", function () {
|
|
26
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
27
|
+
label: "Checkbox",
|
|
28
|
+
optional: true
|
|
29
|
+
})),
|
|
30
|
+
getByRole = _render2.getByRole;
|
|
31
|
+
|
|
32
|
+
expect(getByRole("checkbox").getAttribute("aria-required")).toBe("false");
|
|
19
33
|
});
|
|
20
34
|
test("Calls correct function on click", function () {
|
|
21
35
|
var onChange = jest.fn();
|
|
22
36
|
|
|
23
|
-
var
|
|
37
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
24
38
|
label: "Checkbox",
|
|
25
39
|
onChange: onChange
|
|
26
40
|
})),
|
|
27
|
-
getByText =
|
|
41
|
+
getByText = _render3.getByText;
|
|
28
42
|
|
|
29
43
|
_react2.fireEvent.click(getByText("Checkbox"));
|
|
30
44
|
|
|
@@ -34,45 +48,108 @@ describe("Checkbox component tests", function () {
|
|
|
34
48
|
var onChange = jest.fn();
|
|
35
49
|
var component = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
36
50
|
label: "Checkbox",
|
|
37
|
-
onChange: onChange
|
|
51
|
+
onChange: onChange,
|
|
52
|
+
name: "test"
|
|
38
53
|
}));
|
|
39
54
|
var visibleCheckbox = component.getByText("Checkbox");
|
|
40
55
|
var input = component.getByRole("checkbox");
|
|
41
|
-
|
|
56
|
+
var submitInput = component.container.querySelector("input[name=\"test\"]");
|
|
57
|
+
expect(input.getAttribute("aria-checked")).toBe("false");
|
|
58
|
+
expect(submitInput.checked).toBe(false);
|
|
42
59
|
|
|
43
60
|
_react2.fireEvent.click(visibleCheckbox);
|
|
44
61
|
|
|
45
62
|
expect(onChange).toHaveBeenCalled();
|
|
46
63
|
expect(onChange).toHaveBeenCalledWith(true);
|
|
47
|
-
expect(input.checked).toBe(true);
|
|
64
|
+
expect(input.getAttribute("aria-checked")).toBe("true");
|
|
65
|
+
expect(submitInput.checked).toBe(true);
|
|
48
66
|
});
|
|
49
67
|
test("Controlled checkbox", function () {
|
|
50
68
|
var onChange = jest.fn();
|
|
51
69
|
var component = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
52
70
|
label: "Checkbox",
|
|
53
71
|
checked: false,
|
|
54
|
-
onChange: onChange
|
|
72
|
+
onChange: onChange,
|
|
73
|
+
name: "test"
|
|
55
74
|
}));
|
|
56
75
|
var input = component.getByRole("checkbox");
|
|
57
76
|
var visibleCheckbox = component.getByText("Checkbox");
|
|
77
|
+
var submitInput = component.container.querySelector("input[name=\"test\"]");
|
|
58
78
|
|
|
59
79
|
_react2.fireEvent.click(visibleCheckbox);
|
|
60
80
|
|
|
61
81
|
expect(onChange).toHaveBeenCalled();
|
|
62
82
|
expect(onChange).toHaveBeenCalledWith(true);
|
|
63
|
-
expect(input.checked).toBe(false);
|
|
83
|
+
expect(input.getAttribute("aria-checked")).toBe("false");
|
|
84
|
+
expect(submitInput.checked).toBe(false);
|
|
64
85
|
});
|
|
65
86
|
test("Renders with correct initial value and initial state when it is uncontrolled", function () {
|
|
66
|
-
var
|
|
87
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
67
88
|
label: "Default label",
|
|
68
89
|
defaultChecked: true,
|
|
69
|
-
value: "test-defaultChecked"
|
|
90
|
+
value: "test-defaultChecked",
|
|
91
|
+
name: "test"
|
|
92
|
+
})),
|
|
93
|
+
getByRole = _render4.getByRole,
|
|
94
|
+
container = _render4.container;
|
|
95
|
+
|
|
96
|
+
var checkbox = getByRole("checkbox");
|
|
97
|
+
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
98
|
+
expect(submitInput.value).toBe("test-defaultChecked");
|
|
99
|
+
expect(checkbox.getAttribute("aria-checked")).toBe("true");
|
|
100
|
+
expect(submitInput.checked).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
test("Test disable keyboard and mouse interactions", function () {
|
|
103
|
+
var onChange = jest.fn();
|
|
104
|
+
|
|
105
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
106
|
+
label: "Checkbox",
|
|
107
|
+
onChange: onChange,
|
|
108
|
+
disabled: true,
|
|
109
|
+
name: "test"
|
|
70
110
|
})),
|
|
71
|
-
getByRole =
|
|
111
|
+
getByRole = _render5.getByRole,
|
|
112
|
+
getByText = _render5.getByText,
|
|
113
|
+
container = _render5.container;
|
|
72
114
|
|
|
73
115
|
var input = getByRole("checkbox");
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
116
|
+
var visibleCheckbox = getByText("Checkbox");
|
|
117
|
+
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
118
|
+
|
|
119
|
+
_react2.fireEvent.click(visibleCheckbox);
|
|
120
|
+
|
|
121
|
+
expect(onChange).toHaveBeenCalledTimes(0);
|
|
122
|
+
expect(input.getAttribute("aria-checked")).toBe("false");
|
|
123
|
+
expect(input.getAttribute("aria-disabled")).toBe("true");
|
|
124
|
+
expect(submitInput.checked).toBe(false);
|
|
125
|
+
|
|
126
|
+
_userEvent["default"].tab();
|
|
127
|
+
|
|
128
|
+
expect(document.activeElement === input).toBeFalsy();
|
|
129
|
+
});
|
|
130
|
+
test("Test keyboard interactions", function () {
|
|
131
|
+
var onChange = jest.fn();
|
|
132
|
+
|
|
133
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
134
|
+
label: "Checkbox",
|
|
135
|
+
name: "test",
|
|
136
|
+
onChange: onChange
|
|
137
|
+
})),
|
|
138
|
+
getByRole = _render6.getByRole;
|
|
139
|
+
|
|
140
|
+
var checkbox = getByRole("checkbox");
|
|
141
|
+
|
|
142
|
+
_userEvent["default"].tab();
|
|
143
|
+
|
|
144
|
+
expect(document.activeElement === checkbox).toBeTruthy();
|
|
145
|
+
|
|
146
|
+
_react2.fireEvent.keyDown(checkbox, {
|
|
147
|
+
key: " ",
|
|
148
|
+
code: "Space",
|
|
149
|
+
keyCode: 32,
|
|
150
|
+
charCode: 32
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
expect(onChange).toHaveBeenCalledWith(true);
|
|
77
154
|
});
|
|
78
155
|
});
|
package/checkbox/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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;
|
package/chip/types.d.ts
CHANGED