@dxc-technology/halstack-react 6.2.1 → 7.0.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.
Files changed (40) hide show
  1. package/accordion/types.d.ts +1 -0
  2. package/accordion-group/types.d.ts +1 -0
  3. package/box/types.d.ts +1 -0
  4. package/card/types.d.ts +1 -0
  5. package/common/variables.js +5 -5
  6. package/dialog/Dialog.js +4 -4
  7. package/dialog/Dialog.stories.tsx +56 -0
  8. package/dialog/types.d.ts +1 -0
  9. package/dropdown/Dropdown.js +3 -2
  10. package/dropdown/Dropdown.test.js +1 -2
  11. package/file-input/FileInput.js +13 -5
  12. package/file-input/FileInput.test.js +41 -0
  13. package/flex/Flex.d.ts +1 -1
  14. package/flex/Flex.js +31 -19
  15. package/flex/types.d.ts +14 -3
  16. package/footer/types.d.ts +1 -0
  17. package/header/types.d.ts +1 -0
  18. package/number-input/NumberInput.test.js +38 -1
  19. package/package.json +1 -1
  20. package/paginator/Paginator.js +2 -2
  21. package/paginator/Paginator.test.js +1 -1
  22. package/password-input/PasswordInput.test.js +13 -12
  23. package/quick-nav/QuickNav.js +11 -12
  24. package/quick-nav/QuickNav.stories.tsx +97 -19
  25. package/radio-group/Radio.d.ts +1 -1
  26. package/radio-group/Radio.js +43 -28
  27. package/radio-group/RadioGroup.js +15 -13
  28. package/radio-group/RadioGroup.stories.tsx +1 -0
  29. package/radio-group/RadioGroup.test.js +123 -96
  30. package/radio-group/types.d.ts +2 -2
  31. package/resultsetTable/ResultsetTable.js +1 -3
  32. package/select/Select.js +3 -1
  33. package/select/Select.test.js +267 -209
  34. package/slider/Slider.js +8 -5
  35. package/switch/Switch.js +90 -80
  36. package/switch/Switch.test.js +26 -13
  37. package/table/Table.js +1 -1
  38. package/text-input/TextInput.js +165 -151
  39. package/text-input/TextInput.test.js +140 -82
  40. package/text-input/types.d.ts +5 -0
@@ -48,13 +48,10 @@ var DxcQuickNav = function DxcQuickNav(_ref) {
48
48
  }, /*#__PURE__*/_react["default"].createElement(_Heading["default"], {
49
49
  level: 4,
50
50
  text: title || translatedLabels.quickNav.contentTitle
51
- }), /*#__PURE__*/_react["default"].createElement(ListColumn, null, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
52
- direction: "column",
53
- gap: "0.5rem"
54
- }, links.map(function (link) {
51
+ }), /*#__PURE__*/_react["default"].createElement(ListColumn, null, links.map(function (link) {
55
52
  var _link$links;
56
53
 
57
- return /*#__PURE__*/_react["default"].createElement(ListRow, {
54
+ return /*#__PURE__*/_react["default"].createElement("li", {
58
55
  key: link.label
59
56
  }, /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
60
57
  space: "0.25rem"
@@ -62,18 +59,20 @@ var DxcQuickNav = function DxcQuickNav(_ref) {
62
59
  href: "#".concat((0, _slugify["default"])(link === null || link === void 0 ? void 0 : link.label, {
63
60
  lower: true
64
61
  }))
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
- return /*#__PURE__*/_react["default"].createElement(ListRow, {
62
+ }, link === null || link === void 0 ? void 0 : link.label), /*#__PURE__*/_react["default"].createElement(ListSecondColumn, null, (_link$links = link.links) === null || _link$links === void 0 ? void 0 : _link$links.map(function (sublink) {
63
+ return /*#__PURE__*/_react["default"].createElement("li", {
67
64
  key: sublink.label
68
65
  }, /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
69
66
  horizontal: "0.5rem"
70
67
  }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
71
- href: "#".concat((0, _slugify["default"])(sublink === null || sublink === void 0 ? void 0 : sublink.label, {
68
+ href: "#".concat((0, _slugify["default"])(link === null || link === void 0 ? void 0 : link.label, {
69
+ lower: true
70
+ }), "-").concat((0, _slugify["default"])(sublink === null || sublink === void 0 ? void 0 : sublink.label, {
72
71
  lower: true
73
72
  }))
74
73
  }, sublink === null || sublink === void 0 ? void 0 : sublink.label))));
75
- }))));
76
- }))))));
74
+ })))));
75
+ })))));
77
76
  };
