@dxc-technology/halstack-react 0.0.0-6a36022 → 0.0.0-6b2072d

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 (309) hide show
  1. package/BackgroundColorContext.d.ts +2 -2
  2. package/BackgroundColorContext.js +1 -1
  3. package/HalstackContext.d.ts +1336 -0
  4. package/HalstackContext.js +335 -0
  5. package/accordion/Accordion.d.ts +1 -1
  6. package/accordion/Accordion.js +110 -146
  7. package/accordion/Accordion.stories.tsx +108 -118
  8. package/accordion/Accordion.test.js +71 -0
  9. package/accordion/types.d.ts +7 -18
  10. package/accordion-group/AccordionGroup.d.ts +5 -4
  11. package/accordion-group/AccordionGroup.js +34 -76
  12. package/accordion-group/AccordionGroup.stories.tsx +94 -67
  13. package/accordion-group/AccordionGroup.test.js +116 -0
  14. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  15. package/accordion-group/AccordionGroupAccordion.js +43 -0
  16. package/accordion-group/types.d.ts +13 -18
  17. package/alert/Alert.js +9 -10
  18. package/alert/Alert.stories.tsx +28 -0
  19. package/alert/Alert.test.js +92 -0
  20. package/badge/Badge.d.ts +4 -0
  21. package/badge/Badge.js +5 -3
  22. package/badge/types.d.ts +5 -0
  23. package/bleed/Bleed.d.ts +3 -0
  24. package/bleed/Bleed.js +51 -0
  25. package/bleed/Bleed.stories.tsx +342 -0
  26. package/bleed/types.d.ts +37 -0
  27. package/bleed/types.js +5 -0
  28. package/box/Box.d.ts +1 -1
  29. package/box/Box.js +19 -48
  30. package/box/Box.stories.tsx +38 -51
  31. package/box/Box.test.js +18 -0
  32. package/box/types.d.ts +0 -11
  33. package/bulleted-list/BulletedList.d.ts +7 -0
  34. package/bulleted-list/BulletedList.js +125 -0
  35. package/bulleted-list/BulletedList.stories.tsx +206 -0
  36. package/bulleted-list/types.d.ts +38 -0
  37. package/bulleted-list/types.js +5 -0
  38. package/button/Button.d.ts +1 -1
  39. package/button/Button.js +46 -81
  40. package/button/Button.stories.tsx +163 -14
  41. package/button/Button.test.js +46 -0
  42. package/button/types.d.ts +9 -9
  43. package/card/Card.d.ts +1 -1
  44. package/card/Card.js +37 -58
  45. package/card/Card.stories.tsx +12 -42
  46. package/card/Card.test.js +50 -0
  47. package/card/types.d.ts +1 -6
  48. package/checkbox/Checkbox.d.ts +2 -2
  49. package/checkbox/Checkbox.js +107 -110
  50. package/checkbox/Checkbox.stories.tsx +198 -130
  51. package/checkbox/Checkbox.test.js +155 -0
  52. package/checkbox/types.d.ts +11 -3
  53. package/chip/Chip.d.ts +1 -1
  54. package/chip/Chip.js +36 -95
  55. package/chip/Chip.stories.tsx +123 -30
  56. package/chip/Chip.test.js +54 -0
  57. package/chip/types.d.ts +5 -13
  58. package/common/OpenSans.css +68 -80
  59. package/common/coreTokens.d.ts +146 -0
  60. package/common/coreTokens.js +167 -0
  61. package/common/utils.d.ts +1 -0
  62. package/common/utils.js +4 -4
  63. package/common/variables.d.ts +1482 -0
  64. package/common/variables.js +1097 -1348
  65. package/date-input/Calendar.d.ts +4 -0
  66. package/date-input/Calendar.js +258 -0
  67. package/date-input/DateInput.js +169 -258
  68. package/date-input/DateInput.stories.tsx +199 -33
  69. package/date-input/DateInput.test.js +835 -0
  70. package/date-input/DatePicker.d.ts +4 -0
  71. package/date-input/DatePicker.js +146 -0
  72. package/date-input/Icons.d.ts +6 -0
  73. package/date-input/Icons.js +75 -0
  74. package/date-input/YearPicker.d.ts +4 -0
  75. package/date-input/YearPicker.js +126 -0
  76. package/date-input/types.d.ts +67 -9
  77. package/dialog/Dialog.d.ts +1 -1
  78. package/dialog/Dialog.js +68 -103
  79. package/dialog/Dialog.stories.tsx +154 -171
  80. package/dialog/Dialog.test.js +369 -0
  81. package/dialog/types.d.ts +0 -12
  82. package/dropdown/Dropdown.d.ts +1 -1
  83. package/dropdown/Dropdown.js +248 -277
  84. package/dropdown/Dropdown.stories.tsx +255 -64
  85. package/dropdown/Dropdown.test.js +586 -0
  86. package/dropdown/DropdownMenu.d.ts +4 -0
  87. package/dropdown/DropdownMenu.js +74 -0
  88. package/dropdown/DropdownMenuItem.d.ts +4 -0
  89. package/dropdown/DropdownMenuItem.js +79 -0
  90. package/dropdown/types.d.ts +27 -16
  91. package/file-input/FileInput.d.ts +2 -2
  92. package/file-input/FileInput.js +180 -223
  93. package/file-input/FileInput.stories.tsx +122 -11
  94. package/file-input/FileInput.test.js +457 -0
  95. package/file-input/FileItem.d.ts +4 -14
  96. package/file-input/FileItem.js +44 -66
  97. package/file-input/types.d.ts +18 -1
  98. package/flex/Flex.d.ts +4 -0
  99. package/flex/Flex.js +71 -0
  100. package/flex/Flex.stories.tsx +112 -0
  101. package/flex/types.d.ts +97 -0
  102. package/flex/types.js +5 -0
  103. package/footer/Footer.d.ts +1 -1
  104. package/footer/Footer.js +49 -144
  105. package/footer/Footer.stories.tsx +37 -16
  106. package/footer/Footer.test.js +99 -0
  107. package/footer/Icons.js +1 -1
  108. package/footer/types.d.ts +11 -12
  109. package/grid/Grid.d.ts +7 -0
  110. package/grid/Grid.js +91 -0
  111. package/grid/Grid.stories.tsx +219 -0
  112. package/grid/types.d.ts +115 -0
  113. package/grid/types.js +5 -0
  114. package/header/Header.d.ts +4 -3
  115. package/header/Header.js +102 -150
  116. package/header/Header.stories.tsx +152 -63
  117. package/header/Header.test.js +79 -0
  118. package/header/Icons.js +2 -2
  119. package/header/types.d.ts +0 -13
  120. package/heading/Heading.js +1 -1
  121. package/heading/Heading.test.js +186 -0
  122. package/inset/Inset.js +1 -34
  123. package/inset/Inset.stories.tsx +37 -36
  124. package/inset/types.d.ts +25 -1
  125. package/layout/ApplicationLayout.d.ts +16 -6
  126. package/layout/ApplicationLayout.js +78 -129
  127. package/layout/ApplicationLayout.stories.tsx +84 -93
  128. package/layout/Icons.d.ts +5 -0
  129. package/layout/Icons.js +13 -2
  130. package/layout/SidenavContext.d.ts +5 -0
  131. package/layout/SidenavContext.js +19 -0
  132. package/layout/types.d.ts +19 -35
  133. package/link/Link.d.ts +3 -2
  134. package/link/Link.js +63 -88
  135. package/link/Link.stories.tsx +159 -52
  136. package/link/Link.test.js +81 -0
  137. package/link/types.d.ts +7 -27
  138. package/main.d.ts +12 -15
  139. package/main.js +57 -75
  140. package/nav-tabs/NavTabs.d.ts +8 -0
  141. package/nav-tabs/NavTabs.js +122 -0
  142. package/nav-tabs/NavTabs.stories.tsx +274 -0
  143. package/nav-tabs/NavTabs.test.js +82 -0
  144. package/nav-tabs/Tab.d.ts +4 -0
  145. package/nav-tabs/Tab.js +146 -0
  146. package/nav-tabs/types.d.ts +52 -0
  147. package/nav-tabs/types.js +5 -0
  148. package/number-input/NumberInput.js +11 -18
  149. package/number-input/NumberInput.stories.tsx +5 -5
  150. package/number-input/NumberInput.test.js +542 -0
  151. package/number-input/types.d.ts +17 -10
  152. package/package.json +20 -23
  153. package/paginator/Icons.d.ts +5 -0
  154. package/paginator/Icons.js +16 -28
  155. package/paginator/Paginator.js +20 -49
  156. package/paginator/Paginator.stories.tsx +24 -0
  157. package/paginator/Paginator.test.js +318 -0
  158. package/paragraph/Paragraph.d.ts +5 -0
  159. package/paragraph/Paragraph.js +38 -0
  160. package/paragraph/Paragraph.stories.tsx +44 -0
  161. package/password-input/PasswordInput.js +7 -4
  162. package/password-input/PasswordInput.test.js +181 -0
  163. package/password-input/types.d.ts +14 -11
  164. package/progress-bar/ProgressBar.js +61 -55
  165. package/progress-bar/ProgressBar.stories.jsx +47 -12
  166. package/progress-bar/ProgressBar.test.js +110 -0
  167. package/quick-nav/QuickNav.d.ts +4 -0
  168. package/quick-nav/QuickNav.js +117 -0
  169. package/quick-nav/QuickNav.stories.tsx +356 -0
  170. package/quick-nav/types.d.ts +21 -0
  171. package/quick-nav/types.js +5 -0
  172. package/radio-group/Radio.d.ts +1 -1
  173. package/radio-group/Radio.js +60 -34
  174. package/radio-group/RadioGroup.js +81 -68
  175. package/radio-group/RadioGroup.stories.tsx +171 -36
  176. package/radio-group/RadioGroup.test.js +722 -0
  177. package/radio-group/types.d.ts +81 -3
  178. package/resultsetTable/Icons.d.ts +7 -0
  179. package/resultsetTable/Icons.js +51 -0
  180. package/resultsetTable/ResultsetTable.js +50 -106
  181. package/resultsetTable/ResultsetTable.stories.tsx +56 -33
  182. package/resultsetTable/ResultsetTable.test.js +325 -0
  183. package/resultsetTable/types.d.ts +1 -1
  184. package/select/Icons.d.ts +10 -0
  185. package/select/Icons.js +93 -0
  186. package/select/Listbox.d.ts +4 -0
  187. package/select/Listbox.js +169 -0
  188. package/select/Option.d.ts +4 -0
  189. package/select/Option.js +97 -0
  190. package/select/Select.js +189 -386
  191. package/select/Select.stories.tsx +600 -201
  192. package/select/Select.test.js +2228 -0
  193. package/select/types.d.ts +53 -13
  194. package/sidenav/Icons.d.ts +7 -0
  195. package/sidenav/Icons.js +51 -0
  196. package/sidenav/Sidenav.d.ts +6 -5
  197. package/sidenav/Sidenav.js +146 -44
  198. package/sidenav/Sidenav.stories.tsx +251 -151
  199. package/sidenav/Sidenav.test.js +44 -0
  200. package/sidenav/types.d.ts +52 -26
  201. package/slider/Slider.d.ts +2 -2
  202. package/slider/Slider.js +123 -98
  203. package/slider/Slider.stories.tsx +72 -9
  204. package/slider/Slider.test.js +250 -0
  205. package/slider/types.d.ts +8 -0
  206. package/spinner/Spinner.js +18 -24
  207. package/spinner/Spinner.stories.jsx +53 -27
  208. package/spinner/Spinner.test.js +64 -0
  209. package/switch/Switch.d.ts +2 -2
  210. package/switch/Switch.js +152 -69
  211. package/switch/Switch.stories.tsx +53 -42
  212. package/switch/Switch.test.js +225 -0
  213. package/switch/types.d.ts +10 -2
  214. package/table/Table.js +3 -3
  215. package/table/Table.stories.jsx +80 -1
  216. package/table/Table.test.js +26 -0
  217. package/tabs/Tab.d.ts +4 -0
  218. package/tabs/Tab.js +132 -0
  219. package/tabs/Tabs.d.ts +1 -1
  220. package/tabs/Tabs.js +362 -114
  221. package/tabs/Tabs.stories.tsx +122 -18
  222. package/tabs/Tabs.test.js +350 -0
  223. package/tabs/types.d.ts +37 -15
  224. package/tag/Tag.d.ts +1 -1
  225. package/tag/Tag.js +24 -36
  226. package/tag/Tag.stories.tsx +37 -27
  227. package/tag/Tag.test.js +60 -0
  228. package/tag/types.d.ts +23 -14
  229. package/text-input/Icons.d.ts +8 -0
  230. package/text-input/Icons.js +60 -0
  231. package/text-input/Suggestion.d.ts +4 -0
  232. package/text-input/Suggestion.js +84 -0
  233. package/text-input/Suggestions.d.ts +4 -0
  234. package/text-input/Suggestions.js +134 -0
  235. package/text-input/TextInput.js +225 -346
  236. package/text-input/TextInput.stories.tsx +310 -197
  237. package/text-input/TextInput.test.js +1723 -0
  238. package/text-input/types.d.ts +50 -12
  239. package/textarea/Textarea.js +22 -30
  240. package/textarea/Textarea.stories.jsx +93 -13
  241. package/textarea/Textarea.test.js +435 -0
  242. package/textarea/types.d.ts +18 -11
  243. package/toggle-group/ToggleGroup.d.ts +2 -2
  244. package/toggle-group/ToggleGroup.js +86 -59
  245. package/toggle-group/ToggleGroup.stories.tsx +49 -4
  246. package/toggle-group/ToggleGroup.test.js +170 -0
  247. package/toggle-group/types.d.ts +31 -14
  248. package/typography/Typography.d.ts +4 -0
  249. package/typography/Typography.js +32 -0
  250. package/typography/Typography.stories.tsx +198 -0
  251. package/typography/types.d.ts +18 -0
  252. package/typography/types.js +5 -0
  253. package/useTheme.d.ts +1234 -1
  254. package/useTheme.js +3 -3
  255. package/useTranslatedLabels.d.ts +85 -0
  256. package/useTranslatedLabels.js +20 -0
  257. package/utils/BaseTypography.d.ts +21 -0
  258. package/utils/BaseTypography.js +108 -0
  259. package/utils/FocusLock.d.ts +13 -0
  260. package/utils/FocusLock.js +138 -0
  261. package/wizard/Wizard.d.ts +1 -1
  262. package/wizard/Wizard.js +59 -55
  263. package/wizard/Wizard.stories.tsx +48 -19
  264. package/wizard/Wizard.test.js +141 -0
  265. package/wizard/types.d.ts +8 -4
  266. package/ThemeContext.d.ts +0 -15
  267. package/ThemeContext.js +0 -243
  268. package/V3Select/V3Select.js +0 -455
  269. package/V3Select/index.d.ts +0 -27
  270. package/V3Textarea/V3Textarea.js +0 -260
  271. package/V3Textarea/index.d.ts +0 -27
  272. package/card/ice-cream.jpg +0 -0
  273. package/common/RequiredComponent.js +0 -32
  274. package/date/Date.js +0 -373
  275. package/date/index.d.ts +0 -27
  276. package/input-text/Icons.js +0 -22
  277. package/input-text/InputText.js +0 -611
  278. package/input-text/index.d.ts +0 -36
  279. package/list/List.d.ts +0 -8
  280. package/list/List.js +0 -47
  281. package/list/List.stories.tsx +0 -95
  282. package/radio/Radio.d.ts +0 -4
  283. package/radio/Radio.js +0 -174
  284. package/radio/Radio.stories.tsx +0 -192
  285. package/radio/types.d.ts +0 -54
  286. package/row/Row.d.ts +0 -11
  287. package/row/Row.js +0 -127
  288. package/row/Row.stories.tsx +0 -239
  289. package/stack/Stack.d.ts +0 -10
  290. package/stack/Stack.js +0 -97
  291. package/stack/Stack.stories.tsx +0 -166
  292. package/text/Text.d.ts +0 -7
  293. package/text/Text.js +0 -30
  294. package/text/Text.stories.tsx +0 -19
  295. package/toggle/Toggle.js +0 -186
  296. package/toggle/index.d.ts +0 -21
  297. package/upload/Upload.js +0 -201
  298. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  299. package/upload/buttons-upload/Icons.js +0 -40
  300. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  301. package/upload/dragAndDropArea/Icons.js +0 -39
  302. package/upload/file-upload/FileToUpload.js +0 -115
  303. package/upload/file-upload/Icons.js +0 -66
  304. package/upload/files-upload/FilesToUpload.js +0 -109
  305. package/upload/index.d.ts +0 -15
  306. package/upload/transaction/Icons.js +0 -160
  307. package/upload/transaction/Transaction.js +0 -104
  308. package/upload/transactions/Transactions.js +0 -94
  309. /package/{radio → badge}/types.js +0 -0
