@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,121 @@
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { Flag } from '@wise/art';
3
+ import { lorem10 } from '../../test-utils';
4
+ import { ListItem } from '../ListItem';
5
+ import {
6
+ SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
7
+ SB_LIST_ITEM_CONTROLS as CONTROLS,
8
+ } from '../_stories/subcomponents';
9
+ import { disableControls } from '../_stories/helpers';
10
+ import { ListItemAvatarLayoutProps } from './ListItemAvatarLayout';
11
+
12
+ export default {
13
+ component: ListItem.AvatarLayout,
14
+ title: 'Content/ListItem/ListItem.AvatarLayout',
15
+ parameters: {
16
+ docs: {
17
+ toc: true,
18
+ },
19
+ },
20
+ args: {
21
+ avatars: [{ asset: <Flag code="gb" /> }, { asset: <Flag code="eur" /> }],
22
+ orientation: 'horizontal',
23
+ size: 48,
24
+ },
25
+ argTypes: {
26
+ avatars: {
27
+ description: 'Array of avatar objects with asset and optional styling properties',
28
+ table: {
29
+ type: { summary: 'SingleAvatarType[]' },
30
+ },
31
+ },
32
+ orientation: {
33
+ control: 'inline-radio',
34
+ options: ['horizontal', 'diagonal'],
35
+ description: 'Layout orientation for multiple avatars',
36
+ },
37
+ size: {
38
+ control: 'select',
39
+ options: [32, 40, 48, 56, 72],
40
+ description: 'Size of the avatar layout',
41
+ },
42
+ },
43
+ } satisfies Meta<ListItemAvatarLayoutProps>;
44
+
45
+ type Story = StoryObj<ListItemAvatarLayoutProps>;
46
+
47
+ export const Playground: Story = {
48
+ tags: ['!autodocs'],
49
+ render: (args: ListItemAvatarLayoutProps) => {
50
+ return (
51
+ <ListItem
52
+ title="Transfer from GBP to EUR"
53
+ subtitle="Currency exchange"
54
+ media={<ListItem.AvatarLayout {...args} />}
55
+ control={CONTROLS.iconButton}
56
+ additionalInfo={INFO.nonInteractive}
57
+ />
58
+ );
59
+ },
60
+ };
61
+
62
+ /**
63
+ * AvatarLayout supports two orientations: horizontal (default) and diagonal. <br />
64
+ * Please refer to the [design documentation](https://wise.design/components/avatar#double) for more details.
65
+ */
66
+ export const Orientations: Story = {
67
+ argTypes: disableControls()(['orientation']),
68
+ render: (args) => {
69
+ return (
70
+ <ol className="list-unstyled">
71
+ <ListItem
72
+ title="Horizontal orientation"
73
+ subtitle={lorem10}
74
+ media={<ListItem.AvatarLayout {...args} orientation="horizontal" />}
75
+ control={CONTROLS.iconButton}
76
+ />
77
+
78
+ <ListItem
79
+ title="Diagonal orientation"
80
+ subtitle={lorem10}
81
+ media={<ListItem.AvatarLayout {...args} orientation="diagonal" />}
82
+ control={CONTROLS.iconButton}
83
+ />
84
+ </ol>
85
+ );
86
+ },
87
+ };
88
+
89
+ /**
90
+ * AvatarLayout supports various sizes to fit different list item contexts.
91
+ */
92
+ export const Sizes: Story = {
93
+ parameters: {
94
+ docs: {
95
+ canvas: {
96
+ sourceState: 'hidden',
97
+ },
98
+ },
99
+ },
100
+ argTypes: disableControls()(['size', 'orientation']),
101
+ render: (args) => {
102
+ const sizes = [32, 40, 48, 56, 72] as const;
103
+ const orientations = ['horizontal', 'diagonal'] as const;
104
+
105
+ return (
106
+ <ol className="list-unstyled">
107
+ {orientations.map((orientation) =>
108
+ sizes.map((size) => (
109
+ <ListItem
110
+ key={`${orientation}-${size}`}
111
+ title={`Size ${size}`}
112
+ subtitle={lorem10}
113
+ media={<ListItem.AvatarLayout {...args} size={size} orientation={orientation} />}
114
+ control={CONTROLS.iconButton}
115
+ />
116
+ )),
117
+ )}
118
+ </ol>
119
+ );
120
+ },
121
+ };
@@ -0,0 +1,27 @@
1
+ import AvatarLayoutComp, { type AvatarLayoutProps } from '../../avatarLayout';
2
+ import { clsx } from 'clsx';
3
+ import { useListItemMedia } from '../useListItemMedia';
4
+
5
+ type SizeProp = { size?: 32 | 40 | 48 | 56 | 72 };
6
+
7
+ export type ListItemAvatarLayoutProps = Omit<AvatarLayoutProps, 'size' | 'interactive'> & SizeProp;
8
+
9
+ /**
10
+ * This component allows for rendering 2 avatars. It's a thin wrapper around the
11
+ * [AvatarLayout component](https://storybook.wise.design/?path=/docs/content-avatarlayout--docs), but offers only
12
+ * a subset of its sizes, and disallows interactive mode, in line with the ListItem's constraints. <br />
13
+ * <br />
14
+ * Please refer to the [Design documentation](https://wise.design/components/list-item#avatar) for details.
15
+ */
16
+ export const AvatarLayout = ({ className, size = 48, ...props }: ListItemAvatarLayoutProps) => {
17
+ useListItemMedia(size);
18
+
19
+ return (
20
+ <AvatarLayoutComp
21
+ {...props}
22
+ size={size}
23
+ className={clsx('wds-list-item-media-avatar-layout', className)}
24
+ />
25
+ );
26
+ };
27
+ AvatarLayout.displayName = 'ListItem.AvatarLayout';
@@ -0,0 +1,2 @@
1
+ export type { ListItemAvatarLayoutProps } from './ListItemAvatarLayout';
2
+ export { AvatarLayout } from './ListItemAvatarLayout';
@@ -0,0 +1,75 @@
1
+ import { mockMatchMedia, render, screen } from '../../test-utils';
2
+ import { ListItem, type Props as ListItemProps } from '../ListItem';
3
+
4
+ mockMatchMedia();
5
+
6
+ const baseProps = {
7
+ title: 'Test Title',
8
+ };
9
+
10
+ const avatarProps = {
11
+ imgSrc: 'avatar.jpg',
12
+ profileName: 'User Avatar',
13
+ };
14
+
15
+ const renderWithMedia = (media: ListItemProps['media']) =>
16
+ render(<ListItem title={baseProps.title} media={media} />);
17
+
18
+ describe('ListItem.AvatarView', () => {
19
+ it('applies custom className alongside default class', () => {
20
+ const { container } = renderWithMedia(
21
+ <ListItem.AvatarView
22
+ className="custom-class"
23
+ imgSrc={avatarProps.imgSrc}
24
+ profileName={avatarProps.profileName}
25
+ />,
26
+ );
27
+
28
+ expect(container.querySelector('.custom-class')).toBeInTheDocument();
29
+ });
30
+
31
+ it('renders avatar with correct image src', () => {
32
+ renderWithMedia(
33
+ <ListItem.AvatarView imgSrc={avatarProps.imgSrc} profileName={avatarProps.profileName} />,
34
+ );
35
+
36
+ expect(screen.getByRole('presentation')).toHaveAttribute('src', avatarProps.imgSrc);
37
+ });
38
+
39
+ it('renders without image when no imgSrc provided', () => {
40
+ renderWithMedia(<ListItem.AvatarView profileName={avatarProps.profileName} />);
41
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
42
+ });
43
+
44
+ it('supports accessibility props', () => {
45
+ renderWithMedia(
46
+ <ListItem.AvatarView
47
+ imgSrc={avatarProps.imgSrc}
48
+ profileName={avatarProps.profileName}
49
+ aria-label="Profile picture"
50
+ />,
51
+ );
52
+
53
+ expect(screen.getByLabelText('Profile picture')).toBeInTheDocument();
54
+ });
55
+
56
+ it('passes through role attribute', () => {
57
+ renderWithMedia(
58
+ <ListItem.AvatarView
59
+ imgSrc={avatarProps.imgSrc}
60
+ profileName={avatarProps.profileName}
61
+ role="button"
62
+ aria-label="Profile button"
63
+ />,
64
+ );
65
+
66
+ expect(screen.getByRole('button', { name: 'Profile button' })).toBeInTheDocument();
67
+ });
68
+
69
+ it('renders initials when no image provided', () => {
70
+ const johnDoeProfile = 'John Doe';
71
+ renderWithMedia(<ListItem.AvatarView profileName={johnDoeProfile} />);
72
+
73
+ expect(screen.getByText('JD')).toBeInTheDocument();
74
+ });
75
+ });
@@ -0,0 +1,336 @@
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { Leaf, Taxi } from '@transferwise/icons';
3
+ import { lorem10 } from '../../test-utils';
4
+ import { ProfileType } from '../../common';
5
+ import { ListItem } from '../ListItem';
6
+ import {
7
+ SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
8
+ SB_LIST_ITEM_CONTROLS as CONTROLS,
9
+ } from '../_stories/subcomponents';
10
+ import { disableControls } from '../_stories/helpers';
11
+ import { ListItemAvatarViewProps } from './ListItemAvatarView';
12
+
13
+ const hideControls = disableControls(['badge', 'children']);
14
+
15
+ const SIZES = [32, 40, 48, 56, 72] as const;
16
+ const BADGES = {
17
+ 'Country flag badge': { flagCode: 'GBP' },
18
+ 'StatusIcon badge': { status: 'warning' },
19
+ 'Icon badge': { icon: <Taxi /> },
20
+ 'Default action badge': {
21
+ type: 'action',
22
+ },
23
+ 'Default reference badge': {
24
+ type: 'reference',
25
+ },
26
+ 'Action badge with custom icon': {
27
+ type: 'action',
28
+ icon: <Taxi />,
29
+ },
30
+ 'Reference badge with custom icon': {
31
+ type: 'reference',
32
+ icon: <Taxi />,
33
+ },
34
+ 'Custom badge': {
35
+ asset: (
36
+ <div
37
+ className="d-flex align-items-center justify-content-center"
38
+ style={{
39
+ backgroundColor: 'var(--color-bright-pink)',
40
+ color: 'var(--color-interactive-primary)',
41
+ width: '100%',
42
+ height: '100%',
43
+ }}
44
+ >
45
+ <Leaf />
46
+ </div>
47
+ ),
48
+ },
49
+ } as const;
50
+
51
+ export default {
52
+ component: ListItem.AvatarView,
53
+ title: 'Content/ListItem/ListItem.AvatarView',
54
+ parameters: {
55
+ docs: {
56
+ toc: true,
57
+ },
58
+ },
59
+ args: {
60
+ size: 48,
61
+ selected: false,
62
+ badge: { type: 'action' },
63
+ notification: false,
64
+ profileName: undefined,
65
+ profileType: undefined,
66
+ imgSrc: undefined,
67
+ },
68
+ argTypes: {
69
+ size: {
70
+ control: 'select',
71
+ options: SIZES,
72
+ description: 'Size of the avatar',
73
+ },
74
+ profileName: {
75
+ control: 'text',
76
+ description: 'Name used to generate initials when no image or icon is provided',
77
+ },
78
+ imgSrc: {
79
+ control: 'text',
80
+ description: 'URL of the profile image',
81
+ },
82
+ profileType: {
83
+ control: 'select',
84
+ options: [ProfileType.PERSONAL, ProfileType.BUSINESS],
85
+ description: 'Type of profile for default icons',
86
+ table: {
87
+ type: { summary: 'ProfileType' },
88
+ },
89
+ },
90
+ notification: {
91
+ control: 'boolean',
92
+ description: 'Shows notification dot',
93
+ },
94
+ selected: {
95
+ control: 'boolean',
96
+ description: 'Toggles selected state',
97
+ },
98
+ badge: {
99
+ description: 'Badge configuration object',
100
+ table: {
101
+ type: { summary: 'AvatarViewBadgeProps' },
102
+ },
103
+ },
104
+ children: {
105
+ table: {
106
+ type: { summary: 'ReactNode' },
107
+ },
108
+ },
109
+ style: {
110
+ table: {
111
+ disable: true,
112
+ },
113
+ },
114
+ },
115
+ } satisfies Meta<ListItemAvatarViewProps>;
116
+
117
+ type Story = StoryObj<ListItemAvatarViewProps>;
118
+
119
+ export const Playground: Story = {
120
+ tags: ['!autodocs'],
121
+ render: (args: ListItemAvatarViewProps) => {
122
+ return (
123
+ <ListItem
124
+ title="John Smith"
125
+ subtitle="Personal account"
126
+ media={<ListItem.AvatarView {...args} />}
127
+ control={CONTROLS.iconButton}
128
+ additionalInfo={INFO.nonInteractive}
129
+ />
130
+ );
131
+ },
132
+ };
133
+
134
+ /**
135
+ * AvatarView can display different types of content including icons, profile images, and initials. <br />
136
+ * Refer to the [design documentation](https://wise.design/components/avatar#:~:text=56%2C%20%E2%80%A8and%2072.-,Media,-There%20are%204) for details.
137
+ */
138
+ export const ContentTypes: Story = {
139
+ args: {
140
+ badge: undefined,
141
+ },
142
+ argTypes: hideControls(['profileName', 'imgSrc', 'profileType']),
143
+ parameters: {
144
+ docs: {
145
+ canvas: {
146
+ sourceState: 'hidden',
147
+ },
148
+ },
149
+ },
150
+ render: (args) => {
151
+ return (
152
+ <ol className="list-unstyled">
153
+ <ListItem
154
+ title="With icon"
155
+ subtitle="Default icon content"
156
+ media={
157
+ <ListItem.AvatarView {...args}>
158
+ <Taxi />
159
+ </ListItem.AvatarView>
160
+ }
161
+ control={CONTROLS.iconButton}
162
+ />
163
+
164
+ <ListItem
165
+ title="With profile image"
166
+ subtitle="User profile picture."
167
+ media={
168
+ <ListItem.AvatarView
169
+ {...args}
170
+ imgSrc="../avatar-square-dude.webp"
171
+ profileName="John Smith"
172
+ />
173
+ }
174
+ control={CONTROLS.iconButton}
175
+ />
176
+
177
+ <ListItem
178
+ title="With initials"
179
+ subtitle="Fallback for when no profile image is available."
180
+ media={<ListItem.AvatarView {...args} profileName="Sarah Johnson" />}
181
+ control={CONTROLS.iconButton}
182
+ />
183
+
184
+ <ListItem
185
+ title="Business profile"
186
+ subtitle="Fallback for when no logo is available"
187
+ media={<ListItem.AvatarView {...args} profileType={ProfileType.BUSINESS} />}
188
+ control={CONTROLS.iconButton}
189
+ />
190
+
191
+ <ListItem
192
+ title="Personal profile"
193
+ subtitle="Fallback for when no personal data is available or when image fails to load."
194
+ media={
195
+ <ListItem.AvatarView
196
+ {...args}
197
+ profileType={ProfileType.PERSONAL}
198
+ profileName="Alex Chen"
199
+ />
200
+ }
201
+ control={CONTROLS.iconButton}
202
+ />
203
+ </ol>
204
+ );
205
+ },
206
+ };
207
+
208
+ /**
209
+ * AvatarView supports 5 sizes to fit different list item contexts: `32`, `40`, `48`, `56`, `72`. If decorated with a Badge, those will be sized accordingly as well. <br />
210
+ * Please refer to the [design documentation](https://wise.design/components/list-item#avatar:~:text=of%20the%20avatar.-,Avatar%20sizes,-List%20item%20supports) for details on when to use which one.
211
+ */
212
+ export const Sizes: Story = {
213
+ parameters: {
214
+ docs: {
215
+ canvas: {
216
+ sourceState: 'hidden',
217
+ },
218
+ },
219
+ },
220
+ argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'size']),
221
+ render: (args) => {
222
+ return (
223
+ <ol className="list-unstyled">
224
+ {SIZES.map((size) => (
225
+ <ListItem
226
+ key={size}
227
+ title={`Size ${size}`}
228
+ subtitle={lorem10}
229
+ media={
230
+ <ListItem.AvatarView {...args} size={size}>
231
+ <Taxi />
232
+ </ListItem.AvatarView>
233
+ }
234
+ control={CONTROLS.iconButton}
235
+ />
236
+ ))}
237
+ </ol>
238
+ );
239
+ },
240
+ };
241
+
242
+ /**
243
+ * Similarly, AvatarView also support a notification dot, which also adjusts to the Avatar's size. <br />
244
+ * **NB:** You cannot use notification and badge at the same time – badge will always take precedence over notification.
245
+ */
246
+ export const Notification: Story = {
247
+ parameters: {
248
+ docs: {
249
+ canvas: {
250
+ sourceState: 'hidden',
251
+ },
252
+ },
253
+ },
254
+ args: {
255
+ badge: undefined,
256
+ },
257
+ argTypes: hideControls([
258
+ 'profileName',
259
+ 'imgSrc',
260
+ 'profileType',
261
+ 'size',
262
+ 'notification',
263
+ 'selected',
264
+ ]),
265
+ render: (args) => {
266
+ return (
267
+ <ol className="list-unstyled">
268
+ {SIZES.map((size) => (
269
+ <ListItem
270
+ key={size}
271
+ title={`Size ${size}`}
272
+ subtitle={lorem10}
273
+ media={
274
+ <ListItem.AvatarView {...args} size={size} notification>
275
+ <Taxi />
276
+ </ListItem.AvatarView>
277
+ }
278
+ control={CONTROLS.iconButton}
279
+ />
280
+ ))}
281
+ </ol>
282
+ );
283
+ },
284
+ };
285
+
286
+ /**
287
+ * AvatarView supports different type of badges for additional context and information. <br />
288
+ * Refer to the [design documentation](https://wise.design/components/avatar#:~:text=support%20the%20information.-,With%20badge,-Badges%20contain%20additional) for details.
289
+ */
290
+ export const Badges: Story = {
291
+ args: {
292
+ imgSrc: '../avatar-square-dude.webp',
293
+ },
294
+ argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'notification', 'selected']),
295
+ parameters: {
296
+ docs: {
297
+ canvas: {
298
+ sourceState: 'hidden',
299
+ },
300
+ },
301
+ },
302
+ render: (args) => {
303
+ return (
304
+ <ol className="list-unstyled">
305
+ {Object.entries(BADGES).map(([title, badge]) => (
306
+ <ListItem
307
+ key={title}
308
+ title={title}
309
+ subtitle={lorem10}
310
+ media={<ListItem.AvatarView {...args} badge={badge} />}
311
+ control={CONTROLS.iconButton}
312
+ />
313
+ ))}
314
+ </ol>
315
+ );
316
+ },
317
+ };
318
+
319
+ /**
320
+ * AvatarView supports selected state for interactive contexts.
321
+ */
322
+ export const Selected: Story = {
323
+ argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'notification', 'selected']),
324
+ render: (args) => {
325
+ return (
326
+ <ol className="list-unstyled">
327
+ <ListItem
328
+ title="Selected state"
329
+ subtitle="Currently selected item"
330
+ media={<ListItem.AvatarView profileName="Alex Chen" selected />}
331
+ control={CONTROLS.iconButton}
332
+ />
333
+ </ol>
334
+ );
335
+ },
336
+ };
@@ -0,0 +1,27 @@
1
+ import { clsx } from 'clsx';
2
+ import AvatarViewComp, { AvatarViewProps } from '../../avatarView';
3
+ import { useListItemMedia } from '../useListItemMedia';
4
+
5
+ export type ListItemAvatarViewProps = Omit<AvatarViewProps, 'size' | 'interactive'> & {
6
+ size?: 32 | 40 | 48 | 56 | 72;
7
+ };
8
+
9
+ /**
10
+ * This component renders a single avatar. It's a thin wrapper around the
11
+ * [AvatarView component](https://storybook.wise.design/?path=/docs/content-avatarview--docs), but offers only
12
+ * a subset of its sizes, in line with the ListItem's constraints. <br />
13
+ * <br />
14
+ * Please refer to the [Design documentation](https://wise.design/components/list-item#avatar) for details.
15
+ */
16
+ export const AvatarView = ({ className, size = 48, ...props }: ListItemAvatarViewProps) => {
17
+ useListItemMedia(size);
18
+
19
+ return (
20
+ <AvatarViewComp
21
+ {...props}
22
+ size={size}
23
+ className={clsx('wds-list-item-media-avatar-view', className)}
24
+ />
25
+ );
26
+ };
27
+ AvatarView.displayName = 'ListItem.AvatarView';
@@ -0,0 +1,2 @@
1
+ export type { ListItemAvatarViewProps } from './ListItemAvatarView';
2
+ export { AvatarView } from './ListItemAvatarView';
@@ -0,0 +1,68 @@
1
+ import { screen, mockMatchMedia } from '../../test-utils';
2
+ import { Button as ItemButton } from './ListItemButton';
3
+ import { ButtonPriority } from '../../button/Button.types';
4
+ import { renderWithListItemContext, clearListItemMocks, mockSetControlType } from '../test-utils';
5
+
6
+ mockMatchMedia();
7
+
8
+ describe('ItemButton', () => {
9
+ beforeEach(() => {
10
+ clearListItemMocks();
11
+ });
12
+
13
+ it('always sets v2 to true', () => {
14
+ renderWithListItemContext(<ItemButton priority="primary">Test Button</ItemButton>);
15
+ const button = screen.getByRole('button');
16
+ expect(button).toBeInTheDocument();
17
+ expect(mockSetControlType).toHaveBeenCalledWith('button');
18
+ });
19
+
20
+ it('always sets size to "sm"', () => {
21
+ renderWithListItemContext(<ItemButton priority="primary">Test Button</ItemButton>);
22
+ const button = screen.getByRole('button');
23
+ expect(button).toHaveClass('wds-Button--small');
24
+ });
25
+
26
+ it('supports all priorities', () => {
27
+ const priorities: ButtonPriority[] = ['primary', 'secondary', 'tertiary'];
28
+ priorities.forEach((priority) => {
29
+ renderWithListItemContext(<ItemButton priority={priority}>Test {priority}</ItemButton>);
30
+ const button = screen.getByRole('button', { name: `Test ${priority}` });
31
+ expect(button).toBeInTheDocument();
32
+ });
33
+ });
34
+
35
+ it('renders as a button by default', () => {
36
+ renderWithListItemContext(<ItemButton>Click me</ItemButton>);
37
+ const button = screen.getByRole('button');
38
+ expect(button).toBeInTheDocument();
39
+ expect(button.tagName).toBe('BUTTON');
40
+ });
41
+
42
+ it('renders as an anchor when href is provided', () => {
43
+ renderWithListItemContext(<ItemButton href="https://example.com">Go to Example</ItemButton>);
44
+ const link = screen.getByRole('link', { name: 'Go to Example' });
45
+ expect(link).toBeInTheDocument();
46
+ expect(link.tagName).toBe('A');
47
+ expect(link).toHaveAttribute('href', 'https://example.com');
48
+ });
49
+
50
+ it('spreads additional props to the button', () => {
51
+ renderWithListItemContext(<ItemButton aria-label="Custom Button">Custom</ItemButton>);
52
+ const button = screen.getByRole('button', { name: 'Custom Button' });
53
+ expect(button).toBeInTheDocument();
54
+ expect(button).toHaveAttribute('aria-label', 'Custom Button');
55
+ });
56
+
57
+ it('spreads additional props to the anchor', () => {
58
+ renderWithListItemContext(
59
+ <ItemButton href="https://example.com" target="_blank" aria-label="Custom Link">
60
+ Custom Link
61
+ </ItemButton>,
62
+ );
63
+ const link = screen.getByRole('link', { name: 'Custom Link' });
64
+ expect(link).toBeInTheDocument();
65
+ expect(link).toHaveAttribute('href', 'https://example.com');
66
+ expect(link).toHaveAttribute('target', '_blank');
67
+ });
68
+ });