@transferwise/components 0.0.0-experimental-751dc12 → 0.0.0-experimental-4341b9c

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 (318) hide show
  1. package/build/button/Button.js +0 -1
  2. package/build/button/Button.js.map +1 -1
  3. package/build/button/Button.mjs +0 -1
  4. package/build/button/Button.mjs.map +1 -1
  5. package/build/common/RadioButton/RadioButton.js +2 -5
  6. package/build/common/RadioButton/RadioButton.js.map +1 -1
  7. package/build/common/RadioButton/RadioButton.mjs +2 -5
  8. package/build/common/RadioButton/RadioButton.mjs.map +1 -1
  9. package/build/common/initials.js +4 -1
  10. package/build/common/initials.js.map +1 -1
  11. package/build/common/initials.mjs +4 -1
  12. package/build/common/initials.mjs.map +1 -1
  13. package/build/i18n/de.json +2 -0
  14. package/build/i18n/de.json.js +2 -0
  15. package/build/i18n/de.json.js.map +1 -1
  16. package/build/i18n/de.json.mjs +2 -0
  17. package/build/i18n/de.json.mjs.map +1 -1
  18. package/build/i18n/fr.json +2 -0
  19. package/build/i18n/fr.json.js +2 -0
  20. package/build/i18n/fr.json.js.map +1 -1
  21. package/build/i18n/fr.json.mjs +2 -0
  22. package/build/i18n/fr.json.mjs.map +1 -1
  23. package/build/i18n/hu.json +2 -0
  24. package/build/i18n/hu.json.js +2 -0
  25. package/build/i18n/hu.json.js.map +1 -1
  26. package/build/i18n/hu.json.mjs +2 -0
  27. package/build/i18n/hu.json.mjs.map +1 -1
  28. package/build/i18n/it.json +2 -0
  29. package/build/i18n/it.json.js +2 -0
  30. package/build/i18n/it.json.js.map +1 -1
  31. package/build/i18n/it.json.mjs +2 -0
  32. package/build/i18n/it.json.mjs.map +1 -1
  33. package/build/i18n/ja.json +2 -0
  34. package/build/i18n/ja.json.js +2 -0
  35. package/build/i18n/ja.json.js.map +1 -1
  36. package/build/i18n/ja.json.mjs +2 -0
  37. package/build/i18n/ja.json.mjs.map +1 -1
  38. package/build/i18n/pl.json +2 -0
  39. package/build/i18n/pl.json.js +2 -0
  40. package/build/i18n/pl.json.js.map +1 -1
  41. package/build/i18n/pl.json.mjs +2 -0
  42. package/build/i18n/pl.json.mjs.map +1 -1
  43. package/build/i18n/pt.json +2 -0
  44. package/build/i18n/pt.json.js +2 -0
  45. package/build/i18n/pt.json.js.map +1 -1
  46. package/build/i18n/pt.json.mjs +2 -0
  47. package/build/i18n/pt.json.mjs.map +1 -1
  48. package/build/i18n/ro.json +2 -0
  49. package/build/i18n/ro.json.js +2 -0
  50. package/build/i18n/ro.json.js.map +1 -1
  51. package/build/i18n/ro.json.mjs +2 -0
  52. package/build/i18n/ro.json.mjs.map +1 -1
  53. package/build/i18n/ru.json +2 -0
  54. package/build/i18n/ru.json.js +2 -0
  55. package/build/i18n/ru.json.js.map +1 -1
  56. package/build/i18n/ru.json.mjs +2 -0
  57. package/build/i18n/ru.json.mjs.map +1 -1
  58. package/build/i18n/tr.json +2 -0
  59. package/build/i18n/tr.json.js +2 -0
  60. package/build/i18n/tr.json.js.map +1 -1
  61. package/build/i18n/tr.json.mjs +2 -0
  62. package/build/i18n/tr.json.mjs.map +1 -1
  63. package/build/i18n/zh-CN.json +2 -0
  64. package/build/i18n/zh-CN.json.js +2 -0
  65. package/build/i18n/zh-CN.json.js.map +1 -1
  66. package/build/i18n/zh-CN.json.mjs +2 -0
  67. package/build/i18n/zh-CN.json.mjs.map +1 -1
  68. package/build/i18n/zh-HK.json +2 -0
  69. package/build/i18n/zh-HK.json.js +2 -0
  70. package/build/i18n/zh-HK.json.js.map +1 -1
  71. package/build/i18n/zh-HK.json.mjs +2 -0
  72. package/build/i18n/zh-HK.json.mjs.map +1 -1
  73. package/build/iconButton/IconButton.js.map +1 -1
  74. package/build/iconButton/IconButton.mjs.map +1 -1
  75. package/build/image/Image.js.map +1 -1
  76. package/build/image/Image.mjs.map +1 -1
  77. package/build/index.js +0 -2
  78. package/build/index.js.map +1 -1
  79. package/build/index.mjs +0 -1
  80. package/build/index.mjs.map +1 -1
  81. package/build/main.css +0 -709
  82. package/build/styles/main.css +0 -709
  83. package/build/switch/Switch.js +0 -2
  84. package/build/switch/Switch.js.map +1 -1
  85. package/build/switch/Switch.mjs +0 -2
  86. package/build/switch/Switch.mjs.map +1 -1
  87. package/build/types/button/Button.d.ts.map +1 -1
  88. package/build/types/button/Button.types.d.ts +1 -1
  89. package/build/types/button/Button.types.d.ts.map +1 -1
  90. package/build/types/button/index.d.ts +1 -1
  91. package/build/types/button/index.d.ts.map +1 -1
  92. package/build/types/common/RadioButton/RadioButton.d.ts +1 -3
  93. package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
  94. package/build/types/common/initials.d.ts.map +1 -1
  95. package/build/types/iconButton/IconButton.d.ts +2 -2
  96. package/build/types/iconButton/IconButton.d.ts.map +1 -1
  97. package/build/types/image/Image.d.ts +0 -3
  98. package/build/types/image/Image.d.ts.map +1 -1
  99. package/build/types/image/index.d.ts +0 -1
  100. package/build/types/image/index.d.ts.map +1 -1
  101. package/build/types/index.d.ts +0 -2
  102. package/build/types/index.d.ts.map +1 -1
  103. package/build/types/switch/Switch.d.ts +0 -2
  104. package/build/types/switch/Switch.d.ts.map +1 -1
  105. package/package.json +1 -1
  106. package/src/button/Button.spec.tsx +0 -18
  107. package/src/button/Button.tsx +1 -5
  108. package/src/button/Button.types.ts +1 -1
  109. package/src/button/index.ts +1 -1
  110. package/src/checkboxButton/CheckboxButton.story.tsx +4 -4
  111. package/src/common/RadioButton/RadioButton.tsx +1 -6
  112. package/src/common/initials.spec.tsx +13 -0
  113. package/src/common/initials.ts +5 -0
  114. package/src/i18n/de.json +2 -0
  115. package/src/i18n/fr.json +2 -0
  116. package/src/i18n/hu.json +2 -0
  117. package/src/i18n/it.json +2 -0
  118. package/src/i18n/ja.json +2 -0
  119. package/src/i18n/pl.json +2 -0
  120. package/src/i18n/pt.json +2 -0
  121. package/src/i18n/ro.json +2 -0
  122. package/src/i18n/ru.json +2 -0
  123. package/src/i18n/tr.json +2 -0
  124. package/src/i18n/zh-CN.json +2 -0
  125. package/src/i18n/zh-HK.json +2 -0
  126. package/src/iconButton/IconButton.story.tsx +1 -1
  127. package/src/iconButton/IconButton.tsx +1 -1
  128. package/src/image/Image.tsx +0 -3
  129. package/src/image/index.ts +0 -1
  130. package/src/index.ts +0 -2
  131. package/src/main.css +0 -709
  132. package/src/main.less +0 -1
  133. package/src/switch/Switch.tsx +0 -4
  134. package/src/test-utils/Parameters.d.ts +77 -0
  135. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +0 -56
  136. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +0 -1
  137. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +0 -54
  138. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +0 -1
  139. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +0 -23
  140. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +0 -1
  141. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +0 -21
  142. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +0 -1
  143. package/build/listItem/AvatarView/ListItemAvatarView.js +0 -23
  144. package/build/listItem/AvatarView/ListItemAvatarView.js.map +0 -1
  145. package/build/listItem/AvatarView/ListItemAvatarView.mjs +0 -21
  146. package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +0 -1
  147. package/build/listItem/Button/ListItemButton.js +0 -43
  148. package/build/listItem/Button/ListItemButton.js.map +0 -1
  149. package/build/listItem/Button/ListItemButton.mjs +0 -41
  150. package/build/listItem/Button/ListItemButton.mjs.map +0 -1
  151. package/build/listItem/Checkbox/ListItemCheckbox.js +0 -30
  152. package/build/listItem/Checkbox/ListItemCheckbox.js.map +0 -1
  153. package/build/listItem/Checkbox/ListItemCheckbox.mjs +0 -28
  154. package/build/listItem/Checkbox/ListItemCheckbox.mjs.map +0 -1
  155. package/build/listItem/IconButton/ListItemIconButton.js +0 -42
  156. package/build/listItem/IconButton/ListItemIconButton.js.map +0 -1
  157. package/build/listItem/IconButton/ListItemIconButton.mjs +0 -40
  158. package/build/listItem/IconButton/ListItemIconButton.mjs.map +0 -1
  159. package/build/listItem/Image/ListItemImage.js +0 -31
  160. package/build/listItem/Image/ListItemImage.js.map +0 -1
  161. package/build/listItem/Image/ListItemImage.mjs +0 -29
  162. package/build/listItem/Image/ListItemImage.mjs.map +0 -1
  163. package/build/listItem/ListItem.js +0 -308
  164. package/build/listItem/ListItem.js.map +0 -1
  165. package/build/listItem/ListItem.mjs +0 -303
  166. package/build/listItem/ListItem.mjs.map +0 -1
  167. package/build/listItem/ListItemContext.js +0 -8
  168. package/build/listItem/ListItemContext.js.map +0 -1
  169. package/build/listItem/ListItemContext.mjs +0 -6
  170. package/build/listItem/ListItemContext.mjs.map +0 -1
  171. package/build/listItem/Navigation/ListItemNavigation.js +0 -45
  172. package/build/listItem/Navigation/ListItemNavigation.js.map +0 -1
  173. package/build/listItem/Navigation/ListItemNavigation.mjs +0 -43
  174. package/build/listItem/Navigation/ListItemNavigation.mjs.map +0 -1
  175. package/build/listItem/Prompt/ListItemPrompt.js +0 -59
  176. package/build/listItem/Prompt/ListItemPrompt.js.map +0 -1
  177. package/build/listItem/Prompt/ListItemPrompt.mjs +0 -54
  178. package/build/listItem/Prompt/ListItemPrompt.mjs.map +0 -1
  179. package/build/listItem/Radio/ListItemRadio.js +0 -30
  180. package/build/listItem/Radio/ListItemRadio.js.map +0 -1
  181. package/build/listItem/Radio/ListItemRadio.mjs +0 -28
  182. package/build/listItem/Radio/ListItemRadio.mjs.map +0 -1
  183. package/build/listItem/Switch/ListItemSwitch.js +0 -30
  184. package/build/listItem/Switch/ListItemSwitch.js.map +0 -1
  185. package/build/listItem/Switch/ListItemSwitch.mjs +0 -28
  186. package/build/listItem/Switch/ListItemSwitch.mjs.map +0 -1
  187. package/build/listItem/_stories/images/landscape.svg +0 -1
  188. package/build/listItem/_stories/images/portrait.svg +0 -1
  189. package/build/listItem/useListItemControl.js +0 -22
  190. package/build/listItem/useListItemControl.js.map +0 -1
  191. package/build/listItem/useListItemControl.mjs +0 -20
  192. package/build/listItem/useListItemControl.mjs.map +0 -1
  193. package/build/listItem/useListItemMedia.js +0 -21
  194. package/build/listItem/useListItemMedia.js.map +0 -1
  195. package/build/listItem/useListItemMedia.mjs +0 -19
  196. package/build/listItem/useListItemMedia.mjs.map +0 -1
  197. package/build/styles/listItem/ListItem.css +0 -709
  198. package/build/styles/listItem/ListItem.grid.css +0 -368
  199. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts +0 -15
  200. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts.map +0 -1
  201. package/build/types/listItem/AdditionalInfo/index.d.ts +0 -3
  202. package/build/types/listItem/AdditionalInfo/index.d.ts.map +0 -1
  203. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts +0 -18
  204. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +0 -1
  205. package/build/types/listItem/AvatarLayout/index.d.ts +0 -3
  206. package/build/types/listItem/AvatarLayout/index.d.ts.map +0 -1
  207. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts +0 -16
  208. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +0 -1
  209. package/build/types/listItem/AvatarView/index.d.ts +0 -3
  210. package/build/types/listItem/AvatarView/index.d.ts.map +0 -1
  211. package/build/types/listItem/Button/ListItemButton.d.ts +0 -20
  212. package/build/types/listItem/Button/ListItemButton.d.ts.map +0 -1
  213. package/build/types/listItem/Button/index.d.ts +0 -3
  214. package/build/types/listItem/Button/index.d.ts.map +0 -1
  215. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts +0 -14
  216. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts.map +0 -1
  217. package/build/types/listItem/Checkbox/index.d.ts +0 -3
  218. package/build/types/listItem/Checkbox/index.d.ts.map +0 -1
  219. package/build/types/listItem/IconButton/ListItemIconButton.d.ts +0 -18
  220. package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +0 -1
  221. package/build/types/listItem/IconButton/index.d.ts +0 -3
  222. package/build/types/listItem/IconButton/index.d.ts.map +0 -1
  223. package/build/types/listItem/Image/ListItemImage.d.ts +0 -25
  224. package/build/types/listItem/Image/ListItemImage.d.ts.map +0 -1
  225. package/build/types/listItem/Image/index.d.ts +0 -3
  226. package/build/types/listItem/Image/index.d.ts.map +0 -1
  227. package/build/types/listItem/ListItem.d.ts +0 -113
  228. package/build/types/listItem/ListItem.d.ts.map +0 -1
  229. package/build/types/listItem/ListItemContext.d.ts +0 -22
  230. package/build/types/listItem/ListItemContext.d.ts.map +0 -1
  231. package/build/types/listItem/Navigation/ListItemNavigation.d.ts +0 -15
  232. package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +0 -1
  233. package/build/types/listItem/Navigation/index.d.ts +0 -3
  234. package/build/types/listItem/Navigation/index.d.ts.map +0 -1
  235. package/build/types/listItem/Prompt/ListItemPrompt.d.ts +0 -16
  236. package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +0 -1
  237. package/build/types/listItem/Prompt/index.d.ts +0 -3
  238. package/build/types/listItem/Prompt/index.d.ts.map +0 -1
  239. package/build/types/listItem/Radio/ListItemRadio.d.ts +0 -14
  240. package/build/types/listItem/Radio/ListItemRadio.d.ts.map +0 -1
  241. package/build/types/listItem/Radio/index.d.ts +0 -3
  242. package/build/types/listItem/Radio/index.d.ts.map +0 -1
  243. package/build/types/listItem/Switch/ListItemSwitch.d.ts +0 -14
  244. package/build/types/listItem/Switch/ListItemSwitch.d.ts.map +0 -1
  245. package/build/types/listItem/Switch/index.d.ts +0 -3
  246. package/build/types/listItem/Switch/index.d.ts.map +0 -1
  247. package/build/types/listItem/_stories/subcomponents.d.ts +0 -18
  248. package/build/types/listItem/_stories/subcomponents.d.ts.map +0 -1
  249. package/build/types/listItem/index.d.ts +0 -14
  250. package/build/types/listItem/index.d.ts.map +0 -1
  251. package/build/types/listItem/test-utils.d.ts +0 -7
  252. package/build/types/listItem/test-utils.d.ts.map +0 -1
  253. package/build/types/listItem/useListItemControl.d.ts +0 -5
  254. package/build/types/listItem/useListItemControl.d.ts.map +0 -1
  255. package/build/types/listItem/useListItemMedia.d.ts +0 -6
  256. package/build/types/listItem/useListItemMedia.d.ts.map +0 -1
  257. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.spec.tsx +0 -56
  258. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +0 -145
  259. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.tsx +0 -36
  260. package/src/listItem/AdditionalInfo/index.ts +0 -2
  261. package/src/listItem/AvatarLayout/ListItemAvatarLayout.spec.tsx +0 -59
  262. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +0 -118
  263. package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +0 -27
  264. package/src/listItem/AvatarLayout/index.ts +0 -2
  265. package/src/listItem/AvatarView/ListItemAvatarView.spec.tsx +0 -75
  266. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +0 -318
  267. package/src/listItem/AvatarView/ListItemAvatarView.tsx +0 -27
  268. package/src/listItem/AvatarView/index.ts +0 -2
  269. package/src/listItem/Button/ListItemButton.spec.tsx +0 -68
  270. package/src/listItem/Button/ListItemButton.story.tsx +0 -408
  271. package/src/listItem/Button/ListItemButton.tsx +0 -56
  272. package/src/listItem/Button/index.ts +0 -2
  273. package/src/listItem/Checkbox/ListItemCheckbox.spec.tsx +0 -82
  274. package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +0 -107
  275. package/src/listItem/Checkbox/ListItemCheckbox.tsx +0 -33
  276. package/src/listItem/Checkbox/index.ts +0 -2
  277. package/src/listItem/IconButton/ListItemIconButton.spec.tsx +0 -119
  278. package/src/listItem/IconButton/ListItemIconButton.story.tsx +0 -236
  279. package/src/listItem/IconButton/ListItemIconButton.tsx +0 -56
  280. package/src/listItem/IconButton/index.ts +0 -2
  281. package/src/listItem/Image/ListItemImage.spec.tsx +0 -30
  282. package/src/listItem/Image/ListItemImage.story.tsx +0 -56
  283. package/src/listItem/Image/ListItemImage.tsx +0 -48
  284. package/src/listItem/Image/index.ts +0 -2
  285. package/src/listItem/ListItem.css +0 -709
  286. package/src/listItem/ListItem.grid.css +0 -368
  287. package/src/listItem/ListItem.grid.less +0 -620
  288. package/src/listItem/ListItem.less +0 -346
  289. package/src/listItem/ListItem.spec.tsx +0 -1496
  290. package/src/listItem/ListItem.tsx +0 -441
  291. package/src/listItem/ListItemContext.tsx +0 -27
  292. package/src/listItem/Navigation/ListItemNavigation.spec.tsx +0 -59
  293. package/src/listItem/Navigation/ListItemNavigation.story.tsx +0 -106
  294. package/src/listItem/Navigation/ListItemNavigation.tsx +0 -40
  295. package/src/listItem/Navigation/index.ts +0 -2
  296. package/src/listItem/Prompt/ListItemPrompt.spec.tsx +0 -36
  297. package/src/listItem/Prompt/ListItemPrompt.story.tsx +0 -201
  298. package/src/listItem/Prompt/ListItemPrompt.tsx +0 -32
  299. package/src/listItem/Prompt/index.ts +0 -2
  300. package/src/listItem/Radio/ListItemRadio.spec.tsx +0 -66
  301. package/src/listItem/Radio/ListItemRadio.story.tsx +0 -98
  302. package/src/listItem/Radio/ListItemRadio.tsx +0 -33
  303. package/src/listItem/Radio/index.ts +0 -2
  304. package/src/listItem/Switch/ListItemSwitch.spec.tsx +0 -47
  305. package/src/listItem/Switch/ListItemSwitch.story.tsx +0 -69
  306. package/src/listItem/Switch/ListItemSwitch.tsx +0 -33
  307. package/src/listItem/Switch/index.ts +0 -2
  308. package/src/listItem/_stories/ListItem.focus.test.story.tsx +0 -250
  309. package/src/listItem/_stories/ListItem.layout.test.story.tsx +0 -338
  310. package/src/listItem/_stories/ListItem.story.tsx +0 -670
  311. package/src/listItem/_stories/ListItem.variants.test.story.tsx +0 -271
  312. package/src/listItem/_stories/images/landscape.svg +0 -1
  313. package/src/listItem/_stories/images/portrait.svg +0 -1
  314. package/src/listItem/_stories/subcomponents.tsx +0 -139
  315. package/src/listItem/index.ts +0 -14
  316. package/src/listItem/test-utils.tsx +0 -33
  317. package/src/listItem/useListItemControl.tsx +0 -18
  318. package/src/listItem/useListItemMedia.tsx +0 -13