@@ -21,11 +21,15 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
21
 
22
22
  var _uuid = require("uuid");
23
23
 
24
- var _variables = require("../common/variables.js");
24
+ var _variables = require("../common/variables");
25
25
 
26
26
  var _useTheme = _interopRequireDefault(require("../useTheme"));
27
27
 
28
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
28
+ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
29
+
30
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
31
+
32
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
29
33
 
30
34
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
35
 
@@ -34,6 +38,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
34
38
  var DxcToggleGroup = function DxcToggleGroup(_ref) {
35
39
  var label = _ref.label,
36
40
  helperText = _ref.helperText,
41
+ defaultValue = _ref.defaultValue,
37
42
  value = _ref.value,
38
43
  onChange = _ref.onChange,
39
44
  _ref$disabled = _ref.disabled,
@@ -44,16 +49,18 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
44
49
  multiple = _ref$multiple === void 0 ? false : _ref$multiple,
45
50
  _ref$tabIndex = _ref.tabIndex,
46
51
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
47
- var colorsTheme = (0, _useTheme["default"])();
48
52
 
49
- var _useState = (0, _react.useState)(multiple ? [] : -1),
50
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
51
- selectedValue = _useState2[0],
52
- setSelectedValue = _useState2[1];
53
+ var _useState = (0, _react.useState)("label-toggle-group-".concat((0, _uuid.v4)())),
54
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
55
+ toggleGroupLabelId = _useState2[0];
53
56
 
54
- var _useState3 = (0, _react.useState)("toggle-group-".concat((0, _uuid.v4)())),
55
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
56
- toggleGroupId = _useState4[0];
57
+ var _useState3 = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : -1),
58
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
59
+ selectedValue = _useState4[0],
60
+ setSelectedValue = _useState4[1];
61
+
62
+ var colorsTheme = (0, _useTheme["default"])();
63
+ var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
57
64
 