78
77
 
79
78
  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) {
@@ -88,9 +87,9 @@ var QuickNavContainer = _styledComponents["default"].div(_templateObject || (_te
88
87
  return props.theme.dividerBorderColor;
89
88
  });
90
89
 
91
- var ListColumn = _styledComponents["default"].ul(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n list-style-type: none;\n margin: 0;\n padding: 0;\n width: 100%;\n"])));
90
+ var ListColumn = _styledComponents["default"].ul(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n margin: 0;\n padding: 0;\n list-style-type: none;\n"])));
92
91
 
93
- var ListRow = _styledComponents["default"].li(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n"])));
92
+ var ListSecondColumn = _styledComponents["default"].ul(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n margin: 0;\n padding: 0;\n list-style-type: none;\n"])));
94
93
 
95
94
  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 display: block;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n width: fit-content;\n max-width: 100%;\n\n &:hover {\n color: ", ";\n }\n &:focus {\n outline-color: ", ";\n outline-style: ", ";\n outline-width: ", ";\n border-radius: ", ";\n }\n"])), function (props) {
96
95
  return props.theme.fontSize;
@@ -11,33 +11,60 @@ export default {
11
11
  component: DxcQuickNav,
12
12
  };
13
13
 
14
+ const defaultLinks = [
15
+ {
16
+ label: "Overview",
17
+ },
18
+ {
19
+ label: "Principles",
20
+ links: [{ label: "Color" }, { label: "Spacing" }, { label: "Typography" }],
21
+ },
22
+ {
23
+ label: "Components",
24
+ links: [
25
+ {
26
+ label: "Accordion",
27
+ },
28
+ {
29
+ label: "Button",
30
+ },
31
+ ],
32
+ },
33
+ ];
34
+
14
35
  const links = [
15
36
  {
16
37
  label: "Overview",
17
- id: "overview",
18
38
  links: [
19
39
  {
20
40
  label: "Introduction",
21
- id: "introduction",
41
+ },
42
+ ],
43
+ },
44
+ {
45
+ label: "Components",
46
+ links: [
47
+ {
48
+ label: "Introduction",
49
+ },
50
+ {
51
+ label: "Accordion",
22
52
  },
23
53
  ],
24
54
  },
25
55
  {
26
56
  label: "Principles very very very very very very very very long",
27
- id: "principles",
28
57
  links: [
29
- { label: "Color very very very very very very very very long", id: "color" },
30
- { label: "Spacingveryveryveryveryveryveryveryverylong", id: "spacing" },
31
- { label: "Typography", id: "typography" },
58
+ { label: "Color very very very very very very very very long" },
59
+ { label: "Spacingveryveryveryveryveryveryveryverylong" },
60
+ { label: "Typography" },
32
61
  ],
33
62
  },
34
63
  {
35
64
  label: "Componentsveryveryveryveryveryveryveryverylong",
36
- id: "components",
37
65
  links: [
38
66
  {
39
67
  label: "Accordion",
40
- id: "accordion",
41
68
  },
42
69
  ],
43
70
  },
@@ -48,19 +75,25 @@ export const Chromatic = () => (
48
75
  <ExampleContainer>
49
76
  <Title title="Default" level={4} />
50
77
  <QuickNavContainer>
51
- <DxcQuickNav links={links}></DxcQuickNav>
78
+ <DxcQuickNav links={defaultLinks} />
79
+ </QuickNavContainer>
80
+ </ExampleContainer>
81
+ <ExampleContainer>
82
+ <Title title="Text overflow" level={4} />
83
+ <QuickNavContainer>
84
+ <DxcQuickNav links={links} />
52
85
  </QuickNavContainer>
53
86
  </ExampleContainer>
54
87
  <ExampleContainer pseudoState="pseudo-hover">
55
88
  <Title title="Link hovered" level={4} />
56
89
  <QuickNavContainer>
57
- <DxcQuickNav links={links}></DxcQuickNav>
90
+ <DxcQuickNav links={links} />
58
91
  </QuickNavContainer>
59
92
  </ExampleContainer>
60
93
  <ExampleContainer pseudoState="pseudo-focus">
61
94
  <Title title="Link focus" level={4} />
62
95
  <QuickNavContainer>
63
- <DxcQuickNav links={links}></DxcQuickNav>
96
+ <DxcQuickNav links={links} />
64
97
  </QuickNavContainer>
65
98
  </ExampleContainer>
66
99
  <ExampleContainer>
@@ -87,7 +120,44 @@ export const Chromatic = () => (
87
120
  open source design system for insurance products and digital experiences. Our system provides all the
88
121
  tools and resources needed to create superior, beautiful but above all, functional user experiences.
89
122
  </DxcParagraph>
90
- <Content id="introduction">
123
+ <Content id="overview-introduction">
124
+ <DxcHeading level={2} text="Introduction" margin={{ top: "xsmall", bottom: "xsmall" }} />
125
+ <DxcParagraph>
126
+ Design principles Halstack design principles are the fundamental part of DXC Technology's approach to
127
+ provide guidance for development teams in order to deliver delightful and consistent user experiences to
128
+ our customers: Balance Consistency Visual hierarchy All our components, design tokens, accessibility
129
+ guidelines, responsive design techniques, and layout proposals have been carefully curated by DXC design
130
+ and engineering teams with the objective of creating a unique visual language and ecosystem for our
131
+ applications. This is the DXC way of creating User Experiences. Open Source Halstack is an open source
132
+ design system, this means that we work towards DXC Technology bussines needs, but it is open for anyone
133
+ to use and contribute back to. We are charmed to receive external contributions to help us find bugs,
134
+ design new features, or help us improve the project documentation. If you're interested, definitely
135
+ check out our contribution guidelines.Design principles Halstack design principles are the fundamental
136
+ part of DXC Technology's approach to provide guidance for development teams in order to deliver
137
+ delightful and consistent user experiences to our customers: Balance Consistency Visual hierarchy All
138
+ our components, design tokens, accessibility guidelines, responsive design techniques, and layout
139
+ proposals have been carefully curated by DXC design and engineering teams with the objective of creating
140
+ a unique visual language and ecosystem for our applications. This is the DXC way of creating User
141
+ Experiences. Open Source Halstack is an open source design system, this means that we work towards DXC
142
+ Technology bussines needs, but it is open for anyone to use and contribute back to. We are charmed to
143
+ receive external contributions to help us find bugs, design new features, or help us improve the project
144
+ documentation. If you're interested, definitely check out our contribution guidelines.Design principles
145
+ Halstack design principles are the fundamental part of DXC Technology's approach to provide guidance for
146
+ development teams in order to deliver delightful and consistent user experiences to our customers:
147
+ Balance Consistency Visual hierarchy All our components, design tokens, accessibility guidelines,
148
+ responsive design techniques, and layout proposals have been carefully curated by DXC design and
149
+ engineering teams with the objective of creating a unique visual language and ecosystem for our
150
+ applications. This is the DXC way of creating User Experiences. Open Source Halstack is an open source
151
+ design system, this means that we work towards DXC Technology bussines needs, but it is open for anyone
152
+ to use and contribute back to. We are charmed to receive external contributions to help us find bugs,
153
+ design new features, or help us improve the project documentation. If you're interested, definitely
154
+ check out our contribution guidelines.
155
+ </DxcParagraph>
156
+ </Content>
157
+ </Content>
158
+ <Content id="components">
159
+ <DxcHeading level={1} text="Components" margin={{ top: "small", bottom: "xsmall" }} />
160
+ <Content id="components-introduction">
91
161
  <DxcHeading level={2} text="Introduction" margin={{ top: "xsmall", bottom: "xsmall" }} />
92
162
  <DxcParagraph>
93
163
  Design principles Halstack design principles are the fundamental part of DXC Technology's approach to
@@ -121,10 +191,18 @@ export const Chromatic = () => (
121
191
  check out our contribution guidelines.
122
192
  </DxcParagraph>
123
193
  </Content>
194
+ <Content id="components-accordion">
195
+ <DxcHeading level={2} text="Accordion" margin={{ top: "xsmall", bottom: "xsmall" }} />
196
+ <DxcParagraph>
197
+ Accordions are used to group similar content and hide or show it depending on user needs or preferences.
198
+ Accordions give users more granular control over the interface and help digest content in stages, rather
199
+ than all at once.
200
+ </DxcParagraph>
201
+ </Content>
124
202
  </Content>
125
- <Content id="principles">
203
+ <Content id="principles-very-very-very-very-very-very-very-very-long">
126
204
  <DxcHeading level={1} text="Principles" margin={{ top: "small", bottom: "xsmall" }} />
127
- <Content id="color">
205
+ <Content id="principles-very-very-very-very-very-very-very-very-long-color-very-very-very-very-very-very-very-very-long">
128
206
  <DxcHeading level={2} text="Color" margin={{ top: "xsmall", bottom: "xsmall" }} />
129
207
  <DxcParagraph>
130
208
  The color palette is an essential asset as a communication resource of our design system. Halstack color
@@ -161,7 +239,7 @@ export const Chromatic = () => (
161
239
  role-based color palettes and must not be used outside this context.
162
240
  </DxcParagraph>
163
241
  </Content>
164
- <Content id="spacing">
242
+ <Content id="principles-very-very-very-very-very-very-very-very-long-spacingveryveryveryveryveryveryveryverylong">
165
243
  <DxcHeading level={2} text="Spacing" margin={{ top: "xsmall", bottom: "xsmall" }} />
166
244
  <DxcParagraph>
167
245
  In the search of consistent alignment between the elements we provide a spacing scale based on a root
@@ -183,7 +261,7 @@ export const Chromatic = () => (
183
261
  easily multiplied, they provide flexible and consistent, yet distinct enough, steps between them.
184
262
  </DxcParagraph>
185
263
  </Content>
186
- <Content id="typography">
264
+ <Content id="principles-very-very-very-very-very-very-very-very-long-typography">
187
265
  <DxcHeading level={2} text="Typography" margin={{ top: "xsmall", bottom: "xsmall" }} />
188
266
  <DxcParagraph>
189
267
  Our selected typography helps in structuring our user's experience based on the visual impact that it
@@ -220,9 +298,9 @@ export const Chromatic = () => (
220
298
  </DxcParagraph>
221
299
  </Content>
222
300
  </Content>
223
- <Content id="components">
301
+ <Content id="componentsveryveryveryveryveryveryveryverylong">
224
302
  <DxcHeading level={1} text="Components" margin={{ top: "small", bottom: "xsmall" }} />
225
- <Content id="accordion">
303
+ <Content id="componentsveryveryveryveryveryveryveryverylong-accordion">
226
304
  <DxcHeading level={2} text="Accordion" margin={{ top: "xsmall", bottom: "xsmall" }} />
227
305
  <DxcParagraph>
228
306
  Accordions are used to group similar content and hide or show it depending on user needs or preferences.
@@ -233,7 +311,7 @@ export const Chromatic = () => (
233
311
  </Content>
234
312
  </ContentContainer>
235
313
  <QuickNavContainer>
236
- <DxcQuickNav title="Sections" links={links}></DxcQuickNav>
314
+ <DxcQuickNav title="Sections" links={links} />
237
315
  </QuickNavContainer>
238
316
  </Container>
239
317
  </ExampleContainer>
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { RadioProps } from "./types";
3
- declare const _default: React.MemoExoticComponent<({ option, currentValue, onClick, error, disabled, focused, readonly, tabIndex, }: RadioProps) => JSX.Element>;
3
+ declare const _default: React.MemoExoticComponent<({ label, checked, onClick, error, disabled, focused, readonly, tabIndex, }: RadioProps) => JSX.Element>;
4
4
  export default _default;
@@ -28,10 +28,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
28
28
  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; }
29
29
 
30
30
  var DxcRadio = function DxcRadio(_ref) {
31
- var _option$disabled;
32
-
33
- var option = _ref.option,
34
- currentValue = _ref.currentValue,
31
+ var label = _ref.label,
32
+ checked = _ref.checked,
35
33
  onClick = _ref.onClick,
36
34
  error = _ref.error,
37
35
  disabled = _ref.disabled,
@@ -50,7 +48,7 @@ var DxcRadio = function DxcRadio(_ref) {
50
48
  var _ref$current;
51
49
 
52
50
  onClick();
53
- focused && document.activeElement !== (ref === null || ref === void 0 ? void 0 : ref.current) && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
51
+ document.activeElement !== (ref === null || ref === void 0 ? void 0 : ref.current) && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
54
52
  };
55
53
 
56
54
  var _useState3 = (0, _react.useState)(true),
@@ -75,52 +73,57 @@ var DxcRadio = function DxcRadio(_ref) {
75
73
  error: error,
76
74
  disabled: disabled,
77
75
  readonly: readonly,
78
- onMouseDown: function onMouseDown(event) {
79
- // Prevents div's onClick from stealing the radio input's focus
80
- event.preventDefault();
81
- },
82
- onClick: handleOnClick
76
+ onClick: disabled ? undefined : handleOnClick
83
77
  }, /*#__PURE__*/_react["default"].createElement(RadioInputContainer, null, /*#__PURE__*/_react["default"].createElement(RadioInput, {
84
78
  error: error,
85
79
  disabled: disabled,
86
80
  readonly: readonly,
87
81
  role: "radio",
88
- "aria-checked": option.value === currentValue,
89
- "aria-disabled": (_option$disabled = option.disabled) !== null && _option$disabled !== void 0 ? _option$disabled : false,
82
+ "aria-checked": checked,
83
+ "aria-disabled": disabled,
90
84
  "aria-labelledby": radioLabelId,
91
85
  tabIndex: disabled ? -1 : focused ? tabIndex : -1,
92
86
  ref: ref
93
- }, option.value === currentValue && /*#__PURE__*/_react["default"].createElement(Dot, {
87
+ }, checked && /*#__PURE__*/_react["default"].createElement(Dot, {
94
88
  disabled: disabled,
95
89
  readonly: readonly,
96
90
  error: error
97
91
  }))), /*#__PURE__*/_react["default"].createElement(Label, {
98
92
  id: radioLabelId,
99
93
  disabled: disabled
100
- }, option.label))));
94
+ }, label))));
101
95
  };
102
96
 
103
- var RadioMainContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n"])));
97
+ var getRadioInputStateColor = function getRadioInputStateColor(props, state) {
98
+ switch (state) {
99
+ case "enabled":
100
+ return props.disabled ? props.theme.disabledRadioInputColor : props.error ? props.theme.errorRadioInputColor : props.readonly ? props.theme.readonlyRadioInputColor : props.theme.radioInputColor;
104
101
 
105
- var RadioContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n\n ", "\n"])), function (props) {
106
- return props.disabled ? "not-allowed" : props.readonly ? "default" : "pointer";
107
- }, function (props) {
108
- return !props.disabled ? "\n &:hover {\n & > div > div { \n border-color: ".concat(props.error ? props.theme.hoverErrorRadioInputColor : props.readonly ? props.theme.hoverReadonlyRadioInputColor : props.theme.hoverRadioInputColor, ";\n & > span {\n background-color: ").concat(props.error ? props.theme.hoverErrorRadioInputColor : props.readonly ? props.theme.hoverReadonlyRadioInputColor : props.theme.hoverRadioInputColor, ";\n }\n };\n }\n &:active {\n & > div > div {\n border-color: ").concat(props.error ? props.theme.activeErrorRadioInputColor : props.readonly ? props.theme.activeReadonlyRadioInputColor : props.theme.activeRadioInputColor, ";\n & > span {\n background-color: ").concat(props.error ? props.theme.activeErrorRadioInputColor : props.readonly ? props.theme.activeReadonlyRadioInputColor : props.theme.activeRadioInputColor, ";\n }\n }\n }\n ") : "pointer-events: none;";
109
- });
102
+ case "hover":
103
+ return props.error ? props.theme.hoverErrorRadioInputColor : props.readonly ? props.theme.hoverReadonlyRadioInputColor : props.theme.hoverRadioInputColor;
110
104
 
111
- var RadioInputContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
105
+ case "active":
106
+ return props.error ? props.theme.activeErrorRadioInputColor : props.readonly ? props.theme.activeReadonlyRadioInputColor : props.theme.activeRadioInputColor;
107
+ }
108
+ };
112
109
 
113
- var RadioInput = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n border: 2px solid\n ", ";\n border-radius: 50%;\n\n ", "\n"])), function (props) {
114
- if (props.disabled) return props.theme.disabledRadioInputColor;else if (props.error) return props.theme.errorRadioInputColor;else if (props.readonly) return props.theme.readonlyRadioInputColor;else return props.theme.radioInputColor;
110
+ var RadioMainContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n"])));
111
+
112
+ var RadioInputContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
113
+
114
+ var RadioInput = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n border: 2px solid ", ";\n border-radius: 50%;\n\n &:focus {\n outline: 2px solid ", ";\n outline-offset: 1px;\n }\n ", "\n"])), function (props) {
115
+ return getRadioInputStateColor(props, "enabled");
116
+ }, function (props) {
117
+ return props.theme.focusBorderColor;
115
118
  }, function (props) {
116
- return !props.disabled ? "&:focus {\n outline: 2px solid ".concat(props.theme.focusBorderColor, ";\n outline-offset: 1px;\n }\n &:focus-visible {\n outline: 2px solid ").concat(props.theme.focusBorderColor, ";\n outline-offset: 1px;\n }\n ") : "\n :focus-visible {\n outline: none;\n }\n ";
119
+ return props.disabled && "pointer-events: none;";
117
120
  });
118
121
 
119
- var Dot = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background-color: ", ";\n"])), function (props) {
120
- if (props.disabled) return props.theme.disabledRadioInputColor;else if (props.error) return props.theme.errorRadioInputColor;else if (props.readonly) return props.theme.readonlyRadioInputColor;else return props.theme.radioInputColor;
122
+ var Dot = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background-color: ", ";\n"])), function (props) {
123
+ return getRadioInputStateColor(props, "enabled");
121
124
  });