@@ -1,408 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import { fn } from 'storybook/test';
3
- import { Freeze, ArrowRight } from '@transferwise/icons';
4
- import { ListItem } from '../ListItem';
5
- import {
6
- SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
7
- SB_LIST_ITEM_MEDIA as MEDIA,
8
- } from '../_stories/subcomponents';
9
- import type { ListItemButtonProps } from './ListItemButton';
10
-
11
- /**
12
- * Convenience controls for previewing rich markup,
13
- * not otherwise possible via Storybook
14
- */
15
- type PreviewStoryArgs = ListItemButtonProps & {
16
- previewAddonStart: boolean | ListItemButtonProps['addonStart'];
17
- previewAddonEnd: boolean | ListItemButtonProps['addonEnd'];
18
- };
19
-
20
- const previewArgTypes = {
21
- previewAddonStart: {
22
- control: 'boolean',
23
- name: 'Preview with `addonStart`',
24
- mapping: {
25
- true: { type: 'icon', value: <Freeze /> },
26
- },
27
- description: '**NB:** ListItem.Button only supports icon addons.',
28
- table: {
29
- category: 'Preview options',
30
- type: {
31
- summary: undefined,
32
- },
33
- },
34
- },
35
- previewAddonEnd: {
36
- control: 'boolean',
37
- name: 'Preview with `addonEnd`',
38
- mapping: {
39
- true: { type: 'icon', value: <ArrowRight /> },
40
- },
41
- description: '**NB:** ListItem.Button only supports icon addons.',
42
- table: {
43
- category: 'Preview options',
44
- type: {
45
- summary: undefined,
46
- },
47
- },
48
- },
49
- } as const;
50
-
51
- const getPropsForPreview = (args: PreviewStoryArgs) => {
52
- const { previewAddonStart, previewAddonEnd, ...props } = args as {
53
- previewAddonStart: ListItemButtonProps['addonStart'];
54
- previewAddonEnd: ListItemButtonProps['addonEnd'];
55
- [key: string]: any;
56
- };
57
-
58
- return [
59
- props,
60
- {
61
- addonStart: previewAddonStart,
62
- addonEnd: previewAddonEnd,
63
- },
64
- ] as const;
65
- };
66
-
67
- const meta: Meta<typeof ListItem.Button> = {
68
- component: ListItem.Button,
69
- title: 'Content/ListItem/ListItem.Button',
70
- parameters: {
71
- docs: {
72
- toc: true,
73
- },
74
- },
75
- args: {
76
- partiallyInteractive: false,
77
- priority: 'secondary-neutral',
78
- sentiment: undefined,
79
- loading: undefined,
80
- href: undefined,
81
- target: undefined,
82
- as: undefined,
83
- addonStart: undefined,
84
- addonEnd: undefined,
85
- className: undefined,
86
- children: 'Click me',
87
- onClick: fn(),
88
- },
89
- argTypes: {
90
- children: {
91
- table: {
92
- type: { summary: 'ReactNode' },
93
- },
94
- },
95
- loading: {
96
- control: 'boolean',
97
- description: 'Toggles the loading state',
98
- },
99
- priority: {
100
- control: 'radio',
101
- options: ['unset (undefined)', 'primary', 'secondary', 'secondary-neutral', 'tertiary'],
102
- mapping: {
103
- 'unset (undefined)': undefined,
104
- },
105
- description: 'Sets a visual hierarchy amongst the buttons displayed on the screen',
106
- },
107
- sentiment: {
108
- options: ['unset (undefined)', 'default', 'negative'],
109
- mapping: {
110
- 'unset (undefined)': undefined,
111
- },
112
- description:
113
- 'Sets a visual hierarchy amongst the buttons displayed on the screen. <br /> **NB:** `negative` variant only affects the `primary` and `secondary` priorities.',
114
- },
115
- href: {
116
- control: 'text',
117
- description: 'If set, the component will render as an HTML anchor.',
118
- },
119
- target: {
120
- control: 'select',
121
- options: [undefined, '_blank', '_self', '_parent', '_top'],
122
- description:
123
- 'The `target` attribute for HTML anchor. If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.',
124
- },
125
- addonStart: {
126
- description: 'Icon accessory to be displayed before the label',
127
- },
128
- addonEnd: {
129
- description: 'Icon accessory to be displayed after the label',
130
- },
131
- },
132
- } satisfies Meta<ListItemButtonProps>;
133
-
134
- export default meta;
135
-
136
- type Story = StoryObj<ListItemButtonProps>;
137
-
138
- export const Playground: StoryObj<PreviewStoryArgs> = {
139
- tags: ['!autodocs'],
140
- render: (args: PreviewStoryArgs) => {
141
- const [props, previewProps] = getPropsForPreview(args);
142
-
143
- return (
144
- <ListItem
145
- title="List item title"
146
- subtitle="Subtitle goes here"
147
- media={MEDIA.avatarSingle}
148
- control={<ListItem.Button {...props} {...previewProps} />}
149
- additionalInfo={INFO.nonInteractive}
150
- />
151
- );
152
- },
153
- args: {
154
- previewAddonStart: false,
155
- previewAddonEnd: false,
156
- },
157
- argTypes: {
158
- ...previewArgTypes,
159
- },
160
- };
161
-
162
- /**
163
- * By default, ListItem is fully interactive, which means its whole surface is clickable
164
- * and triggers the control. To remain WCAG-compliant there can be no nested interactive
165
- * elements inside the item.<br />
166
- *
167
- * To work around this limitation, this control also allows for a partially interactive mode,
168
- * which can be enabled via `partiallyInteractive` prop. Once set, only the control will
169
- * remain interactive, which allows for interactive element to be attached to the
170
- * `ListItem.AdditionalInfo`. This allows for more complex layouts while still providing a
171
- * clear, accessible action point for users. <br />
172
- *
173
- * If you still require a fully interactive ListItem, you can alternatively use `ListItem.Prompt`
174
- * which allows for a single instance of a link or an inline button.
175
- *
176
- * Refer to the [design documentation](https://wise.design/components/list-item#interaction) for details.
177
- */
178
- export const Interactivity: Story = {
179
- args: {
180
- children: 'Action',
181
- },
182
- render: (args: ListItemButtonProps) => {
183
- return (
184
- <ol className="list-unstyled">
185
- <ListItem
186
- title="Fully interactive ListItem"
187
- subtitle="Button in fully interactive context"
188
- media={MEDIA.avatarSingle}
189
- control={<ListItem.Button {...args} />}
190
- />
191
-
192
- <ListItem
193
- title="Partially interactive ListItem"
194
- subtitle="Button in partially interactive context"
195
- media={MEDIA.avatarSingle}
196
- control={<ListItem.Button {...args} partiallyInteractive />}
197
- />
198
- </ol>
199
- );
200
- },
201
- };
202
-
203
- /**
204
- * If `href` prop is set, the component will be automatically rendered as an HTML anchor element.
205
- */
206
- export const AsAnchor: Story = {
207
- args: {
208
- children: 'Visit link',
209
- href: 'https://wise.com',
210
- target: '_blank',
211
- },
212
- render: (args: ListItemButtonProps) => {
213
- return (
214
- <ListItem
215
- title="List item with button link"
216
- subtitle="Button rendered as anchor element"
217
- media={MEDIA.avatarSingle}
218
- control={<ListItem.Button {...args} />}
219
- additionalInfo={INFO.nonInteractive}
220
- />
221
- );
222
- },
223
- };
224
-
225
- /**
226
- * There are two different types of button – default and negative – designed to emphasise the nature of the action. <br />
227
- * **NB:** Sentiment only applies to `primary` and `secondary` priorities. <br />
228
- * [Design documentation](https://wise.design/components/button#types)
229
- */
230
- export const Sentiment: Story = {
231
- render: (args: ListItemButtonProps) => {
232
- return (
233
- <ol className="list-unstyled">
234
- <ListItem
235
- title="Default Sentiment - Primary"
236
- subtitle="Default sentiment with primary priority"
237
- media={MEDIA.avatarSingle}
238
- control={
239
- <ListItem.Button {...args} priority="primary">
240
- Default Sentiment
241
- </ListItem.Button>
242
- }
243
- />
244
- <ListItem
245
- title="Negative Sentiment - Primary"
246
- subtitle="Negative sentiment with primary priority"
247
- media={MEDIA.avatarSingle}
248
- control={
249
- <ListItem.Button {...args} priority="primary" sentiment="negative">
250
- Negative Sentiment
251
- </ListItem.Button>
252
- }
253
- />
254
- <ListItem
255
- title="Default Sentiment - Secondary"
256
- subtitle="Default sentiment with secondary priority"
257
- media={MEDIA.avatarSingle}
258
- control={
259
- <ListItem.Button {...args} priority="secondary">
260
- Default Sentiment
261
- </ListItem.Button>
262
- }
263
- />
264
- <ListItem
265
- title="Negative Sentiment - Secondary"
266
- subtitle="Negative sentiment with secondary priority"
267
- media={MEDIA.avatarSingle}
268
- control={
269
- <ListItem.Button {...args} priority="secondary" sentiment="negative">
270
- Negative Sentiment
271
- </ListItem.Button>
272
- }
273
- />
274
- </ol>
275
- );
276
- },
277
- args: {
278
- children: 'Button text',
279
- },
280
- };
281
-
282
- /**
283
- * Priorities set a visual hierarchy amongst the buttons displayed on the
284
- * screen to help more important buttons to take precedence over others. <br />
285
- * [Design documentation](https://wise.design/components/button#priorities)
286
- */
287
- export const Priority: Story = {
288
- render: (args: ListItemButtonProps) => {
289
- return (
290
- <ol className="list-unstyled">
291
- <ListItem
292
- title="Primary Priority"
293
- subtitle="Primary priority (default)"
294
- media={MEDIA.avatarSingle}
295
- control={
296
- <ListItem.Button {...args} priority="primary">
297
- Primary Priority
298
- </ListItem.Button>
299
- }
300
- />
301
- <ListItem
302
- title="Secondary Priority"
303
- subtitle="Secondary priority"
304
- media={MEDIA.avatarSingle}
305
- control={
306
- <ListItem.Button {...args} priority="secondary">
307
- Secondary Priority
308
- </ListItem.Button>
309
- }
310
- />
311
- <ListItem
312
- title="Secondary Neutral Priority"
313
- subtitle="Secondary neutral priority"
314
- media={MEDIA.avatarSingle}
315
- control={
316
- <ListItem.Button {...args} priority="secondary-neutral">
317
- Secondary Neutral Priority
318
- </ListItem.Button>
319
- }
320
- />
321
- <ListItem
322
- title="Tertiary Priority"
323
- subtitle="Tertiary priority"
324
- media={MEDIA.avatarSingle}
325
- control={
326
- <ListItem.Button {...args} priority="tertiary">
327
- Tertiary Priority
328
- </ListItem.Button>
329
- }
330
- />
331
- </ol>
332
- );
333
- },
334
- args: {
335
- children: 'Button text',
336
- },
337
- };
338
-
339
- /**
340
- * Button in loading state.
341
- */
342
- export const Loading: Story = {
343
- render: (args: ListItemButtonProps) => {
344
- return (
345
- <ListItem
346
- title="Loading Button"
347
- subtitle="Button in loading state"
348
- media={MEDIA.avatarSingle}
349
- control={<ListItem.Button {...args}>Loading Button</ListItem.Button>}
350
- additionalInfo={INFO.nonInteractive}
351
- />
352
- );
353
- },
354
- args: {
355
- loading: true,
356
- },
357
- };
358
-
359
- const addonProps = {
360
- addonStart: { type: 'icon', value: <Freeze /> },
361
- addonEnd: { type: 'icon', value: <ArrowRight /> },
362
- } as const;
363
-
364
- /**
365
- * Icons can be displayed before and after the button label. <br />
366
- * **NB:** ListItem.Button only supports icon addons.
367
- */
368
- export const WithIcons: Story = {
369
- render: (args: ListItemButtonProps) => {
370
- return (
371
- <ol className="list-unstyled">
372
- <ListItem
373
- title="With Start Icon"
374
- subtitle="Button with icon before the label"
375
- media={MEDIA.avatarSingle}
376
- control={
377
- <ListItem.Button {...args} addonStart={addonProps.addonStart}>
378
- With start icon
379
- </ListItem.Button>
380
- }
381
- />
382
- <ListItem
383
- title="With End Icon"
384
- subtitle="Button with icon after the label"
385
- media={MEDIA.avatarSingle}
386
- control={
387
- <ListItem.Button {...args} addonEnd={addonProps.addonEnd}>
388
- With end icon
389
- </ListItem.Button>
390
- }
391
- />
392
- <ListItem
393
- title="With Both Icons"
394
- subtitle="Button with icons before and after the label"
395
- media={MEDIA.avatarSingle}
396
- control={
397
- <ListItem.Button {...args} {...addonProps}>
398
- With both icons
399
- </ListItem.Button>
400
- }
401
- />
402
- </ol>
403
- );
404
- },
405
- args: {
406
- children: 'Button text',
407
- },
408
- };
@@ -1,56 +0,0 @@
1
- import { useContext } from 'react';
2
- import { clsx } from 'clsx';
3
- import ButtonComp, { type ButtonAddonIcon, type NewButtonProps } from '../../button';
4
- import { useListItemControl } from '../useListItemControl';
5
- import { ListItemContext } from '../ListItemContext';
6
-
7
- export type ListItemButtonProps = Omit<
8
- NewButtonProps,
9
- 'v2' | 'size' | 'disabled' | 'block' | 'addonStart'
10
- > & {
11
- /**
12
- * Toggles the [interactivity strategy](https://storybook.wise.design/?path=/docs/content-listitem--docs#interactivity) for the whole ListItem.
13
- */
14
- partiallyInteractive?: boolean;
15
- addonStart?: ButtonAddonIcon;
16
- };
17
-
18
- /**
19
- * This component allows for rendering a Button control. It's a thin wrapper around the
20
- * [Button component](https://storybook.wise.design/?path=/docs/content-button--docs), but offers only
21
- * a subset of its features in line with the ListItem's constraints. <br />
22
- * <br />
23
- * Please refer to the [Design documentation](https://wise.design/components/list-item---button) for details.
24
- */
25
- export const Button = ({
26
- priority = 'secondary-neutral',
27
- partiallyInteractive,
28
- ...props
29
- }: ListItemButtonProps) => {
30
- const { baseItemProps } = useListItemControl('button', { partiallyInteractive, ...props });
31
- const { ids, describedByIds } = useContext(ListItemContext);
32
-
33
- const commonProps = {
34
- ...props,
35
- className: clsx(
36
- 'wds-list-item-control',
37
- !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',
38
- ),
39
- id: ids.control,
40
- priority,
41
- v2: true,
42
- size: 'sm',
43
- disabled: baseItemProps.disabled,
44
- };
45
-
46
- const buttonContentId = props.href || partiallyInteractive ? '' : `${ids.control}_content`;
47
-
48
- return (
49
- <ButtonComp
50
- aria-describedby={`${buttonContentId} ${describedByIds}`}
51
- {...(commonProps as NewButtonProps)}
52
- />
53
- );
54
- };
55
-
56
- Button.displayName = 'ListItem.Button';
@@ -1,2 +0,0 @@
1
- export type { ListItemButtonProps } from './ListItemButton';
2
- export { Button } from './ListItemButton';
@@ -1,82 +0,0 @@
1
- import { render, screen } from '../../test-utils';
2
- import userEvent from '@testing-library/user-event';
3
- import { ListItem, type Props as ListItemProps } from '../ListItem';
4
-
5
- describe('ListItem.Checkbox', () => {
6
- const renderWith = (overrides: Partial<ListItemProps> = {}) =>
7
- render(<ListItem title="Test title" {...overrides} />);
8
-
9
- it('renders checkbox', () => {
10
- renderWith({ control: <ListItem.Checkbox /> });
11
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
12
- });
13
-
14
- describe('checked state', () => {
15
- it('reflects checked state', () => {
16
- renderWith({ control: <ListItem.Checkbox checked onChange={jest.fn()} /> });
17
- expect(screen.getByRole('checkbox')).toBeChecked();
18
- });
19
-
20
- it('reflects unchecked state', () => {
21
- renderWith({ control: <ListItem.Checkbox checked={false} onChange={jest.fn()} /> });
22
- expect(screen.getByRole('checkbox')).not.toBeChecked();
23
- });
24
-
25
- it('supports indeterminate state', () => {
26
- renderWith({ control: <ListItem.Checkbox indeterminate /> });
27
- expect(screen.getByRole('checkbox')).toHaveProperty('indeterminate', true);
28
- });
29
- });
30
-
31
- describe('interactivity', () => {
32
- it('handles onChange events', async () => {
33
- const handleChange = jest.fn();
34
- renderWith({ control: <ListItem.Checkbox checked={false} onChange={handleChange} /> });
35
-
36
- await userEvent.click(screen.getByRole('checkbox'));
37
- expect(handleChange).toHaveBeenCalledTimes(1);
38
- });
39
-
40
- it('is disabled when ListItem is disabled', () => {
41
- renderWith({
42
- disabled: true,
43
- control: <ListItem.Checkbox checked={false} onChange={jest.fn()} />,
44
- });
45
-
46
- expect(screen.getByRole('checkbox')).toBeDisabled();
47
- });
48
-
49
- it('handles onFocus events', async () => {
50
- const handleFocus = jest.fn();
51
- renderWith({
52
- control: <ListItem.Checkbox checked={false} onFocus={handleFocus} onChange={() => {}} />,
53
- });
54
-
55
- await userEvent.tab();
56
- expect(handleFocus).toHaveBeenCalledTimes(1);
57
- });
58
-
59
- it('handles onBlur events', async () => {
60
- const handleBlur = jest.fn();
61
- renderWith({
62
- control: <ListItem.Checkbox checked={false} onBlur={handleBlur} onChange={() => {}} />,
63
- });
64
-
65
- const checkbox = screen.getByRole('checkbox');
66
- await userEvent.click(checkbox);
67
- await userEvent.tab();
68
- expect(handleBlur).toHaveBeenCalledTimes(1);
69
- });
70
- });
71
-
72
- it('supports name and value attributes', () => {
73
- const checkboxName = 'test-checkbox';
74
- const checkboxValue = 'test-value';
75
- renderWith({ control: <ListItem.Checkbox name={checkboxName} value={checkboxValue} /> });
76
-
77
- const checkbox = screen.getByRole('checkbox');
78
- expect(checkbox).toHaveAttribute('name', checkboxName);
79
- // eslint-disable-next-line jest-dom/prefer-to-have-value
80
- expect(checkbox).toHaveAttribute('value', checkboxValue);
81
- });
82
- });
@@ -1,107 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import { useState } from 'react';
3
- import { ListItem } from '../ListItem';
4
- import {
5
- SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
6
- SB_LIST_ITEM_MEDIA as MEDIA,
7
- } from '../_stories/subcomponents';
8
- import type { ListItemCheckboxProps } from './ListItemCheckbox';
9
- import { fn } from 'storybook/test';
10
-
11
- const meta: Meta<ListItemCheckboxProps> = {
12
- component: ListItem.Checkbox,
13
- title: 'Content/ListItem/ListItem.Checkbox',
14
- parameters: {
15
- docs: {
16
- toc: true,
17
- },
18
- },
19
- args: {
20
- checked: false,
21
- indeterminate: false,
22
- value: 'checkbox',
23
- name: 'checkbox',
24
- onChange: fn(),
25
- onFocus: fn(),
26
- onBlur: fn(),
27
- },
28
- argTypes: {
29
- checked: {
30
- control: 'boolean',
31
- },
32
- indeterminate: {
33
- control: 'boolean',
34
- },
35
- },
36
- } satisfies Meta<ListItemCheckboxProps>;
37
-
38
- export default meta;
39
-
40
- type Story = StoryObj<ListItemCheckboxProps>;
41
-
42
- export const Playground: Story = {
43
- tags: ['!autodocs'],
44
- render: (args: ListItemCheckboxProps) => {
45
- return (
46
- <ListItem
47
- title="List item with checkbox"
48
- subtitle="Select this option"
49
- media={MEDIA.avatarSingle}
50
- control={<ListItem.Checkbox {...args} />}
51
- additionalInfo={INFO.nonInteractive}
52
- />
53
- );
54
- },
55
- };
56
-
57
- /**
58
- * Checkbox controls demonstrate different states including checked, unchecked, and indeterminate.
59
- */
60
- export const States: Story = {
61
- render: function Render() {
62
- const [isChecked0, setisChecked0] = useState(false);
63
- const [isChecked1, setisChecked1] = useState(true);
64
- const [isChecked2, setisChecked2] = useState(false);
65
-
66
- return (
67
- <ol className="list-unstyled">
68
- <ListItem
69
- control={
70
- <ListItem.Checkbox
71
- checked={isChecked0}
72
- onChange={() => setisChecked0((current) => !current)}
73
- />
74
- }
75
- title="Unchecked option"
76
- subtitle="This option is not selected"
77
- media={MEDIA.avatarSingle}
78
- />
79
-
80
- <ListItem
81
- control={
82
- <ListItem.Checkbox
83
- checked={isChecked1}
84
- onChange={() => setisChecked1((current) => !current)}
85
- />
86
- }
87
- title="Checked option"
88
- subtitle="This option is selected"
89
- media={MEDIA.avatarSingle}
90
- />
91
-
92
- <ListItem
93
- control={
94
- <ListItem.Checkbox
95
- checked={isChecked2}
96
- indeterminate
97
- onChange={() => setisChecked2((current) => !current)}
98
- />
99
- }
100
- title="Indeterminate option"
101
- subtitle="This option is partially selected"
102
- media={MEDIA.avatarSingle}
103
- />
104
- </ol>
105
- );
106
- },
107
- };
@@ -1,33 +0,0 @@
1
- import { useContext } from 'react';
2
- import CheckboxButton, { type CheckboxButtonProps } from '../../checkboxButton/CheckboxButton';
3
- import { useListItemControl } from '../useListItemControl';
4
- import { ListItemContext } from '../ListItemContext';
5
-
6
- export type ListItemCheckboxProps = Pick<
7
- CheckboxButtonProps,
8
- 'checked' | 'indeterminate' | 'onChange' | 'onBlur' | 'onFocus' | 'value' | 'name'
9
- >;
10
-
11
- /**
12
- * This component allows for rendering a checkbox control within a fully interactive ListItem. <br />It's a thin wrapper around the
13
- * [CheckboxButton component](https://storybook.wise.design/?path=/docs/actions-checkboxbutton--docs),
14
- * but offers only a subset of its features in line with the ListItem's constraints. <br />
15
- *
16
- * Please refer to the [Design documentation](https://wise.design/components/list-item---checkbox) for details.
17
- */
18
- export const Checkbox = function (props: ListItemCheckboxProps) {
19
- const { baseItemProps } = useListItemControl('checkbox', { ...props });
20
- const { ids, describedByIds } = useContext(ListItemContext);
21
-
22
- return (
23
- <CheckboxButton
24
- {...props}
25
- className="wds-list-item-control"
26
- disabled={baseItemProps.disabled}
27
- id={ids.control}
28
- aria-describedby={describedByIds}
29
- />
30
- );
31
- };
32
-
33
- Checkbox.displayName = 'ListItem.Checkbox';
@@ -1,2 +0,0 @@
1
- export type { ListItemCheckboxProps } from './ListItemCheckbox';
2
- export { Checkbox } from './ListItemCheckbox';