58
65
  var handleToggleChange = function handleToggleChange(selectedOption) {
59
66
  var newSelectedOptions;
@@ -88,51 +95,67 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
88
95
  onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? newSelectedOptions : selectedOption);
89
96
  };
90
97
 
91
- var handleKeyPress = function handleKeyPress(event, optionValue) {
92
- event.preventDefault();
93
- if (!disabled && (event.nativeEvent.code === "Enter" || event.nativeEvent.code === "Space")) handleToggleChange(optionValue);
98
+ var handleOnKeyDown = function handleOnKeyDown(event, optionValue) {
99
+ switch (event.key) {
100
+ case "Enter":
101
+ case " ":
102
+ event.preventDefault();
103
+ handleToggleChange(optionValue);
104
+ }
94
105
  };
95
106
 
96
107
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
97
108
  theme: colorsTheme.toggleGroup
98
109
  }, /*#__PURE__*/_react["default"].createElement(ToggleGroup, {
99
- margin: margin,
100
- disabled: disabled
110
+ margin: margin
101
111
  }, /*#__PURE__*/_react["default"].createElement(Label, {
102
- htmlFor: toggleGroupId,
112
+ id: toggleGroupLabelId,
103
113
  disabled: disabled
104
114
  }, label), /*#__PURE__*/_react["default"].createElement(HelperText, {
105
115
  disabled: disabled
106
116
  }, helperText), /*#__PURE__*/_react["default"].createElement(OptionsContainer, {
107
- id: toggleGroupId,
108
- role: multiple ? "group" : "radiogroup"
117
+ "aria-labelledby": toggleGroupLabelId
109
118
  }, options.map(function (option, i) {
110
- return /*#__PURE__*/_react["default"].createElement(ToggleContainer, {
111
- selected: multiple && Array.isArray(value) ? value ? value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
112
- role: multiple ? "switch" : "radio",
113
- "aria-checked": multiple && Array.isArray(value) ? value ? value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
114
- tabIndex: !disabled ? tabIndex : -1,
119
+ return /*#__PURE__*/_react["default"].createElement(ToggleButton, {
120
+ key: "toggle-".concat(i, "-").concat(option.label),
121
+ "aria-label": option.title,
122
+ "aria-pressed": multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
123
+ disabled: disabled,
115
124
  onClick: function onClick() {
116
- return !disabled && handleToggleChange(option.value);
125
+ handleToggleChange(option.value);
117
126
  },
118
- isFirst: i === 0,
119
- isLast: i === options.length - 1,
120
- isIcon: option.icon,
121
- optionLabel: option.label,
122
- disabled: disabled,
123
- onKeyPress: function onKeyPress(event) {
124
- handleKeyPress(event, option.value);
127
+ onKeyDown: function onKeyDown(event) {
128
+ handleOnKeyDown(event, option.value);
125
129
  },
126
- key: "toggle-".concat(i, "-").concat(option.label)
127
- }, /*#__PURE__*/_react["default"].createElement(OptionContent, null, option.icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
130
+ tabIndex: !disabled ? tabIndex : -1,
131
+ title: option.title,
132
+ backgroundType: backgroundType,
133
+ hasIcon: option.icon,
134
+ optionLabel: option.label,
135
+ selected: multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue
136
+ }, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
137
+ alignItems: "center"
138
+ }, option.icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
128
139
  optionLabel: option.label
129
- }, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement(Icon, {
140
+ }, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
130
141
  src: option.icon
131
142
  }) : option.icon), option.label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, option.label)));
132
143
  }))));
