@dxc-technology/halstack-react 0.0.0-dfcca07 → 0.0.0-e01c6f9

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 (346) hide show
  1. package/BackgroundColorContext.d.ts +1 -0
  2. package/BackgroundColorContext.js +6 -26
  3. package/HalstackContext.d.ts +1235 -0
  4. package/HalstackContext.js +310 -0
  5. package/README.md +47 -0
  6. package/accordion/Accordion.d.ts +1 -1
  7. package/accordion/Accordion.js +118 -194
  8. package/accordion/Accordion.stories.tsx +283 -0
  9. package/accordion/Accordion.test.js +56 -0
  10. package/accordion/types.d.ts +12 -23
  11. package/accordion-group/AccordionGroup.d.ts +5 -4
  12. package/accordion-group/AccordionGroup.js +39 -108
  13. package/accordion-group/AccordionGroup.stories.tsx +95 -68
  14. package/accordion-group/AccordionGroup.test.js +98 -0
  15. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  16. package/accordion-group/AccordionGroupAccordion.js +31 -0
  17. package/accordion-group/types.d.ts +18 -23
  18. package/action-icon/ActionIcon.d.ts +4 -0
  19. package/action-icon/ActionIcon.js +43 -0
  20. package/action-icon/types.d.ts +26 -0
  21. package/alert/Alert.js +24 -60
  22. package/alert/Alert.stories.tsx +28 -0
  23. package/alert/Alert.test.js +75 -0
  24. package/alert/types.d.ts +5 -5
  25. package/badge/Badge.d.ts +4 -0
  26. package/badge/Badge.js +9 -20
  27. package/badge/types.d.ts +5 -0
  28. package/bleed/Bleed.d.ts +3 -0
  29. package/bleed/Bleed.js +43 -0
  30. package/bleed/Bleed.stories.tsx +342 -0
  31. package/bleed/types.d.ts +37 -0
  32. package/box/Box.d.ts +1 -1
  33. package/box/Box.js +31 -82
  34. package/box/Box.stories.tsx +38 -51
  35. package/box/Box.test.js +13 -0
  36. package/box/types.d.ts +3 -14
  37. package/bulleted-list/BulletedList.d.ts +7 -0
  38. package/bulleted-list/BulletedList.js +89 -0
  39. package/bulleted-list/BulletedList.stories.tsx +115 -0
  40. package/bulleted-list/types.d.ts +38 -0
  41. package/bulleted-list/types.js +5 -0
  42. package/button/Button.d.ts +1 -1
  43. package/button/Button.js +64 -123
  44. package/button/Button.stories.tsx +164 -96
  45. package/button/Button.test.js +36 -0
  46. package/button/types.d.ts +12 -12
  47. package/card/Card.d.ts +1 -1
  48. package/card/Card.js +59 -103
  49. package/card/Card.stories.tsx +13 -43
  50. package/card/Card.test.js +39 -0
  51. package/card/types.d.ts +6 -11
  52. package/checkbox/Checkbox.d.ts +2 -2
  53. package/checkbox/Checkbox.js +145 -183
  54. package/checkbox/Checkbox.stories.tsx +166 -136
  55. package/checkbox/Checkbox.test.js +199 -0
  56. package/checkbox/types.d.ts +19 -7
  57. package/chip/Chip.d.ts +4 -0
  58. package/chip/Chip.js +48 -148
  59. package/chip/Chip.stories.tsx +123 -30
  60. package/chip/Chip.test.js +41 -0
  61. package/chip/types.d.ts +45 -0
  62. package/chip/types.js +5 -0
  63. package/common/OpenSans.css +68 -80
  64. package/common/coreTokens.d.ts +237 -0
  65. package/common/coreTokens.js +184 -0
  66. package/common/utils.d.ts +1 -0
  67. package/common/utils.js +6 -12
  68. package/common/variables.d.ts +1381 -0
  69. package/common/variables.js +1006 -1331
  70. package/container/Container.d.ts +4 -0
  71. package/container/Container.js +194 -0
  72. package/container/Container.stories.tsx +214 -0
  73. package/container/types.d.ts +74 -0
  74. package/container/types.js +5 -0
  75. package/date-input/Calendar.d.ts +4 -0
  76. package/date-input/Calendar.js +214 -0
  77. package/date-input/DateInput.js +175 -313
  78. package/date-input/DateInput.stories.tsx +203 -56
  79. package/date-input/DateInput.test.js +808 -0
  80. package/date-input/DatePicker.d.ts +4 -0
  81. package/date-input/DatePicker.js +115 -0
  82. package/date-input/Icons.d.ts +6 -0
  83. package/date-input/Icons.js +58 -0
  84. package/date-input/YearPicker.d.ts +4 -0
  85. package/date-input/YearPicker.js +100 -0
  86. package/date-input/types.d.ts +86 -22
  87. package/dialog/Dialog.d.ts +1 -1
  88. package/dialog/Dialog.js +69 -130
  89. package/dialog/Dialog.stories.tsx +320 -167
  90. package/dialog/Dialog.test.js +307 -0
  91. package/dialog/types.d.ts +18 -25
  92. package/dropdown/Dropdown.d.ts +1 -1
  93. package/dropdown/Dropdown.js +245 -328
  94. package/dropdown/Dropdown.stories.tsx +438 -0
  95. package/dropdown/Dropdown.test.js +599 -0
  96. package/dropdown/DropdownMenu.d.ts +4 -0
  97. package/dropdown/DropdownMenu.js +63 -0
  98. package/dropdown/DropdownMenuItem.d.ts +4 -0
  99. package/dropdown/DropdownMenuItem.js +67 -0
  100. package/dropdown/types.d.ts +36 -27
  101. package/file-input/FileInput.d.ts +2 -2
  102. package/file-input/FileInput.js +267 -299
  103. package/file-input/FileInput.stories.tsx +618 -0
  104. package/file-input/FileInput.test.js +459 -0
  105. package/file-input/FileItem.d.ts +4 -14
  106. package/file-input/FileItem.js +52 -101
  107. package/file-input/types.d.ts +53 -11
  108. package/flex/Flex.d.ts +4 -0
  109. package/flex/Flex.js +57 -0
  110. package/flex/Flex.stories.tsx +112 -0
  111. package/flex/types.d.ts +97 -0
  112. package/flex/types.js +5 -0
  113. package/footer/Footer.d.ts +1 -1
  114. package/footer/Footer.js +60 -201
  115. package/footer/{Footer.stories.jsx → Footer.stories.tsx} +38 -37
  116. package/footer/Footer.test.js +85 -0
  117. package/footer/Icons.d.ts +2 -0
  118. package/footer/Icons.js +4 -9
  119. package/footer/types.d.ts +22 -33
  120. package/grid/Grid.d.ts +7 -0
  121. package/grid/Grid.js +76 -0
  122. package/grid/Grid.stories.tsx +219 -0
  123. package/grid/types.d.ts +115 -0
  124. package/grid/types.js +5 -0
  125. package/header/Header.d.ts +4 -3
  126. package/header/Header.js +100 -204
  127. package/header/Header.stories.tsx +152 -63
  128. package/header/Header.test.js +66 -0
  129. package/header/Icons.d.ts +2 -0
  130. package/header/Icons.js +4 -9
  131. package/header/types.d.ts +5 -19
  132. package/heading/Heading.js +11 -33
  133. package/heading/Heading.stories.tsx +3 -2
  134. package/heading/Heading.test.js +169 -0
  135. package/heading/types.d.ts +7 -7
  136. package/image/Image.d.ts +4 -0
  137. package/image/Image.js +70 -0
  138. package/image/Image.stories.tsx +127 -0
  139. package/image/types.d.ts +72 -0
  140. package/image/types.js +5 -0
  141. package/inset/Inset.d.ts +3 -0
  142. package/inset/Inset.js +43 -0
  143. package/inset/Inset.stories.tsx +230 -0
  144. package/inset/types.d.ts +37 -0
  145. package/inset/types.js +5 -0
  146. package/layout/ApplicationLayout.d.ts +20 -0
  147. package/layout/ApplicationLayout.js +83 -184
  148. package/layout/ApplicationLayout.stories.tsx +162 -0
  149. package/layout/Icons.d.ts +8 -0
  150. package/layout/Icons.js +51 -48
  151. package/layout/SidenavContext.d.ts +5 -0
  152. package/layout/SidenavContext.js +13 -0
  153. package/layout/types.d.ts +41 -0
  154. package/layout/types.js +5 -0
  155. package/link/Link.d.ts +3 -2
  156. package/link/Link.js +65 -111
  157. package/link/Link.stories.tsx +159 -52
  158. package/link/Link.test.js +63 -0
  159. package/link/types.d.ts +15 -35
  160. package/main.d.ts +15 -13
  161. package/main.js +70 -97
  162. package/nav-tabs/NavTabs.d.ts +8 -0
  163. package/nav-tabs/NavTabs.js +90 -0
  164. package/nav-tabs/NavTabs.stories.tsx +274 -0
  165. package/nav-tabs/NavTabs.test.js +75 -0
  166. package/nav-tabs/Tab.d.ts +4 -0
  167. package/nav-tabs/Tab.js +117 -0
  168. package/nav-tabs/types.d.ts +52 -0
  169. package/nav-tabs/types.js +5 -0
  170. package/number-input/NumberInput.d.ts +7 -0
  171. package/number-input/NumberInput.js +28 -47
  172. package/number-input/NumberInput.stories.tsx +44 -28
  173. package/number-input/NumberInput.test.js +830 -0
  174. package/number-input/types.d.ts +28 -15
  175. package/package.json +46 -45
  176. package/paginator/Icons.d.ts +5 -0
  177. package/paginator/Icons.js +21 -47
  178. package/paginator/Paginator.js +35 -98
  179. package/paginator/Paginator.stories.tsx +24 -0
  180. package/paginator/Paginator.test.js +335 -0
  181. package/paginator/types.d.ts +3 -3
  182. package/paragraph/Paragraph.d.ts +5 -0
  183. package/paragraph/Paragraph.js +22 -0
  184. package/paragraph/Paragraph.stories.tsx +27 -0
  185. package/password-input/Icons.d.ts +6 -0
  186. package/password-input/Icons.js +35 -0
  187. package/password-input/PasswordInput.js +58 -125
  188. package/password-input/PasswordInput.stories.tsx +3 -35
  189. package/password-input/PasswordInput.test.js +198 -0
  190. package/password-input/types.d.ts +21 -17
  191. package/progress-bar/ProgressBar.js +66 -92
  192. package/progress-bar/ProgressBar.stories.tsx +93 -0
  193. package/progress-bar/ProgressBar.test.js +93 -0
  194. package/progress-bar/types.d.ts +3 -3
  195. package/quick-nav/QuickNav.d.ts +4 -0
  196. package/quick-nav/QuickNav.js +94 -0
  197. package/quick-nav/QuickNav.stories.tsx +356 -0
  198. package/quick-nav/types.d.ts +21 -0
  199. package/quick-nav/types.js +5 -0
  200. package/radio-group/Radio.d.ts +4 -0
  201. package/radio-group/Radio.js +124 -0
  202. package/radio-group/RadioGroup.d.ts +4 -0
  203. package/radio-group/RadioGroup.js +235 -0
  204. package/radio-group/RadioGroup.stories.tsx +214 -0
  205. package/radio-group/RadioGroup.test.js +756 -0
  206. package/radio-group/types.d.ts +114 -0
  207. package/radio-group/types.js +5 -0
  208. package/resultset-table/Icons.d.ts +7 -0
  209. package/resultset-table/Icons.js +47 -0
  210. package/resultset-table/ResultsetTable.js +159 -0
  211. package/resultset-table/ResultsetTable.stories.tsx +300 -0
  212. package/resultset-table/ResultsetTable.test.js +305 -0
  213. package/{resultsetTable → resultset-table}/types.d.ts +8 -8
  214. package/resultset-table/types.js +5 -0
  215. package/select/Icons.d.ts +10 -0
  216. package/select/Icons.js +89 -0
  217. package/select/Listbox.d.ts +4 -0
  218. package/select/Listbox.js +143 -0
  219. package/select/Option.d.ts +4 -0
  220. package/select/Option.js +80 -0
  221. package/select/Select.d.ts +4 -0
  222. package/select/Select.js +227 -511
  223. package/select/Select.stories.tsx +603 -204
  224. package/select/Select.test.js +2370 -0
  225. package/select/types.d.ts +209 -0
  226. package/select/types.js +5 -0
  227. package/sidenav/Icons.d.ts +7 -0
  228. package/sidenav/Icons.js +47 -0
  229. package/sidenav/Sidenav.d.ts +6 -5
  230. package/sidenav/Sidenav.js +132 -72
  231. package/sidenav/Sidenav.stories.tsx +251 -134
  232. package/sidenav/Sidenav.test.js +37 -0
  233. package/sidenav/types.d.ts +52 -26
  234. package/slider/Slider.d.ts +2 -2
  235. package/slider/Slider.js +149 -181
  236. package/slider/Slider.test.js +254 -0
  237. package/slider/types.d.ts +11 -3
  238. package/spinner/Spinner.js +32 -76
  239. package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -26
  240. package/spinner/Spinner.test.js +55 -0
  241. package/spinner/types.d.ts +3 -3
  242. package/switch/Switch.d.ts +2 -2
  243. package/switch/Switch.js +150 -115
  244. package/switch/Switch.stories.tsx +45 -68
  245. package/switch/Switch.test.js +180 -0
  246. package/switch/types.d.ts +13 -5
  247. package/table/Table.js +9 -31
  248. package/table/{Table.stories.jsx → Table.stories.tsx} +81 -1
  249. package/table/Table.test.js +21 -0
  250. package/table/types.d.ts +8 -8
  251. package/tabs/Tab.d.ts +4 -0
  252. package/tabs/Tab.js +113 -0
  253. package/tabs/Tabs.d.ts +1 -1
  254. package/tabs/Tabs.js +318 -147
  255. package/tabs/Tabs.stories.tsx +122 -17
  256. package/tabs/Tabs.test.js +294 -0
  257. package/tabs/types.d.ts +46 -24
  258. package/tag/Tag.d.ts +1 -1
  259. package/tag/Tag.js +44 -86
  260. package/tag/Tag.stories.tsx +38 -28
  261. package/tag/Tag.test.js +49 -0
  262. package/tag/types.d.ts +25 -16
  263. package/text-input/Icons.d.ts +8 -0
  264. package/text-input/Icons.js +56 -0
  265. package/text-input/Suggestion.d.ts +4 -0
  266. package/text-input/Suggestion.js +67 -0
  267. package/text-input/Suggestions.d.ts +4 -0
  268. package/text-input/Suggestions.js +84 -0
  269. package/text-input/TextInput.js +330 -544
  270. package/text-input/TextInput.stories.tsx +280 -271
  271. package/text-input/TextInput.test.js +1739 -0
  272. package/text-input/types.d.ts +71 -25
  273. package/textarea/Textarea.d.ts +4 -0
  274. package/textarea/Textarea.js +95 -177
  275. package/textarea/Textarea.stories.tsx +174 -0
  276. package/textarea/Textarea.test.js +406 -0
  277. package/textarea/types.d.ts +141 -0
  278. package/textarea/types.js +5 -0
  279. package/toggle-group/ToggleGroup.d.ts +2 -2
  280. package/toggle-group/ToggleGroup.js +97 -113
  281. package/toggle-group/ToggleGroup.stories.tsx +76 -36
  282. package/toggle-group/ToggleGroup.test.js +137 -0
  283. package/toggle-group/types.d.ts +66 -36
  284. package/typography/Typography.d.ts +4 -0
  285. package/typography/Typography.js +23 -0
  286. package/typography/Typography.stories.tsx +198 -0
  287. package/typography/types.d.ts +18 -0
  288. package/typography/types.js +5 -0
  289. package/useTheme.d.ts +1134 -0
  290. package/useTheme.js +4 -11
  291. package/useTranslatedLabels.d.ts +85 -0
  292. package/useTranslatedLabels.js +14 -0
  293. package/utils/BaseTypography.d.ts +21 -0
  294. package/utils/BaseTypography.js +94 -0
  295. package/utils/FocusLock.d.ts +13 -0
  296. package/utils/FocusLock.js +121 -0
  297. package/wizard/Wizard.d.ts +1 -1
  298. package/wizard/Wizard.js +123 -104
  299. package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +48 -19
  300. package/wizard/Wizard.test.js +114 -0
  301. package/wizard/types.d.ts +14 -14
  302. package/ThemeContext.js +0 -246
  303. package/V3Select/V3Select.js +0 -455
  304. package/V3Select/index.d.ts +0 -27
  305. package/V3Textarea/V3Textarea.js +0 -260
  306. package/V3Textarea/index.d.ts +0 -27
  307. package/card/ice-cream.jpg +0 -0
  308. package/chip/index.d.ts +0 -22
  309. package/common/RequiredComponent.js +0 -32
  310. package/date/Date.js +0 -373
  311. package/date/index.d.ts +0 -27
  312. package/input-text/Icons.js +0 -22
  313. package/input-text/InputText.js +0 -611
  314. package/input-text/index.d.ts +0 -36
  315. package/number-input/NumberInputContext.d.ts +0 -4
  316. package/number-input/NumberInputContext.js +0 -19
  317. package/number-input/numberInputContextTypes.d.ts +0 -19
  318. package/progress-bar/ProgressBar.stories.jsx +0 -58
  319. package/radio/Radio.d.ts +0 -4
  320. package/radio/Radio.js +0 -174
  321. package/radio/Radio.stories.tsx +0 -192
  322. package/radio/types.d.ts +0 -54
  323. package/resultsetTable/ResultsetTable.js +0 -251
  324. package/select/index.d.ts +0 -131
  325. package/slider/Slider.stories.tsx +0 -177
  326. package/textarea/Textarea.stories.jsx +0 -135
  327. package/textarea/index.d.ts +0 -127
  328. package/toggle/Toggle.js +0 -186
  329. package/toggle/index.d.ts +0 -21
  330. package/upload/Upload.js +0 -201
  331. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  332. package/upload/buttons-upload/Icons.js +0 -40
  333. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  334. package/upload/dragAndDropArea/Icons.js +0 -39
  335. package/upload/file-upload/FileToUpload.js +0 -115
  336. package/upload/file-upload/Icons.js +0 -66
  337. package/upload/files-upload/FilesToUpload.js +0 -109
  338. package/upload/index.d.ts +0 -15
  339. package/upload/transaction/Icons.js +0 -160
  340. package/upload/transaction/Transaction.js +0 -104
  341. package/upload/transactions/Transactions.js +0 -94
  342. package/wizard/Icons.js +0 -65
  343. /package/{radio → action-icon}/types.js +0 -0
  344. /package/{resultsetTable → badge}/types.js +0 -0
  345. /package/{number-input/numberInputContextTypes.js → bleed/types.js} +0 -0
  346. /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
