@transferwise/components 0.0.0-experimental-2242f8a → 0.0.0-experimental-5759f4d

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 (255) 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/i18n/en.json +2 -0
  10. package/build/i18n/en.json.js +2 -0
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +2 -0
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/iconButton/IconButton.js.map +1 -1
  15. package/build/iconButton/IconButton.mjs.map +1 -1
  16. package/build/image/Image.js.map +1 -1
  17. package/build/image/Image.mjs.map +1 -1
  18. package/build/index.js +2 -0
  19. package/build/index.js.map +1 -1
  20. package/build/index.mjs +1 -0
  21. package/build/index.mjs.map +1 -1
  22. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +56 -0
  23. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +1 -0
  24. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +54 -0
  25. package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +1 -0
  26. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +21 -0
  27. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -0
  28. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +19 -0
  29. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -0
  30. package/build/listItem/AvatarView/ListItemAvatarView.js +21 -0
  31. package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -0
  32. package/build/listItem/AvatarView/ListItemAvatarView.mjs +19 -0
  33. package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -0
  34. package/build/listItem/Button/ListItemButton.js +43 -0
  35. package/build/listItem/Button/ListItemButton.js.map +1 -0
  36. package/build/listItem/Button/ListItemButton.mjs +41 -0
  37. package/build/listItem/Button/ListItemButton.mjs.map +1 -0
  38. package/build/listItem/Checkbox/ListItemCheckbox.js +30 -0
  39. package/build/listItem/Checkbox/ListItemCheckbox.js.map +1 -0
  40. package/build/listItem/Checkbox/ListItemCheckbox.mjs +28 -0
  41. package/build/listItem/Checkbox/ListItemCheckbox.mjs.map +1 -0
  42. package/build/listItem/IconButton/ListItemIconButton.js +42 -0
  43. package/build/listItem/IconButton/ListItemIconButton.js.map +1 -0
  44. package/build/listItem/IconButton/ListItemIconButton.mjs +40 -0
  45. package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -0
  46. package/build/listItem/Image/ListItemImage.js +27 -0
  47. package/build/listItem/Image/ListItemImage.js.map +1 -0
  48. package/build/listItem/Image/ListItemImage.mjs +25 -0
  49. package/build/listItem/Image/ListItemImage.mjs.map +1 -0
  50. package/build/listItem/ListItem.js +302 -0
  51. package/build/listItem/ListItem.js.map +1 -0
  52. package/build/listItem/ListItem.mjs +297 -0
  53. package/build/listItem/ListItem.mjs.map +1 -0
  54. package/build/listItem/ListItemContext.js +8 -0
  55. package/build/listItem/ListItemContext.js.map +1 -0
  56. package/build/listItem/ListItemContext.mjs +6 -0
  57. package/build/listItem/ListItemContext.mjs.map +1 -0
  58. package/build/listItem/Navigation/ListItemNavigation.js +45 -0
  59. package/build/listItem/Navigation/ListItemNavigation.js.map +1 -0
  60. package/build/listItem/Navigation/ListItemNavigation.mjs +43 -0
  61. package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -0
  62. package/build/listItem/Prompt/ListItemPrompt.js +59 -0
  63. package/build/listItem/Prompt/ListItemPrompt.js.map +1 -0
  64. package/build/listItem/Prompt/ListItemPrompt.mjs +54 -0
  65. package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -0
  66. package/build/listItem/Radio/ListItemRadio.js +30 -0
  67. package/build/listItem/Radio/ListItemRadio.js.map +1 -0
  68. package/build/listItem/Radio/ListItemRadio.mjs +28 -0
  69. package/build/listItem/Radio/ListItemRadio.mjs.map +1 -0
  70. package/build/listItem/Switch/ListItemSwitch.js +30 -0
  71. package/build/listItem/Switch/ListItemSwitch.js.map +1 -0
  72. package/build/listItem/Switch/ListItemSwitch.mjs +28 -0
  73. package/build/listItem/Switch/ListItemSwitch.mjs.map +1 -0
  74. package/build/listItem/useListItemControl.js +22 -0
  75. package/build/listItem/useListItemControl.js.map +1 -0
  76. package/build/listItem/useListItemControl.mjs +20 -0
  77. package/build/listItem/useListItemControl.mjs.map +1 -0
  78. package/build/main.css +657 -0
  79. package/build/styles/listItem/ListItem.css +657 -0
  80. package/build/styles/listItem/ListItem.grid.css +362 -0
  81. package/build/styles/main.css +657 -0
  82. package/build/switch/Switch.js +2 -0
  83. package/build/switch/Switch.js.map +1 -1
  84. package/build/switch/Switch.mjs +2 -0
  85. package/build/switch/Switch.mjs.map +1 -1
  86. package/build/types/button/Button.d.ts.map +1 -1
  87. package/build/types/button/Button.types.d.ts +1 -1
  88. package/build/types/button/Button.types.d.ts.map +1 -1
  89. package/build/types/button/index.d.ts +1 -1
  90. package/build/types/button/index.d.ts.map +1 -1
  91. package/build/types/common/RadioButton/RadioButton.d.ts +3 -1
  92. package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
  93. package/build/types/iconButton/IconButton.d.ts +2 -2
  94. package/build/types/iconButton/IconButton.d.ts.map +1 -1
  95. package/build/types/image/Image.d.ts +3 -0
  96. package/build/types/image/Image.d.ts.map +1 -1
  97. package/build/types/image/index.d.ts +1 -0
  98. package/build/types/image/index.d.ts.map +1 -1
  99. package/build/types/index.d.ts +2 -0
  100. package/build/types/index.d.ts.map +1 -1
  101. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts +15 -0
  102. package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts.map +1 -0
  103. package/build/types/listItem/AdditionalInfo/index.d.ts +3 -0
  104. package/build/types/listItem/AdditionalInfo/index.d.ts.map +1 -0
  105. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts +18 -0
  106. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -0
  107. package/build/types/listItem/AvatarLayout/index.d.ts +3 -0
  108. package/build/types/listItem/AvatarLayout/index.d.ts.map +1 -0
  109. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts +16 -0
  110. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -0
  111. package/build/types/listItem/AvatarView/index.d.ts +3 -0
  112. package/build/types/listItem/AvatarView/index.d.ts.map +1 -0
  113. package/build/types/listItem/Button/ListItemButton.d.ts +20 -0
  114. package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -0
  115. package/build/types/listItem/Button/index.d.ts +3 -0
  116. package/build/types/listItem/Button/index.d.ts.map +1 -0
  117. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts +14 -0
  118. package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts.map +1 -0
  119. package/build/types/listItem/Checkbox/index.d.ts +3 -0
  120. package/build/types/listItem/Checkbox/index.d.ts.map +1 -0
  121. package/build/types/listItem/IconButton/ListItemIconButton.d.ts +18 -0
  122. package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -0
  123. package/build/types/listItem/IconButton/index.d.ts +3 -0
  124. package/build/types/listItem/IconButton/index.d.ts.map +1 -0
  125. package/build/types/listItem/Image/ListItemImage.d.ts +25 -0
  126. package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -0
  127. package/build/types/listItem/Image/index.d.ts +3 -0
  128. package/build/types/listItem/Image/index.d.ts.map +1 -0
  129. package/build/types/listItem/ListItem.d.ts +113 -0
  130. package/build/types/listItem/ListItem.d.ts.map +1 -0
  131. package/build/types/listItem/ListItemContext.d.ts +18 -0
  132. package/build/types/listItem/ListItemContext.d.ts.map +1 -0
  133. package/build/types/listItem/Navigation/ListItemNavigation.d.ts +15 -0
  134. package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -0
  135. package/build/types/listItem/Navigation/index.d.ts +3 -0
  136. package/build/types/listItem/Navigation/index.d.ts.map +1 -0
  137. package/build/types/listItem/Prompt/ListItemPrompt.d.ts +16 -0
  138. package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -0
  139. package/build/types/listItem/Prompt/index.d.ts +3 -0
  140. package/build/types/listItem/Prompt/index.d.ts.map +1 -0
  141. package/build/types/listItem/Radio/ListItemRadio.d.ts +14 -0
  142. package/build/types/listItem/Radio/ListItemRadio.d.ts.map +1 -0
  143. package/build/types/listItem/Radio/index.d.ts +3 -0
  144. package/build/types/listItem/Radio/index.d.ts.map +1 -0
  145. package/build/types/listItem/Switch/ListItemSwitch.d.ts +14 -0
  146. package/build/types/listItem/Switch/ListItemSwitch.d.ts.map +1 -0
  147. package/build/types/listItem/Switch/index.d.ts +3 -0
  148. package/build/types/listItem/Switch/index.d.ts.map +1 -0
  149. package/build/types/listItem/_stories/subcomponents.d.ts +18 -0
  150. package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -0
  151. package/build/types/listItem/index.d.ts +14 -0
  152. package/build/types/listItem/index.d.ts.map +1 -0
  153. package/build/types/listItem/useListItemControl.d.ts +5 -0
  154. package/build/types/listItem/useListItemControl.d.ts.map +1 -0
  155. package/build/types/switch/Switch.d.ts +2 -0
  156. package/build/types/switch/Switch.d.ts.map +1 -1
  157. package/build/types/test-utils/index.d.ts +4 -0
  158. package/build/types/test-utils/index.d.ts.map +1 -1
  159. package/build/types/upload/Upload.d.ts +6 -2
  160. package/build/types/upload/Upload.d.ts.map +1 -1
  161. package/build/types/upload/Upload.messages.d.ts +8 -0
  162. package/build/types/upload/Upload.messages.d.ts.map +1 -1
  163. package/build/types/uploadInput/UploadInput.d.ts +1 -1
  164. package/build/types/uploadInput/uploadButton/UploadButton.d.ts +4 -2
  165. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  166. package/build/upload/Upload.js +16 -9
  167. package/build/upload/Upload.js.map +1 -1
  168. package/build/upload/Upload.messages.js +6 -0
  169. package/build/upload/Upload.messages.js.map +1 -1
  170. package/build/upload/Upload.messages.mjs +6 -0
  171. package/build/upload/Upload.messages.mjs.map +1 -1
  172. package/build/upload/Upload.mjs +16 -9
  173. package/build/upload/Upload.mjs.map +1 -1
  174. package/build/uploadInput/UploadInput.js +1 -1
  175. package/build/uploadInput/UploadInput.js.map +1 -1
  176. package/build/uploadInput/UploadInput.mjs +1 -1
  177. package/build/uploadInput/UploadInput.mjs.map +1 -1
  178. package/build/uploadInput/uploadButton/UploadButton.js +7 -4
  179. package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
  180. package/build/uploadInput/uploadButton/UploadButton.mjs +7 -4
  181. package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
  182. package/package.json +1 -1
  183. package/src/button/Button.spec.tsx +18 -0
  184. package/src/button/Button.tsx +5 -1
  185. package/src/button/Button.types.ts +1 -1
  186. package/src/button/index.ts +1 -1
  187. package/src/checkboxButton/CheckboxButton.story.tsx +4 -4
  188. package/src/common/RadioButton/RadioButton.tsx +6 -1
  189. package/src/i18n/en.json +2 -0
  190. package/src/iconButton/IconButton.story.tsx +1 -1
  191. package/src/iconButton/IconButton.tsx +1 -1
  192. package/src/image/Image.tsx +3 -0
  193. package/src/image/index.ts +1 -0
  194. package/src/index.ts +2 -0
  195. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +145 -0
  196. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.tsx +36 -0
  197. package/src/listItem/AdditionalInfo/index.ts +2 -0
  198. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +118 -0
  199. package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +24 -0
  200. package/src/listItem/AvatarLayout/index.ts +2 -0
  201. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +318 -0
  202. package/src/listItem/AvatarView/ListItemAvatarView.tsx +24 -0
  203. package/src/listItem/AvatarView/index.ts +2 -0
  204. package/src/listItem/Button/ListItemButton.spec.tsx +93 -0
  205. package/src/listItem/Button/ListItemButton.story.tsx +408 -0
  206. package/src/listItem/Button/ListItemButton.tsx +56 -0
  207. package/src/listItem/Button/index.ts +2 -0
  208. package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +107 -0
  209. package/src/listItem/Checkbox/ListItemCheckbox.tsx +33 -0
  210. package/src/listItem/Checkbox/index.ts +2 -0
  211. package/src/listItem/IconButton/ListItemIconButton.story.tsx +236 -0
  212. package/src/listItem/IconButton/ListItemIconButton.tsx +56 -0
  213. package/src/listItem/IconButton/index.ts +2 -0
  214. package/src/listItem/Image/ListItemImage.story.tsx +39 -0
  215. package/src/listItem/Image/ListItemImage.tsx +40 -0
  216. package/src/listItem/Image/index.ts +2 -0
  217. package/src/listItem/ListItem.css +657 -0
  218. package/src/listItem/ListItem.grid.css +362 -0
  219. package/src/listItem/ListItem.grid.less +612 -0
  220. package/src/listItem/ListItem.less +312 -0
  221. package/src/listItem/ListItem.spec.tsx +97 -0
  222. package/src/listItem/ListItem.tsx +428 -0
  223. package/src/listItem/ListItemContext.tsx +22 -0
  224. package/src/listItem/Navigation/ListItemNavigation.story.tsx +106 -0
  225. package/src/listItem/Navigation/ListItemNavigation.tsx +40 -0
  226. package/src/listItem/Navigation/index.ts +2 -0
  227. package/src/listItem/Prompt/ListItemPrompt.spec.tsx +49 -0
  228. package/src/listItem/Prompt/ListItemPrompt.story.tsx +199 -0
  229. package/src/listItem/Prompt/ListItemPrompt.tsx +32 -0
  230. package/src/listItem/Prompt/index.ts +2 -0
  231. package/src/listItem/Radio/ListItemRadio.story.tsx +98 -0
  232. package/src/listItem/Radio/ListItemRadio.tsx +33 -0
  233. package/src/listItem/Radio/index.ts +2 -0
  234. package/src/listItem/Switch/ListItemSwitch.story.tsx +69 -0
  235. package/src/listItem/Switch/ListItemSwitch.tsx +33 -0
  236. package/src/listItem/Switch/index.ts +2 -0
  237. package/src/listItem/_stories/ListItem.focus.test.story.tsx +250 -0
  238. package/src/listItem/_stories/ListItem.layout.test.story.tsx +169 -0
  239. package/src/listItem/_stories/ListItem.story.tsx +670 -0
  240. package/src/listItem/_stories/ListItem.variants.test.story.tsx +266 -0
  241. package/src/listItem/_stories/subcomponents.tsx +139 -0
  242. package/src/listItem/index.ts +14 -0
  243. package/src/listItem/useListItemControl.tsx +18 -0
  244. package/src/main.css +657 -0
  245. package/src/main.less +1 -0
  246. package/src/switch/Switch.tsx +4 -0
  247. package/src/upload/Upload.messages.ts +8 -0
  248. package/src/upload/Upload.spec.tsx +6 -0
  249. package/src/upload/Upload.story.tsx +118 -3
  250. package/src/upload/Upload.tests.story.tsx +5 -3
  251. package/src/upload/Upload.tsx +24 -15
  252. package/src/uploadInput/UploadInput.tests.story.tsx +7 -0
  253. package/src/uploadInput/UploadInput.tsx +2 -2
  254. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +6 -0
  255. package/src/uploadInput/uploadButton/UploadButton.tsx +12 -6