122
125
 
123
- var Label = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
126
+ var Label = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
124
127
  return props.theme.radioInputLabelMargin;
125
128
  }, function (props) {
126
129
  return props.theme.fontFamily;
@@ -133,7 +136,19 @@ var Label = _styledComponents["default"].span(_templateObject6 || (_templateObje
133
136
  }, function (props) {
134
137
  return props.theme.radioInputLabelLineHeight;
135
138
  }, function (props) {
136
- return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, "; pointer-events: none;") : "color: ".concat(props.theme.radioInputLabelFontColor);
139
+ return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, ";") : "color: ".concat(props.theme.radioInputLabelFontColor);
140
+ });
141
+
142
+ var RadioContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n\n &:hover {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n &:active {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n"])), function (props) {
143
+ return props.disabled ? "not-allowed" : props.readonly ? "default" : "pointer";
144
+ }, RadioInput, function (props) {
145
+ return !props.disabled && getRadioInputStateColor(props, "hover");
146
+ }, Dot, function (props) {
147
+ return !props.disabled && getRadioInputStateColor(props, "hover");
148
+ }, RadioInput, function (props) {
149
+ return !props.disabled && getRadioInputStateColor(props, "active");
150
+ }, Dot, function (props) {
151
+ return !props.disabled && getRadioInputStateColor(props, "active");
137
152
  });
