@dxc-technology/halstack-react 11.0.0 → 12.0.1

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 (386) hide show
  1. package/BackgroundColorContext.d.ts +1 -10
  2. package/BackgroundColorContext.js +3 -8
  3. package/HalstackContext.d.ts +32 -145
  4. package/HalstackContext.js +3 -7
  5. package/accordion/Accordion.accessibility.test.d.ts +1 -0
  6. package/accordion/Accordion.accessibility.test.js +71 -0
  7. package/accordion/Accordion.js +18 -35
  8. package/accordion/Accordion.stories.tsx +7 -49
  9. package/accordion/Accordion.test.d.ts +1 -0
  10. package/accordion/Accordion.test.js +3 -3
  11. package/accordion/types.d.ts +1 -1
  12. package/accordion-group/AccordionGroup.accessibility.test.d.ts +1 -0
  13. package/accordion-group/AccordionGroup.accessibility.test.js +82 -0
  14. package/accordion-group/AccordionGroup.d.ts +2 -3
  15. package/accordion-group/AccordionGroup.js +4 -4
  16. package/accordion-group/AccordionGroup.stories.tsx +23 -23
  17. package/accordion-group/AccordionGroup.test.d.ts +1 -0
  18. package/accordion-group/AccordionGroup.test.js +5 -9
  19. package/accordion-group/AccordionGroupAccordion.js +3 -3
  20. package/accordion-group/AccordionGroupContext.d.ts +3 -0
  21. package/accordion-group/AccordionGroupContext.js +8 -0
  22. package/accordion-group/types.d.ts +1 -1
  23. package/action-icon/ActionIcon.accessibility.test.d.ts +1 -0
  24. package/action-icon/ActionIcon.accessibility.test.js +63 -0
  25. package/action-icon/ActionIcon.d.ts +4 -0
  26. package/action-icon/ActionIcon.js +48 -0
  27. package/action-icon/ActionIcon.stories.tsx +41 -0
  28. package/action-icon/ActionIcon.test.d.ts +1 -0
  29. package/action-icon/ActionIcon.test.js +64 -0
  30. package/action-icon/types.d.ts +26 -0
  31. package/action-icon/types.js +5 -0
  32. package/alert/Alert.accessibility.test.d.ts +1 -0
  33. package/alert/Alert.accessibility.test.js +95 -0
  34. package/alert/Alert.js +21 -75
  35. package/alert/Alert.test.d.ts +1 -0
  36. package/alert/Alert.test.js +1 -1
  37. package/badge/Badge.accessibility.test.d.ts +1 -0
  38. package/badge/Badge.accessibility.test.js +129 -0
  39. package/badge/Badge.d.ts +1 -1
  40. package/badge/Badge.js +141 -28
  41. package/badge/Badge.stories.tsx +210 -0
  42. package/badge/Badge.test.d.ts +1 -0
  43. package/badge/Badge.test.js +30 -0
  44. package/badge/types.d.ts +52 -3
  45. package/box/Box.accessibility.test.d.ts +1 -0
  46. package/box/Box.accessibility.test.js +33 -0
  47. package/box/Box.js +2 -5
  48. package/box/Box.test.d.ts +1 -0
  49. package/box/Box.test.js +1 -1
  50. package/breadcrumbs/Breadcrumbs.accessibility.test.d.ts +1 -0
  51. package/breadcrumbs/Breadcrumbs.accessibility.test.js +96 -0
  52. package/breadcrumbs/Breadcrumbs.d.ts +4 -0
  53. package/breadcrumbs/Breadcrumbs.js +79 -0
  54. package/breadcrumbs/Breadcrumbs.stories.tsx +194 -0
  55. package/breadcrumbs/Breadcrumbs.test.d.ts +1 -0
  56. package/breadcrumbs/Breadcrumbs.test.js +169 -0
  57. package/breadcrumbs/Item.d.ts +4 -0
  58. package/breadcrumbs/Item.js +52 -0
  59. package/breadcrumbs/dropdownTheme.d.ts +53 -0
  60. package/breadcrumbs/dropdownTheme.js +62 -0
  61. package/breadcrumbs/types.d.ts +16 -0
  62. package/breadcrumbs/types.js +5 -0
  63. package/bulleted-list/BulletedList.accessibility.test.d.ts +1 -0
  64. package/bulleted-list/BulletedList.accessibility.test.js +119 -0
  65. package/bulleted-list/BulletedList.js +16 -23
  66. package/bulleted-list/BulletedList.stories.tsx +1 -2
  67. package/button/Button.accessibility.test.d.ts +1 -0
  68. package/button/Button.accessibility.test.js +127 -0
  69. package/button/Button.js +16 -16
  70. package/button/Button.stories.tsx +34 -53
  71. package/button/Button.test.d.ts +1 -0
  72. package/button/Button.test.js +4 -2
  73. package/button/types.d.ts +1 -1
  74. package/card/Card.accessibility.test.d.ts +1 -0
  75. package/card/Card.accessibility.test.js +36 -0
  76. package/card/Card.js +3 -2
  77. package/card/Card.test.d.ts +1 -0
  78. package/card/Card.test.js +1 -1
  79. package/checkbox/Checkbox.accessibility.test.d.ts +1 -0
  80. package/checkbox/Checkbox.accessibility.test.js +87 -0
  81. package/checkbox/Checkbox.js +36 -44
  82. package/checkbox/Checkbox.test.d.ts +1 -0
  83. package/checkbox/Checkbox.test.js +1 -1
  84. package/chip/Chip.accessibility.test.d.ts +1 -0
  85. package/chip/Chip.accessibility.test.js +69 -0
  86. package/chip/Chip.js +20 -26
  87. package/chip/Chip.stories.tsx +67 -50
  88. package/chip/Chip.test.d.ts +1 -0
  89. package/chip/Chip.test.js +5 -5
  90. package/chip/types.d.ts +35 -12
  91. package/common/coreTokens.d.ts +105 -14
  92. package/common/coreTokens.js +40 -22
  93. package/common/fonts.css +2 -0
  94. package/common/variables.d.ts +31 -141
  95. package/common/variables.js +104 -214
  96. package/container/Container.d.ts +4 -0
  97. package/container/Container.js +194 -0
  98. package/container/Container.stories.tsx +214 -0
  99. package/container/types.d.ts +74 -0
  100. package/container/types.js +5 -0
  101. package/contextual-menu/ContextualMenu.accessibility.test.d.ts +1 -0
  102. package/contextual-menu/ContextualMenu.accessibility.test.js +98 -0
  103. package/contextual-menu/ContextualMenu.d.ts +5 -0
  104. package/contextual-menu/ContextualMenu.js +88 -0
  105. package/contextual-menu/ContextualMenu.stories.tsx +232 -0
  106. package/contextual-menu/ContextualMenu.test.d.ts +1 -0
  107. package/contextual-menu/ContextualMenu.test.js +205 -0
  108. package/contextual-menu/GroupItem.d.ts +4 -0
  109. package/contextual-menu/GroupItem.js +67 -0
  110. package/contextual-menu/ItemAction.d.ts +4 -0
  111. package/contextual-menu/ItemAction.js +51 -0
  112. package/contextual-menu/MenuItem.d.ts +4 -0
  113. package/contextual-menu/MenuItem.js +29 -0
  114. package/contextual-menu/SingleItem.d.ts +4 -0
  115. package/contextual-menu/SingleItem.js +38 -0
  116. package/contextual-menu/types.d.ts +58 -0
  117. package/contextual-menu/types.js +5 -0
  118. package/date-input/Calendar.js +1 -1
  119. package/date-input/DateInput.accessibility.test.d.ts +1 -0
  120. package/date-input/DateInput.accessibility.test.js +230 -0
  121. package/date-input/DateInput.js +19 -20
  122. package/date-input/DateInput.stories.tsx +15 -8
  123. package/date-input/DateInput.test.d.ts +1 -0
  124. package/date-input/DateInput.test.js +9 -8
  125. package/date-input/DatePicker.js +13 -7
  126. package/date-input/YearPicker.js +1 -1
  127. package/date-input/types.d.ts +2 -2
  128. package/dialog/Dialog.accessibility.test.d.ts +1 -0
  129. package/dialog/Dialog.accessibility.test.js +69 -0
  130. package/dialog/Dialog.js +11 -25
  131. package/dialog/Dialog.stories.tsx +175 -0
  132. package/dialog/Dialog.test.d.ts +1 -0
  133. package/dialog/Dialog.test.js +113 -49
  134. package/divider/Divider.accessibility.test.d.ts +1 -0
  135. package/divider/Divider.accessibility.test.js +33 -0
  136. package/divider/Divider.d.ts +4 -0
  137. package/divider/Divider.js +36 -0
  138. package/divider/Divider.stories.tsx +223 -0
  139. package/divider/Divider.test.d.ts +1 -0
  140. package/divider/Divider.test.js +38 -0
  141. package/divider/types.d.ts +21 -0
  142. package/divider/types.js +5 -0
  143. package/dropdown/Dropdown.accessibility.test.d.ts +1 -0
  144. package/dropdown/Dropdown.accessibility.test.js +184 -0
  145. package/dropdown/Dropdown.js +37 -51
  146. package/dropdown/Dropdown.stories.tsx +15 -26
  147. package/dropdown/Dropdown.test.d.ts +1 -0
  148. package/dropdown/Dropdown.test.js +100 -70
  149. package/dropdown/DropdownMenu.js +4 -4
  150. package/dropdown/DropdownMenuItem.js +8 -4
  151. package/dropdown/types.d.ts +3 -5
  152. package/file-input/FileInput.accessibility.test.d.ts +1 -0
  153. package/file-input/FileInput.accessibility.test.js +167 -0
  154. package/file-input/FileInput.js +127 -145
  155. package/file-input/FileInput.test.d.ts +1 -0
  156. package/file-input/FileInput.test.js +125 -129
  157. package/file-input/FileItem.js +18 -28
  158. package/file-input/types.d.ts +1 -1
  159. package/footer/Footer.accessibility.test.d.ts +1 -0
  160. package/footer/Footer.accessibility.test.js +125 -0
  161. package/footer/Footer.d.ts +1 -1
  162. package/footer/Footer.js +36 -31
  163. package/footer/Footer.stories.tsx +58 -2
  164. package/footer/Footer.test.d.ts +1 -0
  165. package/footer/Footer.test.js +1 -1
  166. package/footer/Icons.d.ts +1 -0
  167. package/footer/Icons.js +52 -16
  168. package/footer/types.d.ts +8 -8
  169. package/header/Header.accessibility.test.d.ts +1 -0
  170. package/header/Header.accessibility.test.js +94 -0
  171. package/header/Header.js +20 -41
  172. package/header/Header.stories.tsx +16 -0
  173. package/header/Header.test.d.ts +1 -0
  174. package/header/Header.test.js +1 -1
  175. package/header/Icons.js +1 -6
  176. package/header/types.d.ts +4 -3
  177. package/heading/Heading.accessibility.test.d.ts +1 -0
  178. package/heading/Heading.accessibility.test.js +33 -0
  179. package/heading/Heading.js +1 -1
  180. package/heading/Heading.test.d.ts +1 -0
  181. package/heading/Heading.test.js +1 -14
  182. package/icon/Icon.accessibility.test.d.ts +1 -0
  183. package/icon/Icon.accessibility.test.js +30 -0
  184. package/icon/Icon.d.ts +4 -0
  185. package/icon/Icon.js +33 -0
  186. package/icon/Icon.stories.tsx +28 -0
  187. package/icon/types.d.ts +4 -0
  188. package/icon/types.js +5 -0
  189. package/image/Image.accessibility.test.d.ts +1 -0
  190. package/image/Image.accessibility.test.js +56 -0
  191. package/image/Image.js +1 -1
  192. package/image/Image.stories.tsx +3 -1
  193. package/layout/ApplicationLayout.d.ts +1 -1
  194. package/layout/ApplicationLayout.js +10 -7
  195. package/layout/Icons.d.ts +0 -1
  196. package/layout/Icons.js +1 -11
  197. package/link/Link.accessibility.test.d.ts +1 -0
  198. package/link/Link.accessibility.test.js +108 -0
  199. package/link/Link.js +8 -6
  200. package/link/Link.stories.tsx +4 -4
  201. package/link/Link.test.d.ts +1 -0
  202. package/link/Link.test.js +1 -1
  203. package/link/types.d.ts +1 -1
  204. package/main.d.ts +8 -3
  205. package/main.js +38 -9
  206. package/nav-tabs/NavTabs.accessibility.test.d.ts +1 -0
  207. package/nav-tabs/NavTabs.accessibility.test.js +44 -0
  208. package/nav-tabs/NavTabs.d.ts +1 -2
  209. package/nav-tabs/NavTabs.js +25 -7
  210. package/nav-tabs/NavTabs.stories.tsx +44 -24
  211. package/nav-tabs/NavTabs.test.d.ts +1 -0
  212. package/nav-tabs/NavTabs.test.js +12 -10
  213. package/nav-tabs/NavTabsContext.d.ts +3 -0
  214. package/nav-tabs/NavTabsContext.js +8 -0
  215. package/nav-tabs/Tab.js +23 -23
  216. package/nav-tabs/types.d.ts +1 -1
  217. package/number-input/NumberInput.accessibility.test.d.ts +1 -0
  218. package/number-input/NumberInput.accessibility.test.js +228 -0
  219. package/number-input/NumberInput.d.ts +0 -7
  220. package/number-input/NumberInput.js +24 -5
  221. package/number-input/NumberInput.test.d.ts +1 -0
  222. package/number-input/NumberInput.test.js +166 -7
  223. package/number-input/NumberInputContext.d.ts +3 -0
  224. package/number-input/NumberInputContext.js +8 -0
  225. package/number-input/types.d.ts +6 -0
  226. package/package.json +20 -18
  227. package/paginator/Paginator.accessibility.test.d.ts +1 -0
  228. package/paginator/Paginator.accessibility.test.js +79 -0
  229. package/paginator/Paginator.js +14 -14
  230. package/paginator/Paginator.test.d.ts +1 -0
  231. package/paginator/Paginator.test.js +1 -1
  232. package/paragraph/Paragraph.accessibility.test.d.ts +1 -0
  233. package/paragraph/Paragraph.accessibility.test.js +28 -0
  234. package/paragraph/Paragraph.js +2 -7
  235. package/password-input/PasswordInput.accessibility.test.d.ts +1 -0
  236. package/password-input/PasswordInput.accessibility.test.js +153 -0
  237. package/password-input/PasswordInput.js +7 -7
  238. package/password-input/PasswordInput.stories.tsx +0 -1
  239. package/password-input/PasswordInput.test.d.ts +1 -0
  240. package/password-input/PasswordInput.test.js +5 -5
  241. package/progress-bar/ProgressBar.accessibility.test.d.ts +1 -0
  242. package/progress-bar/ProgressBar.accessibility.test.js +35 -0
  243. package/progress-bar/ProgressBar.js +11 -15
  244. package/progress-bar/ProgressBar.test.d.ts +1 -0
  245. package/progress-bar/ProgressBar.test.js +1 -1
  246. package/quick-nav/QuickNav.accessibility.test.d.ts +1 -0
  247. package/quick-nav/QuickNav.accessibility.test.js +57 -0
  248. package/quick-nav/QuickNav.js +1 -1
  249. package/radio-group/Radio.js +6 -9
  250. package/radio-group/RadioGroup.accessibility.test.d.ts +1 -0
  251. package/radio-group/RadioGroup.accessibility.test.js +97 -0
  252. package/radio-group/RadioGroup.js +15 -17
  253. package/radio-group/RadioGroup.test.d.ts +1 -0
  254. package/radio-group/RadioGroup.test.js +3 -5
  255. package/resultset-table/ResultsetTable.accessibility.test.d.ts +1 -0
  256. package/resultset-table/ResultsetTable.accessibility.test.js +285 -0
  257. package/resultset-table/ResultsetTable.d.ts +4 -1
  258. package/resultset-table/ResultsetTable.js +25 -13
  259. package/resultset-table/ResultsetTable.stories.tsx +118 -5
  260. package/resultset-table/ResultsetTable.test.d.ts +1 -0
  261. package/resultset-table/ResultsetTable.test.js +76 -1
  262. package/resultset-table/types.d.ts +40 -7
  263. package/select/Listbox.js +24 -16
  264. package/select/Option.js +19 -10
  265. package/select/Select.accessibility.test.d.ts +1 -0
  266. package/select/Select.accessibility.test.js +228 -0
  267. package/select/Select.js +72 -54
  268. package/select/Select.stories.tsx +59 -111
  269. package/select/Select.test.d.ts +1 -0
  270. package/select/Select.test.js +393 -459
  271. package/select/types.d.ts +3 -3
  272. package/sidenav/Sidenav.accessibility.test.d.ts +1 -0
  273. package/sidenav/Sidenav.accessibility.test.js +59 -0
  274. package/sidenav/Sidenav.js +21 -19
  275. package/sidenav/Sidenav.stories.tsx +4 -9
  276. package/sidenav/Sidenav.test.d.ts +1 -0
  277. package/sidenav/Sidenav.test.js +1 -1
  278. package/sidenav/types.d.ts +2 -2
  279. package/slider/Slider.accessibility.test.d.ts +1 -0
  280. package/slider/Slider.accessibility.test.js +104 -0
  281. package/slider/Slider.js +31 -42
  282. package/slider/Slider.stories.tsx +180 -0
  283. package/slider/Slider.test.d.ts +1 -0
  284. package/slider/Slider.test.js +12 -9
  285. package/spinner/Spinner.accessibility.test.d.ts +1 -0
  286. package/spinner/Spinner.accessibility.test.js +96 -0
  287. package/spinner/Spinner.js +12 -16
  288. package/spinner/Spinner.test.d.ts +1 -0
  289. package/spinner/Spinner.test.js +1 -1
  290. package/status-light/StatusLight.accessibility.test.d.ts +1 -0
  291. package/status-light/StatusLight.accessibility.test.js +157 -0
  292. package/status-light/StatusLight.d.ts +4 -0
  293. package/status-light/StatusLight.js +51 -0
  294. package/status-light/StatusLight.stories.tsx +74 -0
  295. package/status-light/StatusLight.test.d.ts +1 -0
  296. package/status-light/StatusLight.test.js +25 -0
  297. package/status-light/types.d.ts +17 -0
  298. package/status-light/types.js +5 -0
  299. package/switch/Switch.accessibility.test.d.ts +1 -0
  300. package/switch/Switch.accessibility.test.js +98 -0
  301. package/switch/Switch.js +29 -37
  302. package/switch/Switch.stories.tsx +12 -0
  303. package/switch/Switch.test.d.ts +1 -0
  304. package/switch/Switch.test.js +1 -1
  305. package/table/DropdownTheme.js +62 -0
  306. package/table/Table.accessibility.test.d.ts +1 -0
  307. package/table/Table.accessibility.test.js +93 -0
  308. package/table/Table.d.ts +6 -2
  309. package/table/Table.js +74 -12
  310. package/table/Table.stories.tsx +309 -2
  311. package/table/Table.test.d.ts +1 -0
  312. package/table/Table.test.js +92 -1
  313. package/table/types.d.ts +28 -0
  314. package/tabs/Tab.js +13 -9
  315. package/tabs/Tabs.accessibility.test.d.ts +1 -0
  316. package/tabs/Tabs.accessibility.test.js +56 -0
  317. package/tabs/Tabs.js +12 -24
  318. package/tabs/Tabs.stories.tsx +8 -4
  319. package/tabs/Tabs.test.d.ts +1 -0
  320. package/tabs/Tabs.test.js +20 -38
  321. package/tabs/types.d.ts +2 -2
  322. package/tag/Tag.accessibility.test.d.ts +1 -0
  323. package/tag/Tag.accessibility.test.js +69 -0
  324. package/tag/Tag.js +7 -7
  325. package/tag/Tag.stories.tsx +4 -7
  326. package/tag/Tag.test.d.ts +1 -0
  327. package/tag/Tag.test.js +5 -13
  328. package/tag/types.d.ts +2 -2
  329. package/text-input/Suggestion.js +1 -1
  330. package/text-input/Suggestions.js +19 -14
  331. package/text-input/TextInput.accessibility.test.d.ts +1 -0
  332. package/text-input/TextInput.accessibility.test.js +321 -0
  333. package/text-input/TextInput.js +103 -126
  334. package/text-input/TextInput.stories.tsx +17 -8
  335. package/text-input/TextInput.test.d.ts +1 -0
  336. package/text-input/TextInput.test.js +97 -80
  337. package/textarea/Textarea.accessibility.test.d.ts +1 -0
  338. package/textarea/Textarea.accessibility.test.js +155 -0
  339. package/textarea/Textarea.js +13 -21
  340. package/textarea/Textarea.stories.tsx +0 -1
  341. package/textarea/Textarea.test.d.ts +1 -0
  342. package/textarea/Textarea.test.js +1 -1
  343. package/toggle-group/ToggleGroup.accessibility.test.d.ts +1 -0
  344. package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
  345. package/toggle-group/ToggleGroup.js +11 -16
  346. package/toggle-group/ToggleGroup.stories.tsx +3 -3
  347. package/toggle-group/ToggleGroup.test.d.ts +1 -0
  348. package/toggle-group/ToggleGroup.test.js +1 -1
  349. package/toggle-group/types.d.ts +2 -2
  350. package/typography/Typography.accessibility.test.d.ts +1 -0
  351. package/typography/Typography.accessibility.test.js +339 -0
  352. package/useTheme.d.ts +31 -141
  353. package/utils/BaseTypography.js +1 -1
  354. package/utils/FocusLock.js +16 -6
  355. package/wizard/Wizard.accessibility.test.d.ts +1 -0
  356. package/wizard/Wizard.accessibility.test.js +55 -0
  357. package/wizard/Wizard.js +14 -25
  358. package/wizard/Wizard.stories.tsx +19 -0
  359. package/wizard/Wizard.test.d.ts +1 -0
  360. package/wizard/Wizard.test.js +1 -1
  361. package/wizard/types.d.ts +2 -2
  362. package/common/OpenSans.css +0 -69
  363. package/common/fonts/OpenSans-Bold.ttf +0 -0
  364. package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  365. package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  366. package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  367. package/common/fonts/OpenSans-Italic.ttf +0 -0
  368. package/common/fonts/OpenSans-Light.ttf +0 -0
  369. package/common/fonts/OpenSans-LightItalic.ttf +0 -0
  370. package/common/fonts/OpenSans-Regular.ttf +0 -0
  371. package/common/fonts/OpenSans-SemiBold.ttf +0 -0
  372. package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  373. package/date-input/Icons.d.ts +0 -6
  374. package/date-input/Icons.js +0 -58
  375. package/paginator/Icons.d.ts +0 -5
  376. package/paginator/Icons.js +0 -40
  377. package/password-input/Icons.d.ts +0 -6
  378. package/password-input/Icons.js +0 -35
  379. package/select/Icons.d.ts +0 -10
  380. package/select/Icons.js +0 -89
  381. package/sidenav/Icons.d.ts +0 -7
  382. package/sidenav/Icons.js +0 -47
  383. package/text-input/Icons.d.ts +0 -8
  384. package/text-input/Icons.js +0 -56
  385. /package/{layout → sidenav}/SidenavContext.d.ts +0 -0
  386. /package/{layout → sidenav}/SidenavContext.js +0 -0
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
5
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
6
+ var _react = _interopRequireDefault(require("react"));
7
+ var _react2 = require("@testing-library/react");
8
+ var _axeHelper = require("../../test/accessibility/axe-helper.js");
9
+ var _Chip = _interopRequireDefault(require("./Chip"));
10
+ var iconSVG = /*#__PURE__*/_react["default"].createElement("svg", {
11
+ version: "1.1",
12
+ x: "0px",
13
+ y: "0px",
14
+ width: "438.536px",
15
+ height: "438.536px",
16
+ viewBox: "0 0 438.536 438.536",
17
+ fill: "currentColor"
18
+ }, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
19
+ d: "M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123\nC8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126\nh274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225\nC438.532,59.576,430.49,40.204,414.41,24.123z M373.155,225.548h-49.963V406.84h-74.802V225.548H210.99V163.02h37.401v-37.402\nc0-26.838,6.283-47.107,18.843-60.813c12.559-13.706,33.304-20.555,62.242-20.555h49.963v62.526h-31.401\nc-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.119h56.534L373.155,225.548z"
20
+ })));
21
+ describe("Chip component accessibility tests", function () {
22
+ it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
23
+ var _render, container, results;
24
+ return _regenerator["default"].wrap(function _callee$(_context) {
25
+ while (1) switch (_context.prev = _context.next) {
26
+ case 0:
27
+ _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
28
+ margin: "small",
29
+ prefixIcon: iconSVG,
30
+ onClickPrefix: function onClickPrefix() {},
31
+ suffixIcon: iconSVG,
32
+ label: "Chip"
33
+ })), container = _render.container;
34
+ _context.next = 3;
35
+ return (0, _axeHelper.axe)(container);
36
+ case 3:
37
+ results = _context.sent;
38
+ expect(results).toHaveNoViolations();
39
+ case 5:
40
+ case "end":
41
+ return _context.stop();
42
+ }
43
+ }, _callee);
44
+ })));
45
+ it("Should not have basic accessibility issues for disabled mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
46
+ var _render2, container, results;
47
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
48
+ while (1) switch (_context2.prev = _context2.next) {
49
+ case 0:
50
+ _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
51
+ margin: "small",
52
+ prefixIcon: iconSVG,
53
+ onClickPrefix: function onClickPrefix() {},
54
+ suffixIcon: iconSVG,
55
+ label: "Chip",
56
+ disabled: true
57
+ })), container = _render2.container;
58
+ _context2.next = 3;
59
+ return (0, _axeHelper.axe)(container);
60
+ case 3:
61
+ results = _context2.sent;
62
+ expect(results).toHaveNoViolations();
63
+ case 5:
64
+ case "end":
65
+ return _context2.stop();
66
+ }
67
+ }, _callee2);
68
+ })));
69
+ });
package/chip/Chip.js CHANGED
@@ -13,9 +13,10 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
13
13
  var _variables = require("../common/variables");