133
144
  };
134
145
 
135
- var Label = _styledComponents["default"].label(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
146
+ var ToggleGroup = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
147
+ return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
148
+ }, function (props) {
149
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
150
+ }, function (props) {
151
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
152
+ }, function (props) {
153
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
154
+ }, function (props) {
155
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
156
+ });
157
+
158
+ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
136
159
  return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
137
160
  }, function (props) {
138
161
  return props.theme.labelFontFamily;
@@ -146,7 +169,7 @@ var Label = _styledComponents["default"].label(_templateObject || (_templateObje
146
169
  return props.theme.labelLineHeight;
147
170
  });
148
171
 
149
- var HelperText = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
172
+ var HelperText = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
150
173
  return props.disabled ? props.theme.disabledHelperTextFontcolor : props.theme.helperTextFontColor;
151
174
  }, function (props) {
152
175
  return props.theme.helperTextFontFamily;
@@ -160,19 +183,7 @@ var HelperText = _styledComponents["default"].span(_templateObject2 || (_templat
160
183
  return props.theme.helperTextLineHeight;
161
184
  });
162
185
 
163
- var ToggleGroup = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
164
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
165
- }, function (props) {
166
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
167
- }, function (props) {
168
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
169
- }, function (props) {
170
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
171
- }, function (props) {
172
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
173
- });
174
-
175
- var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n opacity: 1;\n height: calc(48px - 4px - 4px);\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n border-color: ", ";\n background-color: ", ";\n padding: 4px;\n margin-top: ", ";\n"])), function (props) {
186
+ var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n gap: 0.25rem;\n width: max-content;\n height: calc(48px - 4px - 4px);\n padding: 0.25rem;\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n border-color: ", ";\n margin-top: ", ";\n background-color: ", ";\n"])), function (props) {
176
187
  return props.theme.containerBorderThickness;
