@dxc-technology/halstack-react 5.0.0 → 6.1.0
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.stories.tsx +1 -1
- package/accordion/types.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +1 -0
- package/accordion-group/types.d.ts +1 -1
- package/alert/Alert.js +4 -1
- 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 +22 -32
- 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 +46 -62
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +34 -36
- package/checkbox/Checkbox.js +4 -1
- package/chip/types.d.ts +1 -1
- package/common/variables.js +224 -92
- package/date-input/DateInput.js +8 -5
- 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/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +242 -246
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +510 -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 +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +21 -0
- package/{radio → flex}/types.js +0 -0
- package/footer/Footer.js +7 -5
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +80 -75
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -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 +83 -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 +7 -10
- package/main.js +38 -56
- package/number-input/types.d.ts +1 -1
- package/package.json +8 -6
- 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 +7 -4
- package/password-input/PasswordInput.test.js +1 -2
- 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 +74 -20
- package/quick-nav/QuickNav.stories.tsx +43 -16
- package/quick-nav/types.d.ts +4 -4
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.js +21 -20
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +59 -8
- package/select/Select.js +78 -90
- package/select/Select.stories.tsx +145 -100
- package/select/Select.test.js +362 -244
- 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 +3 -3
- package/slider/Slider.test.js +37 -0
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +113 -54
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +122 -8
- package/switch/types.d.ts +3 -4
- package/tabs/Tabs.stories.tsx +0 -6
- package/tabs/types.d.ts +1 -1
- 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/{row → tabs-nav}/types.js +0 -0
- package/tag/types.d.ts +1 -1
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +58 -93
- package/text-input/TextInput.stories.tsx +1 -2
- package/text-input/TextInput.test.js +1 -1
- package/text-input/types.d.ts +14 -2
- 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/{stack → 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/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/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
|
@@ -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
|
|
|
@@ -23,14 +23,24 @@ const links = [
|
|
|
23
23
|
],
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
label: "Principles",
|
|
26
|
+
label: "Principles very very very very very very very very long",
|
|
27
27
|
id: "principles",
|
|
28
28
|
links: [
|
|
29
|
-
{ label: "Color", id: "color" },
|
|
30
|
-
{ label: "
|
|
29
|
+
{ label: "Color very very very very very very very very long", id: "color" },
|
|
30
|
+
{ label: "Spacingveryveryveryveryveryveryveryverylong", id: "spacing" },
|
|
31
31
|
{ label: "Typography", id: "typography" },
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
label: "Componentsveryveryveryveryveryveryveryverylong",
|
|
36
|
+
id: "components",
|
|
37
|
+
links: [
|
|
38
|
+
{
|
|
39
|
+
label: "Accordion",
|
|
40
|
+
id: "accordion",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
34
44
|
];
|
|
35
45
|
|
|
36
46
|
export const Chromatic = () => (
|
|
@@ -38,13 +48,19 @@ export const Chromatic = () => (
|
|
|
38
48
|
<ExampleContainer>
|
|
39
49
|
<Title title="Default" level={4} />
|
|
40
50
|
<QuickNavContainer>
|
|
41
|
-
<DxcQuickNav
|
|
51
|
+
<DxcQuickNav links={links}></DxcQuickNav>
|
|
42
52
|
</QuickNavContainer>
|
|
43
53
|
</ExampleContainer>
|
|
44
54
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
45
55
|
<Title title="Link hovered" level={4} />
|
|
46
56
|
<QuickNavContainer>
|
|
47
|
-
<DxcQuickNav
|
|
57
|
+
<DxcQuickNav links={links}></DxcQuickNav>
|
|
58
|
+
</QuickNavContainer>
|
|
59
|
+
</ExampleContainer>
|
|
60
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
61
|
+
<Title title="Link focus" level={4} />
|
|
62
|
+
<QuickNavContainer>
|
|
63
|
+
<DxcQuickNav links={links}></DxcQuickNav>
|
|
48
64
|
</QuickNavContainer>
|
|
49
65
|
</ExampleContainer>
|
|
50
66
|
<ExampleContainer>
|
|
@@ -53,7 +69,7 @@ export const Chromatic = () => (
|
|
|
53
69
|
<ContentContainer>
|
|
54
70
|
<Content id="overview">
|
|
55
71
|
<DxcHeading level={1} text="Overview" margin={{ bottom: "small" }} />
|
|
56
|
-
<
|
|
72
|
+
<DxcParagraph>
|
|
57
73
|
Halstack is the DXC Technology's open source design system for insurance products and digital experiences.
|
|
58
74
|
Our system provides all the tools and resources needed to create superior, beautiful but above all,
|
|
59
75
|
functional user experiences. Halstack is the DXC Technology's open source design system for insurance
|
|
@@ -70,10 +86,10 @@ export const Chromatic = () => (
|
|
|
70
86
|
create superior, beautiful but above all, functional user experiences.Halstack is the DXC Technology's
|
|
71
87
|
open source design system for insurance products and digital experiences. Our system provides all the
|
|
72
88
|
tools and resources needed to create superior, beautiful but above all, functional user experiences.
|
|
73
|
-
</
|
|
89
|
+
</DxcParagraph>
|
|
74
90
|
<Content id="introduction">
|
|
75
91
|
<DxcHeading level={2} text="Introduction" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
76
|
-
<
|
|
92
|
+
<DxcParagraph>
|
|
77
93
|
Design principles Halstack design principles are the fundamental part of DXC Technology's approach to
|
|
78
94
|
provide guidance for development teams in order to deliver delightful and consistent user experiences to
|
|
79
95
|
our customers: Balance Consistency Visual hierarchy All our components, design tokens, accessibility
|
|
@@ -103,14 +119,14 @@ export const Chromatic = () => (
|
|
|
103
119
|
to use and contribute back to. We are charmed to receive external contributions to help us find bugs,
|
|
104
120
|
design new features, or help us improve the project documentation. If you're interested, definitely
|
|
105
121
|
check out our contribution guidelines.
|
|
106
|
-
</
|
|
122
|
+
</DxcParagraph>
|
|
107
123
|
</Content>
|
|
108
124
|
</Content>
|
|
109
125
|
<Content id="principles">
|
|
110
126
|
<DxcHeading level={1} text="Principles" margin={{ top: "small", bottom: "xsmall" }} />
|
|
111
127
|
<Content id="color">
|
|
112
128
|
<DxcHeading level={2} text="Color" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
113
|
-
<
|
|
129
|
+
<DxcParagraph>
|
|
114
130
|
The color palette is an essential asset as a communication resource of our design system. Halstack color
|
|
115
131
|
palette brings a unified consistency and helps in guiding the user's perception order. Our color palette
|
|
116
132
|
is based in the HSL model . All our color families are calculated using the lightness value of the
|
|
@@ -143,11 +159,11 @@ export const Chromatic = () => (
|
|
|
143
159
|
tokens to manage color. Appart from a multi-purpose greyscale family, purple and blue are the core color
|
|
144
160
|
families used in our set of components. Additional families as red, green and yellow help as feedback
|
|
145
161
|
role-based color palettes and must not be used outside this context.
|
|
146
|
-
</
|
|
162
|
+
</DxcParagraph>
|
|
147
163
|
</Content>
|
|
148
164
|
<Content id="spacing">
|
|
149
165
|
<DxcHeading level={2} text="Spacing" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
150
|
-
<
|
|
166
|
+
<DxcParagraph>
|
|
151
167
|
In the search of consistent alignment between the elements we provide a spacing scale based on a root
|
|
152
168
|
values of 8px and 4px. The numbers 4 and 8 are easily multiplied, they provide flexible and consistent,
|
|
153
169
|
yet distinct enough, steps between them.In the search of consistent alignment between the elements we
|
|
@@ -165,11 +181,11 @@ export const Chromatic = () => (
|
|
|
165
181
|
consistent, yet distinct enough, steps between them.In the search of consistent alignment between the
|
|
166
182
|
elements we provide a spacing scale based on a root values of 8px and 4px. The numbers 4 and 8 are
|
|
167
183
|
easily multiplied, they provide flexible and consistent, yet distinct enough, steps between them.
|
|
168
|
-
</
|
|
184
|
+
</DxcParagraph>
|
|
169
185
|
</Content>
|
|
170
186
|
<Content id="typography">
|
|
171
187
|
<DxcHeading level={2} text="Typography" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
172
|
-
<
|
|
188
|
+
<DxcParagraph>
|
|
173
189
|
Our selected typography helps in structuring our user's experience based on the visual impact that it
|
|
174
190
|
has on the user interface content. It defines what is the first noticeable piece of information or data
|
|
175
191
|
based on the font shape, size, color, or type and it highlights some pieces of text over the rest. Some
|
|
@@ -201,7 +217,18 @@ export const Chromatic = () => (
|
|
|
201
217
|
Halstack Design System include headers, body, taglines, captions, and labels. Make sure you include all
|
|
202
218
|
the different typographic variants in order to enhance the application's content structure, including
|
|
203
219
|
the Heading component which defines different levels of page and section titles.
|
|
204
|
-
</
|
|
220
|
+
</DxcParagraph>
|
|
221
|
+
</Content>
|
|
222
|
+
</Content>
|
|
223
|
+
<Content id="components">
|
|
224
|
+
<DxcHeading level={1} text="Components" margin={{ top: "small", bottom: "xsmall" }} />
|
|
225
|
+
<Content id="accordion">
|
|
226
|
+
<DxcHeading level={2} text="Accordion" margin={{ top: "xsmall", bottom: "xsmall" }} />
|
|
227
|
+
<DxcParagraph>
|
|
228
|
+
Accordions are used to group similar content and hide or show it depending on user needs or preferences.
|
|
229
|
+
Accordions give users more granular control over the interface and help digest content in stages, rather
|
|
230
|
+
than all at once.
|
|
231
|
+
</DxcParagraph>
|
|
205
232
|
</Content>
|
|
206
233
|
</Content>
|
|
207
234
|
</ContentContainer>
|
package/quick-nav/types.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ declare type Props = {
|
|
|
2
2
|
/**
|
|
3
3
|
* Title of the quick nav component.
|
|
4
4
|
*/
|
|
5
|
-
title
|
|
5
|
+
title?: string;
|
|
6
6
|
/**
|
|
7
7
|
* Links to be shown inside the quick nav component.
|
|
8
8
|
*/
|
|
9
|
-
links:
|
|
9
|
+
links: LinkType[];
|
|
10
10
|
};
|
|
11
|
-
declare type
|
|
11
|
+
declare type LinkType = {
|
|
12
12
|
/**
|
|
13
13
|
* Label to be shown in the link.
|
|
14
14
|
*/
|
|
@@ -16,6 +16,6 @@ declare type Link = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Sublinks of the link.
|
|
18
18
|
*/
|
|
19
|
-
links?:
|
|
19
|
+
links?: LinkType[];
|
|
20
20
|
};
|
|
21
21
|
export default Props;
|
package/radio-group/Radio.js
CHANGED
|
@@ -133,7 +133,7 @@ var Label = _styledComponents["default"].span(_templateObject6 || (_templateObje
|
|
|
133
133
|
}, function (props) {
|
|
134
134
|
return props.theme.radioInputLabelLineHeight;
|
|
135
135
|
}, function (props) {
|
|
136
|
-
return props.disabled
|
|
136
|
+
return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, "; pointer-events: none;") : "color: ".concat(props.theme.radioInputLabelFontColor);
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
var _default = /*#__PURE__*/_react["default"].memo(DxcRadio);
|
|
@@ -23,6 +23,8 @@ var _uuid = require("uuid");
|
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
|
+
|
|
26
28
|
var _Radio = _interopRequireDefault(require("./Radio"));
|
|
27
29
|
|
|
28
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
@@ -47,8 +49,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
47
49
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
48
50
|
_ref$optional = _ref.optional,
|
|
49
51
|
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
50
|
-
|
|
51
|
-
optionalItemLabel = _ref$optionalItemLabe === void 0 ? "N/A" : _ref$optionalItemLabe,
|
|
52
|
+
optionalItemLabel = _ref.optionalItemLabel,
|
|
52
53
|
_ref$readonly = _ref.readonly,
|
|
53
54
|
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
54
55
|
_ref$stacking = _ref.stacking,
|
|
@@ -78,8 +79,10 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
78
79
|
firstTimeFocus = _useState6[0],
|
|
79
80
|
setFirstTimeFocus = _useState6[1];
|
|
80
81
|
|
|
82
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
83
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
81
84
|
var optionalItem = {
|
|
82
|
-
label: optionalItemLabel,
|
|
85
|
+
label: optionalItemLabel || translatedLabels.radioGroup.optionalItemLabelDefault,
|
|
83
86
|
value: "",
|
|
84
87
|
disabled: disabled
|
|
85
88
|
};
|
|
@@ -92,7 +95,6 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
92
95
|
currentFocusIndex = _useState8[0],
|
|
93
96
|
setCurrentFocusIndex = _useState8[1];
|
|
94
97
|
|
|
95
|
-
var colorsTheme = (0, _useTheme["default"])();
|
|
96
98
|
var handleOnChange = (0, _react.useCallback)(function (newValue) {
|
|
97
99
|
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
98
100
|
|
|
@@ -109,7 +111,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
109
111
|
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
110
112
|
!optional && !Boolean(currentValue) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
111
113
|
value: currentValue,
|
|
112
|
-
error:
|
|
114
|
+
error: translatedLabels.formFields.requiredSelectionErrorMessage
|
|
113
115
|
}) : onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
114
116
|
value: currentValue
|
|
115
117
|
});
|
|
@@ -147,27 +149,25 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
147
149
|
};
|
|
148
150
|
|
|
149
151
|
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
150
|
-
switch (event.
|
|
151
|
-
case
|
|
152
|
-
|
|
153
|
-
case
|
|
154
|
-
|
|
152
|
+
switch (event.key) {
|
|
153
|
+
case "Left":
|
|
154
|
+
case "ArrowLeft":
|
|
155
|
+
case "Up":
|
|
156
|
+
case "ArrowUp":
|
|
155
157
|
event.preventDefault();
|
|
156
158
|
setPreviousRadioChecked();
|
|
157
159
|
break;
|
|
158
160
|
|
|
159
|
-
case
|
|
160
|
-
|
|
161
|
-
case
|
|
162
|
-
|
|
161
|
+
case "Right":
|
|
162
|
+
case "ArrowRight":
|
|
163
|
+
case "Down":
|
|
164
|
+
case "ArrowDown":
|
|
163
165
|
event.preventDefault();
|
|
164
166
|
setNextRadioChecked();
|
|
165
167
|
break;
|
|
166
168
|
|
|
167
|
-
case
|
|
168
|
-
|
|
169
|
-
case 32:
|
|
170
|
-
// space
|
|
169
|
+
case "Enter":
|
|
170
|
+
case "Space":
|
|
171
171
|
event.preventDefault();
|
|
172
172
|
handleOnChange(innerOptions[currentFocusIndex].value);
|
|
173
173
|
break;
|
|
@@ -182,7 +182,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
182
182
|
id: radioGroupLabelId,
|
|
183
183
|
helperText: helperText,
|
|
184
184
|
disabled: disabled
|
|
185
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
185
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
186
186
|
disabled: disabled
|
|
187
187
|
}, helperText), /*#__PURE__*/_react["default"].createElement(RadioGroup, {
|
|
188
188
|
onBlur: handleOnBlur,
|
|
@@ -214,7 +214,8 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
214
214
|
disabled: option.disabled || disabled,
|
|
215
215
|
focused: currentFocusIndex === index,
|
|
216
216
|
readonly: readonly,
|
|
217
|
-
tabIndex: tabIndex
|
|
217
|
+
tabIndex: tabIndex,
|
|
218
|
+
key: "radio-".concat(index)
|
|
218
219
|
});
|
|
219
220
|
})), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
220
221
|
id: errorId,
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
6
|
+
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
|
|
5
9
|
var _react = _interopRequireDefault(require("react"));
|
|
6
10
|
|
|
7
11
|
var _react2 = require("@testing-library/react");
|
|
@@ -10,6 +14,44 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
|
10
14
|
|
|
11
15
|
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable"));
|
|
12
16
|
|
|
17
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
18
|
+
global.globalThis = global;
|
|
19
|
+
|
|
20
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
21
|
+
function ResizeObserver(cb) {
|
|
22
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
23
|
+
this.cb = cb;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
27
|
+
key: "observe",
|
|
28
|
+
value: function observe() {
|
|
29
|
+
this.cb([{
|
|
30
|
+
borderBoxSize: {
|
|
31
|
+
inlineSize: 0,
|
|
32
|
+
blockSize: 0
|
|
33
|
+
}
|
|
34
|
+
}]);
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "unobserve",
|
|
38
|
+
value: function unobserve() {}
|
|
39
|
+
}]);
|
|
40
|
+
return ResizeObserver;
|
|
41
|
+
}();
|
|
42
|
+
|
|
43
|
+
global.DOMRect = {
|
|
44
|
+
fromRect: function fromRect() {
|
|
45
|
+
return {
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
bottom: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
13
55
|
var columns = [{
|
|
14
56
|
displayValue: "Id",
|
|
15
57
|
isSortable: false
|
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<
|
|
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,12 +11,16 @@ exports["default"] = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
17
|
|
|
16
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
17
19
|
|
|
18
20
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
19
21
|
|
|
22
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
23
|
+
|
|
20
24
|
var _Option = _interopRequireDefault(require("./Option"));
|
|
21
25
|
|
|
22
26
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
@@ -35,7 +39,7 @@ var groupsHaveOptions = function groupsHaveOptions(options) {
|
|
|
35
39
|
}) : true;
|
|
36
40
|
};
|
|
37
41
|
|
|
38
|
-
var Listbox =
|
|
42
|
+
var Listbox = function Listbox(_ref) {
|
|
39
43
|
var id = _ref.id,
|
|
40
44
|
currentValue = _ref.currentValue,
|
|
41
45
|
options = _ref.options,
|
|
@@ -45,8 +49,17 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
45
49
|
optional = _ref.optional,
|
|
46
50
|
optionalItem = _ref.optionalItem,
|
|
47
51
|
searchable = _ref.searchable,
|
|
48
|
-
handleOptionOnClick = _ref.handleOptionOnClick
|
|
52
|
+
handleOptionOnClick = _ref.handleOptionOnClick,
|
|
53
|
+
getSelectWidth = _ref.getSelectWidth;
|
|
49
54
|
var colorsTheme = (0, _useTheme["default"])();
|
|
55
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
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
|
+
|
|
50
63
|
var globalIndex = optional && !multiple ? 0 : -1; // index for options, starting from 0 to options.length -1
|
|
51
64
|
|
|
52
65
|
var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
|
|
@@ -89,6 +102,42 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
89
102
|
}
|
|
90
103
|
};
|
|
91
104
|
|
|
105
|
+
(0, _react.useLayoutEffect)(function () {
|
|
106
|
+
if (currentValue && !multiple) {
|
|
107
|
+
var _listEl$scrollTo;
|
|
108
|
+
|
|
109
|
+
var listEl = listboxRef === null || listboxRef === void 0 ? void 0 : listboxRef.current;
|
|
110
|
+
var selectedListOptionEl = listEl === null || listEl === void 0 ? void 0 : listEl.querySelector("[aria-selected='true']");
|
|
111
|
+
listEl === null || listEl === void 0 ? void 0 : (_listEl$scrollTo = listEl.scrollTo) === null || _listEl$scrollTo === void 0 ? void 0 : _listEl$scrollTo.call(listEl, {
|
|
112
|
+
top: (selectedListOptionEl === null || selectedListOptionEl === void 0 ? void 0 : selectedListOptionEl.offsetTop) - (listEl === null || listEl === void 0 ? void 0 : listEl.clientHeight) / 2
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, [currentValue, multiple]);
|
|
116
|
+
(0, _react.useLayoutEffect)(function () {
|
|
117
|
+
var _listboxRef$current, _visualFocusedOptionE;
|
|
118
|
+
|
|
119
|
+
var visualFocusedOptionEl = listboxRef === null || listboxRef === void 0 ? void 0 : (_listboxRef$current = listboxRef.current) === null || _listboxRef$current === void 0 ? void 0 : _listboxRef$current.querySelectorAll("[role='option']")[visualFocusIndex];
|
|
120
|
+
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
121
|
+
block: "nearest",
|
|
122
|
+
inline: "start"
|
|
123
|
+
});
|
|
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]);
|
|
92
141
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
93
142
|
theme: colorsTheme.select
|
|
94
143
|
}, /*#__PURE__*/_react["default"].createElement(ListboxContainer, {
|
|
@@ -99,11 +148,13 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
99
148
|
onMouseDown: function onMouseDown(event) {
|
|
100
149
|
event.preventDefault();
|
|
101
150
|
},
|
|
102
|
-
ref:
|
|
151
|
+
ref: listboxRef,
|
|
103
152
|
role: "listbox",
|
|
104
153
|
"aria-multiselectable": multiple,
|
|
105
|
-
"aria-orientation": "vertical"
|
|
106
|
-
|
|
154
|
+
"aria-orientation": "vertical",
|
|
155
|
+
style: styles
|
|
156
|
+
}, searchable && (options.length === 0 || !groupsHaveOptions(options)) ? /*#__PURE__*/_react["default"].createElement(OptionsSystemMessage, null, /*#__PURE__*/_react["default"].createElement(NoMatchesFoundIcon, null, _Icons["default"].searchOff), translatedLabels.select.noMatchesErrorMessage) : optional && !multiple && /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
157
|
+
key: "option-".concat(optionalItem.value),
|
|
107
158
|
id: "option-".concat(0),
|
|
108
159
|
option: optionalItem,
|
|
109
160
|
onClick: handleOptionOnClick,
|
|
@@ -113,9 +164,9 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
113
164
|
isLastOption: lastOptionIndex === 0,
|
|
114
165
|
isSelected: multiple ? currentValue.includes(optionalItem.value) : currentValue === optionalItem.value
|
|
115
166
|
}), options.map(mapOptionFunc)));
|
|
116
|
-
}
|
|
167
|
+
};
|
|
117
168
|
|
|
118
|
-
var ListboxContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
169
|
+
var ListboxContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n max-height: 304px;\n overflow-y: auto;\n margin: 0;\n padding: 0.25rem 0;\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
119
170
|
return props.theme.listDialogBackgroundColor;
|
|
120
171
|
}, function (props) {
|
|
121
172
|
return props.theme.listDialogBorderColor;
|