@dxc-technology/halstack-react 0.0.0-ff43881 → 0.0.0-ff5083e
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 +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +7 -28
- package/accordion/Accordion.stories.tsx +11 -11
- package/accordion/Accordion.test.js +72 -0
- package/accordion/types.d.ts +4 -0
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +13 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +151 -0
- package/accordion-group/types.d.ts +4 -0
- package/alert/Alert.js +4 -1
- package/alert/Alert.test.js +92 -0
- 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 +31 -32
- package/bleed/types.d.ts +25 -1
- package/box/Box.js +22 -32
- package/box/Box.test.js +18 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +120 -0
- package/bulleted-list/BulletedList.stories.tsx +203 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +14 -11
- package/button/Button.test.js +35 -0
- package/card/Card.js +24 -27
- package/card/Card.test.js +50 -0
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +43 -39
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +78 -0
- package/checkbox/types.d.ts +7 -3
- package/chip/Chip.test.js +56 -0
- package/common/variables.js +197 -322
- package/date-input/DateInput.js +53 -39
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +479 -0
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +4 -32
- package/dialog/Dialog.test.js +40 -0
- package/dropdown/Dropdown.js +13 -17
- package/dropdown/Dropdown.test.js +189 -0
- package/file-input/FileInput.js +9 -6
- package/file-input/FileInput.test.js +457 -0
- package/file-input/FileItem.js +7 -5
- package/footer/Footer.js +15 -88
- package/footer/Footer.test.js +109 -0
- package/header/Header.js +27 -48
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +79 -0
- package/heading/Heading.test.js +186 -0
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +32 -32
- package/inset/types.d.ts +25 -1
- package/layout/ApplicationLayout.d.ts +4 -3
- package/layout/ApplicationLayout.js +82 -114
- package/layout/ApplicationLayout.stories.tsx +14 -59
- 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 +5 -10
- package/link/Link.d.ts +3 -2
- package/link/Link.js +57 -74
- package/link/Link.stories.tsx +87 -52
- package/link/Link.test.js +83 -0
- package/link/types.d.ts +7 -23
- package/main.d.ts +7 -10
- package/main.js +33 -51
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +506 -0
- package/number-input/types.d.ts +17 -10
- package/package.json +6 -5
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +266 -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 +7 -4
- package/password-input/PasswordInput.test.js +180 -0
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.js +1 -1
- package/progress-bar/ProgressBar.stories.jsx +11 -11
- package/progress-bar/ProgressBar.test.js +65 -0
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +112 -0
- package/quick-nav/QuickNav.stories.tsx +237 -0
- package/quick-nav/types.d.ts +21 -0
- package/{radio → quick-nav}/types.js +0 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +25 -24
- package/radio-group/RadioGroup.js +46 -37
- package/radio-group/RadioGroup.stories.tsx +60 -39
- package/radio-group/RadioGroup.test.js +530 -83
- package/radio-group/types.d.ts +80 -2
- package/resultsetTable/ResultsetTable.test.js +306 -0
- package/row/types.d.ts +18 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +152 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.js +109 -327
- package/select/Select.stories.tsx +103 -81
- package/select/Select.test.js +2120 -0
- package/select/types.d.ts +54 -11
- package/sidenav/Sidenav.d.ts +1 -1
- package/sidenav/Sidenav.js +20 -9
- package/sidenav/Sidenav.test.js +56 -0
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +2 -1
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +150 -0
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +1 -1
- package/spinner/Spinner.test.js +64 -0
- package/stack/types.d.ts +15 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +35 -19
- package/switch/Switch.stories.tsx +14 -14
- package/switch/Switch.test.js +98 -0
- package/switch/types.d.ts +6 -2
- package/table/Table.test.js +26 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +9 -11
- package/tabs/Tabs.stories.tsx +0 -8
- package/tabs/Tabs.test.js +140 -0
- package/tabs/types.d.ts +4 -0
- 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 +132 -0
- package/tabs-nav/types.d.ts +53 -0
- package/tabs-nav/types.js +5 -0
- package/tag/Tag.js +14 -19
- package/tag/Tag.stories.tsx +12 -8
- package/tag/Tag.test.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +56 -80
- package/text-input/TextInput.stories.tsx +30 -12
- package/text-input/TextInput.test.js +1712 -0
- package/text-input/types.d.ts +31 -12
- package/textarea/Textarea.js +20 -27
- package/textarea/Textarea.stories.jsx +33 -12
- package/textarea/Textarea.test.js +437 -0
- package/textarea/types.d.ts +18 -11
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +156 -0
- package/toggle-group/types.d.ts +8 -0
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +175 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/typography/typographyContextTypes.d.ts +16 -0
- package/typography/typographyContextTypes.js +5 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +55 -44
- package/wizard/Wizard.stories.tsx +13 -23
- package/wizard/Wizard.test.js +141 -0
- package/wizard/types.d.ts +6 -2
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -243
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- 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/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
|
|
11
|
+
var _react2 = require("@testing-library/react");
|
|
12
|
+
|
|
13
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
14
|
+
|
|
15
|
+
var _PasswordInput = _interopRequireDefault(require("./PasswordInput"));
|
|
16
|
+
|
|
17
|
+
describe("Password input component tests", function () {
|
|
18
|
+
test("Password input renders with label", function () {
|
|
19
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
20
|
+
label: "Password input label"
|
|
21
|
+
})),
|
|
22
|
+
getByText = _render.getByText;
|
|
23
|
+
|
|
24
|
+
expect(getByText("Password input label")).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
test("Password input renders with helper text", function () {
|
|
27
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
28
|
+
helperText: "Helper text"
|
|
29
|
+
})),
|
|
30
|
+
getByText = _render2.getByText;
|
|
31
|
+
|
|
32
|
+
expect(getByText("Helper text")).toBeTruthy();
|
|
33
|
+
});
|
|
34
|
+
test("Password input renders error", function () {
|
|
35
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
36
|
+
error: "Error message."
|
|
37
|
+
})),
|
|
38
|
+
getByText = _render3.getByText;
|
|
39
|
+
|
|
40
|
+
expect(getByText("Error message.")).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
test("onChange function is called correctly", function () {
|
|
43
|
+
var onChange = jest.fn();
|
|
44
|
+
|
|
45
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
46
|
+
label: "Password input",
|
|
47
|
+
onChange: onChange
|
|
48
|
+
})),
|
|
49
|
+
getByRole = _render4.getByRole;
|
|
50
|
+
|
|
51
|
+
var passwordInput = getByRole("textbox");
|
|
52
|
+
|
|
53
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
54
|
+
|
|
55
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
56
|
+
value: "P"
|
|
57
|
+
});
|
|
58
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
59
|
+
});
|
|
60
|
+
test("onBlur function is called correctly", function () {
|
|
61
|
+
var onBlur = jest.fn();
|
|
62
|
+
|
|
63
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
64
|
+
label: "Password input",
|
|
65
|
+
onBlur: onBlur
|
|
66
|
+
})),
|
|
67
|
+
getByRole = _render5.getByRole;
|
|
68
|
+
|
|
69
|
+
var passwordInput = getByRole("textbox");
|
|
70
|
+
|
|
71
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
72
|
+
|
|
73
|
+
_react2.fireEvent.blur(passwordInput);
|
|
74
|
+
|
|
75
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
76
|
+
value: "Pa$$w0rd"
|
|
77
|
+
});
|
|
78
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
79
|
+
});
|
|
80
|
+
test("Clear password input value", function () {
|
|
81
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
82
|
+
label: "Password input",
|
|
83
|
+
clearable: true
|
|
84
|
+
})),
|
|
85
|
+
getAllByRole = _render6.getAllByRole,
|
|
86
|
+
getByRole = _render6.getByRole;
|
|
87
|
+
|
|
88
|
+
var passwordInput = getByRole("textbox");
|
|
89
|
+
|
|
90
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
91
|
+
|
|
92
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
93
|
+
var clearButton = getAllByRole("button")[0];
|
|
94
|
+
|
|
95
|
+
_userEvent["default"].click(clearButton);
|
|
96
|
+
|
|
97
|
+
expect(passwordInput.value).toBe("");
|
|
98
|
+
});
|
|
99
|
+
test("Non clearable password input has no clear icon", function () {
|
|
100
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
101
|
+
label: "Password input"
|
|
102
|
+
})),
|
|
103
|
+
getAllByRole = _render7.getAllByRole,
|
|
104
|
+
getByRole = _render7.getByRole;
|
|
105
|
+
|
|
106
|
+
var passwordInput = getByRole("textbox");
|
|
107
|
+
|
|
108
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
109
|
+
|
|
110
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
111
|
+
var buttons = getAllByRole("button");
|
|
112
|
+
expect(buttons.length).toBe(1);
|
|
113
|
+
});
|
|
114
|
+
test("Show/hide password input button works correctly", function () {
|
|
115
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
116
|
+
label: "Password input",
|
|
117
|
+
clearable: true
|
|
118
|
+
})),
|
|
119
|
+
getAllByRole = _render8.getAllByRole,
|
|
120
|
+
getByRole = _render8.getByRole;
|
|
121
|
+
|
|
122
|
+
var passwordInput = getByRole("textbox");
|
|
123
|
+
|
|
124
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
125
|
+
|
|
126
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
127
|
+
expect(passwordInput.type).toBe("password");
|
|
128
|
+
var showButton = getAllByRole("button")[1];
|
|
129
|
+
|
|
130
|
+
_userEvent["default"].click(showButton);
|
|
131
|
+
|
|
132
|
+
expect(passwordInput.type).toBe("text");
|
|
133
|
+
});
|
|
134
|
+
test("Password tooltip is correct", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
135
|
+
var _render9, getAllByRole, getByTitle, queryByTitle, showButton;
|
|
136
|
+
|
|
137
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
138
|
+
while (1) {
|
|
139
|
+
switch (_context.prev = _context.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
_render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
142
|
+
label: "Password input",
|
|
143
|
+
clearable: true,
|
|
144
|
+
value: "Password"
|
|
145
|
+
})), getAllByRole = _render9.getAllByRole, getByTitle = _render9.getByTitle, queryByTitle = _render9.queryByTitle;
|
|
146
|
+
showButton = getAllByRole("button")[1];
|
|
147
|
+
|
|
148
|
+
_userEvent["default"].hover(showButton);
|
|
149
|
+
|
|
150
|
+
expect(getByTitle("Show password")).toBeTruthy();
|
|
151
|
+
|
|
152
|
+
_userEvent["default"].unhover(showButton);
|
|
153
|
+
|
|
154
|
+
expect(queryByTitle("Hide password")).toBeFalsy();
|
|
155
|
+
|
|
156
|
+
case 6:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee);
|
|
162
|
+
})));
|
|
163
|
+
test("Password input has correct accesibility attributes", function () {
|
|
164
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
165
|
+
label: "Password input"
|
|
166
|
+
})),
|
|
167
|
+
getByRole = _render10.getByRole;
|
|
168
|
+
|
|
169
|
+
var passwordInput = getByRole("textbox");
|
|
170
|
+
expect(passwordInput.getAttribute("aria-autocomplete")).toBeNull();
|
|
171
|
+
expect(passwordInput.getAttribute("aria-controls")).toBeNull();
|
|
172
|
+
expect(passwordInput.getAttribute("aria-expanded")).toBeNull();
|
|
173
|
+
var showButton = getByRole("button");
|
|
174
|
+
expect(showButton.getAttribute("aria-label")).toBe("Show password");
|
|
175
|
+
|
|
176
|
+
_userEvent["default"].click(showButton);
|
|
177
|
+
|
|
178
|
+
expect(showButton.getAttribute("aria-label")).toBe("Hide password");
|
|
179
|
+
});
|
|
180
|
+
});
|
|
@@ -30,25 +30,28 @@ declare type Props = {
|
|
|
30
30
|
* This function will be called when the user types within the input
|
|
31
31
|
* element of the component. An object including the current value and
|
|
32
32
|
* the error (if the value entered is not valid) will be passed to this
|
|
33
|
-
* function. If there is no error, error will be
|
|
33
|
+
* function. If there is no error, error will not be defined.
|
|
34
34
|
* */
|
|
35
35
|
onChange?: (val: {
|
|
36
36
|
value: string;
|
|
37
|
-
error
|
|
37
|
+
error?: string;
|
|
38
38
|
}) => void;
|
|
39
39
|
/**
|
|
40
40
|
* This function will be called when the input element loses the focus.
|
|
41
41
|
* An object including the input value and the error (if the value entered is
|
|
42
|
-
* not valid) will be passed to this function. If there is no error, error will be
|
|
42
|
+
* not valid) will be passed to this function. If there is no error, error will not be defined.
|
|
43
43
|
*/
|
|
44
44
|
onBlur?: (val: {
|
|
45
45
|
value: string;
|
|
46
|
-
error
|
|
46
|
+
error?: string;
|
|
47
47
|
}) => void;
|
|
48
48
|
/**
|
|
49
|
-
* If it is defined
|
|
50
|
-
* the error below the password input
|
|
51
|
-
*
|
|
49
|
+
* If it is a defined value and also a truthy string, the component will
|
|
50
|
+
* change its appearance, showing the error below the password input
|
|
51
|
+
* component. If the defined value is an empty string, it will reserve a
|
|
52
|
+
* space below the component for a future error, but it would not change
|
|
53
|
+
* its look. In case of being undefined or null, both the appearance and
|
|
54
|
+
* the space for the error message would not be modified.
|
|
52
55
|
*/
|
|
53
56
|
error?: string;
|
|
54
57
|
/**
|
|
@@ -58,7 +61,7 @@ declare type Props = {
|
|
|
58
61
|
* the pattern, the onBlur and onChange functions will be called with the
|
|
59
62
|
* current value and an internal error informing that this value does not
|
|
60
63
|
* match the pattern. If the pattern is met, the error parameter of both
|
|
61
|
-
* events will be
|
|
64
|
+
* events will not be defined.
|
|
62
65
|
*/
|
|
63
66
|
pattern?: string;
|
|
64
67
|
/**
|
|
@@ -68,7 +71,7 @@ declare type Props = {
|
|
|
68
71
|
* comply the minimum length, the onBlur and onChange functions will be called
|
|
69
72
|
* with the current value and an internal error informing that the value
|
|
70
73
|
* length does not comply the specified range. If a valid length is
|
|
71
|
-
* reached, the error parameter of both events will be
|
|
74
|
+
* reached, the error parameter of both events will not be defined.
|
|
72
75
|
*/
|
|
73
76
|
minLength?: number;
|
|
74
77
|
/**
|
|
@@ -78,7 +81,7 @@ declare type Props = {
|
|
|
78
81
|
* comply the maximum length, the onBlur and onChange functions will be called
|
|
79
82
|
* with the current value and an internal error informing that the value
|
|
80
83
|
* length does not comply the specified range. If a valid length is
|
|
81
|
-
* reached, the error parameter of both events will be
|
|
84
|
+
* reached, the error parameter of both events will not be defined.
|
|
82
85
|
*/
|
|
83
86
|
maxLength?: number;
|
|
84
87
|
/**
|
|
@@ -92,7 +95,7 @@ declare type Props = {
|
|
|
92
95
|
*/
|
|
93
96
|
margin?: Space | Margin;
|
|
94
97
|
/**
|
|
95
|
-
* Size of the component
|
|
98
|
+
* Size of the component.
|
|
96
99
|
*/
|
|
97
100
|
size?: "small" | "medium" | "large" | "fillParent";
|
|
98
101
|
/**
|
|
@@ -37,7 +37,7 @@ var DxcProgressBar = function DxcProgressBar(_ref) {
|
|
|
37
37
|
_ref$helperText = _ref.helperText,
|
|
38
38
|
helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
|
|
39
39
|
_ref$overlay = _ref.overlay,
|
|
40
|
-
overlay = _ref$overlay === void 0 ?
|
|
40
|
+
overlay = _ref$overlay === void 0 ? false : _ref$overlay,
|
|
41
41
|
value = _ref.value,
|
|
42
42
|
_ref$showValue = _ref.showValue,
|
|
43
43
|
showValue = _ref$showValue === void 0 ? false : _ref$showValue,
|
|
@@ -12,40 +12,40 @@ export const Chromatic = () => (
|
|
|
12
12
|
<>
|
|
13
13
|
<ExampleContainer>
|
|
14
14
|
<Title title="Without labels" theme="light" level={4} />
|
|
15
|
-
<DxcProgressBar
|
|
15
|
+
<DxcProgressBar value={50} showValue />
|
|
16
16
|
<Title title="With helperText" theme="light" level={4} />
|
|
17
|
-
<DxcProgressBar helperText="Helper text" value={50}
|
|
17
|
+
<DxcProgressBar helperText="Helper text" value={50} showValue />
|
|
18
18
|
<Title title="Without default value" theme="light" level={4} />
|
|
19
|
-
<DxcProgressBar label="Loading..."
|
|
19
|
+
<DxcProgressBar label="Loading..." showValue />
|
|
20
20
|
</ExampleContainer>
|
|
21
21
|
<Title title="Margins" theme="light" level={2} />
|
|
22
22
|
<ExampleContainer>
|
|
23
23
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
24
|
-
<DxcProgressBar label="Margin xxsmall" margin="xxsmall"
|
|
24
|
+
<DxcProgressBar label="Margin xxsmall" margin="xxsmall" value={50} showValue />
|
|
25
25
|
</ExampleContainer>
|
|
26
26
|
<ExampleContainer>
|
|
27
27
|
<Title title="Xsmall margin" theme="light" level={4} />
|
|
28
|
-
<DxcProgressBar label="Margin xsmall" margin="xsmall"
|
|
28
|
+
<DxcProgressBar label="Margin xsmall" margin="xsmall" value={50} showValue />
|
|
29
29
|
</ExampleContainer>
|
|
30
30
|
<ExampleContainer>
|
|
31
31
|
<Title title="Small margin" theme="light" level={4} />
|
|
32
|
-
<DxcProgressBar label="Margin small" margin="small"
|
|
32
|
+
<DxcProgressBar label="Margin small" margin="small" value={50} showValue />
|
|
33
33
|
</ExampleContainer>
|
|
34
34
|
<ExampleContainer>
|
|
35
35
|
<Title title="Medium margin" theme="light" level={4} />
|
|
36
|
-
<DxcProgressBar label="Margin medium" margin="medium"
|
|
36
|
+
<DxcProgressBar label="Margin medium" margin="medium" value={50} showValue />
|
|
37
37
|
</ExampleContainer>
|
|
38
38
|
<ExampleContainer>
|
|
39
39
|
<Title title="Large margin" theme="light" level={4} />
|
|
40
|
-
<DxcProgressBar label="Margin large" margin="large"
|
|
40
|
+
<DxcProgressBar label="Margin large" margin="large" value={50} showValue />
|
|
41
41
|
</ExampleContainer>
|
|
42
42
|
<ExampleContainer>
|
|
43
43
|
<Title title="Xlarge margin" theme="light" level={4} />
|
|
44
|
-
<DxcProgressBar label="Margin xlarge" margin="xlarge"
|
|
44
|
+
<DxcProgressBar label="Margin xlarge" margin="xlarge" value={50} showValue />
|
|
45
45
|
</ExampleContainer>
|
|
46
46
|
<ExampleContainer>
|
|
47
47
|
<Title title="XxLarge margin" theme="light" level={4} />
|
|
48
|
-
<DxcProgressBar label="Margin xxlarge" margin="xxlarge"
|
|
48
|
+
<DxcProgressBar label="Margin xxlarge" margin="xxlarge" value={50} showValue />
|
|
49
49
|
</ExampleContainer>
|
|
50
50
|
</>
|
|
51
51
|
);
|
|
@@ -53,6 +53,6 @@ export const Chromatic = () => (
|
|
|
53
53
|
export const ProgressBarOverlay = () => (
|
|
54
54
|
<ExampleContainer>
|
|
55
55
|
<Title title="Overlay" theme="dark" level={4} />
|
|
56
|
-
<DxcProgressBar label="Overlay" helperText="Helper text" showValue value={50} />
|
|
56
|
+
<DxcProgressBar label="Overlay" helperText="Helper text" overlay={true} showValue value={50} />
|
|
57
57
|
</ExampleContainer>
|
|
58
58
|
);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _ProgressBar = _interopRequireDefault(require("./ProgressBar"));
|
|
10
|
+
|
|
11
|
+
describe("ProgressBar component tests", function () {
|
|
12
|
+
test("ProgressBar renders with label", function () {
|
|
13
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ProgressBar["default"], {
|
|
14
|
+
label: "test-label"
|
|
15
|
+
})),
|
|
16
|
+
getByText = _render.getByText;
|
|
17
|
+
|
|
18
|
+
expect(getByText("test-label")).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
test("Overlay progressBar renders with label", function () {
|
|
21
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ProgressBar["default"], {
|
|
22
|
+
label: "test-label",
|
|
23
|
+
overlay: true
|
|
24
|
+
})),
|
|
25
|
+
getByText = _render2.getByText;
|
|
26
|
+
|
|
27
|
+
expect(getByText("test-label")).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
test("ProgressBar renders with default value", function () {
|
|
30
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ProgressBar["default"], {
|
|
31
|
+
showValue: true
|
|
32
|
+
})),
|
|
33
|
+
getByText = _render3.getByText;
|
|
34
|
+
|
|
35
|
+
expect(getByText("0 %")).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
test("Overlay progressBar renders with default value", function () {
|
|
38
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ProgressBar["default"], {
|
|
39
|
+
showValue: true,
|
|
40
|
+
overlay: true
|
|
41
|
+
})),
|
|
42
|
+
getByText = _render4.getByText;
|
|
43
|
+
|
|
44
|
+
expect(getByText("0 %")).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
test("ProgressBar renders with value", function () {
|
|
47
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ProgressBar["default"], {
|
|
48
|
+
showValue: true,
|
|
49
|
+
value: 25
|
|
50
|
+
})),
|
|
51
|
+
getByText = _render5.getByText;
|
|
52
|
+
|
|
53
|
+
expect(getByText("25 %")).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
test("Overlay progressBar renders with value", function () {
|
|
56
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ProgressBar["default"], {
|
|
57
|
+
showValue: true,
|
|
58
|
+
value: 25,
|
|
59
|
+
overlay: true
|
|
60
|
+
})),
|
|
61
|
+
getByText = _render6.getByText;
|
|
62
|
+
|
|
63
|
+
expect(getByText("25 %")).toBeTruthy();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
17
|
+
|
|
18
|
+
var _slugify = _interopRequireDefault(require("slugify"));
|
|
19
|
+
|
|
20
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
21
|
+
|
|
22
|
+
var _Heading = _interopRequireDefault(require("../heading/Heading"));
|
|
23
|
+
|
|
24
|
+
var _Stack = _interopRequireDefault(require("../stack/Stack"));
|
|
25
|
+
|
|
26
|
+
var _Inset = _interopRequireDefault(require("../inset/Inset"));
|
|
27
|
+
|
|
28
|
+
var _Typography = _interopRequireDefault(require("../typography/Typography"));
|
|
29
|
+
|
|
30
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
31
|
+
|
|
32
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
33
|
+
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
+
|
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
+
|
|
38
|
+
var DxcQuickNav = function DxcQuickNav(_ref) {
|
|
39
|
+
var title = _ref.title,
|
|
40
|
+
links = _ref.links;
|
|
41
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
42
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
43
|
+
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
44
|
+
theme: colorsTheme.quickNav
|
|
45
|
+
}, /*#__PURE__*/_react["default"].createElement(QuickNavContainer, null, /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
|
|
46
|
+
gutter: "xsmall"
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement(_Heading["default"], {
|
|
48
|
+
level: 4,
|
|
49
|
+
text: title || translatedLabels.quickNav.contentTitle
|
|
50
|
+
}), /*#__PURE__*/_react["default"].createElement(ListColumn, null, /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
|
|
51
|
+
gutter: "xsmall"
|
|
52
|
+
}, links.map(function (link) {
|
|
53
|
+
var _link$links;
|
|
54
|
+
|
|
55
|
+
return /*#__PURE__*/_react["default"].createElement(ListRow, null, /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
|
|
56
|
+
space: "0.25rem"
|
|
57
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
|
|
58
|
+
href: "#".concat((0, _slugify["default"])(link === null || link === void 0 ? void 0 : link.label, {
|
|
59
|
+
lower: true
|
|
60
|
+
}))
|
|
61
|
+
}, link === null || link === void 0 ? void 0 : link.label), (_link$links = link.links) === null || _link$links === void 0 ? void 0 : _link$links.map(function (sublink) {
|
|
62
|
+
return /*#__PURE__*/_react["default"].createElement(ListRow, null, /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
|
|
63
|
+
horizontal: "0.5rem"
|
|
64
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
|
|
65
|
+
href: "#".concat((0, _slugify["default"])(sublink === null || sublink === void 0 ? void 0 : sublink.label, {
|
|
66
|
+
lower: true
|
|
67
|
+
}))
|
|
68
|
+
}, sublink === null || sublink === void 0 ? void 0 : sublink.label))));
|
|
69
|
+
}))));
|
|
70
|
+
}))))));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
var QuickNavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n border-left: 2px solid ", ";\n"])), function (props) {
|
|
74
|
+
return props.theme.paddingTop;
|
|
75
|
+
}, function (props) {
|
|
76
|
+
return props.theme.paddingBottom;
|
|
77
|
+
}, function (props) {
|
|
78
|
+
return props.theme.paddingLeft;
|
|
79
|
+
}, function (props) {
|
|
80
|
+
return props.theme.paddingRight;
|
|
81
|
+
}, function (props) {
|
|
82
|
+
return props.theme.dividerBorderColor;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var ListColumn = _styledComponents["default"].ul(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n list-style-type: none;\n margin: 0;\n padding: 0;\n"])));
|
|
86
|
+
|
|
87
|
+
var ListRow = _styledComponents["default"].li(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
88
|
+
|
|
89
|
+
var Link = _styledComponents["default"].a(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n text-decoration: none;\n font-size: ", ";\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n &:focus {\n outline-color: ", ";\n outline-style: ", ";\n outline-width: ", ";\n border-radius: ", ";\n }\n"])), function (props) {
|
|
90
|
+
return props.theme.fontSize;
|
|
91
|
+
}, function (props) {
|
|
92
|
+
return props.theme.fontFamily;
|
|
93
|
+
}, function (props) {
|
|
94
|
+
return props.theme.fontStyle;
|
|
95
|
+
}, function (props) {
|
|
96
|
+
return props.theme.fontWeight;
|
|
97
|
+
}, function (props) {
|
|
98
|
+
return props.theme.fontColor;
|
|
99
|
+
}, function (props) {
|
|
100
|
+
return props.theme.hoverFontColor;
|
|
101
|
+
}, function (props) {
|
|
102
|
+
return props.theme.focusBorderColor;
|
|
103
|
+
}, function (props) {
|
|
104
|
+
return props.theme.focusBorderStyle;
|
|
105
|
+
}, function (props) {
|
|
106
|
+
return props.theme.focusBorderThickness;
|
|
107
|
+
}, function (props) {
|
|
108
|
+
return props.theme.focusBorderRadius;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
var _default = DxcQuickNav;
|
|
112
|
+
exports["default"] = _default;
|