@transferwise/components 46.103.1 → 46.105.0

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 (250) hide show
  1. package/build/header/Header.js +60 -43
  2. package/build/header/Header.js.map +1 -1
  3. package/build/header/Header.mjs +57 -43
  4. package/build/header/Header.mjs.map +1 -1
  5. package/build/i18n/cs.json +2 -0
  6. package/build/i18n/cs.json.js +2 -0
  7. package/build/i18n/cs.json.js.map +1 -1
  8. package/build/i18n/cs.json.mjs +2 -0
  9. package/build/i18n/cs.json.mjs.map +1 -1
  10. package/build/i18n/es.json +2 -0
  11. package/build/i18n/es.json.js +2 -0
  12. package/build/i18n/es.json.js.map +1 -1
  13. package/build/i18n/es.json.mjs +2 -0
  14. package/build/i18n/es.json.mjs.map +1 -1
  15. package/build/i18n/th.json +2 -0
  16. package/build/i18n/th.json.js +2 -0
  17. package/build/i18n/th.json.js.map +1 -1
  18. package/build/i18n/th.json.mjs +2 -0
  19. package/build/i18n/th.json.mjs.map +1 -1
  20. package/build/index.js +3 -1
  21. package/build/index.js.map +1 -1
  22. package/build/index.mjs +2 -1
  23. package/build/index.mjs.map +1 -1
  24. package/build/inputs/SelectInput.js +1 -1
  25. package/build/inputs/SelectInput.js.map +1 -1
  26. package/build/inputs/SelectInput.mjs +1 -1
  27. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +56 -0
  28. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +1 -0
  29. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +54 -0
  30. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +1 -0
  31. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +23 -0
  32. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -0
  33. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +21 -0
  34. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -0
  35. package/build/listItem/AvatarView/ListItemAvatarView.js +23 -0
  36. package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -0
  37. package/build/listItem/AvatarView/ListItemAvatarView.mjs +21 -0
  38. package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -0
  39. package/build/listItem/Button/ListItemButton.js +43 -0
  40. package/build/listItem/Button/ListItemButton.js.map +1 -0
  41. package/build/listItem/Button/ListItemButton.mjs +41 -0
  42. package/build/listItem/Button/ListItemButton.mjs.map +1 -0
  43. package/build/listItem/Checkbox/ListItemCheckbox.js +30 -0
  44. package/build/listItem/Checkbox/ListItemCheckbox.js.map +1 -0
  45. package/build/listItem/Checkbox/ListItemCheckbox.mjs +28 -0
  46. package/build/listItem/Checkbox/ListItemCheckbox.mjs.map +1 -0
  47. package/build/listItem/IconButton/ListItemIconButton.js +56 -0
  48. package/build/listItem/IconButton/ListItemIconButton.js.map +1 -0
  49. package/build/listItem/IconButton/ListItemIconButton.mjs +54 -0
  50. package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -0
  51. package/build/listItem/Image/ListItemImage.js +31 -0
  52. package/build/listItem/Image/ListItemImage.js.map +1 -0
  53. package/build/listItem/Image/ListItemImage.mjs +29 -0
  54. package/build/listItem/Image/ListItemImage.mjs.map +1 -0
  55. package/build/listItem/ListItem.js +311 -0
  56. package/build/listItem/ListItem.js.map +1 -0
  57. package/build/listItem/ListItem.mjs +306 -0
  58. package/build/listItem/ListItem.mjs.map +1 -0
  59. package/build/listItem/ListItemContext.js +8 -0
  60. package/build/listItem/ListItemContext.js.map +1 -0
  61. package/build/listItem/ListItemContext.mjs +6 -0
  62. package/build/listItem/ListItemContext.mjs.map +1 -0
  63. package/build/listItem/Navigation/ListItemNavigation.js +44 -0
  64. package/build/listItem/Navigation/ListItemNavigation.js.map +1 -0
  65. package/build/listItem/Navigation/ListItemNavigation.mjs +42 -0
  66. package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -0
  67. package/build/listItem/Prompt/ListItemPrompt.js +59 -0
  68. package/build/listItem/Prompt/ListItemPrompt.js.map +1 -0
  69. package/build/listItem/Prompt/ListItemPrompt.mjs +54 -0
  70. package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -0
  71. package/build/listItem/Radio/ListItemRadio.js +30 -0
  72. package/build/listItem/Radio/ListItemRadio.js.map +1 -0
  73. package/build/listItem/Radio/ListItemRadio.mjs +28 -0
  74. package/build/listItem/Radio/ListItemRadio.mjs.map +1 -0
  75. package/build/listItem/Switch/ListItemSwitch.js +30 -0
  76. package/build/listItem/Switch/ListItemSwitch.js.map +1 -0
  77. package/build/listItem/Switch/ListItemSwitch.mjs +28 -0
  78. package/build/listItem/Switch/ListItemSwitch.mjs.map +1 -0
  79. package/build/listItem/useListItemControl.js +22 -0
  80. package/build/listItem/useListItemControl.js.map +1 -0
  81. package/build/listItem/useListItemControl.mjs +20 -0
  82. package/build/listItem/useListItemControl.mjs.map +1 -0
  83. package/build/listItem/useListItemMedia.js +21 -0
  84. package/build/listItem/useListItemMedia.js.map +1 -0
  85. package/build/listItem/useListItemMedia.mjs +19 -0
  86. package/build/listItem/useListItemMedia.mjs.map +1 -0
  87. package/build/main.css +794 -14
  88. package/build/styles/header/Header.css +21 -14
  89. package/build/styles/listItem/ListItem.css +773 -0
  90. package/build/styles/listItem/ListItem.grid.css +370 -0
  91. package/build/styles/listItem/Prompt/ListItemPrompt.css +157 -0
  92. package/build/styles/main.css +794 -14
  93. package/build/title/Title.js +10 -4
  94. package/build/title/Title.js.map +1 -1
  95. package/build/title/Title.mjs +6 -4
  96. package/build/title/Title.mjs.map +1 -1
  97. package/build/types/header/Header.d.ts +27 -11
  98. package/build/types/header/Header.d.ts.map +1 -1
  99. package/build/types/header/index.d.ts +1 -0
  100. package/build/types/header/index.d.ts.map +1 -1
  101. package/build/types/index.d.ts +3 -0
  102. package/build/types/index.d.ts.map +1 -1
  103. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts +15 -0
  104. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts.map +1 -0
  105. package/build/types/listItem/AdditionalInfo/index.d.ts +3 -0
  106. package/build/types/listItem/AdditionalInfo/index.d.ts.map +1 -0
  107. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts +18 -0
  108. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -0
  109. package/build/types/listItem/AvatarLayout/index.d.ts +3 -0
  110. package/build/types/listItem/AvatarLayout/index.d.ts.map +1 -0
  111. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts +16 -0
  112. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -0
  113. package/build/types/listItem/AvatarView/index.d.ts +3 -0
  114. package/build/types/listItem/AvatarView/index.d.ts.map +1 -0
  115. package/build/types/listItem/Button/ListItemButton.d.ts +20 -0
  116. package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -0
  117. package/build/types/listItem/Button/index.d.ts +3 -0
  118. package/build/types/listItem/Button/index.d.ts.map +1 -0
  119. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts +14 -0
  120. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts.map +1 -0
  121. package/build/types/listItem/Checkbox/index.d.ts +3 -0
  122. package/build/types/listItem/Checkbox/index.d.ts.map +1 -0
  123. package/build/types/listItem/IconButton/ListItemIconButton.d.ts +18 -0
  124. package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -0
  125. package/build/types/listItem/IconButton/index.d.ts +3 -0
  126. package/build/types/listItem/IconButton/index.d.ts.map +1 -0
  127. package/build/types/listItem/Image/ListItemImage.d.ts +25 -0
  128. package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -0
  129. package/build/types/listItem/Image/index.d.ts +3 -0
  130. package/build/types/listItem/Image/index.d.ts.map +1 -0
  131. package/build/types/listItem/ListItem.d.ts +111 -0
  132. package/build/types/listItem/ListItem.d.ts.map +1 -0
  133. package/build/types/listItem/ListItemContext.d.ts +21 -0
  134. package/build/types/listItem/ListItemContext.d.ts.map +1 -0
  135. package/build/types/listItem/Navigation/ListItemNavigation.d.ts +15 -0
  136. package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -0
  137. package/build/types/listItem/Navigation/index.d.ts +3 -0
  138. package/build/types/listItem/Navigation/index.d.ts.map +1 -0
  139. package/build/types/listItem/Prompt/ListItemPrompt.d.ts +16 -0
  140. package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -0
  141. package/build/types/listItem/Prompt/index.d.ts +3 -0
  142. package/build/types/listItem/Prompt/index.d.ts.map +1 -0
  143. package/build/types/listItem/Radio/ListItemRadio.d.ts +14 -0
  144. package/build/types/listItem/Radio/ListItemRadio.d.ts.map +1 -0
  145. package/build/types/listItem/Radio/index.d.ts +3 -0
  146. package/build/types/listItem/Radio/index.d.ts.map +1 -0
  147. package/build/types/listItem/Switch/ListItemSwitch.d.ts +14 -0
  148. package/build/types/listItem/Switch/ListItemSwitch.d.ts.map +1 -0
  149. package/build/types/listItem/Switch/index.d.ts +3 -0
  150. package/build/types/listItem/Switch/index.d.ts.map +1 -0
  151. package/build/types/listItem/_stories/helpers.d.ts +27 -0
  152. package/build/types/listItem/_stories/helpers.d.ts.map +1 -0
  153. package/build/types/listItem/_stories/subcomponents.d.ts +18 -0
  154. package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -0
  155. package/build/types/listItem/index.d.ts +14 -0
  156. package/build/types/listItem/index.d.ts.map +1 -0
  157. package/build/types/listItem/test-utils.d.ts +7 -0
  158. package/build/types/listItem/test-utils.d.ts.map +1 -0
  159. package/build/types/listItem/useListItemControl.d.ts +5 -0
  160. package/build/types/listItem/useListItemControl.d.ts.map +1 -0
  161. package/build/types/listItem/useListItemMedia.d.ts +6 -0
  162. package/build/types/listItem/useListItemMedia.d.ts.map +1 -0
  163. package/build/types/title/Title.d.ts +4 -5
  164. package/build/types/title/Title.d.ts.map +1 -1
  165. package/package.json +3 -3
  166. package/src/button/Button.spec.tsx +25 -1
  167. package/src/button/Button.story.tsx +1 -0
  168. package/src/header/Header.accessibility.docs.mdx +85 -0
  169. package/src/header/Header.css +21 -14
  170. package/src/header/Header.less +17 -10
  171. package/src/header/Header.spec.tsx +68 -50
  172. package/src/header/Header.story.tsx +190 -36
  173. package/src/header/Header.tsx +96 -65
  174. package/src/header/index.ts +1 -0
  175. package/src/i18n/cs.json +2 -0
  176. package/src/i18n/es.json +2 -0
  177. package/src/i18n/th.json +2 -0
  178. package/src/iconButton/iconButton.spec.tsx +31 -0
  179. package/src/index.ts +16 -0
  180. package/src/legacylistItem/LegacyListItem.story.tsx +1 -1
  181. package/src/legacylistItem/LegacyListItem.tests.story.tsx +2 -1
  182. package/src/list/List.story.tsx +13 -3
  183. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.spec.tsx +56 -0
  184. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +198 -0
  185. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.tsx +36 -0
  186. package/src/listItem/AdditionalInfo/index.ts +2 -0
  187. package/src/listItem/AvatarLayout/ListItemAvatarLayout.spec.tsx +59 -0
  188. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +124 -0
  189. package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +27 -0
  190. package/src/listItem/AvatarLayout/index.ts +2 -0
  191. package/src/listItem/AvatarView/ListItemAvatarView.spec.tsx +75 -0
  192. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +339 -0
  193. package/src/listItem/AvatarView/ListItemAvatarView.tsx +27 -0
  194. package/src/listItem/AvatarView/index.ts +2 -0
  195. package/src/listItem/Button/ListItemButton.spec.tsx +90 -0
  196. package/src/listItem/Button/ListItemButton.story.tsx +473 -0
  197. package/src/listItem/Button/ListItemButton.tsx +56 -0
  198. package/src/listItem/Button/index.ts +2 -0
  199. package/src/listItem/Checkbox/ListItemCheckbox.spec.tsx +82 -0
  200. package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +128 -0
  201. package/src/listItem/Checkbox/ListItemCheckbox.tsx +33 -0
  202. package/src/listItem/Checkbox/index.ts +2 -0
  203. package/src/listItem/IconButton/ListItemIconButton.spec.tsx +131 -0
  204. package/src/listItem/IconButton/ListItemIconButton.story.tsx +284 -0
  205. package/src/listItem/IconButton/ListItemIconButton.tsx +73 -0
  206. package/src/listItem/IconButton/index.ts +2 -0
  207. package/src/listItem/Image/ListItemImage.spec.tsx +30 -0
  208. package/src/listItem/Image/ListItemImage.story.tsx +80 -0
  209. package/src/listItem/Image/ListItemImage.tsx +46 -0
  210. package/src/listItem/Image/index.ts +2 -0
  211. package/src/listItem/ListItem.css +773 -0
  212. package/src/listItem/ListItem.grid.css +370 -0
  213. package/src/listItem/ListItem.grid.less +622 -0
  214. package/src/listItem/ListItem.less +291 -0
  215. package/src/listItem/ListItem.spec.tsx +1511 -0
  216. package/src/listItem/ListItem.tsx +440 -0
  217. package/src/listItem/ListItemContext.tsx +26 -0
  218. package/src/listItem/Navigation/ListItemNavigation.spec.tsx +67 -0
  219. package/src/listItem/Navigation/ListItemNavigation.story.tsx +114 -0
  220. package/src/listItem/Navigation/ListItemNavigation.tsx +39 -0
  221. package/src/listItem/Navigation/index.ts +2 -0
  222. package/src/listItem/Prompt/ListItemPrompt.css +157 -0
  223. package/src/listItem/Prompt/ListItemPrompt.less +134 -0
  224. package/src/listItem/Prompt/ListItemPrompt.spec.tsx +36 -0
  225. package/src/listItem/Prompt/ListItemPrompt.story.tsx +204 -0
  226. package/src/listItem/Prompt/ListItemPrompt.tsx +32 -0
  227. package/src/listItem/Prompt/index.ts +2 -0
  228. package/src/listItem/Radio/ListItemRadio.spec.tsx +66 -0
  229. package/src/listItem/Radio/ListItemRadio.story.tsx +111 -0
  230. package/src/listItem/Radio/ListItemRadio.tsx +33 -0
  231. package/src/listItem/Radio/index.ts +2 -0
  232. package/src/listItem/Switch/ListItemSwitch.spec.tsx +47 -0
  233. package/src/listItem/Switch/ListItemSwitch.story.tsx +79 -0
  234. package/src/listItem/Switch/ListItemSwitch.tsx +33 -0
  235. package/src/listItem/Switch/index.ts +2 -0
  236. package/src/listItem/_stories/ListItem.focus.test.story.tsx +265 -0
  237. package/src/listItem/_stories/ListItem.layout.test.story.tsx +374 -0
  238. package/src/listItem/_stories/ListItem.scenarios.story.tsx +228 -0
  239. package/src/listItem/_stories/ListItem.story.tsx +774 -0
  240. package/src/listItem/_stories/ListItem.variants.test.story.tsx +274 -0
  241. package/src/listItem/_stories/helpers.tsx +53 -0
  242. package/src/listItem/_stories/subcomponents.tsx +141 -0
  243. package/src/listItem/index.ts +14 -0
  244. package/src/listItem/test-utils.tsx +33 -0
  245. package/src/listItem/useListItemControl.tsx +18 -0
  246. package/src/listItem/useListItemMedia.tsx +16 -0
  247. package/src/main.css +794 -14
  248. package/src/main.less +1 -0
  249. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +15 -4
  250. package/src/title/Title.tsx +25 -12