138
153
 
139
154
  var _default = /*#__PURE__*/_react["default"].memo(DxcRadio);
@@ -41,6 +41,8 @@ var getInitialFocusIndex = function getInitialFocusIndex(innerOptions, value) {
41
41
  };
42
42
 
43
43
  var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
44
+ var _ref2;
45
+
44
46
  var label = _ref.label,
45
47
  name = _ref.name,
46
48
  helperText = _ref.helperText,
@@ -102,11 +104,11 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
102
104
  value !== null && value !== void 0 ? value : setInnerValue(newValue);
103
105
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
104
106
  }
105
- }, [value, innerValue, setInnerValue, onChange]);
107
+ }, [value, innerValue, onChange]);
106
108
 
107
- var handleOnBlur = function handleOnBlur(e) {
109
+ var handleOnBlur = function handleOnBlur(event) {
108
110
  // If the radio group loses the focus to an element not contained inside it...
109
- if (!e.currentTarget.contains(e.relatedTarget)) {
111
+ if (!event.currentTarget.contains(event.relatedTarget)) {
110
112
  setFirstTimeFocus(true);
111
113
  var currentValue = value !== null && value !== void 0 ? value : innerValue;
112
114
  !optional && !Boolean(currentValue) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
@@ -166,8 +168,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
166
168
  setNextRadioChecked();
167
169
  break;
168
170
 
169
- case "Enter":
170
- case "Space":
171
+ case " ":
171
172
  event.preventDefault();
172
173
  handleOnChange(innerOptions[currentFocusIndex].value);
173
174
  break;
@@ -182,7 +183,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
182
183
  id: radioGroupLabelId,
183
184
  helperText: helperText,
184
185
  disabled: disabled
185
- }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
186
+ }, label, optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, " ".concat(translatedLabels.formFields.optionalLabel))), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
186
187
  disabled: disabled
