@dxc-technology/halstack-react 0.0.0-0e7fa98 → 0.0.0-0ea575c

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 (189) hide show
  1. package/HalstackContext.d.ts +12 -0
  2. package/HalstackContext.js +295 -0
  3. package/accordion/Accordion.js +122 -103
  4. package/accordion/Accordion.stories.tsx +5 -6
  5. package/accordion/Accordion.test.js +9 -10
  6. package/accordion/types.d.ts +4 -4
  7. package/accordion-group/AccordionGroup.js +2 -21
  8. package/accordion-group/AccordionGroup.stories.tsx +27 -1
  9. package/accordion-group/AccordionGroup.test.js +20 -45
  10. package/accordion-group/types.d.ts +9 -3
  11. package/alert/Alert.js +5 -2
  12. package/badge/Badge.d.ts +1 -1
  13. package/badge/Badge.js +5 -3
  14. package/badge/types.d.ts +1 -0
  15. package/bleed/Bleed.js +1 -34
  16. package/bleed/Bleed.stories.tsx +94 -95
  17. package/bleed/types.d.ts +1 -1
  18. package/box/Box.js +23 -33
  19. package/bulleted-list/BulletedList.d.ts +7 -0
  20. package/bulleted-list/BulletedList.js +123 -0
  21. package/bulleted-list/BulletedList.stories.tsx +200 -0
  22. package/bulleted-list/types.d.ts +11 -0
  23. package/{list → bulleted-list}/types.js +0 -0
  24. package/button/Button.js +53 -68
  25. package/button/Button.stories.tsx +9 -0
  26. package/button/types.d.ts +7 -7
  27. package/card/Card.js +24 -27
  28. package/checkbox/Checkbox.d.ts +1 -1
  29. package/checkbox/Checkbox.js +99 -97
  30. package/checkbox/Checkbox.stories.tsx +124 -128
  31. package/checkbox/Checkbox.test.js +93 -16
  32. package/checkbox/types.d.ts +5 -5
  33. package/chip/types.d.ts +1 -1
  34. package/common/variables.js +232 -96
  35. package/date-input/DateInput.js +19 -16
  36. package/dialog/Dialog.js +52 -28
  37. package/dialog/Dialog.stories.tsx +57 -2
  38. package/dialog/Dialog.test.js +34 -4
  39. package/dialog/types.d.ts +2 -2
  40. package/dropdown/Dropdown.d.ts +1 -1
  41. package/dropdown/Dropdown.js +243 -251
  42. package/dropdown/Dropdown.stories.tsx +126 -63
  43. package/dropdown/Dropdown.test.js +510 -108
  44. package/dropdown/DropdownMenu.d.ts +4 -0
  45. package/dropdown/DropdownMenu.js +80 -0
  46. package/dropdown/DropdownMenuItem.d.ts +4 -0
  47. package/dropdown/DropdownMenuItem.js +92 -0
  48. package/dropdown/types.d.ts +25 -5
  49. package/file-input/FileInput.js +9 -6
  50. package/file-input/FileItem.js +7 -5
  51. package/flex/Flex.d.ts +4 -0
  52. package/flex/Flex.js +57 -0
  53. package/flex/Flex.stories.tsx +103 -0
  54. package/flex/types.d.ts +21 -0
  55. package/{radio → flex}/types.js +0 -0
  56. package/footer/Footer.js +7 -5
  57. package/footer/Footer.stories.tsx +8 -1
  58. package/footer/Icons.js +1 -1
  59. package/footer/types.d.ts +1 -1
  60. package/header/Header.js +80 -75
  61. package/header/Header.stories.tsx +4 -4
  62. package/header/Icons.js +2 -2
  63. package/header/types.d.ts +2 -2
  64. package/inset/Inset.js +1 -34
  65. package/inset/Inset.stories.tsx +36 -36
  66. package/inset/types.d.ts +1 -1
  67. package/layout/ApplicationLayout.d.ts +16 -6
  68. package/layout/ApplicationLayout.js +70 -117
  69. package/layout/ApplicationLayout.stories.tsx +84 -93
  70. package/layout/Icons.d.ts +5 -0
  71. package/layout/Icons.js +13 -2
  72. package/layout/SidenavContext.d.ts +5 -0
  73. package/layout/SidenavContext.js +19 -0
  74. package/layout/types.d.ts +18 -33
  75. package/link/Link.d.ts +3 -2
  76. package/link/Link.js +57 -74
  77. package/link/Link.stories.tsx +95 -53
  78. package/link/Link.test.js +7 -15
  79. package/link/types.d.ts +7 -23
  80. package/main.d.ts +7 -10
  81. package/main.js +43 -61
  82. package/number-input/types.d.ts +1 -1
  83. package/package.json +12 -11
  84. package/paginator/Paginator.js +17 -38
  85. package/paginator/Paginator.test.js +42 -0
  86. package/paragraph/Paragraph.d.ts +6 -0
  87. package/paragraph/Paragraph.js +38 -0
  88. package/paragraph/Paragraph.stories.tsx +44 -0
  89. package/password-input/PasswordInput.js +7 -4
  90. package/password-input/PasswordInput.test.js +1 -2
  91. package/password-input/types.d.ts +1 -1
  92. package/progress-bar/ProgressBar.d.ts +2 -2
  93. package/progress-bar/ProgressBar.js +57 -51
  94. package/progress-bar/ProgressBar.stories.jsx +13 -11
  95. package/progress-bar/ProgressBar.test.js +67 -22
  96. package/progress-bar/types.d.ts +3 -4
  97. package/quick-nav/QuickNav.js +72 -21
  98. package/quick-nav/QuickNav.stories.tsx +80 -17
  99. package/quick-nav/types.d.ts +4 -4
  100. package/radio-group/Radio.d.ts +1 -1
  101. package/radio-group/Radio.js +43 -28
  102. package/radio-group/RadioGroup.js +33 -34
  103. package/radio-group/RadioGroup.stories.tsx +1 -0
  104. package/radio-group/RadioGroup.test.js +28 -58
  105. package/radio-group/types.d.ts +2 -2
  106. package/resultsetTable/ResultsetTable.test.js +42 -0
  107. package/select/Listbox.d.ts +1 -1
  108. package/select/Listbox.js +58 -8
  109. package/select/Select.js +78 -90
  110. package/select/Select.stories.tsx +145 -100
  111. package/select/Select.test.js +362 -244
  112. package/select/types.d.ts +2 -5
  113. package/sidenav/Sidenav.d.ts +6 -5
  114. package/sidenav/Sidenav.js +184 -52
  115. package/sidenav/Sidenav.stories.tsx +154 -156
  116. package/sidenav/Sidenav.test.js +25 -37
  117. package/sidenav/types.d.ts +50 -27
  118. package/slider/Slider.js +116 -92
  119. package/slider/Slider.stories.tsx +7 -1
  120. package/slider/Slider.test.js +121 -21
  121. package/slider/types.d.ts +2 -2
  122. package/spinner/Spinner.js +1 -1
  123. package/switch/Switch.d.ts +2 -2
  124. package/switch/Switch.js +133 -64
  125. package/switch/Switch.stories.tsx +16 -38
  126. package/switch/Switch.test.js +144 -17
  127. package/switch/types.d.ts +5 -6
  128. package/tabs/Tab.d.ts +4 -0
  129. package/tabs/Tab.js +135 -0
  130. package/tabs/Tabs.js +360 -104
  131. package/tabs/Tabs.stories.tsx +74 -6
  132. package/tabs/Tabs.test.js +217 -6
  133. package/tabs/types.d.ts +15 -5
  134. package/tabs-nav/NavTabs.d.ts +8 -0
  135. package/tabs-nav/NavTabs.js +125 -0
  136. package/tabs-nav/NavTabs.stories.tsx +170 -0
  137. package/tabs-nav/NavTabs.test.js +82 -0
  138. package/tabs-nav/Tab.d.ts +4 -0
  139. package/tabs-nav/Tab.js +130 -0
  140. package/tabs-nav/types.d.ts +53 -0
  141. package/{row → tabs-nav}/types.js +0 -0
  142. package/tag/Tag.js +6 -9
  143. package/tag/types.d.ts +1 -1
  144. package/text-input/Icons.d.ts +8 -0
  145. package/text-input/Icons.js +60 -0
  146. package/text-input/Suggestion.d.ts +4 -0
  147. package/text-input/Suggestion.js +57 -0
  148. package/text-input/Suggestions.d.ts +4 -0
  149. package/text-input/Suggestions.js +134 -0
  150. package/text-input/TextInput.js +140 -273
  151. package/text-input/TextInput.stories.tsx +189 -182
  152. package/text-input/TextInput.test.js +164 -163
  153. package/text-input/types.d.ts +28 -2
  154. package/textarea/Textarea.js +10 -19
  155. package/textarea/types.d.ts +1 -1
  156. package/toggle-group/types.d.ts +1 -1
  157. package/typography/Typography.d.ts +4 -0
  158. package/typography/Typography.js +131 -0
  159. package/typography/Typography.stories.tsx +198 -0
  160. package/typography/types.d.ts +18 -0
  161. package/{stack → typography}/types.js +0 -0
  162. package/useTheme.js +2 -2
  163. package/useTranslatedLabels.d.ts +2 -0
  164. package/useTranslatedLabels.js +20 -0
  165. package/wizard/Wizard.js +36 -41
  166. package/wizard/Wizard.stories.tsx +20 -1
  167. package/wizard/types.d.ts +5 -4
  168. package/ThemeContext.d.ts +0 -10
  169. package/ThemeContext.js +0 -243
  170. package/list/List.d.ts +0 -4
  171. package/list/List.js +0 -47
  172. package/list/List.stories.tsx +0 -95
  173. package/list/types.d.ts +0 -7
  174. package/radio/Radio.d.ts +0 -4
  175. package/radio/Radio.js +0 -174
  176. package/radio/Radio.stories.tsx +0 -192
  177. package/radio/Radio.test.js +0 -71
  178. package/radio/types.d.ts +0 -54
  179. package/row/Row.d.ts +0 -3
  180. package/row/Row.js +0 -127
  181. package/row/Row.stories.tsx +0 -237
  182. package/row/types.d.ts +0 -28
  183. package/stack/Stack.d.ts +0 -3
  184. package/stack/Stack.js +0 -97
  185. package/stack/Stack.stories.tsx +0 -164
  186. package/stack/types.d.ts +0 -24
  187. package/text/Text.d.ts +0 -7
  188. package/text/Text.js +0 -30
  189. 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 DxcText from "../text/Text";
