@transferwise/components 0.0.0-experimental-29d0f94 → 0.0.0-experimental-4b1de0a

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 (319) hide show
  1. package/build/button/Button.js +1 -0
  2. package/build/button/Button.js.map +1 -1
  3. package/build/button/Button.mjs +1 -0
  4. package/build/button/Button.mjs.map +1 -1
  5. package/build/common/RadioButton/RadioButton.js +5 -2
  6. package/build/common/RadioButton/RadioButton.js.map +1 -1
  7. package/build/common/RadioButton/RadioButton.mjs +5 -2
  8. package/build/common/RadioButton/RadioButton.mjs.map +1 -1
  9. package/build/common/initials.js +1 -4
  10. package/build/common/initials.js.map +1 -1
  11. package/build/common/initials.mjs +1 -4
  12. package/build/common/initials.mjs.map +1 -1
  13. package/build/i18n/de.json +0 -2
  14. package/build/i18n/de.json.js +0 -2
  15. package/build/i18n/de.json.js.map +1 -1
  16. package/build/i18n/de.json.mjs +0 -2
  17. package/build/i18n/de.json.mjs.map +1 -1
  18. package/build/i18n/fr.json +0 -2
  19. package/build/i18n/fr.json.js +0 -2
  20. package/build/i18n/fr.json.js.map +1 -1
  21. package/build/i18n/fr.json.mjs +0 -2
  22. package/build/i18n/fr.json.mjs.map +1 -1
  23. package/build/i18n/hu.json +0 -2
  24. package/build/i18n/hu.json.js +0 -2
  25. package/build/i18n/hu.json.js.map +1 -1
  26. package/build/i18n/hu.json.mjs +0 -2
  27. package/build/i18n/hu.json.mjs.map +1 -1
  28. package/build/i18n/it.json +0 -2
  29. package/build/i18n/it.json.js +0 -2
  30. package/build/i18n/it.json.js.map +1 -1
  31. package/build/i18n/it.json.mjs +0 -2
  32. package/build/i18n/it.json.mjs.map +1 -1
  33. package/build/i18n/ja.json +0 -2
  34. package/build/i18n/ja.json.js +0 -2
  35. package/build/i18n/ja.json.js.map +1 -1
  36. package/build/i18n/ja.json.mjs +0 -2
  37. package/build/i18n/ja.json.mjs.map +1 -1
  38. package/build/i18n/pl.json +0 -2
  39. package/build/i18n/pl.json.js +0 -2
  40. package/build/i18n/pl.json.js.map +1 -1
  41. package/build/i18n/pl.json.mjs +0 -2
  42. package/build/i18n/pl.json.mjs.map +1 -1
  43. package/build/i18n/ro.json +0 -2
  44. package/build/i18n/ro.json.js +0 -2
  45. package/build/i18n/ro.json.js.map +1 -1
  46. package/build/i18n/ro.json.mjs +0 -2
  47. package/build/i18n/ro.json.mjs.map +1 -1
  48. package/build/i18n/ru.json +0 -2
  49. package/build/i18n/ru.json.js +0 -2
  50. package/build/i18n/ru.json.js.map +1 -1
  51. package/build/i18n/ru.json.mjs +0 -2
  52. package/build/i18n/ru.json.mjs.map +1 -1
  53. package/build/i18n/tr.json +0 -2
  54. package/build/i18n/tr.json.js +0 -2
  55. package/build/i18n/tr.json.js.map +1 -1
  56. package/build/i18n/tr.json.mjs +0 -2
  57. package/build/i18n/tr.json.mjs.map +1 -1
  58. package/build/i18n/zh-CN.json +0 -2
  59. package/build/i18n/zh-CN.json.js +0 -2
  60. package/build/i18n/zh-CN.json.js.map +1 -1
  61. package/build/i18n/zh-CN.json.mjs +0 -2
  62. package/build/i18n/zh-CN.json.mjs.map +1 -1
  63. package/build/i18n/zh-HK.json +0 -2
  64. package/build/i18n/zh-HK.json.js +0 -2
  65. package/build/i18n/zh-HK.json.js.map +1 -1
  66. package/build/i18n/zh-HK.json.mjs +0 -2
  67. package/build/i18n/zh-HK.json.mjs.map +1 -1
  68. package/build/iconButton/IconButton.js.map +1 -1
  69. package/build/iconButton/IconButton.mjs.map +1 -1
  70. package/build/image/Image.js.map +1 -1
  71. package/build/image/Image.mjs.map +1 -1
  72. package/build/index.js +2 -0
  73. package/build/index.js.map +1 -1
  74. package/build/index.mjs +1 -0
  75. package/build/index.mjs.map +1 -1
  76. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +56 -0
  77. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +1 -0
  78. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +54 -0
  79. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +1 -0
  80. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +23 -0
  81. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -0
  82. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +21 -0
  83. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -0
  84. package/build/listItem/AvatarView/ListItemAvatarView.js +23 -0
  85. package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -0
  86. package/build/listItem/AvatarView/ListItemAvatarView.mjs +21 -0
  87. package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -0
  88. package/build/listItem/Button/ListItemButton.js +43 -0
  89. package/build/listItem/Button/ListItemButton.js.map +1 -0
  90. package/build/listItem/Button/ListItemButton.mjs +41 -0
  91. package/build/listItem/Button/ListItemButton.mjs.map +1 -0
  92. package/build/listItem/Checkbox/ListItemCheckbox.js +30 -0
  93. package/build/listItem/Checkbox/ListItemCheckbox.js.map +1 -0
  94. package/build/listItem/Checkbox/ListItemCheckbox.mjs +28 -0
  95. package/build/listItem/Checkbox/ListItemCheckbox.mjs.map +1 -0
  96. package/build/listItem/IconButton/ListItemIconButton.js +42 -0
  97. package/build/listItem/IconButton/ListItemIconButton.js.map +1 -0
  98. package/build/listItem/IconButton/ListItemIconButton.mjs +40 -0
  99. package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -0
  100. package/build/listItem/Image/ListItemImage.js +31 -0
  101. package/build/listItem/Image/ListItemImage.js.map +1 -0
  102. package/build/listItem/Image/ListItemImage.mjs +29 -0
  103. package/build/listItem/Image/ListItemImage.mjs.map +1 -0
  104. package/build/listItem/ListItem.js +312 -0
  105. package/build/listItem/ListItem.js.map +1 -0
  106. package/build/listItem/ListItem.mjs +307 -0
  107. package/build/listItem/ListItem.mjs.map +1 -0
  108. package/build/listItem/ListItemContext.js +8 -0
  109. package/build/listItem/ListItemContext.js.map +1 -0
  110. package/build/listItem/ListItemContext.mjs +6 -0
  111. package/build/listItem/ListItemContext.mjs.map +1 -0
  112. package/build/listItem/Navigation/ListItemNavigation.js +45 -0
  113. package/build/listItem/Navigation/ListItemNavigation.js.map +1 -0
  114. package/build/listItem/Navigation/ListItemNavigation.mjs +43 -0
  115. package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -0
  116. package/build/listItem/Prompt/ListItemPrompt.js +59 -0
  117. package/build/listItem/Prompt/ListItemPrompt.js.map +1 -0
  118. package/build/listItem/Prompt/ListItemPrompt.mjs +54 -0
  119. package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -0
  120. package/build/listItem/Radio/ListItemRadio.js +30 -0
  121. package/build/listItem/Radio/ListItemRadio.js.map +1 -0
  122. package/build/listItem/Radio/ListItemRadio.mjs +28 -0
  123. package/build/listItem/Radio/ListItemRadio.mjs.map +1 -0
  124. package/build/listItem/Switch/ListItemSwitch.js +30 -0
  125. package/build/listItem/Switch/ListItemSwitch.js.map +1 -0
  126. package/build/listItem/Switch/ListItemSwitch.mjs +28 -0
  127. package/build/listItem/Switch/ListItemSwitch.mjs.map +1 -0
  128. package/build/listItem/useListItemControl.js +22 -0
  129. package/build/listItem/useListItemControl.js.map +1 -0
  130. package/build/listItem/useListItemControl.mjs +20 -0
  131. package/build/listItem/useListItemControl.mjs.map +1 -0
  132. package/build/listItem/useListItemMedia.js +21 -0
  133. package/build/listItem/useListItemMedia.js.map +1 -0
  134. package/build/listItem/useListItemMedia.mjs +19 -0
  135. package/build/listItem/useListItemMedia.mjs.map +1 -0
  136. package/build/main.css +773 -1
  137. package/build/styles/avatarView/AvatarView.css +3 -1
  138. package/build/styles/listItem/ListItem.css +770 -0
  139. package/build/styles/listItem/ListItem.grid.css +370 -0
  140. package/build/styles/main.css +773 -1
  141. package/build/switch/Switch.js +2 -0
  142. package/build/switch/Switch.js.map +1 -1
  143. package/build/switch/Switch.mjs +2 -0
  144. package/build/switch/Switch.mjs.map +1 -1
  145. package/build/test-utils/assets/placeholder-landscape.svg +1 -0
  146. package/build/test-utils/assets/placeholder-portrait.svg +1 -0
  147. package/build/types/button/Button.d.ts.map +1 -1
  148. package/build/types/button/Button.types.d.ts +1 -1
  149. package/build/types/button/Button.types.d.ts.map +1 -1
  150. package/build/types/button/index.d.ts +1 -1
  151. package/build/types/button/index.d.ts.map +1 -1
  152. package/build/types/common/RadioButton/RadioButton.d.ts +3 -1
  153. package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
  154. package/build/types/common/initials.d.ts.map +1 -1
  155. package/build/types/iconButton/IconButton.d.ts +2 -2
  156. package/build/types/iconButton/IconButton.d.ts.map +1 -1
  157. package/build/types/image/Image.d.ts +3 -0
  158. package/build/types/image/Image.d.ts.map +1 -1
  159. package/build/types/image/index.d.ts +1 -0
  160. package/build/types/image/index.d.ts.map +1 -1
  161. package/build/types/index.d.ts +2 -0
  162. package/build/types/index.d.ts.map +1 -1
  163. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts +15 -0
  164. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts.map +1 -0
  165. package/build/types/listItem/AdditionalInfo/index.d.ts +3 -0
  166. package/build/types/listItem/AdditionalInfo/index.d.ts.map +1 -0
  167. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts +18 -0
  168. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -0
  169. package/build/types/listItem/AvatarLayout/index.d.ts +3 -0
  170. package/build/types/listItem/AvatarLayout/index.d.ts.map +1 -0
  171. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts +16 -0
  172. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -0
  173. package/build/types/listItem/AvatarView/index.d.ts +3 -0
  174. package/build/types/listItem/AvatarView/index.d.ts.map +1 -0
  175. package/build/types/listItem/Button/ListItemButton.d.ts +20 -0
  176. package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -0
  177. package/build/types/listItem/Button/index.d.ts +3 -0
  178. package/build/types/listItem/Button/index.d.ts.map +1 -0
  179. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts +14 -0
  180. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts.map +1 -0
  181. package/build/types/listItem/Checkbox/index.d.ts +3 -0
  182. package/build/types/listItem/Checkbox/index.d.ts.map +1 -0
  183. package/build/types/listItem/IconButton/ListItemIconButton.d.ts +18 -0
  184. package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -0
  185. package/build/types/listItem/IconButton/index.d.ts +3 -0
  186. package/build/types/listItem/IconButton/index.d.ts.map +1 -0
  187. package/build/types/listItem/Image/ListItemImage.d.ts +25 -0
  188. package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -0
  189. package/build/types/listItem/Image/index.d.ts +3 -0
  190. package/build/types/listItem/Image/index.d.ts.map +1 -0
  191. package/build/types/listItem/ListItem.d.ts +113 -0
  192. package/build/types/listItem/ListItem.d.ts.map +1 -0
  193. package/build/types/listItem/ListItemContext.d.ts +22 -0
  194. package/build/types/listItem/ListItemContext.d.ts.map +1 -0
  195. package/build/types/listItem/Navigation/ListItemNavigation.d.ts +15 -0
  196. package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -0
  197. package/build/types/listItem/Navigation/index.d.ts +3 -0
  198. package/build/types/listItem/Navigation/index.d.ts.map +1 -0
  199. package/build/types/listItem/Prompt/ListItemPrompt.d.ts +16 -0
  200. package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -0
  201. package/build/types/listItem/Prompt/index.d.ts +3 -0
  202. package/build/types/listItem/Prompt/index.d.ts.map +1 -0
  203. package/build/types/listItem/Radio/ListItemRadio.d.ts +14 -0
  204. package/build/types/listItem/Radio/ListItemRadio.d.ts.map +1 -0
  205. package/build/types/listItem/Radio/index.d.ts +3 -0
  206. package/build/types/listItem/Radio/index.d.ts.map +1 -0
  207. package/build/types/listItem/Switch/ListItemSwitch.d.ts +14 -0
  208. package/build/types/listItem/Switch/ListItemSwitch.d.ts.map +1 -0
  209. package/build/types/listItem/Switch/index.d.ts +3 -0
  210. package/build/types/listItem/Switch/index.d.ts.map +1 -0
  211. package/build/types/listItem/_stories/helpers.d.ts +27 -0
  212. package/build/types/listItem/_stories/helpers.d.ts.map +1 -0
  213. package/build/types/listItem/_stories/subcomponents.d.ts +18 -0
  214. package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -0
  215. package/build/types/listItem/index.d.ts +14 -0
  216. package/build/types/listItem/index.d.ts.map +1 -0
  217. package/build/types/listItem/test-utils.d.ts +7 -0
  218. package/build/types/listItem/test-utils.d.ts.map +1 -0
  219. package/build/types/listItem/useListItemControl.d.ts +5 -0
  220. package/build/types/listItem/useListItemControl.d.ts.map +1 -0
  221. package/build/types/listItem/useListItemMedia.d.ts +6 -0
  222. package/build/types/listItem/useListItemMedia.d.ts.map +1 -0
  223. package/build/types/switch/Switch.d.ts +3 -1
  224. package/build/types/switch/Switch.d.ts.map +1 -1
  225. package/package.json +4 -4
  226. package/src/avatarView/AvatarView.css +3 -1
  227. package/src/avatarView/AvatarView.less +2 -1
  228. package/src/button/Button.spec.tsx +18 -0
  229. package/src/button/Button.tsx +5 -1
  230. package/src/button/Button.types.ts +1 -1
  231. package/src/button/index.ts +1 -1
  232. package/src/checkboxButton/CheckboxButton.story.tsx +4 -4
  233. package/src/common/RadioButton/RadioButton.tsx +6 -1
  234. package/src/common/initials.spec.tsx +0 -13
  235. package/src/common/initials.ts +0 -5
  236. package/src/i18n/de.json +0 -2
  237. package/src/i18n/fr.json +0 -2
  238. package/src/i18n/hu.json +0 -2
  239. package/src/i18n/it.json +0 -2
  240. package/src/i18n/ja.json +0 -2
  241. package/src/i18n/pl.json +0 -2
  242. package/src/i18n/ro.json +0 -2
  243. package/src/i18n/ru.json +0 -2
  244. package/src/i18n/tr.json +0 -2
  245. package/src/i18n/zh-CN.json +0 -2
  246. package/src/i18n/zh-HK.json +0 -2
  247. package/src/iconButton/IconButton.story.tsx +1 -1
  248. package/src/iconButton/IconButton.tsx +1 -1
  249. package/src/image/Image.tsx +3 -0
  250. package/src/image/index.ts +1 -0
  251. package/src/index.ts +2 -0
  252. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.spec.tsx +56 -0
  253. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +195 -0
  254. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.tsx +36 -0
  255. package/src/listItem/AdditionalInfo/index.ts +2 -0
  256. package/src/listItem/AvatarLayout/ListItemAvatarLayout.spec.tsx +59 -0
  257. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +121 -0
  258. package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +27 -0
  259. package/src/listItem/AvatarLayout/index.ts +2 -0
  260. package/src/listItem/AvatarView/ListItemAvatarView.spec.tsx +75 -0
  261. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +336 -0
  262. package/src/listItem/AvatarView/ListItemAvatarView.tsx +27 -0
  263. package/src/listItem/AvatarView/index.ts +2 -0
  264. package/src/listItem/Button/ListItemButton.spec.tsx +68 -0
  265. package/src/listItem/Button/ListItemButton.story.tsx +466 -0
  266. package/src/listItem/Button/ListItemButton.tsx +56 -0
  267. package/src/listItem/Button/index.ts +2 -0
  268. package/src/listItem/Checkbox/ListItemCheckbox.spec.tsx +82 -0
  269. package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +125 -0
  270. package/src/listItem/Checkbox/ListItemCheckbox.tsx +33 -0
  271. package/src/listItem/Checkbox/index.ts +2 -0
  272. package/src/listItem/IconButton/ListItemIconButton.spec.tsx +119 -0
  273. package/src/listItem/IconButton/ListItemIconButton.story.tsx +249 -0
  274. package/src/listItem/IconButton/ListItemIconButton.tsx +56 -0
  275. package/src/listItem/IconButton/index.ts +2 -0
  276. package/src/listItem/Image/ListItemImage.spec.tsx +30 -0
  277. package/src/listItem/Image/ListItemImage.story.tsx +77 -0
  278. package/src/listItem/Image/ListItemImage.tsx +48 -0
  279. package/src/listItem/Image/index.ts +2 -0
  280. package/src/listItem/ListItem.css +770 -0
  281. package/src/listItem/ListItem.grid.css +370 -0
  282. package/src/listItem/ListItem.grid.less +622 -0
  283. package/src/listItem/ListItem.less +421 -0
  284. package/src/listItem/ListItem.spec.tsx +1496 -0
  285. package/src/listItem/ListItem.tsx +447 -0
  286. package/src/listItem/ListItemContext.tsx +27 -0
  287. package/src/listItem/Navigation/ListItemNavigation.spec.tsx +59 -0
  288. package/src/listItem/Navigation/ListItemNavigation.story.tsx +109 -0
  289. package/src/listItem/Navigation/ListItemNavigation.tsx +40 -0
  290. package/src/listItem/Navigation/index.ts +2 -0
  291. package/src/listItem/Prompt/ListItemPrompt.spec.tsx +36 -0
  292. package/src/listItem/Prompt/ListItemPrompt.story.tsx +201 -0
  293. package/src/listItem/Prompt/ListItemPrompt.tsx +32 -0
  294. package/src/listItem/Prompt/index.ts +2 -0
  295. package/src/listItem/Radio/ListItemRadio.spec.tsx +66 -0
  296. package/src/listItem/Radio/ListItemRadio.story.tsx +108 -0
  297. package/src/listItem/Radio/ListItemRadio.tsx +33 -0
  298. package/src/listItem/Radio/index.ts +2 -0
  299. package/src/listItem/Switch/ListItemSwitch.spec.tsx +47 -0
  300. package/src/listItem/Switch/ListItemSwitch.story.tsx +77 -0
  301. package/src/listItem/Switch/ListItemSwitch.tsx +33 -0
  302. package/src/listItem/Switch/index.ts +2 -0
  303. package/src/listItem/_stories/ListItem.focus.test.story.tsx +250 -0
  304. package/src/listItem/_stories/ListItem.layout.test.story.tsx +353 -0
  305. package/src/listItem/_stories/ListItem.scenarios.story.tsx +209 -0
  306. package/src/listItem/_stories/ListItem.story.tsx +772 -0
  307. package/src/listItem/_stories/ListItem.variants.test.story.tsx +271 -0
  308. package/src/listItem/_stories/helpers.tsx +53 -0
  309. package/src/listItem/_stories/subcomponents.tsx +139 -0
  310. package/src/listItem/index.ts +14 -0
  311. package/src/listItem/test-utils.tsx +33 -0
  312. package/src/listItem/useListItemControl.tsx +18 -0
  313. package/src/listItem/useListItemMedia.tsx +13 -0
  314. package/src/main.css +773 -1
  315. package/src/main.less +1 -0
  316. package/src/switch/Switch.tsx +5 -1
  317. package/src/test-utils/assets/placeholder-landscape.svg +1 -0
  318. package/src/test-utils/assets/placeholder-portrait.svg +1 -0
  319. package/src/test-utils/Parameters.d.ts +0 -77