187
188
  }, helperText), /*#__PURE__*/_react["default"].createElement(RadioGroup, {
188
189
  onBlur: handleOnBlur,
@@ -192,20 +193,22 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
192
193
  role: "radiogroup",
193
194
  "aria-disabled": disabled,
194
195
  "aria-labelledby": radioGroupLabelId,
195
- "aria-invalid": error ? "true" : "false",
196
+ "aria-invalid": error ? true : false,
196
197
  "aria-errormessage": error ? errorId : undefined,
197
198
  "aria-required": !disabled && !readonly && !optional,
198
199
  "aria-readonly": readonly,
199
200
  "aria-orientation": stacking === "column" ? "vertical" : "horizontal"
200
201
  }, /*#__PURE__*/_react["default"].createElement(ValueInput, {
201
202
  name: name,
202
- value: value !== null && value !== void 0 ? value : innerValue,
203
+ disabled: disabled,
204
+ value: (_ref2 = value !== null && value !== void 0 ? value : innerValue) !== null && _ref2 !== void 0 ? _ref2 : "",
203
205
  readOnly: true,
204
206
  "aria-hidden": "true"
205
207
  }), innerOptions.map(function (option, index) {
206
208
  return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
207
- option: option,
208
- currentValue: value !== null && value !== void 0 ? value : innerValue,
209
+ key: "radio-".concat(index),
210
+ label: option.label,
211
+ checked: (value !== null && value !== void 0 ? value : innerValue) === option.value,
209
212
  onClick: function onClick() {
210
213
  handleOnChange(option.value);
211
214
  setCurrentFocusIndex(index);
@@ -214,8 +217,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
214
217
  disabled: option.disabled || disabled,
215
218
  focused: currentFocusIndex === index,
216
219
  readonly: readonly,
217
- tabIndex: tabIndex,
218
- key: "radio-".concat(index)
220
+ tabIndex: tabIndex
219
221
  });
220
222
  })), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
221
223
  id: errorId,
@@ -261,7 +263,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
261
263
  return props.theme.groupLabelMargin;
262
264
  });
263
265
 
264
- var RadioGroup = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n\n row-gap: ", ";\n column-gap: ", ";\n"])), function (props) {
266
+ var RadioGroup = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n row-gap: ", ";\n column-gap: ", ";\n"])), function (props) {
265
267
  return props.stacking;
266
268
  }, function (props) {
267
269
  return props.theme.groupVerticalGutter;
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
2
3
  import Title from "../../.storybook/components/Title";
3
4
  import DxcRadioGroup from "./RadioGroup";