@@ -0,0 +1,31 @@
1
+ import IconButton from './IconButton';
2
+ import { mockMatchMedia, render, screen, userEvent } from '../test-utils';
3
+ import { Edit } from '@transferwise/icons';
4
+
5
+ mockMatchMedia();
6
+
7
+ describe('IconButton', () => {
8
+ describe('onClick', () => {
9
+ it('should respect onClick if rendered as HTML button', async () => {
10
+ const handleClick = jest.fn();
11
+ render(
12
+ <IconButton onClick={handleClick}>
13
+ <Edit />
14
+ </IconButton>,
15
+ );
16
+ await userEvent.click(screen.getByRole('button'));
17
+ expect(handleClick).toHaveBeenCalledTimes(1);
18
+ });
19
+
20
+ it('should respect onClick if rendered as HTML anchor', async () => {
21
+ const handleClick = jest.fn();
22
+ render(
23
+ <IconButton href="#target" onClick={handleClick}>
24
+ <Edit />
25
+ </IconButton>,
26
+ );
27
+ await userEvent.click(screen.getByRole('link'));
28
+ expect(handleClick).toHaveBeenCalledTimes(1);
29
+ });
30
+ });
31
+ });
package/src/index.ts CHANGED
@@ -31,6 +31,7 @@ export type { DefinitionListProps, DefinitionListDefinition } from './definition
31
31
  export type { DimmerProps } from './dimmer';