14
14
  var _utils = require("../common/utils");
15
15
  var _useTheme = _interopRequireDefault(require("../useTheme"));
16
+ var _Icon = _interopRequireDefault(require("../icon/Icon"));
16
17
  var _templateObject, _templateObject2, _templateObject3;
17
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
19
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
19
20
  var DxcChip = function DxcChip(_ref) {
20
21
  var label = _ref.label,
21
22
  suffixIcon = _ref.suffixIcon,
@@ -30,41 +31,36 @@ var DxcChip = function DxcChip(_ref) {
30
31
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
31
32
  theme: colorsTheme.chip
32
33
  }, /*#__PURE__*/_react["default"].createElement(Chip, {
33
- disabled: disabled,
34
34
  margin: margin
35
35
  }, prefixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
36
36
  role: typeof onClickPrefix === "function" ? "button" : undefined,
37
+ "aria-label": typeof onClickPrefix === "function" ? "Prefix Action" : undefined,
37
38
  disabled: disabled,
38
39
  interactuable: typeof onClickPrefix === "function" && !disabled,
39
40
  tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
40
- onClick: function onClick() {
41
- return onClickPrefix && !disabled && onClickPrefix();
42
- }
43
- }, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
44
- src: prefixIcon
45
- }) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
46
- disabled: disabled
47
- }, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
41
+ onClick: onClickPrefix
42
+ }, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
43
+ icon: prefixIcon
44
+ }) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
48
45
  role: typeof onClickSuffix === "function" ? "button" : undefined,