177
188
  }, function (props) {
178
189
  return props.theme.containerBorderStyle;
@@ -180,16 +191,36 @@ var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_te
180
191
  return props.theme.containerBorderRadius;
181
192
  }, function (props) {
182
193
  return props.theme.containerBorderColor;
183
- }, function (props) {
184
- return props.theme.containerBackgroundColor;
185
194
  }, function (props) {
186
195
  return props.theme.containerMarginTop;
196
+ }, function (props) {
197
+ return props.theme.containerBackgroundColor;
187
198
  });
188
199
 
189
- var ToggleContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n margin-right: ", ";\n\n ", "\n"])), function (props) {
190
- return !props.isLast && "4px";
200
+ var ToggleButton = _styledComponents["default"].button(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n padding-left: ", ";\n padding-right: ", ";\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n background-color: ", ";\n color: ", ";\n cursor: pointer;\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n color: #ffffff;\n }\n &:focus {\n outline: none;\n box-shadow: ", ";\n }\n &:disabled {\n background-color: ", ";\n color: ", ";\n cursor: not-allowed;\n }\n"])), function (props) {
201
+ return props.optionLabel && props.hasIcon || props.optionLabel && !props.hasIcon ? props.theme.labelPaddingLeft : props.theme.iconPaddingLeft;
191
202
  }, function (props) {
192
- return "\n background-color: ".concat(props.selected ? props.disabled ? props.theme.selectedDisabledBackgroundColor : props.theme.selectedBackgroundColor : props.disabled ? props.theme.unselectedDisabledBackgroundColor : props.theme.unselectedBackgroundColor, ";\n border-width: ").concat(props.theme.optionBorderThickness, ";\n border-style: ").concat(props.theme.optionBorderStyle, ";\n border-radius: ").concat(props.theme.optionBorderRadius, ";\n padding-left: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingLeft : props.theme.iconPaddingLeft, ";\n padding-right: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingRight : props.theme.iconPaddingRight, ";\n ").concat(!props.disabled ? ":hover {\n background-color: ".concat(props.selected ? props.theme.selectedHoverBackgroundColor : props.theme.unselectedHoverBackgroundColor, ";\n }\n :active {\n background-color: ").concat(props.selected ? props.theme.selectedActiveBackgroundColor : props.theme.unselectedActiveBackgroundColor, ";\n color: #ffffff;\n } \n :focus {\n border-color: transparent;\n box-shadow: 0 0 0 ").concat(props.theme.optionFocusBorderThickness, " ").concat(props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor, ";\n }\n &:focus-visible {\n outline: none;\n }\n cursor: pointer;\n color: ").concat(props.selected ? props.theme.selectedFontColor : props.theme.unselectedFontColor, ";\n") : "color: ".concat(props.selected ? props.theme.selectedDisabledFontColor : props.theme.unselectedDisabledFontColor, ";\n cursor: not-allowed;"), "\n ");
203
+ return props.optionLabel && props.hasIcon || props.optionLabel && !props.hasIcon ? props.theme.labelPaddingRight : props.theme.iconPaddingRight;
204
+ }, function (props) {
205
+ return props.theme.optionBorderThickness;
206
+ }, function (props) {
207
+ return props.theme.optionBorderStyle;
208
+ }, function (props) {
209
+ return props.theme.optionBorderRadius;
210
+ }, function (props) {
211
+ return props.selected ? props.theme.selectedBackgroundColor : props.theme.unselectedBackgroundColor;
212
+ }, function (props) {
213
+ return props.selected ? props.theme.selectedFontColor : props.theme.unselectedFontColor;
214
+ }, function (props) {
215
+ return props.selected ? props.theme.selectedHoverBackgroundColor : props.theme.unselectedHoverBackgroundColor;
216
+ }, function (props) {
217
+ return props.selected ? props.theme.selectedActiveBackgroundColor : props.theme.unselectedActiveBackgroundColor;
218
+ }, function (props) {
219
+ return "0 0 0 ".concat(props.theme.optionFocusBorderThickness, " ").concat(props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor);
220
+ }, function (props) {
221
+ return props.selected ? props.theme.selectedDisabledBackgroundColor : props.theme.unselectedDisabledBackgroundColor;
222
+ }, function (props) {
223
+ return props.selected ? props.theme.selectedDisabledFontColor : props.theme.unselectedDisabledFontColor;
193
224
  });
