@transferwise/components 0.0.0-experimental-e06e456 → 0.0.0-experimental-e3978a5

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 (201) hide show
  1. package/build/index.js +2 -0
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +1 -0
  4. package/build/index.mjs.map +1 -1
  5. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +56 -0
  6. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +1 -0
  7. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +54 -0
  8. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +1 -0
  9. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +23 -0
  10. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -0
  11. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +21 -0
  12. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -0
  13. package/build/listItem/AvatarView/ListItemAvatarView.js +23 -0
  14. package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -0
  15. package/build/listItem/AvatarView/ListItemAvatarView.mjs +21 -0
  16. package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -0
  17. package/build/listItem/Button/ListItemButton.js +43 -0
  18. package/build/listItem/Button/ListItemButton.js.map +1 -0
  19. package/build/listItem/Button/ListItemButton.mjs +41 -0
  20. package/build/listItem/Button/ListItemButton.mjs.map +1 -0
  21. package/build/listItem/Checkbox/ListItemCheckbox.js +30 -0
  22. package/build/listItem/Checkbox/ListItemCheckbox.js.map +1 -0
  23. package/build/listItem/Checkbox/ListItemCheckbox.mjs +28 -0
  24. package/build/listItem/Checkbox/ListItemCheckbox.mjs.map +1 -0
  25. package/build/listItem/IconButton/ListItemIconButton.js +56 -0
  26. package/build/listItem/IconButton/ListItemIconButton.js.map +1 -0
  27. package/build/listItem/IconButton/ListItemIconButton.mjs +54 -0
  28. package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -0
  29. package/build/listItem/Image/ListItemImage.js +31 -0
  30. package/build/listItem/Image/ListItemImage.js.map +1 -0
  31. package/build/listItem/Image/ListItemImage.mjs +29 -0
  32. package/build/listItem/Image/ListItemImage.mjs.map +1 -0
  33. package/build/listItem/ListItem.js +313 -0
  34. package/build/listItem/ListItem.js.map +1 -0
  35. package/build/listItem/ListItem.mjs +308 -0
  36. package/build/listItem/ListItem.mjs.map +1 -0
  37. package/build/listItem/ListItemContext.js +8 -0
  38. package/build/listItem/ListItemContext.js.map +1 -0
  39. package/build/listItem/ListItemContext.mjs +6 -0
  40. package/build/listItem/ListItemContext.mjs.map +1 -0
  41. package/build/listItem/Navigation/ListItemNavigation.js +44 -0
  42. package/build/listItem/Navigation/ListItemNavigation.js.map +1 -0
  43. package/build/listItem/Navigation/ListItemNavigation.mjs +42 -0
  44. package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -0
  45. package/build/listItem/Prompt/ListItemPrompt.js +59 -0
  46. package/build/listItem/Prompt/ListItemPrompt.js.map +1 -0
  47. package/build/listItem/Prompt/ListItemPrompt.mjs +54 -0
  48. package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -0
  49. package/build/listItem/Radio/ListItemRadio.js +30 -0
  50. package/build/listItem/Radio/ListItemRadio.js.map +1 -0
  51. package/build/listItem/Radio/ListItemRadio.mjs +28 -0
  52. package/build/listItem/Radio/ListItemRadio.mjs.map +1 -0
  53. package/build/listItem/Switch/ListItemSwitch.js +30 -0
  54. package/build/listItem/Switch/ListItemSwitch.js.map +1 -0
  55. package/build/listItem/Switch/ListItemSwitch.mjs +28 -0
  56. package/build/listItem/Switch/ListItemSwitch.mjs.map +1 -0
  57. package/build/listItem/useListItemControl.js +22 -0
  58. package/build/listItem/useListItemControl.js.map +1 -0
  59. package/build/listItem/useListItemControl.mjs +20 -0
  60. package/build/listItem/useListItemControl.mjs.map +1 -0
  61. package/build/listItem/useListItemMedia.js +21 -0
  62. package/build/listItem/useListItemMedia.js.map +1 -0
  63. package/build/listItem/useListItemMedia.mjs +19 -0
  64. package/build/listItem/useListItemMedia.mjs.map +1 -0
  65. package/build/main.css +771 -1
  66. package/build/styles/button/Button.css +1 -1
  67. package/build/styles/listItem/ListItem.css +770 -0
  68. package/build/styles/listItem/ListItem.grid.css +370 -0
  69. package/build/styles/main.css +771 -1
  70. package/build/types/index.d.ts +2 -0
  71. package/build/types/index.d.ts.map +1 -1
  72. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts +15 -0
  73. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts.map +1 -0
  74. package/build/types/listItem/AdditionalInfo/index.d.ts +3 -0
  75. package/build/types/listItem/AdditionalInfo/index.d.ts.map +1 -0
  76. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts +18 -0
  77. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -0
  78. package/build/types/listItem/AvatarLayout/index.d.ts +3 -0
  79. package/build/types/listItem/AvatarLayout/index.d.ts.map +1 -0
  80. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts +16 -0
  81. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -0
  82. package/build/types/listItem/AvatarView/index.d.ts +3 -0
  83. package/build/types/listItem/AvatarView/index.d.ts.map +1 -0
  84. package/build/types/listItem/Button/ListItemButton.d.ts +20 -0
  85. package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -0
  86. package/build/types/listItem/Button/index.d.ts +3 -0
  87. package/build/types/listItem/Button/index.d.ts.map +1 -0
  88. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts +14 -0
  89. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts.map +1 -0
  90. package/build/types/listItem/Checkbox/index.d.ts +3 -0
  91. package/build/types/listItem/Checkbox/index.d.ts.map +1 -0
  92. package/build/types/listItem/IconButton/ListItemIconButton.d.ts +18 -0
  93. package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -0
  94. package/build/types/listItem/IconButton/index.d.ts +3 -0
  95. package/build/types/listItem/IconButton/index.d.ts.map +1 -0
  96. package/build/types/listItem/Image/ListItemImage.d.ts +25 -0
  97. package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -0
  98. package/build/types/listItem/Image/index.d.ts +3 -0
  99. package/build/types/listItem/Image/index.d.ts.map +1 -0
  100. package/build/types/listItem/ListItem.d.ts +113 -0
  101. package/build/types/listItem/ListItem.d.ts.map +1 -0
  102. package/build/types/listItem/ListItemContext.d.ts +21 -0
  103. package/build/types/listItem/ListItemContext.d.ts.map +1 -0
  104. package/build/types/listItem/Navigation/ListItemNavigation.d.ts +15 -0
  105. package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -0
  106. package/build/types/listItem/Navigation/index.d.ts +3 -0
  107. package/build/types/listItem/Navigation/index.d.ts.map +1 -0
  108. package/build/types/listItem/Prompt/ListItemPrompt.d.ts +16 -0
  109. package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -0
  110. package/build/types/listItem/Prompt/index.d.ts +3 -0
  111. package/build/types/listItem/Prompt/index.d.ts.map +1 -0
  112. package/build/types/listItem/Radio/ListItemRadio.d.ts +14 -0
  113. package/build/types/listItem/Radio/ListItemRadio.d.ts.map +1 -0
  114. package/build/types/listItem/Radio/index.d.ts +3 -0
  115. package/build/types/listItem/Radio/index.d.ts.map +1 -0
  116. package/build/types/listItem/Switch/ListItemSwitch.d.ts +14 -0
  117. package/build/types/listItem/Switch/ListItemSwitch.d.ts.map +1 -0
  118. package/build/types/listItem/Switch/index.d.ts +3 -0
  119. package/build/types/listItem/Switch/index.d.ts.map +1 -0
  120. package/build/types/listItem/_stories/helpers.d.ts +27 -0
  121. package/build/types/listItem/_stories/helpers.d.ts.map +1 -0
  122. package/build/types/listItem/_stories/subcomponents.d.ts +18 -0
  123. package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -0
  124. package/build/types/listItem/index.d.ts +14 -0
  125. package/build/types/listItem/index.d.ts.map +1 -0
  126. package/build/types/listItem/test-utils.d.ts +7 -0
  127. package/build/types/listItem/test-utils.d.ts.map +1 -0
  128. package/build/types/listItem/useListItemControl.d.ts +5 -0
  129. package/build/types/listItem/useListItemControl.d.ts.map +1 -0
  130. package/build/types/listItem/useListItemMedia.d.ts +6 -0
  131. package/build/types/listItem/useListItemMedia.d.ts.map +1 -0
  132. package/package.json +1 -1
  133. package/src/button/Button.css +1 -1
  134. package/src/button/Button.less +1 -1
  135. package/src/button/Button.story.tsx +4 -9
  136. package/src/index.ts +15 -0
  137. package/src/list/List.story.tsx +13 -3
  138. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.spec.tsx +56 -0
  139. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +198 -0
  140. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.tsx +36 -0
  141. package/src/listItem/AdditionalInfo/index.ts +2 -0
  142. package/src/listItem/AvatarLayout/ListItemAvatarLayout.spec.tsx +59 -0
  143. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +124 -0
  144. package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +27 -0
  145. package/src/listItem/AvatarLayout/index.ts +2 -0
  146. package/src/listItem/AvatarView/ListItemAvatarView.spec.tsx +75 -0
  147. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +339 -0
  148. package/src/listItem/AvatarView/ListItemAvatarView.tsx +27 -0
  149. package/src/listItem/AvatarView/index.ts +2 -0
  150. package/src/listItem/Button/ListItemButton.spec.tsx +68 -0
  151. package/src/listItem/Button/ListItemButton.story.tsx +473 -0
  152. package/src/listItem/Button/ListItemButton.tsx +56 -0
  153. package/src/listItem/Button/index.ts +2 -0
  154. package/src/listItem/Checkbox/ListItemCheckbox.spec.tsx +82 -0
  155. package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +128 -0
  156. package/src/listItem/Checkbox/ListItemCheckbox.tsx +33 -0
  157. package/src/listItem/Checkbox/index.ts +2 -0
  158. package/src/listItem/IconButton/ListItemIconButton.spec.tsx +119 -0
  159. package/src/listItem/IconButton/ListItemIconButton.story.tsx +284 -0
  160. package/src/listItem/IconButton/ListItemIconButton.tsx +73 -0
  161. package/src/listItem/IconButton/index.ts +2 -0
  162. package/src/listItem/Image/ListItemImage.spec.tsx +30 -0
  163. package/src/listItem/Image/ListItemImage.story.tsx +80 -0
  164. package/src/listItem/Image/ListItemImage.tsx +46 -0
  165. package/src/listItem/Image/index.ts +2 -0
  166. package/src/listItem/ListItem.css +770 -0
  167. package/src/listItem/ListItem.grid.css +370 -0
  168. package/src/listItem/ListItem.grid.less +622 -0
  169. package/src/listItem/ListItem.less +421 -0
  170. package/src/listItem/ListItem.spec.tsx +1521 -0
  171. package/src/listItem/ListItem.tsx +444 -0
  172. package/src/listItem/ListItemContext.tsx +26 -0
  173. package/src/listItem/Navigation/ListItemNavigation.spec.tsx +59 -0
  174. package/src/listItem/Navigation/ListItemNavigation.story.tsx +112 -0
  175. package/src/listItem/Navigation/ListItemNavigation.tsx +39 -0
  176. package/src/listItem/Navigation/index.ts +2 -0
  177. package/src/listItem/Prompt/ListItemPrompt.spec.tsx +36 -0
  178. package/src/listItem/Prompt/ListItemPrompt.story.tsx +204 -0
  179. package/src/listItem/Prompt/ListItemPrompt.tsx +32 -0
  180. package/src/listItem/Prompt/index.ts +2 -0
  181. package/src/listItem/Radio/ListItemRadio.spec.tsx +66 -0
  182. package/src/listItem/Radio/ListItemRadio.story.tsx +111 -0
  183. package/src/listItem/Radio/ListItemRadio.tsx +33 -0
  184. package/src/listItem/Radio/index.ts +2 -0
  185. package/src/listItem/Switch/ListItemSwitch.spec.tsx +47 -0
  186. package/src/listItem/Switch/ListItemSwitch.story.tsx +79 -0
  187. package/src/listItem/Switch/ListItemSwitch.tsx +33 -0
  188. package/src/listItem/Switch/index.ts +2 -0
  189. package/src/listItem/_stories/ListItem.focus.test.story.tsx +265 -0
  190. package/src/listItem/_stories/ListItem.layout.test.story.tsx +354 -0
  191. package/src/listItem/_stories/ListItem.scenarios.story.tsx +228 -0
  192. package/src/listItem/_stories/ListItem.story.tsx +775 -0
  193. package/src/listItem/_stories/ListItem.variants.test.story.tsx +271 -0
  194. package/src/listItem/_stories/helpers.tsx +53 -0
  195. package/src/listItem/_stories/subcomponents.tsx +139 -0
  196. package/src/listItem/index.ts +14 -0
  197. package/src/listItem/test-utils.tsx +33 -0
  198. package/src/listItem/useListItemControl.tsx +18 -0
  199. package/src/listItem/useListItemMedia.tsx +16 -0
  200. package/src/main.css +771 -1
  201. package/src/main.less +1 -0