@@ -3,42 +3,38 @@ 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
- title: "ToggleGroup",
9
+ title: "Toggle Group",
9
10
  component: DxcToggleGroup,
10
11
  };
11
12
 
12
- const ethernetSVG = () => {
13
- return (
14
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
15
- <path d="M0 0h24v24H0V0z" fill="none" />
16
- <path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z" />
17
- </svg>
18
- );
19
- };
20
- const gMobileSVG = () => {
21
- return (
22
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
23
- <g>
24
- <path d="M0,0h24v24H0V0z" fill="none" />
25
- </g>
13
+ const ethernetSVG = (
14
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
15
+ <path d="M0 0h24v24H0V0z" fill="none" />
16
+ <path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z" />
17
+ </svg>
18
+ );
19
+ const gMobileSVG = (
20
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
21
+ <g>
22
+ <path d="M0,0h24v24H0V0z" fill="none" />
23
+ </g>
24
+ <g>
26
25
  <g>
27
- <g>
28
- <path d="M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z" />
29
- </g>
26
+ <path d="M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z" />
30
27
  </g>
31
- </svg>
32
- );
33
- };
34
- const wifiSVG = () => {
35
- return (
36
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
37
- <path d="M0 0h24v24H0V0zm0 0h24v24H0V0z" fill="none" />
38
- <path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z" />
39
- </svg>
40
- );
41
- };
28
+ </g>
29
+ </svg>
30
+ );
31
+ const wifiSVG = (
32
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
33
+ <path d="M0 0h24v24H0V0zm0 0h24v24H0V0z" fill="none" />
34
+ <path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z" />
35
+ </svg>
36
+ );
37
+
42
38
  const options = [
43
39
  {
44
40
  value: 1,
@@ -46,7 +42,7 @@ const options = [
46
42
  },
47
43
  {
48
44
  value: 2,
49
- label: "Twitter",
45
+ label: "X",
50
46
  },
51
47
  {
52
48
  value: 3,
@@ -57,14 +53,17 @@ const optionsWithIcon = [
57
53
  {
58
54
  value: 1,
59
55
  icon: wifiSVG,
56
+ title: "WiFi connection",
60
57
  },
61
58
  {
62
59
  value: 2,
63
60
  icon: ethernetSVG,
61
+ title: "Ethernet connection",
64
62
  },
65
63
  {
66
64
  value: 3,
67
65
  icon: gMobileSVG,
66
+ title: "3G Mobile data connection",
68
67
  },
69
68
  ];
70
69
  const optionsWithIconAndLabel = [
@@ -91,9 +90,19 @@ const twoOptions = [
91
90
  },
92
91
  {
93
92
  value: 2,
94
- label: "Twitter",
93
+ label: "X",
95
94
  },
96
95
  ];
96
+
97
+ const opinionatedTheme = {
98
+ toggleGroup: {
99
+ selectedBaseColor: "#5f249f",
100
+ selectedFontColor: "#ffffff",
101
+ unselectedBaseColor: "#e6e6e6",
102
+ unselectedFontColor: "#000000",
103
+ },
104
+ };
105
+
97
106
  export const Chromatic = () => (
98
107
  <>
99
108
  <ExampleContainer>
@@ -102,7 +111,7 @@ export const Chromatic = () => (
102
111
  </ExampleContainer>
103
112
  <ExampleContainer>
104
113
  <Title title="Selected" theme="light" level={4} />
105
- <DxcToggleGroup label="Selected" helperText="HelperText" value={2} options={options} />
114
+ <DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
106
115
  </ExampleContainer>
107
116
  <ExampleContainer>
108
117
  <Title title="Icons toggle group" theme="light" level={4} />
@@ -114,11 +123,11 @@ export const Chromatic = () => (
114
123
  </ExampleContainer>
115
124
  <ExampleContainer>
116
125
  <Title title="Disabled" theme="light" level={4} />
117
- <DxcToggleGroup label="Disabled" value={2} options={options} disabled />
126
+ <DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
118
127
  </ExampleContainer>
119
128
  <ExampleContainer pseudoState="pseudo-hover">
120
129
  <Title title="Hovered" theme="light" level={4} />
121
- <DxcToggleGroup label="Hovered" options={twoOptions} value={2} />
130
+ <DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
122
131
  </ExampleContainer>
123
132
  <ExampleContainer>
124
133
  <Title title="Multiple toggleGroup" theme="light" level={4} />
@@ -126,7 +135,7 @@ export const Chromatic = () => (
126
135
  label="Toggle group"
127
136
  helperText="Please select one or more"
128
137
  options={options}
129
- value={[1, 3]}
138
+ defaultValue={[1, 3]}
130
139
  multiple
131
140
  ></DxcToggleGroup>
132
141
  </ExampleContainer>
@@ -159,6 +168,37 @@ export const Chromatic = () => (
159
168
  <Title title="xxLarge" theme="light" level={4} />
160
169
  <DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
161
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>
162
202
  </>
163
203
  );
164
204
  const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
@@ -172,7 +212,7 @@ ToggleGroupSelectedActived.play = async ({ canvasElement }) => {
172
212
  export const ToggleGroupUnselectedActived = OptionSelected.bind({});
173
213
  ToggleGroupUnselectedActived.play = async ({ canvasElement }) => {
174
214
  const canvas = within(canvasElement);
175
- const option = canvas.getByText("Twitter");
215
+ const option = canvas.getByText("X");
176
216
  await userEvent.click(option);
177
217
  userEvent.tab();
178
218
  };
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup.tsx"));
7
+ var options = [{
8
+ value: 1,
9
+ label: "Amazon"
10
+ }, {
11
+ value: 2,
12
+ label: "Ebay"
13
+ }, {
14
+ value: 3,
15
+ label: "Apple"
16
+ }, {
17
+ value: 4,
18
+ label: "Google"
19
+ }];
20
+ describe("Toggle group component tests", function () {
21
+ test("Toggle group renders with correct labels", function () {
22
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
23
+ label: "Toggle group label",
24
+ helperText: "Toggle group helper text",
25
+ options: options
26
+ })),
27
+ getByText = _render.getByText;
28
+ expect(getByText("Toggle group label")).toBeTruthy();
29
+ expect(getByText("Toggle group helper text")).toBeTruthy();
30
+ expect(getByText("Amazon")).toBeTruthy();
31
+ expect(getByText("Ebay")).toBeTruthy();
32
+ expect(getByText("Apple")).toBeTruthy();
33
+ expect(getByText("Google")).toBeTruthy();
34
+ });
35
+ test("Toggle group renders with correct aria-label in only-icon scenario", function () {
36
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
37
+ label: "Toggle group label",
38
+ helperText: "Toggle group helper text",
39
+ options: [{
40
+ value: 1,
41
+ icon: "https://cdn.icon-icons.com/icons2/2645/PNG/512/mic_mute_icon_159965.png",
42
+ title: "Mute"
43
+ }]
44
+ })),
45
+ getByRole = _render2.getByRole;
46
+ expect(getByRole("button").getAttribute("aria-label")).toBe("Mute");
47
+ });
48
+ test("Uncontrolled toggle group calls correct function on change with value", function () {
49
+ var onChange = jest.fn();
50
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
51
+ options: options,
52
+ onChange: onChange
53
+ })),
54
+ getByText = _render3.getByText;
55
+ var option = getByText("Ebay");
56
+ _react2.fireEvent.click(option);
57
+ expect(onChange).toHaveBeenCalledWith(2);
58
+ });
59
+ test("Controlled toggle group calls correct function on change with value", function () {
60
+ var onChange = jest.fn();
61
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
62
+ options: options,
63
+ onChange: onChange,
64
+ value: 1
65
+ })),
66
+ getByText = _render4.getByText;
67
+ var option = getByText("Ebay");
68
+ _react2.fireEvent.click(option);
69
+ expect(onChange).toHaveBeenCalledWith(2);
70
+ });
71
+ test("Function on change is not called when disable", function () {
72
+ var onChange = jest.fn();
73
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
74
+ options: options,
75
+ onChange: onChange,
76
+ disabled: true
77
+ })),
78
+ getByText = _render5.getByText;
79
+ var option = getByText("Ebay");
80
+ _react2.fireEvent.click(option);
81
+ expect(onChange).toHaveBeenCalledTimes(0);
82
+ });
83
+ test("Uncontrolled multiple toggle group calls correct function on change with value when is multiple", function () {
84
+ var onChange = jest.fn();
85
+ var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
86
+ options: options,
87
+ onChange: onChange,
88
+ multiple: true
89
+ })),
90
+ getAllByRole = _render6.getAllByRole;
91
+ var toggleOptions = getAllByRole("button");
92
+ _react2.fireEvent.click(toggleOptions[0]);
93
+ expect(onChange).toHaveBeenCalledWith([1]);
94
+ _react2.fireEvent.click(toggleOptions[1]);
95
+ _react2.fireEvent.click(toggleOptions[3]);
96
+ expect(onChange).toHaveBeenCalledWith([1, 2, 4]);
97
+ expect(toggleOptions[0].getAttribute("aria-pressed")).toBe("true");
98
+ expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
99
+ expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
100
+ });
101
+ test("Controlled multiple toggle returns always same values", function () {
102
+ var onChange = jest.fn();
103
+ var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
104
+ options: options,
105
+ onChange: onChange,
106
+ value: [1],
107
+ multiple: true
108
+ })),
109
+ getByText = _render7.getByText;
110
+ var option = getByText("Ebay");
111
+ _react2.fireEvent.click(option);
112
+ expect(onChange).toHaveBeenCalledWith([1, 2]);
113
+ var option2 = getByText("Google");
114
+ _react2.fireEvent.click(option2);
115
+ expect(onChange).toHaveBeenNthCalledWith(2, [1, 4]);
116
+ });
117
+ test("Single selection: Renders with correct default value", function () {
118
+ var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
119
+ options: options,
120
+ defaultValue: 2
121
+ })),
122
+ getAllByRole = _render8.getAllByRole;
123
+ var toggleOptions = getAllByRole("button");
124
+ expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
125
+ });
126
+ test("Multiple selection: Renders with correct default value", function () {
127
+ var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
128
+ options: options,
129
+ defaultValue: [2, 4],
130
+ multiple: true
131
+ })),
132
+ getAllByRole = _render9.getAllByRole;
133
+ var toggleOptions = getAllByRole("button");
134
+ expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
135
+ expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
136
+ });
137
+ });
@@ -1,33 +1,28 @@
1
1
  /// <reference types="react" />