32
32
  export type { DrawerProps } from './drawer';
33
33
  export type { DividerProps } from './divider';
34
+ export type { HeaderProps } from './header';
34
35
  export type { EmphasisProps } from './emphasis';
35
36
  export type { FieldProps } from './field/Field';
36
37
  export type { InfoProps } from './info';
@@ -108,6 +109,20 @@ export type {
108
109
  TableCellStatus,
109
110
  TableCellType,
110
111
  } from './table';
112
+ export type {
113
+ ListItemProps,
114
+ ListItemSwitchProps,
115
+ ListItemRadioProps,
116
+ ListItemPromptProps,
117
+ ListItemNavigationProps,
118
+ ListItemImageProps,
119
+ ListItemIconButtonProps,
120
+ ListItemAdditionalInfoProps,
121
+ ListItemButtonProps,
122
+ ListItemCheckboxProps,
123
+ ListItemAvatarLayoutProps,
124
+ ListItemAvatarViewProps,
125
+ } from './listItem';
111
126
  export type { ListProps } from './list';
112
127
 
113
128
  /**
@@ -210,6 +225,7 @@ export { default as Typeahead } from './typeahead';
210
225
  export { default as Upload } from './upload';
211
226
  export { default as UploadInput } from './uploadInput';
212
227
  export { default as Table } from './table';
228
+ export { default as ListItem } from './listItem';
213
229
  export { default as List } from './list';
214
230
 
215
231
  /**
@@ -10,7 +10,7 @@ import LegacyListItem from '.';
10
10
 
11
11
  export default {
12
12
  component: LegacyListItem,
13
- title: 'Other/LegacyListItem',
13
+ title: 'Content/LegacyListItem',
14
14
  };
15
15
 
16
16
  const Template = ({
@@ -6,7 +6,8 @@ import List from '../list';
6
6
 
7
7
  export default {
8
8
  component: LegacyListItem,
9
- title: 'Other/LegacyListItem/tests',
9
+ tags: ['!autodocs'],
10
+ title: 'Content/LegacyListItem/tests',
10
11
  };
11
12
 
12
13
  export const LongText = () => {
@@ -1,5 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import LegacyListItem from '../legacylistItem';
2
+ import ListItem from '../listItem';
3
3
  import List from './List';
4
4
 
5
5
  export default {
@@ -13,8 +13,18 @@ type Story = StoryObj<typeof List>;
13
13
  export const Basic: Story = {
14
14
  render: (args) => (
15
15
  <List {...args}>
16
- <LegacyListItem title="First item" value="This is the first item." />
17
- <LegacyListItem title="Second item" value="This is the second item." />
16
+ <ListItem
17
+ as={args.as === 'div' ? 'div' : undefined}
18
+ title="First item"
19
+ subtitle="This is the first item."
20
+ media={<ListItem.AvatarView />}
21
+ />
22
+ <ListItem
23
+ as={args.as === 'div' ? 'div' : undefined}
24
+ title="Second item"
25
+ subtitle="This is the second item."
26
+ media={<ListItem.AvatarView />}
27
+ />
18
28
  </List>
19
29
  ),
20
30
  };
@@ -0,0 +1,56 @@
1
+ import { render, screen } from '../../test-utils';
2
+ import { ListItem, type ListItemProps } from '../ListItem';
3
+
4
+ describe('ListItem.AdditionalInfo', () => {
5
+ const renderWithInfo = (info: ListItemProps['additionalInfo']) =>
6
+ render(<ListItem title="Test title" subtitle="Test subtitle" additionalInfo={info} />);
7
+
8
+ it('renders children content', () => {
9
+ renderWithInfo(
10
+ <ListItem.AdditionalInfo>Additional information content</ListItem.AdditionalInfo>,
11
+ );
12
+ expect(screen.getByText('Additional information content')).toBeInTheDocument();
13
+ });
14
+
15
+ it('renders action button when onClick provided', () => {
16
+ const handleActionClick = jest.fn();
17
+ renderWithInfo(
18
+ <ListItem.AdditionalInfo action={{ label: 'Learn more', onClick: handleActionClick }}>
19
+ Additional info
20
+ </ListItem.AdditionalInfo>,
21
+ );
22
+
23
+ expect(screen.getByRole('button', { name: 'Learn more' })).toBeInTheDocument();
24
+ });
25
+
26
+ it('renders action link with href when provided', () => {
27
+ renderWithInfo(
28
+ <ListItem.AdditionalInfo action={{ label: 'Learn more', href: '/learn' }}>
29
+ Additional info
30
+ </ListItem.AdditionalInfo>,
31
+ );
32
+
33
+ const actionLink = screen.getByRole('link', { name: 'Learn more' });
34
+ expect(actionLink).toBeInTheDocument();
35
+ expect(actionLink).toHaveAttribute('href', '/learn');
36
+ });
37
+
38
+ it('renders action link with target when provided', () => {
39
+ renderWithInfo(
40
+ <ListItem.AdditionalInfo action={{ label: 'Learn more', href: '/learn', target: '_blank' }}>
41
+ Additional info
42
+ </ListItem.AdditionalInfo>,
43
+ );
44
+
45
+ const actionLink = screen.getByRole('link', { name: 'Learn more (opens in new tab)' });
46
+ expect(actionLink).toBeInTheDocument();
47
+ expect(actionLink).toHaveAttribute('target', '_blank');
48
+ });
49
+
50
+ it('does not render action when not provided', () => {
51
+ renderWithInfo(<ListItem.AdditionalInfo>Additional info only</ListItem.AdditionalInfo>);
52
+
53
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
54
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
55
+ });
56
+ });
@@ -0,0 +1,198 @@
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { fn } from 'storybook/test';
3
+ import { action } from 'storybook/actions';
4
+ import { lorem20 } from '../../test-utils';
5
+ import List from '../../list';
6
+ import { ListItem } from '../ListItem';
7
+ import {
8
+ SB_LIST_ITEM_CONTROLS as CONTROLS,
9
+ SB_LIST_ITEM_MEDIA as MEDIA,
10
+ } from '../_stories/subcomponents';
11
+ import { disableControls } from '../_stories/helpers';
12
+ import type { ListItemAdditionalInfoProps } from './ListItemAdditionalInfo';
13
+
14
+ /**
15
+ * Use additional information to add extra details that help make the information clearer for users. Use additional information only after you've used the subtitle.
16
+ *
17
+ * Refer to the [design documentation](https://wise.design/components/list-item#content:~:text=StatusIcon.iconLabel.error-,Additional%20information,-Use%20additional%20information) for more details.
18
+ */
19
+ export default {
20
+ component: ListItem.AdditionalInfo,
21
+ title: 'Content/ListItem/ListItem.AdditionalInfo',
22
+ parameters: {
23
+ docs: {
24
+ toc: true,
25
+ },
26
+ },
27
+ args: {
28
+ children: lorem20,
29
+ },
30
+ argTypes: {
31
+ children: {
32
+ table: {
33
+ type: { summary: 'ReactNode' },
34
+ },
35
+ },
36
+ action: {
37
+ table: {
38
+ type: { summary: `{ label: string } & Pick<LinkProps, 'href' | 'onClick' | 'target'>` },
39
+ },
40
+ },
41
+ },
42
+ } satisfies Meta<ListItemAdditionalInfoProps>;
43
+
44
+ type Story = StoryObj<ListItemAdditionalInfoProps>;
45
+
46
+ /**
47
+ * Convenience controls for previewing rich markup,
48
+ * not otherwise possible via Storybook
49
+ */
50
+ type PreviewStoryArgs = ListItemAdditionalInfoProps & {
51
+ previewAction?: string | ListItemAdditionalInfoProps['action'];
52
+ };
53
+
54
+ const previewArgGroup = {
55
+ category: 'Preview options',
56
+ type: {
57
+ summary: undefined,
58
+ },
59
+ };
60
+
61
+ const previewArgTypes = {
62
+ previewAction: {
63
+ name: 'Preview `action`',
64
+ control: 'radio',
65
+ options: ['unset (undefined)', 'link', 'button'],
66
+ mapping: {
67
+ 'unset (undefined)': undefined,
68
+ link: {
69
+ label: 'Details about the subject.',
70
+ href: 'https://wise.com',
71
+ target: '_blank',
72
+ },
73
+ button: {
74
+ label: 'Details about the subject.',
75
+ onClick: fn(),
76
+ },
77
+ },
78
+ table: previewArgGroup,
79
+ },
80
+ } as const;
81
+
82
+ export const Playground: StoryObj<PreviewStoryArgs> = {
83
+ tags: ['!autodocs'],
84
+ argTypes: previewArgTypes,
85
+ args: {
86
+ children: lorem20,
87
+ previewAction: 'link',
88
+ },
89
+ render: (args: PreviewStoryArgs) => {
90
+ const { previewAction, ...props } = args as {
91
+ previewAction: ListItemAdditionalInfoProps['action'];
92
+ props: ListItemAdditionalInfoProps;
93
+ };
94
+
95
+ return (
96
+ <List>
97
+ <ListItem
98
+ title="List item title"
99
+ subtitle="Subtitle goes here"
100
+ media={MEDIA.avatarSingle}
101
+ control={CONTROLS.partialButton}
102
+ additionalInfo={<ListItem.AdditionalInfo {...props} action={previewAction} />}
103
+ />
104
+ </List>
105
+ );
106
+ },
107
+ };
108
+
109
+ /**
110
+ * Fully interactive ListItems do not allow for any nested links or inline buttons as that would fail accessibility compliance.
111
+ *
112
+ * Non-interactive or partially-interactive ListItems allow appending a single link or inline button via `action` prop. The restriction has been introduced to ensure that the ListItem remains accessible and adheres to the vendors' best practices for mobile platforms.
113
+ */
114
+ export const Interactivity: Story = {
115
+ args: {
116
+ action: {
117
+ label: 'Details about the subject.',
118
+ href: 'https://wise.com',
119
+ target: '_blank',
120
+ },
121
+ },
122
+ argTypes: disableControls()(['action']),
123
+ render: (args: ListItemAdditionalInfoProps) => {
124
+ return (
125
+ <List>
126
+ <ListItem
127
+ title="Fully interactive ListItem"
128
+ subtitle="Subtitle goes here"
129
+ media={MEDIA.avatarSingle}
130
+ control={CONTROLS.button}
131
+ additionalInfo={<ListItem.AdditionalInfo {...args} action={undefined} />}
132
+ />
133
+
134
+ <ListItem
135
+ title="Partially interactive ListItem"
136
+ subtitle="Subtitle goes here"
137
+ media={MEDIA.avatarSingle}
138
+ control={CONTROLS.partialButton}
139
+ additionalInfo={<ListItem.AdditionalInfo {...args} />}
140
+ />
141
+
142
+ <ListItem
143
+ title="Non-interactive ListItem"
144
+ subtitle="Subtitle goes here"
145
+ media={MEDIA.avatarSingle}
146
+ additionalInfo={<ListItem.AdditionalInfo {...args} />}
147
+ />
148
+ </List>
149
+ );
150
+ },
151
+ };
152
+
153
+ /**
154
+ * Interactive `ListItem.AdditionalInfo` allows for 2 types of actions: a link or a button.
155
+ */
156
+ export const Actions: Story = {
157
+ argTypes: disableControls()(['action']),
158
+ render: (args: ListItemAdditionalInfoProps) => {
159
+ return (
160
+ <List>
161
+ <ListItem
162
+ title="Partially interactive ListItem"
163
+ subtitle="Subtitle goes here"
164
+ media={MEDIA.avatarSingle}
165
+ control={CONTROLS.partialButton}
166
+ additionalInfo={
167
+ <ListItem.AdditionalInfo
168
+ {...args}
169
+ action={{
170
+ label: 'I am a link.',
171
+ href: 'https://wise.com',
172
+ target: '_blank',
173
+ }}
174
+ />
175
+ }
176
+ />
177
+
178
+ <ListItem
179
+ title="Partially interactive ListItem"
180
+ subtitle="Subtitle goes here"
181
+ media={MEDIA.avatarSingle}
182
+ control={CONTROLS.partialButton}
183
+ additionalInfo={
184
+ <ListItem.AdditionalInfo
185
+ {...args}
186
+ action={{
187
+ label: 'I am a button.',
188
+ onClick: () => {
189
+ action('Button clicked')();
190
+ },
191
+ }}
192
+ />
193
+ }
194
+ />
195
+ </List>
196
+ );
197
+ },
198
+ };
@@ -0,0 +1,36 @@
1
+ import { PropsWithChildren, useContext } from 'react';
2
+ import { ListItemContext, type ListItemContextData } from '../ListItemContext';
3
+ import Body from '../../body';
4
+ import Link, { type LinkProps } from '../../link';
5
+ import { Typography } from '../../common';
6
+
7
+ export type ListItemAdditionalInfoProps = PropsWithChildren<{
8
+ /**
9
+ * Props object to be passed to the [Link](https://storybook.wise.design/?path=/docs/typography-link--docs) component.
10
+ */
11
+ action?: { label: string } & Pick<LinkProps, 'href' | 'onClick' | 'target'>;
12
+ }>;
13
+
14
+ export const AdditionalInfo = function ({ children, action }: ListItemAdditionalInfoProps) {
15
+ const { ids } = useContext<ListItemContextData>(ListItemContext);
16
+
17
+ return (
18
+ <Body
19
+ type={Typography.BODY_DEFAULT}
20
+ id={ids.additionalInfo}
21
+ className="wds-list-item-additional-info"
22
+ >
23
+ {children}
24
+ {action ? (
25
+ <>
26
+ {' '}
27
+ <Link href={action.href} target={action.target} onClick={action.onClick}>
28
+ {action.label}
29
+ </Link>
30
+ </>
31
+ ) : null}
32
+ </Body>
33
+ );
34
+ };
35
+
36
+ AdditionalInfo.displayName = 'ListItem.AdditionalInfo';
@@ -0,0 +1,2 @@
1
+ export type { ListItemAdditionalInfoProps } from './ListItemAdditionalInfo';
2
+ export { AdditionalInfo } from './ListItemAdditionalInfo';
@@ -0,0 +1,59 @@
1
+ import { mockMatchMedia, render, screen } from '../../test-utils';
2
+ import { ListItem, type ListItemProps } from '../ListItem';
3
+
4
+ mockMatchMedia();
5
+
6
+ const avatars = [
7
+ { imgSrc: 'avatar1.jpg', profileName: 'User 1' },
8
+ { imgSrc: 'avatar2.jpg', profileName: 'User 2' },
9
+ ];
10
+
11
+ const renderWithMedia = (media: ListItemProps['media']) =>
12
+ render(<ListItem title="Test Title" media={media} />);
13
+
14
+ describe('ListItem.AvatarLayout', () => {
15
+ it('applies custom className alongside default class', () => {
16
+ renderWithMedia(
17
+ <ListItem.AvatarLayout
18
+ className="custom-class"
19
+ role="group"
20
+ aria-label="Custom avatar group"
21
+ avatars={avatars}
22
+ />,
23
+ );
24
+
25
+ expect(screen.getByRole('group', { name: 'Custom avatar group' })).toHaveClass('custom-class');
26
+ });
27
+
28
+ it('renders both avatars', () => {
29
+ renderWithMedia(<ListItem.AvatarLayout avatars={avatars} />);
30
+
31
+ const images = screen.getAllByRole('presentation');
32
+ expect(images).toHaveLength(avatars.length);
33
+ expect(images[0]).toHaveAttribute('src', avatars[0].imgSrc);
34
+ expect(images[1]).toHaveAttribute('src', avatars[1].imgSrc);
35
+ });
36
+
37
+ it('renders with single avatar', () => {
38
+ renderWithMedia(<ListItem.AvatarLayout avatars={[avatars[0]]} />);
39
+ expect(screen.getByRole('presentation')).toHaveAttribute('src', avatars[0].imgSrc);
40
+ });
41
+
42
+ it('handles empty avatars array', () => {
43
+ renderWithMedia(<ListItem.AvatarLayout avatars={[]} />);
44
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
45
+ });
46
+
47
+ it('supports accessibility props', () => {
48
+ renderWithMedia(<ListItem.AvatarLayout aria-label="User avatars" avatars={avatars} />);
49
+ expect(screen.getByLabelText('User avatars')).toBeInTheDocument();
50
+ });
51
+
52
+ it('passes through role', () => {
53
+ renderWithMedia(
54
+ <ListItem.AvatarLayout role="group" aria-label="Avatar group" avatars={avatars} />,
55
+ );
56
+
57
+ expect(screen.getByRole('group', { name: 'Avatar group' })).toBeInTheDocument();
58
+ });
59
+ });
@@ -0,0 +1,124 @@
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 List from '../../list';
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 type { ListItemAvatarLayoutProps } from './ListItemAvatarLayout';
12
+
13
+ export default {
14
+ component: ListItem.AvatarLayout,
15
+ title: 'Content/ListItem/ListItem.AvatarLayout',
16
+ parameters: {
17
+ docs: {
18
+ toc: true,
19
+ },
20
+ },
21
+ args: {
22
+ avatars: [{ asset: <Flag code="gb" /> }, { asset: <Flag code="eur" /> }],
23
+ orientation: 'horizontal',
24
+ size: 48,
25
+ },
26
+ argTypes: {
27
+ avatars: {
28
+ description: 'Array of avatar objects with asset and optional styling properties',
29
+ table: {
30
+ type: { summary: 'SingleAvatarType[]' },
31
+ },
32
+ },
33
+ orientation: {
34
+ control: 'inline-radio',
35
+ options: ['horizontal', 'diagonal'],
36
+ description: 'Layout orientation for multiple avatars',
37
+ },
38
+ size: {
39
+ control: 'select',
40
+ options: [32, 40, 48, 56, 72],
41
+ description: 'Size of the avatar layout',
42
+ },
43
+ },
44
+ } satisfies Meta<ListItemAvatarLayoutProps>;
45
+
46
+ type Story = StoryObj<ListItemAvatarLayoutProps>;
47
+
48
+ export const Playground: Story = {
49
+ tags: ['!autodocs'],
50
+ render: (args: ListItemAvatarLayoutProps) => {
51
+ return (
52
+ <List>
53
+ <ListItem
54
+ title="Transfer from GBP to EUR"
55
+ subtitle="Currency exchange"
56
+ media={<ListItem.AvatarLayout {...args} />}
57
+ control={CONTROLS.iconButton}
58
+ additionalInfo={INFO.nonInteractive}
59
+ />
60
+ </List>
61
+ );
62
+ },
63
+ };
64
+
65
+ /**
66
+ * AvatarLayout supports two orientations: horizontal (default) and diagonal. <br />
67
+ * Please refer to the [design documentation](https://wise.design/components/avatar#double) for more details.
68
+ */
69
+ export const Orientations: Story = {
70
+ argTypes: disableControls()(['orientation']),
71
+ render: (args) => {
72
+ return (
73
+ <List>
74
+ <ListItem
75
+ title="Horizontal orientation"
76
+ subtitle={lorem10}
77
+ media={<ListItem.AvatarLayout {...args} orientation="horizontal" />}
78
+ control={CONTROLS.iconButton}
79
+ />
80
+
81
+ <ListItem
82
+ title="Diagonal orientation"
83
+ subtitle={lorem10}
84
+ media={<ListItem.AvatarLayout {...args} orientation="diagonal" />}
85
+ control={CONTROLS.iconButton}
86
+ />
87
+ </List>
88
+ );
89
+ },
90
+ };
91
+
92
+ /**
93
+ * AvatarLayout supports various sizes to fit different list item contexts.
94
+ */
95
+ export const Sizes: Story = {
96
+ parameters: {
97
+ docs: {
98
+ canvas: {
99
+ sourceState: 'hidden',
100
+ },
101
+ },
102
+ },
103
+ argTypes: disableControls()(['size', 'orientation']),
104
+ render: (args) => {
105
+ const sizes = [32, 40, 48, 56, 72] as const;
106
+ const orientations = ['horizontal', 'diagonal'] as const;
107
+
108
+ return (
109
+ <List>
110
+ {orientations.map((orientation) =>
111
+ sizes.map((size) => (
112
+ <ListItem
113
+ key={`${orientation}-${size}`}
114
+ title={`Size ${size}`}
115
+ subtitle={lorem10}
116
+ media={<ListItem.AvatarLayout {...args} size={size} orientation={orientation} />}
117
+ control={CONTROLS.iconButton}
118
+ />
119
+ )),
120
+ )}
121
+ </List>
122
+ );
123
+ },
124
+ };
@@ -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';