46
+ "aria-label": typeof onClickSuffix === "function" ? "Suffix Action" : undefined,
49
47
  disabled: disabled,
50
48
  interactuable: typeof onClickSuffix === "function" && !disabled,
51
49
  tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
52
- onClick: function onClick() {
53
- return !disabled && (onClickSuffix === null || onClickSuffix === void 0 ? void 0 : onClickSuffix());
54
- }
55
- }, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
56
- src: suffixIcon
50
+ onClick: onClickSuffix
51
+ }, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
52
+ icon: suffixIcon
57
53
  }) : suffixIcon)));
58
54
  };
59
55
  var calculateWidth = function calculateWidth(margin) {
60
56
  return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
61
57
  };
62
- var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n"])), function (props) {
58
+ var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
63
59
  return props.theme.iconSpacing;
64
60
  }, function (props) {
65
61
  return calculateWidth(props.margin);
66
62
  }, function (props) {
67
- return props.disabled && props.theme.disabledBackgroundColor || props.theme.backgroundColor;
63
+ return props.theme.backgroundColor;
68
64
  }, function (props) {
69
65
  return props.theme.borderRadius;
70
66
  }, function (props) {
@@ -91,9 +87,6 @@ var Chip = _styledComponents["default"].div(_templateObject || (_templateObject
91
87
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
92
88
  }, function (props) {
93
89
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
94
- }, function (_ref2) {
95
- var disabled = _ref2.disabled;
96
- return disabled && "not-allowed";
97
90
  });
98
91
  var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-weight: ", ";\n font-style: ", ";\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n"])), function (props) {
99
92
  return props.theme.fontSize;
@@ -104,18 +97,19 @@ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_tem
104
97
  }, function (props) {
105
98
  return props.theme.fontStyle;
106
99
  }, function (props) {
107
- return props.disabled ? props.theme.disabledFontColor : props.theme.fontColor;
100
+ return props.theme.fontColor;
108
101
  });