@@ -0,0 +1,250 @@
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import Link from '../../link';
3
+ import { ListItem, Props as ItemProps } from '../ListItem';
4
+ import { expect, userEvent, within, waitFor } from 'storybook/test';
5
+
6
+ const waitForFocus = async (assertion: () => Promise<void>, timeout = 3000) => {
7
+ await waitFor(assertion, { timeout });
8
+ };
9
+
10
+ const waitForListItem = async (canvas: ReturnType<typeof within>, timeout = 3000) => {
11
+ await waitFor(
12
+ async () => {
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
14
+ await expect(canvas.getByRole('listitem')).toBeInTheDocument();
15
+ },
16
+ { timeout },
17
+ );
18
+ };
19
+
20
+ export default {
21
+ component: ListItem,
22
+ title: 'Content/ListItem/tests/focus',
23
+ tags: ['!autodocs'],
24
+ parameters: {
25
+ controls: { disable: true },
26
+ actions: { disable: true },
27
+ a11y: { disable: true },
28
+ knobs: { disable: true },
29
+ },
30
+ } satisfies Meta<ItemProps>;
31
+ type Story = StoryObj<ItemProps>;
32
+
33
+ const title = {
34
+ full: 'Fully interactive',
35
+ partial: 'Partially interactive',
36
+ };
37
+
38
+ const subtitle = {
39
+ full: 'Whole item should be focusable, control should not.',
40
+ partial: 'Only control should be focusable, not whole item.',
41
+ };
42
+
43
+ const additionalInfo = {
44
+ static: (
45
+ <ListItem.AdditionalInfo>
46
+ Fully interactive ListItems don&apos;t allow any nested interactive elements like links or
47
+ buttons within AdditionalInfo.
48
+ </ListItem.AdditionalInfo>
49
+ ),
50
+ interactive: (
51
+ <ListItem.AdditionalInfo
52
+ action={{ label: 'appended to the end.', href: 'https://wise.com', target: '_blank' }}
53
+ >
54
+ This additional info has a focusable link
55
+ </ListItem.AdditionalInfo>
56
+ ),
57
+ };
58
+
59
+ const prompt = {
60
+ static: <ListItem.Prompt sentiment="positive">Non-interactive prompt.</ListItem.Prompt>,
61
+ interactive: (
62
+ <ListItem.Prompt sentiment="positive">
63
+ This prompt has a{' '}
64
+ <Link href="https://wise.com" target="_blank" rel="noreferrer">
65
+ single interactive element
66
+ </Link>{' '}
67
+ that spreads across the whole prompt area.
68
+ </ListItem.Prompt>
69
+ ),
70
+ };
71
+
72
+ const button = {
73
+ full: (
74
+ <ListItem.Button priority="secondary-neutral" onClick={() => {}}>
75
+ Click me
76
+ </ListItem.Button>
77
+ ),
78
+ partial: (
79
+ <ListItem.Button partiallyInteractive priority="secondary-neutral" onClick={() => {}}>
80
+ Click me
81
+ </ListItem.Button>
82
+ ),
83
+ };
84
+
85
+ export const FullyInteractive: Story = {
86
+ play: async ({ canvasElement }) => {
87
+ const canvas = within(canvasElement);
88
+ await waitForListItem(canvas);
89
+ await userEvent.tab();
90
+ await waitForFocus(async () => {
91
+ await expect(canvas.getByRole('button')).toHaveFocus();
92
+ });
93
+ },
94
+ render: () => (
95
+ <ListItem
96
+ title={title.full}
97
+ subtitle={subtitle.full}
98
+ additionalInfo={additionalInfo.static}
99
+ control={button.full}
100
+ prompt={prompt.static}
101
+ />
102
+ ),
103
+ };
104
+
105
+ export const FullyInteractiveFocusedOnPrompt: Story = {
106
+ play: async ({ canvasElement }) => {
107
+ const canvas = within(canvasElement);
108
+ await waitForListItem(canvas);
109
+
110
+ await userEvent.tab();
111
+ await waitForFocus(async () => {
112
+ await expect(canvas.getByRole('button')).toHaveFocus();
113
+ });
114
+
115
+ await userEvent.tab();
116
+ await waitForFocus(async () => {
117
+ await expect(canvas.getByRole('link', { name: /^single interactive element/ })).toHaveFocus();
118
+ });
119
+ },
120
+ render: () => (
121
+ <ListItem
122
+ title={title.full}
123
+ subtitle={subtitle.full}
124
+ additionalInfo={additionalInfo.static}
125
+ control={button.full}
126
+ prompt={prompt.interactive}
127
+ />
128
+ ),
129
+ };
130
+
131
+ export const PartiallyInteractiveFocusedOnControl: Story = {
132
+ play: async ({ canvasElement }) => {
133
+ const canvas = within(canvasElement);
134
+ await waitForListItem(canvas);
135
+ await userEvent.tab();
136
+ await waitForFocus(async () => {
137
+ await expect(canvas.getByRole('button')).toHaveFocus();
138
+ });
139
+ },
140
+ render: () => (
141
+ <ListItem
142
+ title={title.partial}
143
+ subtitle={subtitle.partial}
144
+ additionalInfo={additionalInfo.interactive}
145
+ control={button.partial}
146
+ prompt={prompt.interactive}
147
+ />
148
+ ),
149
+ };
150
+
151
+ export const PartiallyInteractiveFocusedOnAdditionInfo: Story = {
152
+ play: async ({ canvasElement }) => {
153
+ const canvas = within(canvasElement);
154
+ await waitForListItem(canvas);
155
+
156
+ await userEvent.tab();
157
+ await waitForFocus(async () => {
158
+ await expect(canvas.getByRole('button')).toHaveFocus();
159
+ });
160
+
161
+ await userEvent.tab();
162
+ await waitForFocus(async () => {
163
+ await expect(canvas.getByRole('link', { name: /^appended to the end/ })).toHaveFocus();
164
+ });
165
+ },
166
+ render: () => (
167
+ <ListItem
168
+ title={title.partial}
169
+ subtitle={subtitle.partial}
170
+ additionalInfo={additionalInfo.interactive}
171
+ control={button.partial}
172
+ prompt={prompt.interactive}
173
+ />
174
+ ),
175
+ };
176
+
177
+ export const PartiallyInteractiveFocusedOnPrompt: Story = {
178
+ play: async ({ canvasElement }) => {
179
+ const canvas = within(canvasElement);
180
+ await waitForListItem(canvas);
181
+
182
+ await userEvent.tab();
183
+ await waitForFocus(async () => {
184
+ await expect(canvas.getByRole('button')).toHaveFocus();
185
+ });
186
+
187
+ await userEvent.tab();
188
+ await waitForFocus(async () => {
189
+ await expect(canvas.getByRole('link', { name: /^appended to the end/ })).toHaveFocus();
190
+ });
191
+
192
+ await userEvent.tab();
193
+ await waitForFocus(async () => {
194
+ await expect(canvas.getByRole('link', { name: /^single interactive element/ })).toHaveFocus();
195
+ });
196
+ },
197
+ render: () => (
198
+ <ListItem
199
+ title={title.partial}
200
+ subtitle={subtitle.partial}
201
+ additionalInfo={additionalInfo.interactive}
202
+ control={button.partial}
203
+ prompt={prompt.interactive}
204
+ />
205
+ ),
206
+ };
207
+
208
+ export const FullyInteractiveDisabled: Story = {
209
+ play: async ({ canvasElement }) => {
210
+ const canvas = within(canvasElement);
211
+ await waitForListItem(canvas);
212
+
213
+ await userEvent.tab();
214
+ await waitForFocus(async () => {
215
+ await expect(canvas.getByRole('button')).not.toHaveFocus();
216
+ });
217
+ },
218
+ render: () => (
219
+ <ListItem
220
+ disabled
221
+ title={title.full}
222
+ subtitle={subtitle.full}
223
+ additionalInfo={additionalInfo.static}
224
+ control={button.full}
225
+ prompt={prompt.static}
226
+ />
227
+ ),
228
+ };
229
+
230
+ export const PartiallyInteractiveDisabled: Story = {
231
+ play: async ({ canvasElement }) => {
232
+ const canvas = within(canvasElement);
233
+ await waitForListItem(canvas);
234
+
235
+ await userEvent.tab();
236
+ await waitForFocus(async () => {
237
+ await expect(canvas.getByRole('button')).not.toHaveFocus();
238
+ });
239
+ },
240
+ render: () => (
241
+ <ListItem
242
+ disabled
243
+ title={title.partial}
244
+ subtitle={subtitle.partial}
245
+ additionalInfo={additionalInfo.interactive}
246
+ control={button.partial}
247
+ prompt={prompt.interactive}
248
+ />
249
+ ),
250
+ };
@@ -0,0 +1,353 @@
1
+ import { Fragment } from 'react';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
+ import { Bank, FastFlag, MultiCurrency, Receipt, Savings } from '@transferwise/icons';
4
+ import Link from '../../link';
5
+ import { ListItem, Props as ItemProps } from '../ListItem';
6
+ import { lorem10, lorem20, lorem5 } from '../../test-utils';
7
+ import portraitImage from '../../test-utils/assets/placeholder-landscape.svg';
8
+ import landscapeImage from '../../test-utils/assets/placeholder-portrait.svg';
9
+ import { SB_LIST_ITEM_CONTROLS as CONTROLS, SB_LIST_ITEM_MEDIA as MEDIA } from './subcomponents';
10
+ import { ListItemMediaSize } from '../ListItemContext';
11
+
12
+ const withSizedContainer = (width: number) => (Story: any) => (
13
+ <ol
14
+ className="list-unstyled"
15
+ style={{
16
+ width,
17
+ display: 'flex',
18
+ flexDirection: 'column',
19
+ gap: 16,
20
+ }}
21
+ >
22
+ <Story />
23
+ </ol>
24
+ );
25
+
26
+ export default {
27
+ title: 'Content/ListItem/tests/layout',
28
+ tags: ['!autodocs'],
29
+ parameters: {
30
+ controls: { disable: true },
31
+ actions: { disable: true },
32
+ a11y: { disable: true },
33
+ knobs: { disable: true },
34
+ },
35
+ } satisfies Meta<ItemProps>;
36
+ type Story = StoryObj<ItemProps>;
37
+
38
+ const variants = [
39
+ <ListItem
40
+ key="button"
41
+ title="Button only"
42
+ control={
43
+ <ListItem.Button priority="secondary-neutral" onClick={() => {}}>
44
+ Click me
45
+ </ListItem.Button>
46
+ }
47
+ />,
48
+ <ListItem
49
+ key="media"
50
+ title="With media"
51
+ subtitle="Short subtitle"
52
+ additionalInfo={<ListItem.AdditionalInfo>{lorem5}</ListItem.AdditionalInfo>}
53
+ media={
54
+ <ListItem.AvatarView>
55
+ <FastFlag />
56
+ </ListItem.AvatarView>
57
+ }
58
+ />,
59
+ <ListItem key="value" title="With value" valueTitle="100 GBP" valueSubtitle="100 USD" />,
60
+ <ListItem
61
+ key="prompt"
62
+ title="With prompt"
63
+ prompt={
64
+ <ListItem.Prompt sentiment="positive">
65
+ This is a prompt with <Link href="https://wise.com">a link</Link>.
66
+ </ListItem.Prompt>
67
+ }
68
+ />,
69
+ <ListItem
70
+ key="button-media"
71
+ title="Button + media"
72
+ media={
73
+ <ListItem.AvatarView>
74
+ <MultiCurrency />
75
+ </ListItem.AvatarView>
76
+ }
77
+ control={
78
+ <ListItem.Button priority="primary" onClick={() => {}}>
79
+ Action
80
+ </ListItem.Button>
81
+ }
82
+ />,
83
+ <ListItem
84
+ key="button-value"
85
+ title="Button + value"
86
+ valueTitle="42 EUR"
87
+ control={
88
+ <ListItem.Button priority="secondary-neutral" onClick={() => {}}>
89
+ Pay
90
+ </ListItem.Button>
91
+ }
92
+ />,
93
+ <ListItem
94
+ key="media-value"
95
+ valueColumnWidth={80}
96
+ title="Media + value"
97
+ subtitle="this column is 20% wide"
98
+ media={
99
+ <ListItem.AvatarView>
100
+ <Bank />
101
+ </ListItem.AvatarView>
102
+ }
103
+ valueTitle="1,000 USD"
104
+ />,
105
+ <ListItem
106
+ key="prompt-value"
107
+ title="Prompt + value"
108
+ valueTitle="10 GBP"
109
+ prompt={<ListItem.Prompt sentiment="warning">Warning prompt!</ListItem.Prompt>}
110
+ />,
111
+ <ListItem
112
+ key="media-prompt"
113
+ title="Media + prompt"
114
+ media={
115
+ <ListItem.AvatarView>
116
+ <Receipt />
117
+ </ListItem.AvatarView>
118
+ }
119
+ prompt={<ListItem.Prompt sentiment="positive">Discount available!</ListItem.Prompt>}
120
+ />,
121
+ <ListItem
122
+ key="most"
123
+ title="Everything but button"
124
+ subtitle="No control"
125
+ media={
126
+ <ListItem.AvatarView>
127
+ <Savings />
128
+ </ListItem.AvatarView>
129
+ }
130
+ valueTitle="999 GBP"
131
+ prompt={
132
+ <ListItem.Prompt sentiment="positive">
133
+ <Link href="https://wise.com">See details</Link>
134
+ </ListItem.Prompt>
135
+ }
136
+ />,
137
+ <ListItem
138
+ key="all"
139
+ title="All together"
140
+ subtitle="Everything in one"
141
+ media={
142
+ <ListItem.AvatarView>
143
+ <Savings />
144
+ </ListItem.AvatarView>
145
+ }
146
+ valueTitle="999 GBP"
147
+ prompt={
148
+ <ListItem.Prompt sentiment="positive">
149
+ <Link href="https://wise.com">See details</Link>
150
+ </ListItem.Prompt>
151
+ }
152
+ control={
153
+ <ListItem.Button priority="secondary-neutral" onClick={() => {}}>
154
+ Go
155
+ </ListItem.Button>
156
+ }
157
+ />,
158
+ ];
159
+
160
+ export const Under320: Story = {
161
+ render: () => <>{variants}</>,
162
+ decorators: [withSizedContainer(320)],
163
+ };
164
+
165
+ export const Between321And399: Story = {
166
+ render: () => <>{variants}</>,
167
+ decorators: [withSizedContainer(360)],
168
+ };
169
+
170
+ export const Over400: Story = {
171
+ render: () => <>{variants}</>,
172
+ decorators: [withSizedContainer(400)],
173
+ };
174
+
175
+ export const GapsBetweenItems: Story = {
176
+ render: () => {
177
+ const props = {
178
+ title: lorem5,
179
+ subtitle: lorem10,
180
+ media: MEDIA.image,
181
+ control: CONTROLS.switch,
182
+ };
183
+ return (
184
+ <ol className="list-unstyled">
185
+ <ListItem {...props} />
186
+ <ListItem {...props} spotlight="active" />
187
+ <ListItem {...props} spotlight="inactive" />
188
+ <ListItem {...props} />
189
+ </ol>
190
+ );
191
+ },
192
+ };
193
+
194
+ type PreviewStoryArgs = ItemProps & {
195
+ previewImageSize: ListItemMediaSize;
196
+ previewWithLineGuides: boolean;
197
+ previewPrompt: boolean | ItemProps['prompt'];
198
+ };
199
+
200
+ const previewArgGroup = {
201
+ category: 'Preview options',
202
+ type: {
203
+ summary: undefined,
204
+ },
205
+ };
206
+
207
+ const previewArgTypes = {
208
+ previewImageSize: {
209
+ options: [32, 40, 48, 56, 72],
210
+ control: {
211
+ type: 'inline-radio',
212
+ },
213
+ name: 'Preview with image size',
214
+ table: previewArgGroup,
215
+ },
216
+ previewWithLineGuides: {
217
+ control: {
218
+ type: 'boolean',
219
+ },
220
+ name: 'Preview with line guides',
221
+ table: previewArgGroup,
222
+ },
223
+ previewPrompt: {
224
+ control: {
225
+ type: 'boolean',
226
+ },
227
+ mapping: {
228
+ true: <ListItem.Prompt sentiment="positive">This is a prompt</ListItem.Prompt>,
229
+ false: null,
230
+ },
231
+ name: 'Preview with `prompt`',
232
+ table: previewArgGroup,
233
+ },
234
+ } as const;
235
+
236
+ const getPropsForPreview = (args: PreviewStoryArgs) => {
237
+ const { previewImageSize, previewWithLineGuides, previewPrompt, ...props } = args as {
238
+ previewImageSize: ListItemMediaSize;
239
+ previewWithLineGuides: boolean;
240
+ previewPrompt: boolean | ItemProps['prompt'];
241
+ title: ItemProps['title'];
242
+ subtitle: ItemProps['subtitle'];
243
+ [key: string]: any;
244
+ };
245
+
246
+ return [
247
+ {
248
+ ...props,
249
+ prompt: previewPrompt,
250
+ },
251
+ {
252
+ previewImageSize,
253
+ previewWithLineGuides,
254
+ },
255
+ ] as const;
256
+ };
257
+
258
+ // Create a completely untyped story object
259
+ const ImageAlignmentStory: StoryObj<PreviewStoryArgs> = {
260
+ parameters: {
261
+ controls: { disable: false },
262
+ },
263
+ args: {
264
+ title: lorem5,
265
+ subtitle: lorem10,
266
+ previewImageSize: 48,
267
+ previewWithLineGuides: true,
268
+ previewPrompt: false,
269
+ },
270
+ argTypes: previewArgTypes,
271
+ decorators: [
272
+ (Story: any, { args }: { args: PreviewStoryArgs }) => (
273
+ <>
274
+ {args.previewWithLineGuides && (
275
+ <style
276
+ dangerouslySetInnerHTML={{
277
+ __html: `
278
+ .wds-list-item-media-image-wrapper::before{
279
+ content: '';
280
+ border: 1px dashed blue;
281
+ position: absolute;
282
+ width: ${args.previewImageSize}px;
283
+ height: ${args.previewImageSize}px;
284
+ }
285
+ .wds-list-item-media-image-wrapper::after {
286
+ content: '';
287
+ border: 1px dashed red;
288
+ position: absolute;
289
+ left: 0;
290
+ width: 100%;
291
+ height: ${args.previewImageSize}px;
292
+ }
293
+ `,
294
+ }}
295
+ />
296
+ )}
297
+ <ol
298
+ className="list-unstyled"
299
+ style={{ display: 'grid', gridTemplateColumns: '340px 400px', gap: '16px' }}
300
+ >
301
+ <Story />
302
+ </ol>
303
+ </>
304
+ ),
305
+ ],
306
+ render: (args: PreviewStoryArgs) => {
307
+ const [{ title, subtitle, ...props }, previewProps] = getPropsForPreview(args);
308
+
309
+ const additionalInfo = <ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>;
310
+ const control = CONTROLS.button;
311
+ const size = previewProps.previewImageSize;
312
+
313
+ const instances = [
314
+ { title, ...props },
315
+ { title, subtitle, ...props },
316
+ { title, subtitle, additionalInfo, ...props },
317
+ { title, control, ...props },
318
+ { title, subtitle, control, ...props },
319
+ { title, subtitle, additionalInfo, control, ...props },
320
+ ] as const;
321
+
322
+ return (
323
+ <>
324
+ {instances.map((itemProps, index) => (
325
+ <Fragment key={`landscape-${index}`}>
326
+ <ListItem
327
+ {...itemProps}
328
+ media={<ListItem.Image size={size} src={landscapeImage} alt="landscape image" />}
329
+ />
330
+ <ListItem
331
+ {...itemProps}
332
+ media={<ListItem.Image size={size} src={landscapeImage} alt="landscape image" />}
333
+ />
334
+ </Fragment>
335
+ ))}
336
+ {instances.map((itemProps, index) => (
337
+ <Fragment key={`portrait-${index}`}>
338
+ <ListItem
339
+ {...itemProps}
340
+ media={<ListItem.Image size={size} src={portraitImage} alt="portrait image" />}
341
+ />
342
+ <ListItem
343
+ {...itemProps}
344
+ media={<ListItem.Image size={size} src={portraitImage} alt="portrait image" />}
345
+ />
346
+ </Fragment>
347
+ ))}
348
+ </>
349
+ );
350
+ },
351
+ };
352
+
353
+ export const ImageAlignment = ImageAlignmentStory;