2
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- declare type Margin = {
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
4
  top?: Space;
5
5
  bottom?: Space;
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
10
- declare type OptionCommons = {
11
- /**
12
- * Number with the option inner value.
13
- */
14
- value: string;
15
- /**
16
- * @deprecated URL of the icon that will be placed. IconSrc and label can't be used at same time.
17
- */
18
- iconSrc?: string;
19
- };
20
- declare type OptionIcon = OptionCommons & {
9
+ type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
+ type OptionIcon = {
21
11
  /**
22
12
  * String with the option display value.
23
13
  */
24
- label?: string;
14
+ label?: never;
25
15
  /**
26
16
  * Element used as the icon. Icon and label can't be used at same time.
27
17
  */
28
- icon: SVG;
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;
29
24
  };
30
- declare type OptionLabel = OptionCommons & {
25
+ export type OptionLabel = {
31
26
  /**
32
27
  * String with the option display value.
33
28
  */
@@ -35,10 +30,20 @@ declare type OptionLabel = OptionCommons & {
35
30
  /**
36
31
  * Element used as the icon. Icon and label can't be used at same time.
37
32
  */
38
- icon?: SVG;
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;
39
39
  };
40
- declare type Option = OptionIcon | OptionLabel;
41
- declare type Props = {
40
+ type Option = {
41
+ /**
42
+ * Number with the option inner value.
43
+ */
44
+ value: number;
45
+ } & (OptionIcon | OptionLabel);
46
+ type CommonProps = {
42
47
  /**
43
48
  * Text to be placed above the component.
44
49
  */
@@ -47,18 +52,6 @@ declare type Props = {
47
52
  * Helper text to be placed above the component.
48
53
  */
49
54
  helperText?: string;
50
- /**
51
- * The key(s) of the selected value(s). If the toggle group component doesn't allow multiple selection,
52
- * it must be one unique value. If the component allows multiple selection, value must be an array.
53
- * If undefined, the component will be uncontrolled and the value will be managed internally by the component.
54
- */
55
- value?: string | string[];
56
- /**
57
- * This function will be called every time the selection changes. The number with the key of the selected
58
- * value will be passed as a parameter to this function.
59
- * If multiple selection is allowed, an array of keys will be passed.
60
- */
61
- onChange?: (optionIndex: number | number[]) => void;
62
55
  /**
63
56
  * If true, the component will be disabled.
64
57
  */
@@ -67,10 +60,6 @@ declare type Props = {
67
60
  * An array of objects representing the selectable options.
68
61
  */
69
62
  options: Option[];
70
- /**
71
- * 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.
72
- */
73
- multiple?: boolean;
74
63
  /**
75
64
  * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
76
65
  * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
@@ -81,4 +70,45 @@ declare type Props = {
81
70
  */
82
71
  tabIndex?: number;
83
72
  };
73
+ type SingleSelectionToggleGroup = CommonProps & {
74
+ /**
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.
76
+ */
77
+ multiple?: false;
78
+ /**
79
+ * The key of the initially selected value.
80
+ */
81
+ defaultValue?: number;
82
+ /**
83
+ * The key of the selected value. If the component allows multiple selection, value must be an array.
84
+ * If undefined, the component will be uncontrolled and the value will be managed internally by the component.
85
+ */
86
+ value?: number;
87
+ /**
88
+ * This function will be called every time the selection changes. The number with the key of the selected
89
+ * value will be passed as a parameter to this function.
90
+ */
91
+ onChange?: (optionIndex: number) => void;
92
+ };
93
+ type MultipleSelectionToggleGroup = CommonProps & {
94
+ /**
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.
96
+ */
97
+ multiple: true;
98
+ /**
99
+ * The array of keys with the initially selected values.
100
+ */
101
+ defaultValue?: number[];
102
+ /**
103
+ * An array with the keys of the selected values.
104
+ * If undefined, the component will be uncontrolled and the value will be managed internally by the component.
105
+ */
106
+ value?: number[];
107
+ /**
108
+ * This function will be called every time the selection changes. An array with the key of
109
+ * the selected values will be passed as a parameter to this function.
110
+ */
111
+ onChange?: (optionIndex: number[]) => void;
112
+ };
113
+ type Props = SingleSelectionToggleGroup | MultipleSelectionToggleGroup;
84
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,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _BaseTypography = _interopRequireDefault(require("../utils/BaseTypography"));
12
+ var _excluded = ["textOverflow", "whiteSpace", "children"];
13
+ var DxcTypography = function DxcTypography(_ref) {
14
+ var textOverflow = _ref.textOverflow,
15
+ whiteSpace = _ref.whiteSpace,
16
+ children = _ref.children,
17
+ props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
18
+ return /*#__PURE__*/_react["default"].createElement(_BaseTypography["default"], (0, _extends2["default"])({
19
+ textOverflow: textOverflow,
20
+ whiteSpace: whiteSpace == null && textOverflow != null && textOverflow !== "unset" ? "nowrap" : whiteSpace
21
+ }, props), children);
22
+ };
23
+ var _default = exports["default"] = DxcTypography;