109
- var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n ", "\n\n ", "\n\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
110
- return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
111
- }, function (_ref3) {
112
- var interactuable = _ref3.interactuable;
113
- return interactuable && "cursor: pointer;";
102
+ var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n cursor: ", ";\n ", "\n\n font-size: ", ";\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
103
+ return props.disabled && (props.onClick || props.onClick) ? props.theme.disabledIconColor : props.theme.iconColor;
104
+ }, function (props) {
105
+ return props.disabled && (props.onClick || props.onClick) ? "not-allowed" : props.interactuable ? "pointer" : "";
114
106
  }, function (props) {
115
107
  return props.interactuable && "\n &:hover {\n color: ".concat(props.theme.hoverIconColor, ";\n }\n &:focus,\n &:focus-visible {\n outline: ").concat(props.theme.focusBorderThickness, " ").concat(props.theme.focusBorderStyle, " ").concat(props.theme.focusColor, ";\n }\n &:active {\n color: ").concat(props.theme.activeIconColor, ";\n }\n ");
116
108
  }, function (props) {
117
109
  return props.theme.iconSize;
118
110
  }, function (props) {
119
111
  return props.theme.iconSize;
112
+ }, function (props) {
113
+ return props.theme.iconSize;
120
114
  });
121
115
  var _default = exports["default"] = DxcChip;