@@ -0,0 +1,775 @@
1
+ import { useState } from 'react';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
+ import { MultiCurrency, Plus } from '@transferwise/icons';
4
+ import { lorem5, lorem10 } from '../../test-utils';
5
+ import Emphasis from '../../emphasis';
6
+ import List from '../../list';
7
+ import { ListItem, type ListItemProps } from '../ListItem';
8
+ import {
9
+ SB_LIST_ITEM_CONTROLS as CONTROLS,
10
+ SB_LIST_ITEM_ADDITIONAL_INFO as ADDITIONAL_INFO,
11
+ SB_LIST_ITEM_PROMPTS as PROMPTS,
12
+ SB_LIST_ITEM_MEDIA as MEDIA,
13
+ } from './subcomponents';
14
+ import { disableControls, storySourceWithoutNoise, withoutKey } from './helpers';
15
+ import Link from '../../link';
16
+
17
+ const hideControls = disableControls([
18
+ 'additionalInfo',
19
+ 'control',
20
+ 'prompt',
21
+ 'media',
22
+ 'className',
23
+ 'id',
24
+ 'role',
25
+ 'aria-labelledby',
26
+ 'as',
27
+ ]);
28
+
29
+ /**
30
+ * List Items let users review or select options from a dynamic list.<br />
31
+ * For more details please refer to the [release notes](https://transferwise.atlassian.net/wiki/spaces/DS/pages/3647251055/List+Item+release+notes) and the [design spec](https://wise.design/components/list-item). <br />
32
+ *
33
+ * > This component replaces now deprecated `LegacyListItem`, `Summary` and all `*Option` components
34
+ */
35
+ export default {
36
+ component: ListItem,
37
+ subcomponents: {
38
+ 'ListItem.AdditionalInfo': ListItem.AdditionalInfo,
39
+ 'ListItem.Prompt': ListItem.Prompt,
40
+ 'ListItem.Button': ListItem.Button,
41
+ 'ListItem.IconButton': ListItem.IconButton,
42
+ 'ListItem.Navigation': ListItem.Navigation,
43
+ 'ListItem.Checkbox': ListItem.Checkbox,
44
+ 'ListItem.Radio': ListItem.Radio,
45
+ 'ListItem.Switch': ListItem.Switch,
46
+ 'ListItem.AvatarView': ListItem.AvatarView,
47
+ 'ListItem.AvatarLayout': ListItem.AvatarLayout,
48
+ 'ListItem.Image': ListItem.Image,
49
+ },
50
+ title: 'Content/ListItem',
51
+ parameters: {
52
+ docs: {
53
+ toc: true,
54
+ },
55
+ },
56
+ args: {
57
+ title: 'List item title',
58
+ subtitle: 'Subtitle goes here',
59
+ valueTitle: '100 GBP',
60
+ valueSubtitle: '100 USD',
61
+ disabled: false,
62
+ spotlight: undefined,
63
+ inverted: false,
64
+ valueColumnWidth: undefined,
65
+ },
66
+ argTypes: {
67
+ spotlight: {
68
+ control: 'radio',
69
+ options: ['unset (undefined)', 'active', 'inactive'],
70
+ mapping: {
71
+ 'unset (undefined)': undefined,
72
+ active: 'active',
73
+ inactive: 'inactive',
74
+ },
75
+ },
76
+ },
77
+ } satisfies Meta<ListItemProps>;
78
+
79
+ type Story = StoryObj<ListItemProps>;
80
+
81
+ /**
82
+ * Convenience controls for previewing rich markup,
83
+ * not otherwise possible via Storybook
84
+ */
85
+ type PreviewStoryArgs = ListItemProps & {
86
+ previewInteractivity: 'non-interactive' | 'fully-interactive' | 'partially-interactive';
87
+ previewControlFull: ListItemProps['control'];
88
+ previewControlPartial: ListItemProps['control'];
89
+ previewAdditionalInfoFull: ListItemProps['additionalInfo'];
90
+ previewAdditionalInfoPartial: ListItemProps['additionalInfo'];
91
+ previewPrompt: ListItemProps['prompt'];
92
+ previewMedia: ListItemProps['media'];
93
+ };
94
+
95
+ const previewArgGroup = {
96
+ category: 'Preview options',
97
+ type: {
98
+ summary: undefined,
99
+ },
100
+ };
101
+
102
+ const previewArgTypes = {
103
+ previewInteractivity: {
104
+ name: 'Preview different interactivity',
105
+ control: 'radio',
106
+ options: ['non-interactive', 'fully-interactive', 'partially-interactive'],
107
+ table: previewArgGroup,
108
+ },
109
+
110
+ previewControlFull: {
111
+ name: 'Preview with `control`',
112
+ if: {
113
+ arg: 'previewInteractivity',
114
+ eq: 'fully-interactive',
115
+ },
116
+ control: 'select',
117
+ options: [
118
+ 'unset (undefined)',
119
+ 'Button',
120
+ 'Button as anchor',
121
+ 'IconButton',
122
+ 'IconButton as anchor',
123
+ 'Navigation',
124
+ 'Navigation as button',
125
+ 'Checkbox',
126
+ 'Radio',
127
+ 'Switch',
128
+ ],
129
+ mapping: {
130
+ 'unset (undefined)': undefined,
131
+ Button: CONTROLS.button,
132
+ 'Button as anchor': CONTROLS.buttonAsLink,
133
+ IconButton: CONTROLS.iconButton,
134
+ 'IconButton as anchor': CONTROLS.iconButtonAsLink,
135
+ Navigation: CONTROLS.navigation,
136
+ 'Navigation as button': CONTROLS.navigationAsButton,
137
+ Checkbox: CONTROLS.checkbox,
138
+ Radio: CONTROLS.radio,
139
+ Switch: CONTROLS.switch,
140
+ },
141
+ table: previewArgGroup,
142
+ },
143
+
144
+ previewControlPartial: {
145
+ name: 'Preview with `control`',
146
+ if: {
147
+ arg: 'previewInteractivity',
148
+ eq: 'partially-interactive',
149
+ },
150
+ control: 'select',
151
+ options: [
152
+ 'unset (undefined)',
153
+ 'Button',
154
+ 'Button as anchor',
155
+ 'IconButton',
156
+ 'IconButton as anchor',
157
+ ],
158
+ mapping: {
159
+ 'unset (undefined)': undefined,
160
+ Button: CONTROLS.partialButton,
161
+ 'Button as anchor': CONTROLS.partialButtonAsLink,
162
+ IconButton: CONTROLS.partialIconButton,
163
+ 'IconButton as anchor': CONTROLS.partialIconButtonAsLink,
164
+ },
165
+ table: previewArgGroup,
166
+ },
167
+
168
+ previewAdditionalInfoFull: {
169
+ name: 'Preview with `additionalInfo`',
170
+ if: {
171
+ arg: 'previewInteractivity',
172
+ eq: 'fully-interactive',
173
+ },
174
+ control: 'radio',
175
+ options: ['unset (undefined)', 'non-interactive'],
176
+ mapping: {
177
+ 'unset (undefined)': undefined,
178
+ 'non-interactive': ADDITIONAL_INFO.nonInteractive,
179
+ },
180
+ table: previewArgGroup,
181
+ },
182
+ previewAdditionalInfoPartial: {
183
+ name: 'Preview with `additionalInfo`',
184
+ if: {
185
+ arg: 'previewInteractivity',
186
+ eq: 'partially-interactive',
187
+ },
188
+ control: 'radio',
189
+ options: ['unset (undefined)', 'interactive', 'non-interactive'],
190
+ mapping: {
191
+ 'unset (undefined)': undefined,
192
+ interactive: ADDITIONAL_INFO.interactive,
193
+ 'non-interactive': ADDITIONAL_INFO.nonInteractive,
194
+ },
195
+ table: previewArgGroup,
196
+ },
197
+
198
+ previewPrompt: {
199
+ name: 'Preview with `prompt`',
200
+ control: 'radio',
201
+ options: ['unset (undefined)', 'interactive', 'non-interactive'],
202
+ mapping: {
203
+ 'unset (undefined)': undefined,
204
+ interactive: PROMPTS.interactive,
205
+ 'non-interactive': PROMPTS.nonInteractive,
206
+ },
207
+ table: previewArgGroup,
208
+ },
209
+
210
+ previewMedia: {
211
+ name: 'Preview with `media`',
212
+ control: 'select',
213
+ options: [
214
+ 'unset (undefined)',
215
+ 'image',
216
+ 'avatar: single',
217
+ 'avatar: double',
218
+ 'avatar: double-diagonal',
219
+ ],
220
+ mapping: {
221
+ 'unset (undefined)': undefined,
222
+ image: MEDIA.image,
223
+ 'avatar: single': MEDIA.avatarSingle,
224
+ 'avatar: double': MEDIA.avatarDouble,
225
+ 'avatar: double-diagonal': MEDIA.avatarDiagonal,
226
+ },
227
+ table: previewArgGroup,
228
+ },
229
+ } as const;
230
+
231
+ const getPropsForPreview = (args: PreviewStoryArgs): [ListItemProps, Partial<ListItemProps>] => {
232
+ const {
233
+ previewInteractivity,
234
+ previewControlFull,
235
+ previewControlPartial,
236
+ previewAdditionalInfoFull,
237
+ previewAdditionalInfoPartial,
238
+ previewPrompt,
239
+ previewMedia,
240
+ ...props
241
+ } = args;
242
+
243
+ return [
244
+ props,
245
+ {
246
+ control: previewControlFull || previewControlPartial,
247
+ additionalInfo: previewAdditionalInfoFull || previewAdditionalInfoPartial,
248
+ prompt: previewPrompt,
249
+ media: previewMedia,
250
+ },
251
+ ];
252
+ };
253
+
254
+ export const Playground: StoryObj<PreviewStoryArgs> = {
255
+ tags: ['!autodocs'],
256
+ render: (args: PreviewStoryArgs) => {
257
+ const [props, previewProps] = getPropsForPreview(args);
258
+
259
+ return (
260
+ <List>
261
+ <ListItem {...props} {...previewProps} />
262
+ </List>
263
+ );
264
+ },
265
+ argTypes: previewArgTypes,
266
+ args: {
267
+ previewInteractivity: 'fully-interactive',
268
+ previewPrompt: 'interactive',
269
+ previewMedia: 'avatar: single',
270
+ previewControlFull: 'Button',
271
+ previewControlPartial: 'Button',
272
+ previewAdditionalInfoFull: 'non-interactive',
273
+ previewAdditionalInfoPartial: 'non-interactive',
274
+ },
275
+ decorators: [withoutKey],
276
+ };
277
+
278
+ /**
279
+ * ListItem uses container queries under the hood, which means its layout self-adjusts based on
280
+ * the available space. At the 100% zoom level, these breakpoints correspond to
281
+ * containers under `290px`, those between `291px and 380px`, and finally everything including
282
+ * and above `381px`. <br />
283
+ * This also supports high levels of zoom for assistive tech users.
284
+ */
285
+ export const Responsiveness: StoryObj<PreviewStoryArgs> = {
286
+ parameters: {
287
+ docs: {
288
+ canvas: {
289
+ sourceState: 'hidden',
290
+ },
291
+ },
292
+ },
293
+ argTypes: {
294
+ ...hideControls(),
295
+ ...previewArgTypes,
296
+ },
297
+ args: {
298
+ subtitle: lorem10,
299
+ previewInteractivity: 'fully-interactive',
300
+ previewPrompt: 'interactive',
301
+ previewMedia: 'image',
302
+ previewControlFull: 'Button',
303
+ previewControlPartial: 'Button',
304
+ previewAdditionalInfoFull: 'non-interactive',
305
+ previewAdditionalInfoPartial: 'non-interactive',
306
+ },
307
+ decorators: [withoutKey],
308
+ render: (args) => {
309
+ const [props, previewProps] = getPropsForPreview(args);
310
+
311
+ return (
312
+ <List
313
+ as="ol"
314
+ className="list-unstyled"
315
+ style={{ display: 'grid', gridTemplateColumns: '290px 350px 381px', gap: 16 }}
316
+ >
317
+ <ListItem {...props} {...previewProps} />
318
+ <ListItem {...props} {...previewProps} />
319
+ <ListItem {...props} {...previewProps} />
320
+ </List>
321
+ );
322
+ },
323
+ };
324
+
325
+ /**
326
+ * Due to platform limitations, the component is unable to automagically adjust its content to
327
+ * all possible configurations. <br />
328
+ * By default, it'll follow a CSS grid `1fr max-content` ratio of left side content (`title` and
329
+ * `subtitle`) to the right side content (`valueTitle` and `valueSubtitle`).
330
+ *
331
+ * To adjust the width of the right side content, you can use `valueColumnWidth` prop which accepts
332
+ * a number between `0–100` which resolves to a `fr` value of a `grid-template-columns` declaration.
333
+ * E.g. `valueColumnWidth={25}` will result in a `75fr 25fr`.
334
+ *
335
+ * **NB:** This behaviour is slightly different on mobile platforms as they have more control over
336
+ * layout calculations.
337
+ */
338
+ export const ContentRatio: StoryObj<PreviewStoryArgs> = {
339
+ parameters: {
340
+ docs: {
341
+ canvas: {
342
+ sourceState: 'hidden',
343
+ },
344
+ },
345
+ },
346
+ args: {
347
+ valueColumnWidth: 70,
348
+ subtitle: lorem5,
349
+ valueTitle: `${lorem5} ${lorem5}`,
350
+ valueSubtitle: lorem5,
351
+ previewInteractivity: 'fully-interactive',
352
+ previewPrompt: 'interactive',
353
+ previewMedia: 'image',
354
+ previewControlFull: 'Button',
355
+ previewControlPartial: 'Button',
356
+ previewAdditionalInfoFull: 'non-interactive',
357
+ previewAdditionalInfoPartial: 'non-interactive',
358
+ as: 'div',
359
+ },
360
+ argTypes: {
361
+ ...hideControls(['disabled', 'spotlight']),
362
+ ...previewArgTypes,
363
+ },
364
+ render: (args) => {
365
+ const [props, previewProps] = getPropsForPreview(args);
366
+
367
+ return <ListItem {...props} {...previewProps} />;
368
+ },
369
+ };
370
+
371
+ /**
372
+ * List item supports default and inverted title and description to allow for further flexibility
373
+ * in the component. No other content elements are affected by this prop.
374
+ *
375
+ * Refer to the [design documentation](https://wise.design/components/list-item#content-hierarchy) for more details.
376
+ */
377
+ export const ContentHierarchy: StoryObj<PreviewStoryArgs> = {
378
+ args: {
379
+ inverted: true,
380
+ previewInteractivity: 'fully-interactive',
381
+ previewPrompt: 'interactive',
382
+ previewMedia: 'image',
383
+ previewControlFull: 'Button',
384
+ previewControlPartial: 'Button',
385
+ previewAdditionalInfoFull: 'non-interactive',
386
+ previewAdditionalInfoPartial: 'non-interactive',
387
+ as: 'div',
388
+ },
389
+ argTypes: {
390
+ ...hideControls(['valueColumnWidth', 'disabled']),
391
+ ...previewArgTypes,
392
+ },
393
+ render: (args) => {
394
+ const [props, previewProps] = getPropsForPreview(args);
395
+
396
+ return <ListItem {...props} {...previewProps} />;
397
+ },
398
+ };
399
+
400
+ /**
401
+ * Interactive list items can alternatively be displayed with a spotlight.
402
+ *
403
+ * Refer to the [design documentation](https://wise.design/components/list-item#spotlight) for more details.
404
+ */
405
+ export const Spotlight: StoryObj<PreviewStoryArgs> = {
406
+ argTypes: {
407
+ ...hideControls(['spotlight', 'valueColumnWidth']),
408
+ ...previewArgTypes,
409
+ },
410
+ args: {
411
+ subtitle: lorem10,
412
+ previewInteractivity: 'fully-interactive',
413
+ previewPrompt: 'interactive',
414
+ previewMedia: 'image',
415
+ previewControlFull: 'Button',
416
+ previewControlPartial: 'Button',
417
+ previewAdditionalInfoFull: 'non-interactive',
418
+ previewAdditionalInfoPartial: 'non-interactive',
419
+ },
420
+ decorators: [withoutKey],
421
+ render: (args) => {
422
+ const [props, previewProps] = getPropsForPreview(args);
423
+
424
+ return (
425
+ <List>
426
+ <ListItem {...props} {...previewProps} spotlight="inactive" />
427
+ <ListItem {...props} {...previewProps} spotlight="active" />
428
+ </List>
429
+ );
430
+ },
431
+ };
432
+
433
+ /**
434
+ * By default, all list items are fully interactive, meaning that their whole surface triggers the
435
+ * main action. The only 2 exceptions are those using `ListItem.Button` and `ListItem.IconButton`
436
+ * as their controls, which can be made partially interactive by toggling `partiallyInteractive`
437
+ * prop directly on them.
438
+ *
439
+ * Fully interactive list items **cannot contain any other interactive elements**, such as links or
440
+ * buttons, inside them, with the only exception being the `ListItem.Prompt` subcomponent, as it's
441
+ * rendered on a separate Accessibility Tree branch. <br/>
442
+ * Partially interactive items can also have interactive `ListItem.AdditionalInfo` which allows
443
+ * for a single, appended link or inline button.
444
+ *
445
+ * All of these limitations were put in place to ensure that the list item is compliant with
446
+ * accessibility guidance and offers consistent experience across all engineering platforms.
447
+ *
448
+ * Please refer to the [design documentation](https://wise.design/components/list-item#interaction) for more details.
449
+ */
450
+ export const Interactivity: StoryObj<PreviewStoryArgs> = storySourceWithoutNoise({
451
+ argTypes: {
452
+ ...hideControls([
453
+ 'title',
454
+ 'subtitle',
455
+ 'valueTitle',
456
+ 'valueSubtitle',
457
+ 'valueColumnWidth',
458
+ 'inverted',
459
+ ]),
460
+ },
461
+ args: {
462
+ subtitle: lorem10,
463
+ },
464
+ decorators: [withoutKey],
465
+ render: function Render(args) {
466
+ const [clicked, setClicked] = useState(0);
467
+
468
+ const renderPrompt = () => (
469
+ <ListItem.Prompt sentiment="positive">
470
+ Finally, there is a prompt{' '}
471
+ <Link href="https://wise.com" target="_blank" rel="noreferrer">
472
+ referencing some details
473
+ </Link>{' '}
474
+ for your convenience.
475
+ </ListItem.Prompt>
476
+ );
477
+
478
+ const renderInteractiveInfo = () => (
479
+ <ListItem.AdditionalInfo
480
+ action={{
481
+ label: 'Details about the subject.',
482
+ href: 'https://wise.com',
483
+ target: '_blank',
484
+ }}
485
+ >
486
+ Which is augmented with additional info.
487
+ </ListItem.AdditionalInfo>
488
+ );
489
+
490
+ const renderStaticInfo = () => (
491
+ <ListItem.AdditionalInfo>Which is augmented with additional info.</ListItem.AdditionalInfo>
492
+ );
493
+
494
+ return (
495
+ <>
496
+ <output>Count: {clicked}</output>
497
+ <List>
498
+ <ListItem
499
+ {...args}
500
+ title="Fully interactive"
501
+ control={
502
+ <ListItem.Button
503
+ priority="secondary-neutral"
504
+ onClick={() => setClicked((current) => current + 1)}
505
+ >
506
+ as Button
507
+ </ListItem.Button>
508
+ }
509
+ additionalInfo={renderStaticInfo()}
510
+ prompt={renderPrompt()}
511
+ />
512
+ <ListItem
513
+ {...args}
514
+ title="Partially interactive"
515
+ control={
516
+ <ListItem.Button
517
+ priority="secondary-neutral"
518
+ partiallyInteractive
519
+ onClick={() => setClicked((current) => current + 1)}
520
+ >
521
+ as Button
522
+ </ListItem.Button>
523
+ }
524
+ additionalInfo={renderInteractiveInfo()}
525
+ prompt={renderPrompt()}
526
+ />
527
+ <ListItem
528
+ {...args}
529
+ title="Fully interactive"
530
+ control={
531
+ <ListItem.IconButton
532
+ aria-label="Add something to me"
533
+ onClick={() => setClicked((current) => current + 1)}
534
+ >
535
+ <Plus />
536
+ </ListItem.IconButton>
537
+ }
538
+ additionalInfo={renderStaticInfo()}
539
+ prompt={renderPrompt()}
540
+ />
541
+ <ListItem
542
+ {...args}
543
+ title="Partially interactive"
544
+ control={
545
+ <ListItem.IconButton
546
+ aria-label="Add something to me"
547
+ partiallyInteractive
548
+ onClick={() => setClicked((current) => current + 1)}
549
+ >
550
+ <Plus />
551
+ </ListItem.IconButton>
552
+ }
553
+ additionalInfo={renderInteractiveInfo()}
554
+ prompt={renderPrompt()}
555
+ />
556
+ </List>
557
+ </>
558
+ );
559
+ },
560
+ });
561
+
562
+ /**
563
+ * While most disabled states will show as grayed out, the navigation control switches from chevron
564
+ * to a new icon for improved user experience and accessibility. <br />
565
+ * For the same reason, only the control part of the List Item is dimmed, while all the content
566
+ * retains high contrast and interactivity.
567
+ *
568
+ * Please refer to the [design documentation](https://wise.design/components/list-item#accessibility:~:text=-,Disabled%20states,-) for more details
569
+ */
570
+ export const Disabled: Story = {
571
+ parameters: {
572
+ docs: {
573
+ canvas: {
574
+ sourceState: 'hidden',
575
+ },
576
+ },
577
+ controls: { disable: true },
578
+ knobs: { disable: true },
579
+ },
580
+ render: (args) => (
581
+ <List>
582
+ <ListItem
583
+ disabled
584
+ media={
585
+ <ListItem.AvatarView>
586
+ <MultiCurrency />
587
+ </ListItem.AvatarView>
588
+ }
589
+ title="Navigation"
590
+ subtitle={lorem5}
591
+ control={<ListItem.Navigation onClick={() => {}} />}
592
+ />
593
+ <ListItem
594
+ disabled
595
+ media={
596
+ <ListItem.AvatarView>
597
+ <MultiCurrency />
598
+ </ListItem.AvatarView>
599
+ }
600
+ title="Button secondary neutral"
601
+ subtitle={lorem5}
602
+ control={<ListItem.Button priority="secondary-neutral">Secondary Neutral</ListItem.Button>}
603
+ />
604
+ <ListItem
605
+ disabled
606
+ media={
607
+ <ListItem.AvatarView>
608
+ <MultiCurrency />
609
+ </ListItem.AvatarView>
610
+ }
611
+ title="Button primary"
612
+ subtitle={lorem5}
613
+ control={<ListItem.Button priority="primary">Primary</ListItem.Button>}
614
+ />
615
+ <ListItem
616
+ disabled
617
+ media={
618
+ <ListItem.AvatarView>
619
+ <MultiCurrency />
620
+ </ListItem.AvatarView>
621
+ }
622
+ title="Button tertiary"
623
+ subtitle={lorem5}
624
+ control={<ListItem.Button priority="tertiary">Tertiary</ListItem.Button>}
625
+ />
626
+ <ListItem
627
+ disabled
628
+ media={
629
+ <ListItem.AvatarView>
630
+ <MultiCurrency />
631
+ </ListItem.AvatarView>
632
+ }
633
+ title="Icon Button"
634
+ subtitle={lorem5}
635
+ control={
636
+ <ListItem.IconButton>
637
+ <Plus />
638
+ </ListItem.IconButton>
639
+ }
640
+ />
641
+ <ListItem
642
+ disabled
643
+ media={
644
+ <ListItem.AvatarView>
645
+ <MultiCurrency />
646
+ </ListItem.AvatarView>
647
+ }
648
+ title="Checkbox"
649
+ subtitle={lorem5}
650
+ control={<ListItem.Checkbox />}
651
+ />
652
+ <ListItem
653
+ disabled
654
+ media={
655
+ <ListItem.AvatarView>
656
+ <MultiCurrency />
657
+ </ListItem.AvatarView>
658
+ }
659
+ title="Checkbox checked"
660
+ subtitle={lorem5}
661
+ control={<ListItem.Checkbox checked />}
662
+ />
663
+ <ListItem
664
+ disabled
665
+ media={
666
+ <ListItem.AvatarView>
667
+ <MultiCurrency />
668
+ </ListItem.AvatarView>
669
+ }
670
+ title="Checkbox indeterminate"
671
+ subtitle={lorem5}
672
+ control={<ListItem.Checkbox indeterminate />}
673
+ />
674
+ <ListItem
675
+ disabled
676
+ media={
677
+ <ListItem.AvatarView>
678
+ <MultiCurrency />
679
+ </ListItem.AvatarView>
680
+ }
681
+ title="Switch on"
682
+ subtitle={lorem5}
683
+ control={<ListItem.Switch checked onClick={() => {}} />}
684
+ />
685
+ <ListItem
686
+ disabled
687
+ media={
688
+ <ListItem.AvatarView>
689
+ <MultiCurrency />
690
+ </ListItem.AvatarView>
691
+ }
692
+ title="Switch off"
693
+ subtitle={lorem5}
694
+ control={<ListItem.Switch onClick={() => {}} />}
695
+ />
696
+ <ListItem
697
+ disabled
698
+ media={
699
+ <ListItem.AvatarView>
700
+ <MultiCurrency />
701
+ </ListItem.AvatarView>
702
+ }
703
+ title="Switch off"
704
+ subtitle={lorem5}
705
+ control={<ListItem.Radio name="radio" checked />}
706
+ />
707
+ <ListItem
708
+ disabled
709
+ media={
710
+ <ListItem.AvatarView>
711
+ <MultiCurrency />
712
+ </ListItem.AvatarView>
713
+ }
714
+ title="Switch off"
715
+ subtitle={lorem5}
716
+ control={<ListItem.Radio name="radios" />}
717
+ />
718
+ <ListItem
719
+ disabled
720
+ media={
721
+ <ListItem.AvatarView>
722
+ <MultiCurrency />
723
+ </ListItem.AvatarView>
724
+ }
725
+ title="Switch off"
726
+ subtitle={lorem5}
727
+ additionalInfo={ADDITIONAL_INFO.interactive}
728
+ prompt={PROMPTS.interactive}
729
+ control={
730
+ <ListItem.Button partiallyInteractive onClick={() => {}}>
731
+ Click me
732
+ </ListItem.Button>
733
+ }
734
+ />
735
+ </List>
736
+ ),
737
+ };
738
+
739
+ /**
740
+ * For backwards compatibility, all of the ListItem's content elements accept `ReactNode`.
741
+ * That said, most of them should be fed with plain text only. The exception is `valueTitle`
742
+ * and `valueSubtitle` which can be augmented with sentiment colours, strikethrough or bold
743
+ * styles. <br />
744
+ *
745
+ * Please refer to the [design documentation](https://wise.design/components/list-item#content) for more details.
746
+ */
747
+ export const StylingLabels: Story = {
748
+ argTypes: {
749
+ ...hideControls(['spotlight', 'valueColumnWidth']),
750
+ },
751
+ args: {
752
+ title: lorem5,
753
+ subtitle: lorem10,
754
+ media: MEDIA.image,
755
+ control: CONTROLS.iconButton,
756
+ prompt: PROMPTS.interactive,
757
+ },
758
+ decorators: [withoutKey],
759
+ render: function Render(args) {
760
+ return (
761
+ <List>
762
+ <ListItem
763
+ {...args}
764
+ valueTitle={<Emphasis text="<negative>100 GBP</negative>" />}
765
+ valueSubtitle={<s>125 GBP</s>}
766
+ />
767
+ <ListItem
768
+ {...args}
769
+ valueTitle={<Emphasis text="<positive>100 GBP</positive>" />}
770
+ valueSubtitle={<strong>125 GBP</strong>}
771
+ />
772
+ </List>
773
+ );
774
+ },
775
+ };