5
+ import DxcParagraph from "../paragraph/Paragraph";
6
6
  import Title from "../../.storybook/components/Title";
7
7
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
8
8
 
@@ -11,6 +11,36 @@ export default {
11
11
  component: DxcQuickNav,
12
12
  };
13
13
 
14
+ const defaultLinks = [
15
+ {
16
+ label: "Overview",
17
+ id: "overview",
18
+ },
19
+ {
20
+ label: "Principles",
21
+ id: "principles",
22
+ links: [
23
+ { label: "Color", id: "color" },
24
+ { label: "Spacing", id: "spacing" },
25
+ { label: "Typography", id: "typography" },
26
+ ],
27
+ },
28
+ {
29
+ label: "Components",
30
+ id: "components",
31
+ links: [
32
+ {
33
+ label: "Accordion",
34
+ id: "accordion",
35
+ },
36
+ {
37
+ label: "Button",
38
+ id: "button",
39
+ },
40
+ ],
41
+ },
42
+ ];
43
+
14
44
  const links = [
15
45
  {
16
46
  label: "Overview",
@@ -23,14 +53,24 @@ const links = [
23
53
  ],
24
54
  },
25
55
  {
26
- label: "Principles",
56
+ label: "Principles very very very very very very very very long",
27
57
  id: "principles",
28
58
  links: [
29
- { label: "Color", id: "color" },
30
- { label: "Spacing", id: "spacing" },
59
+ { label: "Color very very very very very very very very long", id: "color" },
60
+ { label: "Spacingveryveryveryveryveryveryveryverylong", id: "spacing" },
31
61
  { label: "Typography", id: "typography" },
32
62
  ],
33
63
  },
64
+ {
65
+ label: "Componentsveryveryveryveryveryveryveryverylong",
66
+ id: "components",
67
+ links: [
68
+ {
69
+ label: "Accordion",
70
+ id: "accordion",
71
+ },
72
+ ],
73
+ },
34
74
  ];