194
225
 
195
226
  var LabelContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
@@ -202,11 +233,7 @@ var LabelContainer = _styledComponents["default"].span(_templateObject6 || (_tem
202
233
  return props.theme.optionLabelFontWeight;
203
234
  });
204
235
 
205
- var OptionContent = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n align-items: center;\n"])));
206
-
207
- var Icon = _styledComponents["default"].img(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])([""])));
208
-
209
- var IconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: ", ";\n height: 24px;\n width: 24px;\n overflow: hidden;\n display: flex;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
236
+ var IconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n height: 24px;\n width: 24px;\n margin-right: ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
210
237
  return props.optionLabel && props.theme.iconMarginRight;
211
238
  });
212
239
 
@@ -3,6 +3,7 @@ import { userEvent, within } from "@storybook/testing-library";
3
3
  import DxcToggleGroup from "./ToggleGroup";
4
4
  import Title from "../../.storybook/components/Title";
5
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
+ import { HalstackProvider } from "../HalstackContext";
6
7
 
7
8
  export default {
8
9
  title: "ToggleGroup",
@@ -52,14 +53,17 @@ const optionsWithIcon = [
52
53
  {
53
54
  value: 1,
54
55
  icon: wifiSVG,
56
+ title: "WiFi connection",
55
57
  },
56
58
  {
57
59
  value: 2,
58
60
  icon: ethernetSVG,
61
+ title: "Ethernet connection",
59
62
  },
60
63
  {
61
64
  value: 3,
62
65
  icon: gMobileSVG,
66
+ title: "3G Mobile data connection",
63
67
  },
64
68
  ];
65
69
  const optionsWithIconAndLabel = [
@@ -89,6 +93,16 @@ const twoOptions = [
89
93
  label: "Twitter",
90
94
  },
91
95
  ];
96
+
97
+ const opinionatedTheme = {
98
+ toggleGroup: {
99
+ selectedBaseColor: "#5f249f",
100
+ selectedFontColor: "#ffffff",
101
+ unselectedBaseColor: "#e6e6e6",
102
+ unselectedFontColor: "#000000",
103
+ },
104
+ };
105
+
92
106
  export const Chromatic = () => (
93
107
  <>
94
108
  <ExampleContainer>
@@ -97,7 +111,7 @@ export const Chromatic = () => (
97
111
  </ExampleContainer>
98
112
  <ExampleContainer>
99
113
  <Title title="Selected" theme="light" level={4} />
100
- <DxcToggleGroup label="Selected" helperText="HelperText" value={2} options={options} />
114
+ <DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
101
115
  </ExampleContainer>
102
116
  <ExampleContainer>
103
117
  <Title title="Icons toggle group" theme="light" level={4} />
@@ -109,11 +123,11 @@ export const Chromatic = () => (
109
123
  </ExampleContainer>
110
124
  <ExampleContainer>
111
125
  <Title title="Disabled" theme="light" level={4} />
112
- <DxcToggleGroup label="Disabled" value={2} options={options} disabled />
126
+ <DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
113
127
  </ExampleContainer>
114
128
  <ExampleContainer pseudoState="pseudo-hover">
115
129
  <Title title="Hovered" theme="light" level={4} />
116
- <DxcToggleGroup label="Hovered" options={twoOptions} value={2} />
130
+ <DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
117
131
  </ExampleContainer>
118
132
  <ExampleContainer>
119
133
  <Title title="Multiple toggleGroup" theme="light" level={4} />
@@ -121,7 +135,7 @@ export const Chromatic = () => (
121
135
  label="Toggle group"
122
136
  helperText="Please select one or more"
123
137
  options={options}
124
- value={[1, 3]}
138
+ defaultValue={[1, 3]}
125
139
  multiple
126
140
  ></DxcToggleGroup>
127
141
  </ExampleContainer>
@@ -154,6 +168,37 @@ export const Chromatic = () => (
154
168
  <Title title="xxLarge" theme="light" level={4} />
155
169
  <DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
156
170
  </ExampleContainer>
171
+ <Title title="Opinionated theme" theme="light" level={2} />
172
+ <ExampleContainer>
173
+ <HalstackProvider theme={opinionatedTheme}>
174
+ <Title title="Selected" theme="light" level={4} />
175
+ <DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
176
+ </HalstackProvider>
177
+ </ExampleContainer>
178
+ <ExampleContainer>
179
+ <HalstackProvider theme={opinionatedTheme}>
180
+ <Title title="Icons & label toggle group" theme="light" level={4} />
181
+ <DxcToggleGroup label="Icons & label" options={optionsWithIconAndLabel} />
182
+ </HalstackProvider>
183
+ </ExampleContainer>
184
+ <ExampleContainer>
185
+ <HalstackProvider theme={opinionatedTheme}>
186
+ <Title title="Disabled" theme="light" level={4} />
187
+ <DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
188
+ </HalstackProvider>
189
+ </ExampleContainer>
190
+ <ExampleContainer pseudoState="pseudo-hover">
191
+ <Title title="Hovered" theme="light" level={4} />
192
+ <HalstackProvider theme={opinionatedTheme}>
193
+ <DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
194
+ </HalstackProvider>
195
+ </ExampleContainer>
196
+ <ExampleContainer pseudoState="pseudo-active">
197
+ <Title title="Actived" theme="light" level={4} />
198
+ <HalstackProvider theme={opinionatedTheme}>
199
+ <DxcToggleGroup label="Actived" options={twoOptions} defaultValue={2} />
200
+ </HalstackProvider>
201
+ </ExampleContainer>
157
202
  </>
158
203
  );
159
204
  const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup.tsx"));
10
+
11
+ var options = [{
12
+ value: 1,
13
+ label: "Amazon"
14
+ }, {
15
+ value: 2,
16
+ label: "Ebay"
17
+ }, {
18
+ value: 3,
19
+ label: "Apple"
20
+ }, {
21
+ value: 4,
22
+ label: "Google"
23
+ }];
24
+ describe("Toggle group component tests", function () {
25
+ test("Toggle group renders with correct labels", function () {
26
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
27
+ label: "Toggle group label",
28
+ helperText: "Toggle group helper text",
29
+ options: options
30
+ })),
31
+ getByText = _render.getByText;
32
+
33
+ expect(getByText("Toggle group label")).toBeTruthy();
34
+ expect(getByText("Toggle group helper text")).toBeTruthy();
35
+ expect(getByText("Amazon")).toBeTruthy();
36
+ expect(getByText("Ebay")).toBeTruthy();
37
+ expect(getByText("Apple")).toBeTruthy();
38
+ expect(getByText("Google")).toBeTruthy();
39
+ });
40
+ test("Toggle group renders with correct aria-label in only-icon scenario", function () {
41
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
42
+ label: "Toggle group label",
43
+ helperText: "Toggle group helper text",
44
+ options: [{
45
+ value: 1,
46
+ icon: "https://cdn.icon-icons.com/icons2/2645/PNG/512/mic_mute_icon_159965.png",
47
+ title: "Mute"
48
+ }]
49
+ })),
50
+ getByRole = _render2.getByRole;
51
+
52
+ expect(getByRole("button").getAttribute("aria-label")).toBe("Mute");
53
+ });
54
+ test("Uncontrolled toggle group calls correct function on change with value", function () {
55
+ var onChange = jest.fn();
56
+
57
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
58
+ options: options,
59
+ onChange: onChange
60
+ })),
61
+ getByText = _render3.getByText;
62
+
63
+ var option = getByText("Ebay");
64
+
65
+ _react2.fireEvent.click(option);
66
+
67
+ expect(onChange).toHaveBeenCalledWith(2);
68
+ });
69
+ test("Controlled toggle group calls correct function on change with value", function () {
70
+ var onChange = jest.fn();
71
+
72
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
73
+ options: options,
74
+ onChange: onChange,
75
+ value: 1
76
+ })),
77
+ getByText = _render4.getByText;
78
+
79
+ var option = getByText("Ebay");
80
+
81
+ _react2.fireEvent.click(option);
82
+
83
+ expect(onChange).toHaveBeenCalledWith(2);
84
+ });
85
+ test("Function on change is not called when disable", function () {
86
+ var onChange = jest.fn();
87
+
88
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
89
+ options: options,
90
+ onChange: onChange,
91
+ disabled: true
92
+ })),
93
+ getByText = _render5.getByText;
94
+
95
+ var option = getByText("Ebay");
96
+
97
+ _react2.fireEvent.click(option);
98
+
99
+ expect(onChange).toHaveBeenCalledTimes(0);
100
+ });
101
+ test("Uncontrolled multiple toggle group calls correct function on change with value when is multiple", function () {
102
+ var onChange = jest.fn();
103
+
104
+ var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
105
+ options: options,
106
+ onChange: onChange,
107
+ multiple: true
108
+ })),
109
+ getAllByRole = _render6.getAllByRole;
110
+
111
+ var toggleOptions = getAllByRole("button");
112
+
113
+ _react2.fireEvent.click(toggleOptions[0]);
114
+
115
+ expect(onChange).toHaveBeenCalledWith([1]);
116
+
117
+ _react2.fireEvent.click(toggleOptions[1]);
118
+
119
+ _react2.fireEvent.click(toggleOptions[3]);
120
+
121
+ expect(onChange).toHaveBeenCalledWith([1, 2, 4]);
122
+ expect(toggleOptions[0].getAttribute("aria-pressed")).toBe("true");
123
+ expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
124
+ expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
125
+ });
126
+ test("Controlled multiple toggle returns always same values", function () {
127
+ var onChange = jest.fn();
128
+
129
+ var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
130
+ options: options,
131
+ onChange: onChange,
132
+ value: [1],
133
+ multiple: true
134
+ })),
135
+ getByText = _render7.getByText;
136
+
137
+ var option = getByText("Ebay");
138
+
139
+ _react2.fireEvent.click(option);
140
+
141
+ expect(onChange).toHaveBeenCalledWith([1, 2]);
142
+ var option2 = getByText("Google");
143
+
144
+ _react2.fireEvent.click(option2);
145
+
146
+ expect(onChange).toHaveBeenNthCalledWith(2, [1, 4]);
147
+ });
148
+ test("Single selection: Renders with correct default value", function () {
149
+ var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
150
+ options: options,
151
+ defaultValue: 2
152
+ })),
153
+ getAllByRole = _render8.getAllByRole;
154
+
155
+ var toggleOptions = getAllByRole("button");
156
+ expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
157
+ });
158
+ test("Multiple selection: Renders with correct default value", function () {
159
+ var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
160
+ options: options,
161
+ defaultValue: [2, 4],
162
+ multiple: true
163
+ })),
164
+ getAllByRole = _render9.getAllByRole;
165
+
166
+ var toggleOptions = getAllByRole("button");
167
+ expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
168
+ expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
169
+ });
170
+ });
@@ -6,24 +6,23 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement>;
10
- declare type OptionCommons = {
11
- /**
12
- * Number with the option inner value.
13
- */
14
- value: number;
15
- };
16
- declare type OptionIcon = OptionCommons & {
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
+ declare type OptionIcon = {
17
11
  /**
18
12
  * String with the option display value.
19
13
  */
20
- label?: string;
14
+ label?: never;
21
15
  /**
22
16
  * Element used as the icon. Icon and label can't be used at same time.
23
17
  */
24
18
  icon: string | SVG;
19
+ /**
20
+ * Value for the HTML properties title and aria-label.
21
+ * When a label is defined, this prop can not be use.
22
+ */
23
+ title: string;
25
24
  };
26
- declare type OptionLabel = OptionCommons & {
25
+ export declare type OptionLabel = {
27
26
  /**
28
27
  * String with the option display value.
29
28
  */
@@ -32,8 +31,18 @@ declare type OptionLabel = OptionCommons & {
32
31
  * Element used as the icon. Icon and label can't be used at same time.
33
32
  */
34
33
  icon?: string | SVG;
34
+ /**
35
+ * Value for the HTML properties title and aria-label.
36
+ * When a label is defined, this prop can not be use.
37
+ */
38
+ title?: never;
35
39
  };
36
- declare type Option = OptionIcon | OptionLabel;
40
+ declare type Option = {
41
+ /**
42
+ * Number with the option inner value.
43
+ */
44
+ value: number;
45
+ } & (OptionIcon | OptionLabel);
37
46
  declare type CommonProps = {
38
47
  /**
39
48
  * Text to be placed above the component.
@@ -61,11 +70,15 @@ declare type CommonProps = {
61
70
  */
62
71
  tabIndex?: number;
63
72
  };
64
- declare type SingleSelectionToggle = CommonProps & {
73
+ declare type SingleSelectionToggleGroup = CommonProps & {
65
74
  /**
66
75
  * If true, the toggle group will support multiple selection. In that case, value must be an array of numbers with the keys of the selected values.
67
76
  */
68
77
  multiple?: false;
78
+ /**
79
+ * The key of the initially selected value.
80
+ */
81
+ defaultValue?: number;
69
82
  /**
70
83
  * The key of the selected value. If the component allows multiple selection, value must be an array.
71
84
  * If undefined, the component will be uncontrolled and the value will be managed internally by the component.
@@ -77,11 +90,15 @@ declare type SingleSelectionToggle = CommonProps & {
77
90
  */
78
91
  onChange?: (optionIndex: number) => void;
79
92
  };
80
- declare type MultipleSelectionToggle = CommonProps & {
93
+ declare type MultipleSelectionToggleGroup = CommonProps & {
81
94
  /**
82
95
  * If true, the toggle group will support multiple selection. In that case, value must be an array of numbers with the keys of the selected values.
83
96
  */
84
97
  multiple: true;
98
+ /**
99
+ * The array of keys with the initially selected values.
100
+ */
101
+ defaultValue?: number[];
85
102
  /**
86
103
  * An array with the keys of the selected values.
87
104
  * If undefined, the component will be uncontrolled and the value will be managed internally by the component.
@@ -93,5 +110,5 @@ declare type MultipleSelectionToggle = CommonProps & {
93
110
  */
94
111
  onChange?: (optionIndex: number[]) => void;
95
112
  };
96
- declare type Props = SingleSelectionToggle | MultipleSelectionToggle;
113
+ declare type Props = SingleSelectionToggleGroup | MultipleSelectionToggleGroup;
97
114
  export default Props;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import TypographyPropsTypes from "./types";
3
+ declare const DxcTypography: ({ textOverflow, whiteSpace, children, ...props }: TypographyPropsTypes) => JSX.Element;
4
+ export default DxcTypography;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _BaseTypography = _interopRequireDefault(require("../utils/BaseTypography"));
17
+
18
+ var _excluded = ["textOverflow", "whiteSpace", "children"];
19
+
20
+ var DxcTypography = function DxcTypography(_ref) {
21
+ var textOverflow = _ref.textOverflow,
22
+ whiteSpace = _ref.whiteSpace,
23
+ children = _ref.children,
24
+ props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
25
+ return /*#__PURE__*/_react["default"].createElement(_BaseTypography["default"], (0, _extends2["default"])({
26
+ textOverflow: textOverflow,
27
+ whiteSpace: whiteSpace == null && textOverflow != null && textOverflow !== "unset" ? "nowrap" : whiteSpace
28
+ }, props), children);
29
+ };
30
+
31
+ var _default = DxcTypography;
32
+ exports["default"] = _default;