@@ -0,0 +1,236 @@
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { Edit, Heart } from '@transferwise/icons';
3
+ import { ListItem } from '../ListItem';
4
+ import {
5
+ SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
6
+ SB_LIST_ITEM_MEDIA as MEDIA,
7
+ SB_LIST_ITEM_PROMPTS as PROMPTS,
8
+ } from '../_stories/subcomponents';
9
+ import type { ListItemIconButtonProps } from './ListItemIconButton';
10
+ import { fn } from 'storybook/test';
11
+
12
+ /**
13
+ * Use IconButton to provide compact action controls within a ListItem context using iconography.
14
+ *
15
+ * Refer to the [design documentation](https://wise.design/components/list-item) for more details.
16
+ */
17
+ const meta: Meta<ListItemIconButtonProps> = {
18
+ component: ListItem.IconButton,
19
+ title: 'Content/ListItem/ListItem.IconButton',
20
+ parameters: {
21
+ docs: {
22
+ toc: true,
23
+ },
24
+ },
25
+ args: {
26
+ partiallyInteractive: false,
27
+ priority: undefined,
28
+ type: undefined,
29
+ children: <Edit />,
30
+ href: undefined,
31
+ target: undefined,
32
+ onClick: fn(),
33
+ },
34
+ argTypes: {
35
+ children: {
36
+ description: 'Once of the [Icon components](https://transferwise.github.io/icons/).',
37
+ table: {
38
+ type: { summary: 'ReactNode' },
39
+ },
40
+ control: false,
41
+ },
42
+ priority: {
43
+ control: 'radio',
44
+ options: ['unset (undefined)', 'primary', 'secondary', 'tertiary', 'minimal'],
45
+ mapping: {
46
+ 'unset (undefined)': undefined,
47
+ },
48
+ description: 'IconButton priority/style variant',
49
+ },
50
+ type: {
51
+ control: 'radio',
52
+ options: ['unset (undefined)', 'default', 'negative'],
53
+ mapping: {
54
+ 'unset (undefined)': undefined,
55
+ },
56
+ description:
57
+ 'Sets a visual hierarchy amongst the buttons displayed on the screen. <br /> **NB:** `negative` sentiment only affects the `primary` and `secondary` priorities.',
58
+ },
59
+ partiallyInteractive: {
60
+ control: 'boolean',
61
+ description: 'Whether the icon button allows partial interactivity in the ListItem',
62
+ },
63
+ href: {
64
+ control: 'text',
65
+ description: 'URL for icon button rendered as link',
66
+ },
67
+ target: {
68
+ control: 'select',
69
+ options: [undefined, '_blank', '_self', '_parent', '_top'],
70
+ description:
71
+ 'The `target` attribute for HTML anchor. If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.',
72
+ },
73
+ },
74
+ } satisfies Meta<ListItemIconButtonProps>;
75
+
76
+ export default meta;
77
+
78
+ type Story = StoryObj<ListItemIconButtonProps>;
79
+
80
+ export const Playground: Story = {
81
+ tags: ['!autodocs'],
82
+ render: (args: ListItemIconButtonProps) => {
83
+ return (
84
+ <ListItem
85
+ title="List item title"
86
+ subtitle="Subtitle goes here"
87
+ media={MEDIA.avatarSingle}
88
+ control={<ListItem.IconButton {...args} />}
89
+ additionalInfo={INFO.nonInteractive}
90
+ />
91
+ );
92
+ },
93
+ };
94
+
95
+ /**
96
+ * By default, ListItem is fully interactive, which means its whole surface is clickable
97
+ * and triggers the control. To remain WCAG-compliant there can be no nested interactive
98
+ * elements inside the item.<br />
99
+ *
100
+ * To work around this limitation, this control also allows for a partially interactive mode,
101
+ * which can be enabled via `partiallyInteractive` prop. Once set, only the control will
102
+ * remain interactive, which allows for interactive element to be attached to the
103
+ * `ListItem.AdditionalInfo`. This allows for more complex layouts while still providing a
104
+ * clear, accessible action point for users. <br />
105
+ *
106
+ * If you still require a fully interactive ListItem, you can alternatively use `ListItem.Prompt`
107
+ * which allows for a single instance of a link or an inline button.
108
+ *
109
+ * Refer to the [design documentation](https://wise.design/components/list-item#interaction) for details.
110
+ */
111
+ export const Interactivity: Story = {
112
+ args: {
113
+ children: <Edit />,
114
+ },
115
+ render: (args: ListItemIconButtonProps) => {
116
+ return (
117
+ <ol className="list-unstyled">
118
+ <ListItem
119
+ control={<ListItem.IconButton {...args} />}
120
+ title="Fully interactive ListItem"
121
+ subtitle="IconButton in fully interactive context"
122
+ media={MEDIA.avatarSingle}
123
+ additionalInfo={INFO.nonInteractive}
124
+ prompt={PROMPTS.interactive}
125
+ />
126
+
127
+ <ListItem
128
+ control={<ListItem.IconButton {...args} partiallyInteractive />}
129
+ title="Partially interactive ListItem"
130
+ subtitle="IconButton in partially interactive context"
131
+ media={MEDIA.avatarSingle}
132
+ additionalInfo={INFO.interactive}
133
+ prompt={PROMPTS.interactive}
134
+ />
135
+ </ol>
136
+ );
137
+ },
138
+ };
139
+
140
+ /**
141
+ * There are two different types of icon button – default and negative – designed to emphasise the nature of the action. <br />
142
+ * **NB:** Sentiment only applies to `primary` and `secondary` priorities. <br />
143
+ * [Design documentation](https://wise.design/components/icon-button#types)
144
+ */
145
+ export const Sentiment: Story = {
146
+ render: (args) => {
147
+ return (
148
+ <ol className="list-unstyled">
149
+ <ListItem
150
+ control={<ListItem.IconButton {...args} priority="primary" type="default" />}
151
+ title="Default Sentiment - Primary"
152
+ subtitle="Default sentiment with primary priority"
153
+ media={MEDIA.avatarSingle}
154
+ />
155
+ <ListItem
156
+ control={<ListItem.IconButton {...args} priority="secondary" type="default" />}
157
+ title="Default Sentiment - Secondary"
158
+ subtitle="Default sentiment with secondary priority"
159
+ media={MEDIA.avatarSingle}
160
+ />
161
+ <ListItem
162
+ control={<ListItem.IconButton {...args} priority="primary" type="negative" />}
163
+ title="Negative Sentiment - Primary"
164
+ subtitle="Negative sentiment with primary priority"
165
+ media={MEDIA.avatarSingle}
166
+ />
167
+ <ListItem
168
+ control={<ListItem.IconButton {...args} priority="secondary" type="negative" />}
169
+ title="Negative Sentiment - Secondary"
170
+ subtitle="Negative sentiment with secondary priority"
171
+ media={MEDIA.avatarSingle}
172
+ />
173
+ </ol>
174
+ );
175
+ },
176
+ };
177
+
178
+ /**
179
+ * Priorities set a visual hierarchy amongst the buttons displayed on the
180
+ * screen to help more important buttons to take precedence over others. <br />
181
+ * [Design documentation](https://wise.design/components/icon-button#priorities)
182
+ */
183
+ export const Priority: Story = {
184
+ render: (args) => {
185
+ return (
186
+ <ol className="list-unstyled">
187
+ <ListItem
188
+ title="Primary Priority"
189
+ subtitle="Primary priority (default)"
190
+ media={MEDIA.avatarSingle}
191
+ control={<ListItem.IconButton {...args} priority="primary" />}
192
+ />
193
+ <ListItem
194
+ title="Secondary Priority"
195
+ subtitle="Secondary priority"
196
+ media={MEDIA.avatarSingle}
197
+ control={<ListItem.IconButton {...args} priority="secondary" />}
198
+ />
199
+ <ListItem
200
+ title="Secondary Neutral Priority"
201
+ subtitle="Secondary neutral priority"
202
+ media={MEDIA.avatarSingle}
203
+ control={<ListItem.IconButton {...args} priority="tertiary" />}
204
+ />
205
+ <ListItem
206
+ title="Tertiary Priority"
207
+ subtitle="Tertiary priority"
208
+ media={MEDIA.avatarSingle}
209
+ control={<ListItem.IconButton {...args} priority="minimal" />}
210
+ />
211
+ </ol>
212
+ );
213
+ },
214
+ };
215
+
216
+ /**
217
+ * If `href` prop is set, the component will be automatically rendered as an HTML anchor element.
218
+ */
219
+ export const AsAnchor: Story = {
220
+ args: {
221
+ children: <Edit />,
222
+ href: 'https://wise.com',
223
+ target: '_blank',
224
+ onClick: undefined,
225
+ },
226
+ render: (args: ListItemIconButtonProps) => {
227
+ return (
228
+ <ListItem
229
+ control={<ListItem.IconButton {...args} />}
230
+ title="List item with icon button link"
231
+ subtitle="IconButton rendered as anchor element"
232
+ media={MEDIA.avatarSingle}
233
+ />
234
+ );
235
+ },
236
+ };
@@ -0,0 +1,56 @@
1
+ import { clsx } from 'clsx';
2
+ import { useContext, type ReactNode } from 'react';
3
+ import IconButtonComp, { type IconButtonProps } from '../../iconButton';
4
+ import { useListItemControl } from '../useListItemControl';
5
+ import { ListItemContext } from '../ListItemContext';
6
+
7
+ export type ListItemIconButtonProps = Pick<
8
+ IconButtonProps,
9
+ 'priority' | 'type' | 'onClick' | 'href' | 'target' | 'aria-label'
10
+ > & {
11
+ children: ReactNode;
12
+ partiallyInteractive?: boolean;
13
+ };
14
+
15
+ /**
16
+ * This component allows for rendering a IconButton control. It's a thin wrapper around the
17
+ * [IconButton component](https://storybook.wise.design/?path=/docs/actions-iconbutton--docs), but offers only
18
+ * a subset of its features in line with the ListItem's constraints. <br />
19
+ * <br />
20
+ * Please refer to the [Design documentation](https://wise.design/components/list-item---icon-button) for details.
21
+ */
22
+ export const IconButton = function ({ priority = 'minimal', ...props }: ListItemIconButtonProps) {
23
+ const { partiallyInteractive, ...restProps } = props;
24
+
25
+ const { ids, props: itemProps } = useContext(ListItemContext);
26
+ const { baseItemProps } = useListItemControl('icon-button', {
27
+ partiallyInteractive,
28
+ ...restProps,
29
+ });
30
+
31
+ const descriptorIds = [
32
+ itemProps.inverted ? ids.subtitle : ids.title,
33
+ itemProps.inverted ? ids.title : ids.subtitle,
34
+ itemProps.inverted ? ids.valueSubtitle : ids.valueTitle,
35
+ itemProps.inverted ? ids.valueTitle : ids.valueSubtitle,
36
+ ids.additionalInfo,
37
+ ids.prompt,
38
+ ].join(' ');
39
+
40
+ return (
41
+ <IconButtonComp
42
+ {...restProps}
43
+ aria-describedby={descriptorIds}
44
+ className={clsx(
45
+ 'wds-list-item-control',
46
+ !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',
47
+ )}
48
+ id={ids.control}
49
+ size={40}
50
+ priority={priority}
51
+ disabled={baseItemProps.disabled}
52
+ />
53
+ );
54
+ };
55
+
56
+ IconButton.displayName = 'ListItem.IconButton';
@@ -0,0 +1,2 @@
1
+ export type { ListItemIconButtonProps } from './ListItemIconButton';
2
+ export { IconButton } from './ListItemIconButton';
@@ -0,0 +1,39 @@
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { ListItem } from '../ListItem';
3
+ import {
4
+ SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
5
+ SB_LIST_ITEM_CONTROLS as CONTROLS,
6
+ } from '../_stories/subcomponents';
7
+ import { ListItemImageProps } from './ListItemImage';
8
+
9
+ export default {
10
+ component: ListItem.Image,
11
+ title: 'Content/ListItem/ListItem.Image',
12
+ parameters: {
13
+ docs: {
14
+ toc: true,
15
+ },
16
+ },
17
+ args: {
18
+ src: 'https://wise.com/public-resources/assets/spend/card-asset/medium/v2/personal_green_wise_2023_active.svg',
19
+ size: undefined,
20
+ loading: undefined,
21
+ alt: undefined,
22
+ },
23
+ } satisfies Meta<ListItemImageProps>;
24
+
25
+ type Story = StoryObj<ListItemImageProps>;
26
+
27
+ export const Playground: Story = {
28
+ render: (args: ListItemImageProps) => {
29
+ return (
30
+ <ListItem
31
+ title="List item title"
32
+ subtitle="Subtitle goes here"
33
+ media={<ListItem.Image {...args} />}
34
+ control={CONTROLS.partialButton}
35
+ additionalInfo={INFO.nonInteractive}
36
+ />
37
+ );
38
+ },
39
+ };
@@ -0,0 +1,40 @@
1
+ import ImageComp, { type ImageProps } from '../../image';
2
+ import { clsx } from 'clsx';
3
+
4
+ type SizeProp = {};
5
+
6
+ export type ListItemImageProps = Omit<ImageProps, 'stretch' | 'shrink' | 'id' | 'alt' | 'role'> & {
7
+ /**
8
+ * The size of square container for the image, matching available avatar sizes.
9
+ */
10
+ size?: 32 | 40 | 48 | 56 | 72;
11
+ /**
12
+ * When unset, it will force `role="presentation"` on the image. Otherwise, it will set `role="graphics-symbol"`.
13
+ */
14
+ alt?: string;
15
+ };
16
+
17
+ /**
18
+ * This component should be used as a last resort, for rare cases when `<ListItem.AvatarView />`
19
+ * or `<ListItem.AvatarLayout />` are insufficient.
20
+ * It's a wrapper around the
21
+ * [Image component](https://storybook.wise.design/?path=/docs/content-image--docs), but offers only
22
+ * a subset of its props, in line with the ListItem's constraints.
23
+ *
24
+ * > **NB**: This component is [not intended for use with illustrations](https://wise.design/foundations/illustration#scale).
25
+ */
26
+ export const Image = ({ alt = '', size = 48, ...props }: ListItemImageProps) => {
27
+ return (
28
+ <div
29
+ className={clsx('wds-list-item-media-image')}
30
+ style={
31
+ {
32
+ '--item-media-image-size': `${size}px`,
33
+ } as React.CSSProperties
34
+ }
35
+ >
36
+ <ImageComp {...props} alt={alt} role={alt ? 'graphics-symbol' : 'presentation'} />
37
+ </div>
38
+ );
39
+ };
40
+ Image.displayName = 'ListItem.Image';
@@ -0,0 +1,2 @@
1
+ export type { ListItemImageProps } from './ListItemImage';
2
+ export { Image } from './ListItemImage';