@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,250 +0,0 @@
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
- };
@@ -1,338 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import { Bank, FastFlag, MultiCurrency, Receipt, Savings } from '@transferwise/icons';
3
- import Link from '../../link';
4
- import { ListItem, Props as ItemProps } from '../ListItem';
5
- import { lorem10, lorem20, lorem5 } from '../../test-utils';
6
- import { SB_LIST_ITEM_CONTROLS as CONTROLS, SB_LIST_ITEM_MEDIA as MEDIA } from './subcomponents';
7
- import portraitImage from './images/portrait.svg';
8
- import landscapeImage from './images/landscape.svg';
9
- import type { ListItemButtonProps } from '../Button';
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
- <Story />
298
- </>
299
- ),
300
- ],
301
- render: (args: PreviewStoryArgs) => {
302
- const [{ title, subtitle, ...props }, previewProps] = getPropsForPreview(args);
303
-
304
- const additionalInfo = <ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>;
305
- const control = CONTROLS.button;
306
- const size = previewProps.previewImageSize;
307
-
308
- const instances = [
309
- { title, ...props },
310
- { title, subtitle, ...props },
311
- { title, subtitle, additionalInfo, ...props },
312
- { title, control, ...props },
313
- { title, subtitle, control, ...props },
314
- { title, subtitle, additionalInfo, control, ...props },
315
- ] as const;
316
-
317
- return (
318
- <ol className="list-unstyled">
319
- {instances.map((itemProps, index) => (
320
- <ListItem
321
- key={`landscape-${index}`}
322
- {...itemProps}
323
- media={<ListItem.Image size={size} src={landscapeImage} alt="landscape image" />}
324
- />
325
- ))}
326
- {instances.map((itemProps, index) => (
327
- <ListItem
328
- key={`portrait-${index}`}
329
- {...itemProps}
330
- media={<ListItem.Image size={size} src={portraitImage} alt="portrait image" />}
331
- />
332
- ))}
333
- </ol>
334
- );
335
- },
336
- };
337
-
338
- export const ImageAlignment = ImageAlignmentStory;