@@ -13,7 +13,6 @@ export default {
13
13
  const iconSVG = (
14
14
  <svg
15
15
  version="1.1"
16
- id="Capa_1"
17
16
  x="0px"
18
17
  y="0px"
19
18
  width="438.536px"
@@ -34,12 +33,6 @@ c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.11
34
33
  </svg>
35
34
  );
36
35
 
37
- const smallIconSVG = (
38
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20">
39
- <path d="m10 17-1.042-.938q-2.083-1.854-3.437-3.177-1.354-1.323-2.136-2.354Q2.604 9.5 2.302 8.646 2 7.792 2 6.896q0-1.854 1.271-3.125T6.396 2.5q1.021 0 1.979.438.958.437 1.625 1.229.667-.792 1.625-1.229.958-.438 1.979-.438 1.854 0 3.125 1.271T18 6.896q0 .896-.292 1.729-.291.833-1.073 1.854-.781 1.021-2.145 2.365-1.365 1.344-3.49 3.26Zm0-2.021q1.938-1.729 3.188-2.948 1.25-1.219 1.989-2.125.74-.906 1.031-1.614.292-.709.292-1.396 0-1.229-.833-2.063Q14.833 4 13.604 4q-.729 0-1.364.302-.636.302-1.094.844L10.417 6h-.834l-.729-.854q-.458-.542-1.114-.844Q7.083 4 6.396 4q-1.229 0-2.063.833-.833.834-.833 2.063 0 .687.271 1.364.271.678.989 1.573.719.896 1.98 2.125Q8 13.188 10 14.979Zm0-5.5Z" />
40
- </svg>
41
- );
42
-
43
36
  const opinionatedTheme = {
44
37
  chip: {
45
38
  baseColor: "#e6e6e6",
@@ -51,42 +44,79 @@ const opinionatedTheme = {
51
44
  export const Chromatic = () => (
52
45
  <>
53
46
  <ExampleContainer>
54
- <Title title="Basic chip" theme="light" level={4} />
55
- <DxcChip label="Default Chip" />
47
+ <Title title="Default" theme="light" level={4} />
48
+ <DxcChip label="Default" />
49
+ </ExampleContainer>
50
+ <ExampleContainer>
51
+ <Title title="With prefix (SVG)" theme="light" level={4} />
52
+ <DxcChip label="Prefix" prefixIcon={iconSVG} />
56
53
  </ExampleContainer>
57
54
  <ExampleContainer>
58
- <Title title="Chip with prefix SVG (small icon)" theme="light" level={4} />
59
- <DxcChip label="Chip with prefix" prefixIcon={smallIconSVG} />
55
+ <Title title="With action prefix (SVG)" theme="light" level={4} />
56
+ <DxcChip label="Action prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
57
+ </ExampleContainer>
58
+ <ExampleContainer>
59
+ <Title title="Disabled action prefix (SVG)" theme="light" level={4} />
60
+ <DxcChip label="Disabled action prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} disabled />
61
+ </ExampleContainer>
62
+ <ExampleContainer>
63
+ <Title title="With suffix (Material icon)" theme="light" level={4} />
64
+ <DxcChip label="Suffix" suffixIcon="filled_check_circle" />
65
+ </ExampleContainer>
66
+ <ExampleContainer>
67
+ <Title title="With action suffix (Material icon)" theme="light" level={4} />
68
+ <DxcChip label="Action suffix" suffixIcon="filled_check_circle" onClickSuffix={() => {}} />
69
+ </ExampleContainer>
70
+ <ExampleContainer>
71
+ <Title title="Action prefix and suffix" theme="light" level={4} />
72
+ <DxcChip
73
+ label="Action prefix and suffix"
74
+ prefixIcon="filled_check_circle"
75
+ onClickPrefix={() => {}}
76
+ suffixIcon={iconSVG}
77
+ />
78
+ </ExampleContainer>
79
+ <ExampleContainer>
80
+ <Title title="Prefix and action suffix" theme="light" level={4} />
81
+ <DxcChip
82
+ label="Prefix and action suffix"
83
+ prefixIcon="filled_check_circle"
84
+ suffixIcon={iconSVG}
85
+ onClickSuffix={() => {}}
86
+ />
60
87
  </ExampleContainer>
61
88
  <ExampleContainer>
62
- <Title title="Chip with suffix SVG (large icon)" theme="light" level={4} />
63
- <DxcChip label="Chip with suffix" suffixIcon={iconSVG} />
89
+ <Title title="Disabled action suffix (Material icon)" theme="light" level={4} />
90
+ <DxcChip label="Disabled action suffix" suffixIcon="filled_check_circle" onClickSuffix={() => {}} disabled />
64
91
  </ExampleContainer>
65
92
  <ExampleContainer>
66
- <Title title="Chip with prefix (SVG) and suffix (URL)" theme="light" level={4} />
93
+ <Title title="Disabled action prefix and suffix" theme="light" level={4} />
67
94
  <DxcChip
68
- label="Chip with prefix and suffix"
95
+ label="Disabled action prefix"
96
+ disabled
69
97
  prefixIcon={iconSVG}
70
- suffixIcon="https://upload.wikimedia.org/wikipedia/commons/e/e0/Check_green_icon.svg"
98
+ onClickPrefix={() => {}}
99
+ suffixIcon="filled_check_circle"
71
100
  />
72
101
  </ExampleContainer>
73
102
  <ExampleContainer>
74
- <Title title="Disabled chip" theme="light" level={4} />
103
+ <Title title="Prefix and disabled action suffix" theme="light" level={4} />
75
104
  <DxcChip
76
- label="Disabled"
105
+ label="Disabled action suffix"
77
106
  disabled
78
107
  prefixIcon={iconSVG}
79
- suffixIcon="https://upload.wikimedia.org/wikipedia/commons/e/e0/Check_green_icon.svg"
108
+ suffixIcon="filled_check_circle"
109
+ onClickSuffix={() => {}}
80
110
  />
81
111
  </ExampleContainer>
82
112
  <ExampleContainer>
83
- <Title title="Chip with ellipsis" theme="light" level={4} />
113
+ <Title title="With ellipsis" theme="light" level={4} />
84
114
  <div style={{ width: "200px" }}>
85
115
  <DxcChip label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fg ssssssssssss ssss" />
86
116
  </div>
87
117
  </ExampleContainer>
88
118
  <ExampleContainer>
89
- <Title title="Chip with ellipsis and suffix" theme="light" level={4} />
119
+ <Title title="With ellipsis and suffix" theme="light" level={4} />
90
120
  <div style={{ width: "200px" }}>
91
121
  <DxcChip
92
122
  suffixIcon={iconSVG}
@@ -95,7 +125,7 @@ export const Chromatic = () => (
95
125
  </div>
96
126
  </ExampleContainer>
97
127
  <ExampleContainer>
98
- <Title title="Chip with ellipsis and prefix" theme="light" level={4} />
128
+ <Title title="With ellipsis and prefix" theme="light" level={4} />
99
129
  <div style={{ width: "200px" }}>
100
130
  <DxcChip
101
131
  prefixIcon={iconSVG}
@@ -104,10 +134,11 @@ export const Chromatic = () => (
104
134
  </div>
105
135
  </ExampleContainer>
106
136
  <ExampleContainer>
107
- <Title title="Chip with ellipsis, suffix and prefix" theme="light" level={4} />
137
+ <Title title="With ellipsis, action prefix and suffix" theme="light" level={4} />
108
138
  <div style={{ width: "200px" }}>
109
139
  <DxcChip
110
140
  prefixIcon={iconSVG}
141
+ onClickPrefix={() => {}}
111
142
  suffixIcon={iconSVG}
112
143
  label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasdf"
113
144
  />
@@ -144,62 +175,48 @@ export const Chromatic = () => (
144
175
  </ExampleContainer>
145
176
  <Title title="Opinionated theme" theme="light" level={2} />
146
177
  <ExampleContainer>
147
- <Title title="Chip with prefix and suffix" theme="light" level={4} />
178
+ <Title title="With prefix and suffix" theme="light" level={4} />
148
179
  <HalstackProvider theme={opinionatedTheme}>
149
- <DxcChip
150
- label="Chip"
151
- prefixIcon={iconSVG}
152
- suffixIcon="https://upload.wikimedia.org/wikipedia/commons/e/e0/Check_green_icon.svg"
153
- />
180
+ <DxcChip label="Chip" prefixIcon={iconSVG} onClickPrefix={() => {}} suffixIcon="filled_check_circle" />
154
181
  </HalstackProvider>
155
182
  </ExampleContainer>
156
183
  <ExampleContainer>
157
- <Title title="Chip with prefix and suffix" theme="light" level={4} />
184
+ <Title title="With prefix and suffix" theme="light" level={4} />
158
185
  <HalstackProvider theme={opinionatedTheme}>
159
186
  <DxcChip
160
- label="Chip"
187
+ label="Disabled"
161
188
  disabled
162
189
  prefixIcon={iconSVG}
163
- suffixIcon="https://upload.wikimedia.org/wikipedia/commons/e/e0/Check_green_icon.svg"
190
+ suffixIcon="filled_check_circle"
191
+ onClickSuffix={() => {}}
164
192
  />
165
193
  </HalstackProvider>
166
194
  </ExampleContainer>
167
195
  <ExampleContainer pseudoState="pseudo-hover">
168
196
  <Title title="Hovered" theme="light" level={4} />
169
197
  <HalstackProvider theme={opinionatedTheme}>
170
- <DxcChip
171
- label="Chip"
172
- prefixIcon={iconSVG}
173
- suffixIcon={iconSVG}
174
- onClickPrefix={() => {}}
175
- onClickSuffix={() => {}}
176
- />
198
+ <DxcChip label="Chip" prefixIcon={iconSVG} suffixIcon={iconSVG} onClickPrefix={() => {}} />
177
199
  </HalstackProvider>
178
200
  </ExampleContainer>
179
201
  <ExampleContainer pseudoState="pseudo-active">
180
202
  <Title title="Actived" theme="light" level={4} />
181
203
  <HalstackProvider theme={opinionatedTheme}>
182
- <DxcChip
183
- label="Chip"
184
- prefixIcon={iconSVG}
185
- suffixIcon={iconSVG}
186
- onClickPrefix={() => {}}
187
- onClickSuffix={() => {}}
188
- />
204
+ <DxcChip label="Chip" prefixIcon={iconSVG} suffixIcon={iconSVG} onClickPrefix={() => {}} />
189
205
  </HalstackProvider>
190
206
  </ExampleContainer>
191
207
  </>
192
208
  );
209
+
193
210
  const ChipPrefixFocused = () => (
194
211
  <ExampleContainer>
195
- <Title title="Chip with prefix" theme="light" level={4} />
196
- <DxcChip label="Chip with prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
212
+ <Title title="With prefix" theme="light" level={4} />
213
+ <DxcChip label="Prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
197
214
  </ExampleContainer>
198
215
  );
199
216
  const ChipSuffixFocused = () => (
200
217
  <ExampleContainer>
201
- <Title title="Chip with suffix" theme="light" level={4} />
202
- <DxcChip label="Chip with suffix" suffixIcon="https://icons-for-free.com/download-icon-close+icon-1320184117228553763_512.png" onClickSuffix={() => {}} />
218
+ <Title title="With suffix" theme="light" level={4} />
219
+ <DxcChip label="Suffix" suffixIcon="filled_delete" onClickSuffix={() => {}} />
203
220
  </ExampleContainer>
204
221
  );
205
222
 
@@ -0,0 +1 @@
1
+ export {};
package/chip/Chip.test.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  var _react = _interopRequireDefault(require("react"));
5
5
  var _react2 = require("@testing-library/react");
6
- var _Chip = _interopRequireDefault(require("./Chip.tsx"));
6
+ var _Chip = _interopRequireDefault(require("./Chip"));
7
7
  describe("Chip component tests", function () {
8
8
  test("Chip renders with correct text", function () {
9
9
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
@@ -16,26 +16,26 @@ describe("Chip component tests", function () {
16
16
  var onClick = jest.fn();
17
17
  var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
18
18
  label: "Chip",
19
- prefixIcon: "https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png",
19
+ prefixIcon: "nutrition",
20
20
  onClickPrefix: onClick
21
21
  })),
22
22
  getByText = _render2.getByText,
23
23
  getByRole = _render2.getByRole;
24
24
  expect(getByText("Chip")).toBeTruthy();
25
- _react2.fireEvent.click(getByRole("img"));
25
+ _react2.fireEvent.click(getByRole("button"));
26
26
  expect(onClick).toHaveBeenCalled();
27
27
  });
28
28
  test("Calls correct function when clicking on suffix icon", function () {
29
29
  var onClick = jest.fn();
30
30
  var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
31
31
  label: "Chip",
32
- suffixIcon: "https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png",
32
+ suffixIcon: "nutrition",
33
33
  onClickSuffix: onClick
34
34
  })),
35
35
  getByText = _render3.getByText,
36
36
  getByRole = _render3.getByRole;
37
37
  expect(getByText("Chip")).toBeTruthy();
38
- _react2.fireEvent.click(getByRole("img"));
38
+ _react2.fireEvent.click(getByRole("button"));
39
39
  expect(onClick).toHaveBeenCalled();
40
40
  });
41
41
  });
package/chip/types.d.ts CHANGED
@@ -7,31 +7,53 @@ type Margin = {
7
7
  right?: Space;
8
8
  };
9
9
  type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
- type Props = {
10
+ type Icon = string | SVG;
11
+ type PrefixIconProps = {
11
12
  /**
12
- * Text to be placed on the chip.
13
+ * Element or path used as icon to be placed before the chip label.
13
14
  */
14
- label?: string;
15
+ prefixIcon: Icon;
15
16
  /**
16
- * Element or path used as icon to be placed after the chip label.
17
+ * This function will be called when the prefix is clicked.
17
18
  */
18
- suffixIcon?: string | SVG;
19
+ onClickPrefix: () => void;
19
20
  /**
20
- * Element or path used as icon to be placed before the chip label.
21
+ * Element or path used as icon to be placed after the chip label.
21
22
  */
22
- prefixIcon?: string | SVG;
23
+ suffixIcon?: Icon;
23
24
  /**
24
25
  * This function will be called when the suffix is clicked.
25
26
  */
26
- onClickSuffix?: () => void;
27
+ onClickSuffix?: never;
27
28
  /**
28
- * This function will be called when the prefix is clicked.
29
+ * If true, the action icon will be disabled.
29
30
  */
30
- onClickPrefix?: () => void;
31
+ disabled?: boolean;
32
+ } | {
33
+ prefixIcon?: Icon;
34
+ onClickPrefix?: never;
35
+ suffixIcon?: never;
36
+ onClickSuffix?: never;
37
+ disabled?: never;
38
+ };
39
+ type SuffixIconProps = {
40
+ suffixIcon: Icon;
41
+ onClickSuffix: () => void;
42
+ prefixIcon?: Icon;
43
+ onClickPrefix?: never;
44
+ disabled?: boolean;
45
+ } | {
46
+ suffixIcon?: Icon;
47
+ onClickSuffix?: never;
48
+ prefixIcon?: never;
49
+ onClickPrefix?: never;
50
+ disabled?: never;
51
+ };
52
+ type CommonProps = {
31
53
  /**
32
- * If true, the component will be disabled.
54
+ * Text to be placed on the chip.
33
55
  */
34
- disabled?: boolean;
56
+ label?: string;
35
57
  /**
36
58
  * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
37
59
  * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
@@ -42,4 +64,5 @@ type Props = {
42
64
  */
43
65
  tabIndex?: number;
44
66
  };
67
+ type Props = (PrefixIconProps | SuffixIconProps) & CommonProps;
45
68
  export default Props;
@@ -1,5 +1,8 @@
1
- declare const CORE_TOKENS: {
2
- inherit: string;
1
+ /**
2
+ * Halstack Color Palette
3
+ * @link https://developer.dxc.com/halstack/next/principles/color/#color-tokens-core-color-tokens
4
+ */
5
+ declare const CoreColorTokens: {
3
6
  color_black: string;
4
7
  color_white: string;
5
8
  color_transparent: string;
@@ -83,6 +86,11 @@ declare const CORE_TOKENS: {
83
86
  color_orange_700: string;
84
87
  color_orange_800: string;
85
88
  color_orange_900: string;
89
+ };
90
+ export declare const getCoreColorToken: (key: CoreColorTokens) => string;
91
+ export type CoreColorTokens = keyof typeof CoreColorTokens;
92
+ declare const CoreTokens: {
93
+ inherit: string;
86
94
  type_sans: string;
87
95
  type_scale_root: string;
88
96
  type_scale_08: string;
@@ -116,6 +124,17 @@ declare const CORE_TOKENS: {
116
124
  type_leading_normal: string;
117
125
  type_leading_loose_01: string;
118
126
  type_leading_loose_02: string;
127
+ border_width_0: string;
128
+ border_width_1: string;
129
+ border_width_2: string;
130
+ border_width_4: string;
131
+ border_radius_none: string;
132
+ border_radius_small: string;
133
+ border_radius_medium: string;
134
+ border_radius_large: string;
135
+ border_solid: string;
136
+ border_dashed: string;
137
+ border_none: string;
119
138
  spacing_0: string;
120
139
  spacing_2: string;
121
140
  spacing_4: string;
@@ -131,16 +150,88 @@ declare const CORE_TOKENS: {
131
150
  spacing_80: string;
132
151
  spacing_96: string;
133
152
  spacing_112: string;
134
- border_width_0: string;
135
- border_width_1: string;
136
- border_width_2: string;
137
- border_width_4: string;
138
- border_radius_none: string;
139
- border_radius_small: string;
140
- border_radius_medium: string;
141
- border_radius_large: string;
142
- border_solid: string;
143
- border_dashed: string;
144
- border_none: string;
153
+ color_black: string;
154
+ color_white: string;
155
+ color_transparent: string;
156
+ color_grey_50: string;
157
+ color_grey_100: string;
158
+ color_grey_200: string;
159
+ color_grey_300: string;
160
+ color_grey_400: string;
161
+ color_grey_500: string;
162
+ color_grey_600: string;
163
+ color_grey_700: string;
164
+ color_grey_800: string;
165
+ color_grey_900: string;
166
+ color_grey_50_a: string;
167
+ color_grey_100_a: string;
168
+ color_grey_200_a: string;
169
+ color_grey_300_a: string;
170
+ color_grey_400_a: string;
171
+ color_grey_500_a: string;
172
+ color_grey_600_a: string;
173
+ color_grey_700_a: string;
174
+ color_grey_800_a: string;
175
+ color_grey_900_a: string;
176
+ color_purple_50: string;
177
+ color_purple_100: string;
178
+ color_purple_200: string;
179
+ color_purple_300: string;
180
+ color_purple_400: string;
181
+ color_purple_500: string;
182
+ color_purple_600: string;
183
+ color_purple_700: string;
184
+ color_purple_800: string;
185
+ color_purple_900: string;
186
+ color_blue_50: string;
187
+ color_blue_100: string;
188
+ color_blue_200: string;
189
+ color_blue_300: string;
190
+ color_blue_400: string;
191
+ color_blue_500: string;
192
+ color_blue_600: string;
193
+ color_blue_700: string;
194
+ color_blue_800: string;
195
+ color_blue_900: string;
196
+ color_red_50: string;
197
+ color_red_100: string;
198
+ color_red_200: string;
199
+ color_red_300: string;
200
+ color_red_400: string;
201
+ color_red_500: string;
202
+ color_red_600: string;
203
+ color_red_700: string;
204
+ color_red_800: string;
205
+ color_red_900: string;
206
+ color_green_50: string;
207
+ color_green_100: string;
208
+ color_green_200: string;
209
+ color_green_300: string;
210
+ color_green_400: string;
211
+ color_green_500: string;
212
+ color_green_600: string;
213
+ color_green_700: string;
214
+ color_green_800: string;
215
+ color_green_900: string;
216
+ color_yellow_50: string;
217
+ color_yellow_100: string;
218
+ color_yellow_200: string;
219
+ color_yellow_300: string;
220
+ color_yellow_400: string;
221
+ color_yellow_500: string;
222
+ color_yellow_600: string;
223
+ color_yellow_700: string;
224
+ color_yellow_800: string;
225
+ color_yellow_900: string;
226
+ color_orange_50: string;
227
+ color_orange_100: string;
228
+ color_orange_200: string;
229
+ color_orange_300: string;
230
+ color_orange_400: string;
231
+ color_orange_500: string;
232
+ color_orange_600: string;
233
+ color_orange_700: string;
234
+ color_orange_800: string;
235
+ color_orange_900: string;
145
236
  };
146
- export default CORE_TOKENS;
237
+ export default CoreTokens;