35
75
 
36
76
  export const Chromatic = () => (
@@ -38,13 +78,25 @@ export const Chromatic = () => (
38
78
  <ExampleContainer>
39
79
  <Title title="Default" level={4} />
40
80
  <QuickNavContainer>
41
- <DxcQuickNav title="Sections" links={links}></DxcQuickNav>
81
+ <DxcQuickNav links={defaultLinks} />
82
+ </QuickNavContainer>
83
+ </ExampleContainer>
84
+ <ExampleContainer>
85
+ <Title title="Text overflow" level={4} />
86
+ <QuickNavContainer>
87
+ <DxcQuickNav links={links} />
42
88
  </QuickNavContainer>
43
89
  </ExampleContainer>
44
90
  <ExampleContainer pseudoState="pseudo-hover">
45
91
  <Title title="Link hovered" level={4} />
46
92
  <QuickNavContainer>
47
- <DxcQuickNav title="Sections" links={links}></DxcQuickNav>
93
+ <DxcQuickNav links={links} />
94
+ </QuickNavContainer>
95
+ </ExampleContainer>
96
+ <ExampleContainer pseudoState="pseudo-focus">
97
+ <Title title="Link focus" level={4} />
98
+ <QuickNavContainer>
99
+ <DxcQuickNav links={links} />
48
100
  </QuickNavContainer>
49
101
  </ExampleContainer>
50
102
  <ExampleContainer>
@@ -53,7 +105,7 @@ export const Chromatic = () => (
53
105
  <ContentContainer>
54
106
  <Content id="overview">
55
107
  <DxcHeading level={1} text="Overview" margin={{ bottom: "small" }} />
56
- <DxcText>
108
+ <DxcParagraph>
57
109
  Halstack is the DXC Technology's open source design system for insurance products and digital experiences.
58
110
  Our system provides all the tools and resources needed to create superior, beautiful but above all,
59
111
  functional user experiences. Halstack is the DXC Technology's open source design system for insurance
@@ -70,10 +122,10 @@ export const Chromatic = () => (
70
122
  create superior, beautiful but above all, functional user experiences.Halstack is the DXC Technology's
71
123
  open source design system for insurance products and digital experiences. Our system provides all the
72
124
  tools and resources needed to create superior, beautiful but above all, functional user experiences.
73
- </DxcText>
125
+ </DxcParagraph>
74
126
  <Content id="introduction">
75
127
  <DxcHeading level={2} text="Introduction" margin={{ top: "xsmall", bottom: "xsmall" }} />
76
- <DxcText>
128
+ <DxcParagraph>
77
129
  Design principles Halstack design principles are the fundamental part of DXC Technology's approach to
78
130
  provide guidance for development teams in order to deliver delightful and consistent user experiences to
79
131
  our customers: Balance Consistency Visual hierarchy All our components, design tokens, accessibility
@@ -103,14 +155,14 @@ export const Chromatic = () => (
103
155
  to use and contribute back to. We are charmed to receive external contributions to help us find bugs,
104
156
  design new features, or help us improve the project documentation. If you're interested, definitely
105
157
  check out our contribution guidelines.
106
- </DxcText>
158
+ </DxcParagraph>
107
159
  </Content>
108
160
  </Content>
109
161
  <Content id="principles">
110
162
  <DxcHeading level={1} text="Principles" margin={{ top: "small", bottom: "xsmall" }} />
111
163
  <Content id="color">
112
164
  <DxcHeading level={2} text="Color" margin={{ top: "xsmall", bottom: "xsmall" }} />
113
- <DxcText>
165
+ <DxcParagraph>
114
166
  The color palette is an essential asset as a communication resource of our design system. Halstack color
115
167
  palette brings a unified consistency and helps in guiding the user's perception order. Our color palette
116
168
  is based in the HSL model . All our color families are calculated using the lightness value of the
@@ -143,11 +195,11 @@ export const Chromatic = () => (
143
195
  tokens to manage color. Appart from a multi-purpose greyscale family, purple and blue are the core color
144
196
  families used in our set of components. Additional families as red, green and yellow help as feedback
145
197
  role-based color palettes and must not be used outside this context.
146
- </DxcText>
198
+ </DxcParagraph>
147
199
  </Content>
148
200
  <Content id="spacing">
149
201
  <DxcHeading level={2} text="Spacing" margin={{ top: "xsmall", bottom: "xsmall" }} />
150
- <DxcText>
202
+ <DxcParagraph>
151
203
  In the search of consistent alignment between the elements we provide a spacing scale based on a root
152
204
  values of 8px and 4px. The numbers 4 and 8 are easily multiplied, they provide flexible and consistent,
153
205
  yet distinct enough, steps between them.In the search of consistent alignment between the elements we
@@ -165,11 +217,11 @@ export const Chromatic = () => (
165
217
  consistent, yet distinct enough, steps between them.In the search of consistent alignment between the
166
218
  elements we provide a spacing scale based on a root values of 8px and 4px. The numbers 4 and 8 are
167
219
  easily multiplied, they provide flexible and consistent, yet distinct enough, steps between them.
168
- </DxcText>
220
+ </DxcParagraph>
169
221
  </Content>
170
222
  <Content id="typography">
171
223
  <DxcHeading level={2} text="Typography" margin={{ top: "xsmall", bottom: "xsmall" }} />
172
- <DxcText>
224
+ <DxcParagraph>
173
225
  Our selected typography helps in structuring our user's experience based on the visual impact that it
174
226
  has on the user interface content. It defines what is the first noticeable piece of information or data
175
227
  based on the font shape, size, color, or type and it highlights some pieces of text over the rest. Some
@@ -201,12 +253,23 @@ export const Chromatic = () => (
201
253
  Halstack Design System include headers, body, taglines, captions, and labels. Make sure you include all
202
254
  the different typographic variants in order to enhance the application's content structure, including
203
255
  the Heading component which defines different levels of page and section titles.
204
- </DxcText>
256
+ </DxcParagraph>
257
+ </Content>
258
+ </Content>
259
+ <Content id="components">
260
+ <DxcHeading level={1} text="Components" margin={{ top: "small", bottom: "xsmall" }} />
261
+ <Content id="accordion">
262
+ <DxcHeading level={2} text="Accordion" margin={{ top: "xsmall", bottom: "xsmall" }} />
263
+ <DxcParagraph>
264
+ Accordions are used to group similar content and hide or show it depending on user needs or preferences.
265
+ Accordions give users more granular control over the interface and help digest content in stages, rather
266
+ than all at once.
267
+ </DxcParagraph>
205
268
  </Content>
206
269
  </Content>
207
270
  </ContentContainer>
208
271
  <QuickNavContainer>
209
- <DxcQuickNav title="Sections" links={links}></DxcQuickNav>
272
+ <DxcQuickNav title="Sections" links={links} />
210
273
  </QuickNavContainer>
211
274
  </Container>
212
275
  </ExampleContainer>
@@ -2,13 +2,13 @@ declare type Props = {
2
2
  /**
3
3
  * Title of the quick nav component.
4
4
  */
5
- title: string;
5
+ title?: string;
6
6
  /**
7
7
  * Links to be shown inside the quick nav component.
8
8
  */
9
- links: Link[];
9
+ links: LinkType[];
10
10
  };
11
- declare type Link = {
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?: Link[];
19
+ links?: LinkType[];
20
20
  };
21
21
  export default Props;
@@ -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;");
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);
@@ -23,9 +23,11 @@ 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
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
30
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
29
31
 
30
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
33
 
@@ -39,6 +41,8 @@ var getInitialFocusIndex = function getInitialFocusIndex(innerOptions, value) {
39
41
  };
40
42
 
41
43
  var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
44
+ var _ref2;
45
+
42
46
  var label = _ref.label,
43
47
  name = _ref.name,
44
48
  helperText = _ref.helperText,
@@ -47,8 +51,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
47
51
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
48
52
  _ref$optional = _ref.optional,
49
53
  optional = _ref$optional === void 0 ? false : _ref$optional,
50
- _ref$optionalItemLabe = _ref.optionalItemLabel,
51
- optionalItemLabel = _ref$optionalItemLabe === void 0 ? "N/A" : _ref$optionalItemLabe,
54
+ optionalItemLabel = _ref.optionalItemLabel,
52
55
  _ref$readonly = _ref.readonly,
53
56
  readonly = _ref$readonly === void 0 ? false : _ref$readonly,
54
57
  _ref$stacking = _ref.stacking,
@@ -78,8 +81,10 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
78
81
  firstTimeFocus = _useState6[0],
79
82
  setFirstTimeFocus = _useState6[1];
80
83
 
84
+ var colorsTheme = (0, _useTheme["default"])();
85
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
81
86
  var optionalItem = {
82
- label: optionalItemLabel,
87
+ label: optionalItemLabel || translatedLabels.radioGroup.optionalItemLabelDefault,
83
88
  value: "",
84
89
  disabled: disabled
85
90
  };
@@ -92,7 +97,6 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
92
97
  currentFocusIndex = _useState8[0],
93
98
  setCurrentFocusIndex = _useState8[1];
94
99
 
95
- var colorsTheme = (0, _useTheme["default"])();
96
100
  var handleOnChange = (0, _react.useCallback)(function (newValue) {
97
101
  var currentValue = value !== null && value !== void 0 ? value : innerValue;
98
102
 
@@ -100,16 +104,16 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
100
104
  value !== null && value !== void 0 ? value : setInnerValue(newValue);
101
105
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
102
106
  }
103
- }, [value, innerValue, setInnerValue, onChange]);
107
+ }, [value, innerValue, onChange]);
104
108
 
105
- var handleOnBlur = function handleOnBlur(e) {
109
+ var handleOnBlur = function handleOnBlur(event) {
106
110
  // If the radio group loses the focus to an element not contained inside it...
107
- if (!e.currentTarget.contains(e.relatedTarget)) {
111
+ if (!event.currentTarget.contains(event.relatedTarget)) {
108
112
  setFirstTimeFocus(true);
109
113
  var currentValue = value !== null && value !== void 0 ? value : innerValue;
110
114
  !optional && !Boolean(currentValue) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
111
115
  value: currentValue,
112
- error: "This field is required. Please, choose an option."
116
+ error: translatedLabels.formFields.requiredSelectionErrorMessage
113
117
  }) : onBlur === null || onBlur === void 0 ? void 0 : onBlur({
114
118
  value: currentValue
115
119
  });
@@ -147,27 +151,24 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
147
151
  };
148
152
 
149
153
  var handleOnKeyDown = function handleOnKeyDown(event) {
150
- switch (event.keyCode) {
151
- case 37: // arrow left
152
-
153
- case 38:
154
- // arrow up
154
+ switch (event.key) {
155
+ case "Left":
156
+ case "ArrowLeft":
157
+ case "Up":
158
+ case "ArrowUp":
155
159
  event.preventDefault();
156
160
  setPreviousRadioChecked();
157
161
  break;
158
162
 
159
- case 39: // arrow right
160
-
161
- case 40:
162
- // arrow down
163
+ case "Right":
164
+ case "ArrowRight":
165
+ case "Down":
166
+ case "ArrowDown":
163
167
  event.preventDefault();
164
168
  setNextRadioChecked();
165
169
  break;
166
170
 
167
- case 13: // enter
168
-
169
- case 32:
170
- // 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, "(Optional)")), 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,20 @@ 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
- }, /*#__PURE__*/_react["default"].createElement(ValueInput, {
201
+ }, /*#__PURE__*/_react["default"].createElement("input", {
202
+ type: "hidden",
201
203
  name: name,
202
- value: value !== null && value !== void 0 ? value : innerValue,
203
- readOnly: true,
204
- "aria-hidden": "true"
204
+ value: (_ref2 = value !== null && value !== void 0 ? value : innerValue) !== null && _ref2 !== void 0 ? _ref2 : ""
205
205
  }), innerOptions.map(function (option, index) {
206
206
  return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
207
- option: option,
208
- currentValue: value !== null && value !== void 0 ? value : innerValue,
207
+ key: "radio-".concat(index),
208
+ label: option.label,
209
+ checked: (value !== null && value !== void 0 ? value : innerValue) === option.value,
209
210
  onClick: function onClick() {
210
211
  handleOnChange(option.value);
211
212
  setCurrentFocusIndex(index);
@@ -260,7 +261,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
260
261
  return props.theme.groupLabelMargin;
261
262
  });
262
263
 
263
- 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) {
264
+ 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) {
264
265
  return props.stacking;
265
266
  }, function (props) {
266
267
  return props.theme.groupVerticalGutter;
@@ -268,9 +269,7 @@ var RadioGroup = _styledComponents["default"].div(_templateObject5 || (_template
268
269
  return props.theme.groupHorizontalGutter;
269
270
  });
270
271
 
271
- var ValueInput = _styledComponents["default"].input(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
272
-
273
- var Error = _styledComponents["default"].span(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.5rem;\n"])), function (props) {
272
+ var Error = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.5rem;\n"])), function (props) {
274
273
  return props.theme.errorMessageColor;
275
274
  }, function (props) {
276
275
  return props.theme.fontFamily;
@@ -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";