@dxc-technology/halstack-react 0.0.0-f9a5f2c → 0.0.0-f9b872d
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/accordion/types.d.ts +1 -1
- package/accordion-group/types.d.ts +1 -1
- 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/chip/types.d.ts +1 -1
- package/common/variables.js +41 -11
- package/dialog/Dialog.js +52 -28
- package/dialog/Dialog.stories.tsx +1 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +2 -2
- package/dropdown/types.d.ts +1 -1
- package/flex/Flex.d.ts +2 -1
- package/flex/Flex.js +38 -55
- package/flex/types.d.ts +2 -2
- package/footer/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +15 -6
- package/layout/ApplicationLayout.js +36 -64
- package/layout/ApplicationLayout.stories.tsx +79 -44
- package/layout/types.d.ts +17 -27
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +12 -5
- package/link/types.d.ts +1 -1
- package/main.d.ts +4 -8
- package/main.js +24 -56
- package/package.json +7 -7
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +56 -50
- package/progress-bar/ProgressBar.stories.jsx +3 -1
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.js +5 -5
- package/quick-nav/QuickNav.stories.tsx +13 -13
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +25 -1
- package/select/Select.js +14 -31
- package/select/Select.stories.tsx +6 -5
- package/select/Select.test.js +63 -50
- package/select/types.d.ts +2 -4
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +176 -55
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/tabs/types.d.ts +1 -1
- package/tabs-nav/types.d.ts +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/TextInput.stories.tsx +1 -2
- package/text-input/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/wizard/Wizard.js +9 -16
- 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 -48
- package/list/List.stories.tsx +0 -89
- package/list/types.d.ts +0 -7
- 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 -4
- package/stack/Stack.js +0 -56
- package/stack/Stack.stories.tsx +0 -263
- package/stack/types.d.ts +0 -32
- 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
package/quick-nav/QuickNav.js
CHANGED
|
@@ -25,7 +25,7 @@ var _Flex = _interopRequireDefault(require("../flex/Flex"));
|
|
|
25
25
|
|
|
26
26
|
var _Inset = _interopRequireDefault(require("../inset/Inset"));
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _Typography = _interopRequireDefault(require("../typography/Typography"));
|
|
29
29
|
|
|
30
30
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
31
31
|
|
|
@@ -58,21 +58,21 @@ var DxcQuickNav = function DxcQuickNav(_ref) {
|
|
|
58
58
|
key: link.label
|
|
59
59
|
}, /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
|
|
60
60
|
space: "0.25rem"
|
|
61
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
|
|
62
62
|
href: "#".concat((0, _slugify["default"])(link === null || link === void 0 ? void 0 : link.label, {
|
|
63
63
|
lower: true
|
|
64
64
|
}))
|
|
65
|
-
}, link === null || link === void 0 ? void 0 : link.label),
|
|
65
|
+
}, 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) {
|
|
66
66
|
return /*#__PURE__*/_react["default"].createElement(ListRow, {
|
|
67
67
|
key: sublink.label
|
|
68
68
|
}, /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
|
|
69
69
|
horizontal: "0.5rem"
|
|
70
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
70
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
|
|
71
71
|
href: "#".concat((0, _slugify["default"])(sublink === null || sublink === void 0 ? void 0 : sublink.label, {
|
|
72
72
|
lower: true
|
|
73
73
|
}))
|
|
74
74
|
}, sublink === null || sublink === void 0 ? void 0 : sublink.label))));
|
|
75
|
-
}))))
|
|
75
|
+
}))));
|
|
76
76
|
}))))));
|
|
77
77
|
};
|
|
78
78
|
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import DxcQuickNav from "./QuickNav";
|
|
4
4
|
import DxcHeading from "../heading/Heading";
|
|
5
|
-
import
|
|
5
|
+
import DxcParagraph from "../paragraph/Paragraph";
|
|
6
6
|
import Title from "../../.storybook/components/Title";
|
|
7
7
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
8
8
|
|
|
@@ -69,7 +69,7 @@ export const Chromatic = () => (
|
|
|
69
69
|
<ContentContainer>
|
|
70
70
|
<Content id="overview">
|
|
71
71
|
<DxcHeading level={1} text="Overview" margin={{ bottom: "small" }} />
|
|
72
|
-
<
|
|
72
|
+
<DxcParagraph>
|
|
73
73
|
Halstack is the DXC Technology's open source design system for insurance products and digital experiences.
|
|
74
74
|
Our system provides all the tools and resources needed to create superior, beautiful but above all,
|
|
75
75
|
functional user experiences. Halstack is the DXC Technology's open source design system for insurance
|
|
@@ -86,10 +86,10 @@ export const Chromatic = () => (
|
|
|
86
86
|
create superior, beautiful but above all, functional user experiences.Halstack is the DXC Technology's
|
|
87
87
|
open source design system for insurance products and digital experiences. Our system provides all the
|
|
88
88
|
tools and resources needed to create superior, beautiful but above all, functional user experiences.
|
|
89
|
-
</
|
|
89
|
+
</DxcParagraph>
|
|
90
90
|
<Content id="introduction">
|
|
91
91
|
<DxcHeading level={2} text="Introduction" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
92
|
-
<
|
|
92
|
+
<DxcParagraph>
|
|
93
93
|
Design principles Halstack design principles are the fundamental part of DXC Technology's approach to
|
|
94
94
|
provide guidance for development teams in order to deliver delightful and consistent user experiences to
|
|
95
95
|
our customers: Balance Consistency Visual hierarchy All our components, design tokens, accessibility
|
|
@@ -119,14 +119,14 @@ export const Chromatic = () => (
|
|
|
119
119
|
to use and contribute back to. We are charmed to receive external contributions to help us find bugs,
|
|
120
120
|
design new features, or help us improve the project documentation. If you're interested, definitely
|
|
121
121
|
check out our contribution guidelines.
|
|
122
|
-
</
|
|
122
|
+
</DxcParagraph>
|
|
123
123
|
</Content>
|
|
124
124
|
</Content>
|
|
125
125
|
<Content id="principles">
|
|
126
126
|
<DxcHeading level={1} text="Principles" margin={{ top: "small", bottom: "xsmall" }} />
|
|
127
127
|
<Content id="color">
|
|
128
128
|
<DxcHeading level={2} text="Color" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
129
|
-
<
|
|
129
|
+
<DxcParagraph>
|
|
130
130
|
The color palette is an essential asset as a communication resource of our design system. Halstack color
|
|
131
131
|
palette brings a unified consistency and helps in guiding the user's perception order. Our color palette
|
|
132
132
|
is based in the HSL model . All our color families are calculated using the lightness value of the
|
|
@@ -159,11 +159,11 @@ export const Chromatic = () => (
|
|
|
159
159
|
tokens to manage color. Appart from a multi-purpose greyscale family, purple and blue are the core color
|
|
160
160
|
families used in our set of components. Additional families as red, green and yellow help as feedback
|
|
161
161
|
role-based color palettes and must not be used outside this context.
|
|
162
|
-
</
|
|
162
|
+
</DxcParagraph>
|
|
163
163
|
</Content>
|
|
164
164
|
<Content id="spacing">
|
|
165
165
|
<DxcHeading level={2} text="Spacing" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
166
|
-
<
|
|
166
|
+
<DxcParagraph>
|
|
167
167
|
In the search of consistent alignment between the elements we provide a spacing scale based on a root
|
|
168
168
|
values of 8px and 4px. The numbers 4 and 8 are easily multiplied, they provide flexible and consistent,
|
|
169
169
|
yet distinct enough, steps between them.In the search of consistent alignment between the elements we
|
|
@@ -181,11 +181,11 @@ export const Chromatic = () => (
|
|
|
181
181
|
consistent, yet distinct enough, steps between them.In the search of consistent alignment between the
|
|
182
182
|
elements we provide a spacing scale based on a root values of 8px and 4px. The numbers 4 and 8 are
|
|
183
183
|
easily multiplied, they provide flexible and consistent, yet distinct enough, steps between them.
|
|
184
|
-
</
|
|
184
|
+
</DxcParagraph>
|
|
185
185
|
</Content>
|
|
186
186
|
<Content id="typography">
|
|
187
187
|
<DxcHeading level={2} text="Typography" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
188
|
-
<
|
|
188
|
+
<DxcParagraph>
|
|
189
189
|
Our selected typography helps in structuring our user's experience based on the visual impact that it
|
|
190
190
|
has on the user interface content. It defines what is the first noticeable piece of information or data
|
|
191
191
|
based on the font shape, size, color, or type and it highlights some pieces of text over the rest. Some
|
|
@@ -217,18 +217,18 @@ export const Chromatic = () => (
|
|
|
217
217
|
Halstack Design System include headers, body, taglines, captions, and labels. Make sure you include all
|
|
218
218
|
the different typographic variants in order to enhance the application's content structure, including
|
|
219
219
|
the Heading component which defines different levels of page and section titles.
|
|
220
|
-
</
|
|
220
|
+
</DxcParagraph>
|
|
221
221
|
</Content>
|
|
222
222
|
</Content>
|
|
223
223
|
<Content id="components">
|
|
224
224
|
<DxcHeading level={1} text="Components" margin={{ top: "small", bottom: "xsmall" }} />
|
|
225
225
|
<Content id="accordion">
|
|
226
226
|
<DxcHeading level={2} text="Accordion" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
227
|
-
<
|
|
227
|
+
<DxcParagraph>
|
|
228
228
|
Accordions are used to group similar content and hide or show it depending on user needs or preferences.
|
|
229
229
|
Accordions give users more granular control over the interface and help digest content in stages, rather
|
|
230
230
|
than all at once.
|
|
231
|
-
</
|
|
231
|
+
</DxcParagraph>
|
|
232
232
|
</Content>
|
|
233
233
|
</Content>
|
|
234
234
|
</ContentContainer>
|
package/select/Listbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ListboxProps } from "./types";
|
|
3
|
-
declare const _default: React.MemoExoticComponent<({ id, currentValue, options, visualFocusIndex, lastOptionIndex, multiple, optional, optionalItem, searchable, handleOptionOnClick,
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ id, currentValue, options, visualFocusIndex, lastOptionIndex, multiple, optional, optionalItem, searchable, handleOptionOnClick, getSelectWidth, }: ListboxProps) => JSX.Element>;
|
|
4
4
|
export default _default;
|
package/select/Listbox.js
CHANGED
|
@@ -11,6 +11,8 @@ exports["default"] = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
13
|
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
14
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
17
|
|
|
16
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
@@ -48,10 +50,16 @@ var Listbox = function Listbox(_ref) {
|
|
|
48
50
|
optionalItem = _ref.optionalItem,
|
|
49
51
|
searchable = _ref.searchable,
|
|
50
52
|
handleOptionOnClick = _ref.handleOptionOnClick,
|
|
51
|
-
|
|
53
|
+
getSelectWidth = _ref.getSelectWidth;
|
|
52
54
|
var colorsTheme = (0, _useTheme["default"])();
|
|
53
55
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
54
56
|
var listboxRef = (0, _react.useRef)(null);
|
|
57
|
+
|
|
58
|
+
var _useState = (0, _react.useState)(null),
|
|
59
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
60
|
+
styles = _useState2[0],
|
|
61
|
+
setStyles = _useState2[1];
|
|
62
|
+
|
|
55
63
|
var globalIndex = optional && !multiple ? 0 : -1; // index for options, starting from 0 to options.length -1
|
|
56
64
|
|
|
57
65
|
var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
|
|
@@ -114,6 +122,22 @@ var Listbox = function Listbox(_ref) {
|
|
|
114
122
|
inline: "start"
|
|
115
123
|
});
|
|
116
124
|
}, [visualFocusIndex]);
|
|
125
|
+
|
|
126
|
+
var handleResize = function handleResize() {
|
|
127
|
+
setStyles({
|
|
128
|
+
width: getSelectWidth()
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
(0, _react.useLayoutEffect)(function () {
|
|
133
|
+
handleResize();
|
|
134
|
+
}, [getSelectWidth]);
|
|
135
|
+
(0, _react.useEffect)(function () {
|
|
136
|
+
window.addEventListener("resize", handleResize);
|
|
137
|
+
return function () {
|
|
138
|
+
window.removeEventListener("resize", handleResize);
|
|
139
|
+
};
|
|
140
|
+
}, [getSelectWidth]);
|
|
117
141
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
118
142
|
theme: colorsTheme.select
|
|
119
143
|
}, /*#__PURE__*/_react["default"].createElement(ListboxContainer, {
|
package/select/Select.js
CHANGED
|
@@ -197,11 +197,6 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
197
197
|
isOpen = _useState10[0],
|
|
198
198
|
changeIsOpen = _useState10[1];
|
|
199
199
|
|
|
200
|
-
var _useState11 = (0, _react.useState)(null),
|
|
201
|
-
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
202
|
-
listboxStyles = _useState12[0],
|
|
203
|
-
setListboxStyles = _useState12[1];
|
|
204
|
-
|
|
205
200
|
var selectRef = (0, _react.useRef)(null);
|
|
206
201
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
207
202
|
var colorsTheme = (0, _useTheme["default"])();
|
|
@@ -281,9 +276,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
281
276
|
};
|
|
282
277
|
|
|
283
278
|
var handleSelectOnKeyDown = function handleSelectOnKeyDown(event) {
|
|
284
|
-
switch (event.
|
|
285
|
-
case
|
|
286
|
-
|
|
279
|
+
switch (event.key) {
|
|
280
|
+
case "Down":
|
|
281
|
+
case "ArrowDown":
|
|
287
282
|
event.preventDefault();
|
|
288
283
|
singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
|
|
289
284
|
if (visualFocusIndex < lastOptionIndex) return visualFocusIndex + 1;else if (visualFocusIndex === lastOptionIndex) return 0;
|
|
@@ -291,8 +286,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
291
286
|
openOptions();
|
|
292
287
|
break;
|
|
293
288
|
|
|
294
|
-
case
|
|
295
|
-
|
|
289
|
+
case "Up":
|
|
290
|
+
case "ArrowUp":
|
|
296
291
|
event.preventDefault();
|
|
297
292
|
singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
|
|
298
293
|
return visualFocusIndex === 0 || visualFocusIndex === -1 ? lastOptionIndex : visualFocusIndex - 1;
|
|
@@ -300,15 +295,14 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
300
295
|
openOptions();
|
|
301
296
|
break;
|
|
302
297
|
|
|
303
|
-
case
|
|
304
|
-
|
|
298
|
+
case "Esc":
|
|
299
|
+
case "Escape":
|
|
305
300
|
event.preventDefault();
|
|
306
301
|
closeOptions();
|
|
307
302
|
setSearchValue("");
|
|
308
303
|
break;
|
|
309
304
|
|
|
310
|
-
case
|
|
311
|
-
// Enter
|
|
305
|
+
case "Enter":
|
|
312
306
|
if (isOpen && visualFocusIndex >= 0) {
|
|
313
307
|
var accLength = optional && !multiple ? 1 : 0;
|
|
314
308
|
|
|
@@ -365,23 +359,12 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
365
359
|
!multiple && closeOptions();
|
|
366
360
|
setSearchValue("");
|
|
367
361
|
}, [handleSelectChangeValue, closeOptions, multiple]);
|
|
368
|
-
|
|
369
|
-
var handleListboxResize = function handleListboxResize() {
|
|
362
|
+
var getSelectWidth = (0, _react.useCallback)(function () {
|
|
370
363
|
var _selectRef$current;
|
|
371
364
|
|
|
372
365
|
var rect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect();
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
});
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
(0, _react.useEffect)(function () {
|
|
379
|
-
handleListboxResize();
|
|
380
|
-
window.addEventListener("resize", handleListboxResize);
|
|
381
|
-
return function () {
|
|
382
|
-
window.removeEventListener("resize", handleListboxResize);
|
|
383
|
-
};
|
|
384
|
-
}, [setListboxStyles]);
|
|
366
|
+
return rect === null || rect === void 0 ? void 0 : rect.width;
|
|
367
|
+
}, []);
|
|
385
368
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
386
369
|
theme: colorsTheme.select
|
|
387
370
|
}, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
|
|
@@ -410,7 +393,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
410
393
|
onFocus: handleSelectOnFocus,
|
|
411
394
|
onKeyDown: handleSelectOnKeyDown,
|
|
412
395
|
ref: selectRef,
|
|
413
|
-
tabIndex: tabIndex,
|
|
396
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
414
397
|
role: "combobox",
|
|
415
398
|
"aria-controls": optionsListId,
|
|
416
399
|
"aria-disabled": disabled,
|
|
@@ -418,7 +401,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
418
401
|
"aria-haspopup": "listbox",
|
|
419
402
|
"aria-labelledby": label ? selectLabelId : undefined,
|
|
420
403
|
"aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
|
|
421
|
-
"aria-invalid": error ?
|
|
404
|
+
"aria-invalid": error ? true : false,
|
|
422
405
|
"aria-errormessage": error ? errorId : undefined,
|
|
423
406
|
"aria-required": !disabled && !optional
|
|
424
407
|
}, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
@@ -486,7 +469,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
486
469
|
optionalItem: optionalItem,
|
|
487
470
|
searchable: searchable,
|
|
488
471
|
handleOptionOnClick: handleOptionOnClick,
|
|
489
|
-
|
|
472
|
+
getSelectWidth: getSelectWidth
|
|
490
473
|
}))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
491
474
|
id: errorId,
|
|
492
475
|
"aria-live": error ? "assertive" : "off"
|
|
@@ -379,7 +379,7 @@ const SelectListbox = () => (
|
|
|
379
379
|
optionalItem={{ label: "Empty", value: "" }}
|
|
380
380
|
searchable={false}
|
|
381
381
|
handleOptionOnClick={() => {}}
|
|
382
|
-
|
|
382
|
+
getSelectWidth={() => 360}
|
|
383
383
|
/>
|
|
384
384
|
</ExampleContainer>
|
|
385
385
|
<ExampleContainer pseudoState="pseudo-active">
|
|
@@ -395,7 +395,8 @@ const SelectListbox = () => (
|
|
|
395
395
|
optionalItem={{ label: "Empty", value: "" }}
|
|
396
396
|
searchable={false}
|
|
397
397
|
handleOptionOnClick={() => {}}
|
|
398
|
-
|
|
398
|
+
getSelectWidth={() => 360}
|
|
399
|
+
|
|
399
400
|
/>
|
|
400
401
|
</ExampleContainer>
|
|
401
402
|
<ExampleContainer>
|
|
@@ -411,7 +412,7 @@ const SelectListbox = () => (
|
|
|
411
412
|
optionalItem={{ label: "Empty", value: "" }}
|
|
412
413
|
searchable={false}
|
|
413
414
|
handleOptionOnClick={() => {}}
|
|
414
|
-
|
|
415
|
+
getSelectWidth={() => 360}
|
|
415
416
|
/>
|
|
416
417
|
</ExampleContainer>
|
|
417
418
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
@@ -427,7 +428,7 @@ const SelectListbox = () => (
|
|
|
427
428
|
optionalItem={{ label: "Empty", value: "" }}
|
|
428
429
|
searchable={false}
|
|
429
430
|
handleOptionOnClick={() => {}}
|
|
430
|
-
|
|
431
|
+
getSelectWidth={() => 360}
|
|
431
432
|
/>
|
|
432
433
|
</ExampleContainer>
|
|
433
434
|
<ExampleContainer pseudoState="pseudo-active">
|
|
@@ -443,7 +444,7 @@ const SelectListbox = () => (
|
|
|
443
444
|
optionalItem={{ label: "Empty", value: "" }}
|
|
444
445
|
searchable={false}
|
|
445
446
|
handleOptionOnClick={() => {}}
|
|
446
|
-
|
|
447
|
+
getSelectWidth={() => 360}
|
|
447
448
|
/>
|
|
448
449
|
</ExampleContainer>
|
|
449
450
|
</>
|
package/select/Select.test.js
CHANGED
|
@@ -306,7 +306,7 @@ var grouped_icon_options = [{
|
|
|
306
306
|
}]
|
|
307
307
|
}];
|
|
308
308
|
describe("Select component tests", function () {
|
|
309
|
-
test("
|
|
309
|
+
test("When clicking the label, the focus goes to the select", function () {
|
|
310
310
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
311
311
|
label: "test-select-label",
|
|
312
312
|
helperText: "test-select-helper-text",
|
|
@@ -317,40 +317,18 @@ describe("Select component tests", function () {
|
|
|
317
317
|
|
|
318
318
|
var select = getByRole("combobox");
|
|
319
319
|
var label = getByText("test-select-label");
|
|
320
|
-
expect(label).toBeTruthy();
|
|
321
320
|
|
|
322
321
|
_userEvent["default"].click(label);
|
|
323
322
|
|
|
324
323
|
expect(document.activeElement).toEqual(select);
|
|
325
324
|
});
|
|
326
|
-
test("Renders with correct
|
|
325
|
+
test("Renders with correct aria attributes when is in error state", function () {
|
|
327
326
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
328
|
-
label: "test-select-label",
|
|
329
|
-
helperText: "test-select-helper-text",
|
|
330
|
-
placeholder: "Example text"
|
|
331
|
-
})),
|
|
332
|
-
getByText = _render2.getByText;
|
|
333
|
-
|
|
334
|
-
expect(getByText("test-select-helper-text")).toBeTruthy();
|
|
335
|
-
expect(getByText("Example text")).toBeTruthy();
|
|
336
|
-
});
|
|
337
|
-
test("Renders with correct optional label", function () {
|
|
338
|
-
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
339
|
-
label: "test-select-label",
|
|
340
|
-
optional: true
|
|
341
|
-
})),
|
|
342
|
-
getByText = _render3.getByText;
|
|
343
|
-
|
|
344
|
-
expect(getByText("test-select-label")).toBeTruthy();
|
|
345
|
-
expect(getByText("(Optional)")).toBeTruthy();
|
|
346
|
-
});
|
|
347
|
-
test("Renders with error message and correct aria attributes", function () {
|
|
348
|
-
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
349
327
|
label: "Error label",
|
|
350
328
|
error: "Error message."
|
|
351
329
|
})),
|
|
352
|
-
getByText =
|
|
353
|
-
getByRole =
|
|
330
|
+
getByText = _render2.getByText,
|
|
331
|
+
getByRole = _render2.getByRole;
|
|
354
332
|
|
|
355
333
|
var select = getByRole("combobox");
|
|
356
334
|
var errorMessage = getByText("Error message.");
|
|
@@ -360,13 +338,13 @@ describe("Select component tests", function () {
|
|
|
360
338
|
expect(errorMessage.getAttribute("aria-live")).toBe("assertive");
|
|
361
339
|
});
|
|
362
340
|
test("Renders with correct aria attributes", function () {
|
|
363
|
-
var
|
|
341
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
364
342
|
label: "test-select-label",
|
|
365
343
|
placeholder: "Example",
|
|
366
344
|
options: single_options
|
|
367
345
|
})),
|
|
368
|
-
getByText =
|
|
369
|
-
getByRole =
|
|
346
|
+
getByText = _render3.getByText,
|
|
347
|
+
getByRole = _render3.getByRole;
|
|
370
348
|
|
|
371
349
|
var select = getByRole("combobox");
|
|
372
350
|
var label = getByText("test-select-label");
|
|
@@ -385,17 +363,17 @@ describe("Select component tests", function () {
|
|
|
385
363
|
expect(list.getAttribute("aria-multiselectable")).toBe("false");
|
|
386
364
|
});
|
|
387
365
|
test("Single selection: Renders with correct default value", function () {
|
|
388
|
-
var
|
|
366
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
389
367
|
label: "test-select-label",
|
|
390
368
|
name: "test",
|
|
391
369
|
defaultValue: "4",
|
|
392
370
|
options: single_options
|
|
393
371
|
})),
|
|
394
|
-
getByText =
|
|
395
|
-
getByRole =
|
|
396
|
-
getAllByRole =
|
|
397
|
-
queryByRole =
|
|
398
|
-
container =
|
|
372
|
+
getByText = _render4.getByText,
|
|
373
|
+
getByRole = _render4.getByRole,
|
|
374
|
+
getAllByRole = _render4.getAllByRole,
|
|
375
|
+
queryByRole = _render4.queryByRole,
|
|
376
|
+
container = _render4.container;
|
|
399
377
|
|
|
400
378
|
var select = getByRole("combobox");
|
|
401
379
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
@@ -413,18 +391,18 @@ describe("Select component tests", function () {
|
|
|
413
391
|
expect(submitInput.value).toBe("8");
|
|
414
392
|
});
|
|
415
393
|
test("Multiple selection: Renders with correct default value", function () {
|
|
416
|
-
var
|
|
394
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
417
395
|
label: "test-select-label",
|
|
418
396
|
name: "test",
|
|
419
397
|
defaultValue: ["4", "2", "6"],
|
|
420
398
|
options: single_options,
|
|
421
399
|
multiple: true
|
|
422
400
|
})),
|
|
423
|
-
getByText =
|
|
424
|
-
getByRole =
|
|
425
|
-
getAllByRole =
|
|
426
|
-
queryByRole =
|
|
427
|
-
container =
|
|
401
|
+
getByText = _render5.getByText,
|
|
402
|
+
getByRole = _render5.getByRole,
|
|
403
|
+
getAllByRole = _render5.getAllByRole,
|
|
404
|
+
queryByRole = _render5.queryByRole,
|
|
405
|
+
container = _render5.container;
|
|
428
406
|
|
|
429
407
|
var select = getByRole("combobox");
|
|
430
408
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
@@ -443,18 +421,15 @@ describe("Select component tests", function () {
|
|
|
443
421
|
expect(getByText("Option 02, Option 03, Option 04, Option 06")).toBeTruthy();
|
|
444
422
|
expect(submitInput.value).toBe("4,2,6,3");
|
|
445
423
|
});
|
|
446
|
-
test("Disabled select -
|
|
447
|
-
var
|
|
424
|
+
test("Disabled select - Cannot gain focus or open the listbox via click", function () {
|
|
425
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
448
426
|
label: "test-select-label",
|
|
449
427
|
value: ["1", "2"],
|
|
450
428
|
options: single_options,
|
|
451
|
-
disabled: true
|
|
452
|
-
searchable: true,
|
|
453
|
-
multiple: true
|
|
429
|
+
disabled: true
|
|
454
430
|
})),
|
|
455
|
-
getByRole =
|
|
456
|
-
|
|
457
|
-
queryByRole = _render8.queryByRole;
|
|
431
|
+
getByRole = _render6.getByRole,
|
|
432
|
+
queryByRole = _render6.queryByRole;
|
|
458
433
|
|
|
459
434
|
var select = getByRole("combobox");
|
|
460
435
|
expect(select.getAttribute("aria-disabled")).toBe("true");
|
|
@@ -462,12 +437,49 @@ describe("Select component tests", function () {
|
|
|
462
437
|
_userEvent["default"].click(select);
|
|
463
438
|
|
|
464
439
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
440
|
+
expect(document.activeElement === select).toBeFalsy();
|
|
441
|
+
});
|
|
442
|
+
test("Disabled select - Clear all options action must be shown but not clickable", function () {
|
|
443
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
444
|
+
label: "test-select-label",
|
|
445
|
+
value: ["1", "2"],
|
|
446
|
+
options: single_options,
|
|
447
|
+
disabled: true,
|
|
448
|
+
searchable: true,
|
|
449
|
+
multiple: true
|
|
450
|
+
})),
|
|
451
|
+
getByRole = _render7.getByRole,
|
|
452
|
+
getByText = _render7.getByText;
|
|
465
453
|
|
|
466
454
|
_userEvent["default"].click(getByRole("button"));
|
|
467
455
|
|
|
468
456
|
expect(getByText("Option 01, Option 02")).toBeTruthy();
|
|
469
457
|
});
|
|
470
|
-
test("
|
|
458
|
+
test("Disabled select - Does not call onBlur event", function () {
|
|
459
|
+
var onBlur = jest.fn();
|
|
460
|
+
|
|
461
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
462
|
+
label: "test-select-label",
|
|
463
|
+
options: single_options,
|
|
464
|
+
disabled: true,
|
|
465
|
+
onBlur: onBlur
|
|
466
|
+
})),
|
|
467
|
+
getByRole = _render8.getByRole;
|
|
468
|
+
|
|
469
|
+
var select = getByRole("combobox");
|
|
470
|
+
|
|
471
|
+
_userEvent["default"].click(select);
|
|
472
|
+
|
|
473
|
+
_react2.fireEvent.keyDown(getByRole("combobox"), {
|
|
474
|
+
key: "Tab",
|
|
475
|
+
code: "Tab",
|
|
476
|
+
keyCode: 9,
|
|
477
|
+
charCode: 9
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
expect(onBlur).not.toHaveBeenCalled();
|
|
481
|
+
});
|
|
482
|
+
test("Disabled select - When the component gains the focus, the listbox does not open", function () {
|
|
471
483
|
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
472
484
|
label: "test-select-label",
|
|
473
485
|
value: ["1", "2"],
|
|
@@ -484,6 +496,7 @@ describe("Select component tests", function () {
|
|
|
484
496
|
_react2.fireEvent.focus(select);
|
|
485
497
|
|
|
486
498
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
499
|
+
expect(document.activeElement === select).toBeFalsy();
|
|
487
500
|
});
|
|
488
501
|
test("Controlled - Single selection - Not optional constraint", function () {
|
|
489
502
|
var onChange = jest.fn();
|
package/select/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
9
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
10
|
declare type OptionGroup = {
|
|
11
11
|
/**
|
|
12
12
|
* Label of the group to be shown in the select's listbox.
|
|
@@ -201,9 +201,7 @@ export declare type ListboxProps = {
|
|
|
201
201
|
optionalItem: Option;
|
|
202
202
|
searchable: boolean;
|
|
203
203
|
handleOptionOnClick: (option: Option) => void;
|
|
204
|
-
|
|
205
|
-
width: number;
|
|
206
|
-
};
|
|
204
|
+
getSelectWidth: () => number;
|
|
207
205
|
};
|
|
208
206
|
/**
|
|
209
207
|
* Reference to the select component.
|
package/sidenav/Sidenav.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import SidenavPropsType, {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import SidenavPropsType, { SidenavGroupPropsType, SidenavLinkPropsType, SidenavSectionPropsType, SidenavTitlePropsType } from "./types.js";
|
|
3
3
|
declare const DxcSidenav: {
|
|
4
|
-
({
|
|
4
|
+
({ children, title }: SidenavPropsType): JSX.Element;
|
|
5
|
+
Section: ({ children }: SidenavSectionPropsType) => JSX.Element;
|
|
6
|
+
Group: ({ children, title, collapsable, icon }: SidenavGroupPropsType) => JSX.Element;
|
|
7
|
+
Link: React.ForwardRefExoticComponent<SidenavLinkPropsType & React.RefAttributes<HTMLAnchorElement>>;
|
|
5
8
|
Title: ({ children }: SidenavTitlePropsType) => JSX.Element;
|
|
6
|
-
Subtitle: ({ children }: SidenavSubtitlePropsType) => JSX.Element;
|
|
7
|
-
Link: ({ tabIndex, href, onClick, children }: SidenavLinkPropsType) => JSX.Element;
|
|
8
9
|
};
|
|
9
10
|
export default DxcSidenav;
|