@transferwise/components 0.0.0-experimental-e1870f3 → 0.0.0-experimental-302d967

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 (106) hide show
  1. package/build/flowNavigation/animatedLabel/AnimatedLabel.js +2 -2
  2. package/build/flowNavigation/animatedLabel/AnimatedLabel.js.map +1 -1
  3. package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs +2 -2
  4. package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs.map +1 -1
  5. package/build/index.js +2 -2
  6. package/build/index.mjs +1 -1
  7. package/build/{listItem → legacylistItem}/List.js +2 -3
  8. package/build/legacylistItem/List.js.map +1 -0
  9. package/build/{listItem → legacylistItem}/List.mjs +2 -3
  10. package/build/legacylistItem/List.mjs.map +1 -0
  11. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +2 -0
  12. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -1
  13. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +2 -0
  14. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -1
  15. package/build/listItem/AvatarView/ListItemAvatarView.js +2 -0
  16. package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -1
  17. package/build/listItem/AvatarView/ListItemAvatarView.mjs +2 -0
  18. package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -1
  19. package/build/listItem/Image/ListItemImage.js +6 -2
  20. package/build/listItem/Image/ListItemImage.js.map +1 -1
  21. package/build/listItem/Image/ListItemImage.mjs +6 -2
  22. package/build/listItem/Image/ListItemImage.mjs.map +1 -1
  23. package/build/listItem/ListItem.js +16 -14
  24. package/build/listItem/ListItem.js.map +1 -1
  25. package/build/listItem/ListItem.mjs +16 -14
  26. package/build/listItem/ListItem.mjs.map +1 -1
  27. package/build/listItem/ListItemContext.js.map +1 -1
  28. package/build/listItem/ListItemContext.mjs.map +1 -1
  29. package/build/listItem/Navigation/ListItemNavigation.js +1 -1
  30. package/build/listItem/Navigation/ListItemNavigation.js.map +1 -1
  31. package/build/listItem/Navigation/ListItemNavigation.mjs +1 -1
  32. package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -1
  33. package/build/listItem/_stories/images/landscape.svg +1 -0
  34. package/build/listItem/_stories/images/portrait.svg +1 -0
  35. package/build/listItem/useListItemMedia.js +21 -0
  36. package/build/listItem/useListItemMedia.js.map +1 -0
  37. package/build/listItem/useListItemMedia.mjs +19 -0
  38. package/build/listItem/useListItemMedia.mjs.map +1 -0
  39. package/build/main.css +64 -101
  40. package/build/styles/avatarView/AvatarView.css +1 -3
  41. package/build/styles/listItem/ListItem.css +63 -98
  42. package/build/styles/listItem/ListItem.grid.css +17 -11
  43. package/build/styles/main.css +64 -101
  44. package/build/types/index.d.ts +4 -4
  45. package/build/types/index.d.ts.map +1 -1
  46. package/build/types/legacylistItem/List.d.ts +6 -0
  47. package/build/types/legacylistItem/List.d.ts.map +1 -0
  48. package/build/types/legacylistItem/index.d.ts +2 -0
  49. package/build/types/legacylistItem/index.d.ts.map +1 -1
  50. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -1
  51. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -1
  52. package/build/types/listItem/Image/ListItemImage.d.ts +1 -1
  53. package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -1
  54. package/build/types/listItem/ListItem.d.ts +1 -1
  55. package/build/types/listItem/ListItem.d.ts.map +1 -1
  56. package/build/types/listItem/ListItemContext.d.ts +4 -0
  57. package/build/types/listItem/ListItemContext.d.ts.map +1 -1
  58. package/build/types/listItem/index.d.ts +0 -2
  59. package/build/types/listItem/index.d.ts.map +1 -1
  60. package/build/types/listItem/test-utils.d.ts +7 -0
  61. package/build/types/listItem/test-utils.d.ts.map +1 -0
  62. package/build/types/listItem/useListItemMedia.d.ts +6 -0
  63. package/build/types/listItem/useListItemMedia.d.ts.map +1 -0
  64. package/package.json +1 -1
  65. package/src/avatarView/AvatarView.css +1 -3
  66. package/src/avatarView/AvatarView.less +1 -2
  67. package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +1 -1
  68. package/src/index.ts +4 -9
  69. package/src/legacylistItem/LegacyListItem.story.tsx +2 -2
  70. package/src/legacylistItem/LegacyListItem.tests.story.tsx +1 -2
  71. package/src/legacylistItem/List.tsx +10 -0
  72. package/src/legacylistItem/index.ts +2 -0
  73. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +4 -5
  74. package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +3 -0
  75. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +4 -5
  76. package/src/listItem/AvatarView/ListItemAvatarView.tsx +3 -0
  77. package/src/listItem/Button/ListItemButton.spec.tsx +10 -35
  78. package/src/listItem/Button/ListItemButton.story.tsx +8 -9
  79. package/src/listItem/IconButton/ListItemIconButton.story.tsx +8 -8
  80. package/src/listItem/Image/ListItemImage.spec.tsx +8 -5
  81. package/src/listItem/Image/ListItemImage.story.tsx +23 -6
  82. package/src/listItem/Image/ListItemImage.tsx +12 -4
  83. package/src/listItem/ListItem.css +63 -98
  84. package/src/listItem/ListItem.grid.css +17 -11
  85. package/src/listItem/ListItem.grid.less +24 -16
  86. package/src/listItem/ListItem.less +60 -113
  87. package/src/listItem/ListItem.tsx +24 -18
  88. package/src/listItem/ListItemContext.tsx +5 -0
  89. package/src/listItem/Navigation/ListItemNavigation.tsx +1 -1
  90. package/src/listItem/Prompt/ListItemPrompt.story.tsx +7 -7
  91. package/src/listItem/Switch/ListItemSwitch.story.tsx +2 -3
  92. package/src/listItem/_stories/ListItem.layout.test.story.tsx +142 -2
  93. package/src/listItem/_stories/ListItem.story.tsx +7 -45
  94. package/src/listItem/_stories/ListItem.variants.test.story.tsx +11 -7
  95. package/src/listItem/_stories/images/landscape.svg +1 -0
  96. package/src/listItem/_stories/images/portrait.svg +1 -0
  97. package/src/listItem/index.ts +0 -3
  98. package/src/listItem/test-utils.tsx +33 -0
  99. package/src/listItem/useListItemMedia.tsx +13 -0
  100. package/src/main.css +64 -101
  101. package/build/listItem/List.js.map +0 -1
  102. package/build/listItem/List.mjs.map +0 -1
  103. package/build/types/listItem/List.d.ts +0 -7
  104. package/build/types/listItem/List.d.ts.map +0 -1
  105. package/src/listItem/List.tsx +0 -11
  106. package/src/listItem/_stories/ListItem.scenarios.story.tsx +0 -226
@@ -1,226 +0,0 @@
1
- import { useState } from 'react';
2
- import { Title, Subtitle, Description, Stories } from '@storybook/addon-docs/blocks';
3
- import { Meta, StoryObj } from '@storybook/react-webpack5';
4
- import { action } from 'storybook/actions';
5
- import { InfoCircle, Documents } from '@transferwise/icons';
6
- import { lorem10, lorem100, lorem20, lorem5 } from '../../test-utils';
7
- import Modal from '../../modal';
8
- import Link from '../../link';
9
- import Popover from '../../popover';
10
- import { SnackbarConsumer, type SnackbarContextType } from '../../snackbar/SnackbarContext';
11
- import SnackbarProvider from '../../snackbar/SnackbarProvider';
12
- import Tooltip from '../../tooltip';
13
- import { Position } from '../../common';
14
- import { ListItem, type Props as ItemProps } from '../ListItem';
15
- import {
16
- SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
17
- SB_LIST_ITEM_CONTROLS as CONTROLS,
18
- SB_LIST_ITEM_MEDIA as MEDIA,
19
- SB_LIST_ITEM_PROMPTS as PROMPTS,
20
- } from './subcomponents';
21
-
22
- /**
23
- * Recent storybook versions render the full source including all story parameters which
24
- * creates noise, this simple workaround only shows the render function.
25
- * This is a workaround for the issue.
26
- * @see https://github.com/storybookjs/storybook/issues/22281
27
- */
28
- const storySourceWithoutNoise = (config: Story): Story => {
29
- const newConfig: Story = {
30
- ...config,
31
- parameters: {
32
- ...config.parameters,
33
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
34
- docs: {
35
- ...config.parameters?.docs,
36
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
37
- source: {
38
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
39
- ...config.parameters?.docs?.source,
40
- type: 'code' as const,
41
- transform: (code: string) =>
42
- // eslint-disable-next-line regexp/no-super-linear-backtracking
43
- code.replace(/storySourceWithoutNoise\(\{\s+render\s?:\s+(.*)\}\)$/gms, '$1'),
44
- },
45
- },
46
- },
47
- };
48
-
49
- return newConfig;
50
- };
51
-
52
- export default {
53
- component: ListItem,
54
- title: 'Content/ListItem/common scenarios',
55
- tags: ['autodocs'],
56
- args: {
57
- title: lorem5,
58
- subtitle: lorem10,
59
- media: MEDIA.image,
60
- additionalInfo: INFO.nonInteractive,
61
- prompt: PROMPTS.interactive,
62
- control: CONTROLS.button,
63
- },
64
- parameters: {
65
- docs: {
66
- toc: true,
67
- page: () => (
68
- <>
69
- <Title>Common scenarios</Title>
70
- <Subtitle />
71
- <Description />
72
- <Stories />
73
- </>
74
- ),
75
- },
76
- },
77
- } satisfies Meta<ItemProps>;
78
- type Story = StoryObj<ItemProps>;
79
-
80
- /**
81
- * Aside from using the main control for triggering a [Modal](?path=/docs/dialogs-modal--docs),
82
- * it's also possible to toggle it via inline-button as part of the `<ListItem.AdditionalInfo>`
83
- * or `<ListItem.Prompt>`.
84
- */
85
- export const WithModals: Story = storySourceWithoutNoise({
86
- render: function WithModals(listItemProps) {
87
- const [isModalOpen, setIsModalOpen] = useState(false);
88
-
89
- const handleOpening = () => {
90
- setIsModalOpen(true);
91
- action('Modal opening')();
92
- };
93
- const handleClosing = () => {
94
- setIsModalOpen(false);
95
- action('Modal closing')();
96
- };
97
-
98
- return (
99
- <>
100
- <ListItem
101
- {...listItemProps}
102
- control={
103
- <ListItem.Button partiallyInteractive onClick={handleOpening}>
104
- Open modal
105
- </ListItem.Button>
106
- }
107
- additionalInfo={
108
- <ListItem.AdditionalInfo
109
- action={{ label: 'button opening a modal', onClick: handleOpening }}
110
- >
111
- This is additional information that contains a
112
- </ListItem.AdditionalInfo>
113
- }
114
- prompt={
115
- <ListItem.Prompt sentiment="positive">
116
- {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
117
- This prompt also has a <Link onClick={handleOpening}>
118
- button that opens a modal
119
- </Link>{' '}
120
- for your convenience.
121
- </ListItem.Prompt>
122
- }
123
- />
124
- <Modal body={lorem100} open={isModalOpen} onClose={handleClosing} />
125
- </>
126
- );
127
- },
128
- });
129
-
130
- /**
131
- * The control or inline buttons can trigger a [Popover](?path=/docs/dialogs-popover--docs).
132
- */
133
- export const WithPopover: Story = {
134
- render: (listItemProps) => {
135
- return (
136
- <ListItem
137
- {...listItemProps}
138
- control={
139
- <Popover preferredPlacement={Position.BOTTOM} title={lorem5} content={lorem20}>
140
- <ListItem.IconButton partiallyInteractive>
141
- <InfoCircle />
142
- </ListItem.IconButton>
143
- </Popover>
144
- }
145
- prompt={PROMPTS.nonInteractive}
146
- />
147
- );
148
- },
149
- };
150
-
151
- /**
152
- * The control or inline buttons can trigger a [Tooltip](?path=/docs/dialogs-tooltip--docs).
153
- */
154
- export const WithTooltip: Story = {
155
- render: (listItemProps) => {
156
- return (
157
- <ListItem
158
- {...listItemProps}
159
- control={
160
- <Tooltip position={Position.BOTTOM} label={lorem10}>
161
- <ListItem.IconButton partiallyInteractive>
162
- <InfoCircle />
163
- </ListItem.IconButton>
164
- </Tooltip>
165
- }
166
- prompt={PROMPTS.nonInteractive}
167
- />
168
- );
169
- },
170
- };
171
-
172
- /**
173
- * ListItem is often used as a simple copy and paste button augmented with a [Snackbar](?path=/docs/dialogs-snackbar--docs). <br />
174
- *
175
- * **NB** The snippet below uses a simplified example implementation of a clipboard handler,
176
- * which may not be suitable or sufficient for your needs.
177
- */
178
- export const CopyAndPasteWithSnackbar: Story = storySourceWithoutNoise({
179
- render: function CopyAndPaste() {
180
- const title = 'Artie Choke';
181
- const subtitle = 'Account holder';
182
-
183
- const handleCopy = async (createSnackbar: SnackbarContextType['createSnackbar']) =>
184
- navigator.clipboard
185
- .writeText(`${subtitle}: ${title}`)
186
- .catch((err) => {
187
- console.error('Failed to copy text: ', err);
188
- })
189
- .then(() => {
190
- createSnackbar({
191
- text: `${subtitle} copied to clipboard.`,
192
- });
193
- });
194
-
195
- return (
196
- <ListItem
197
- title={title}
198
- subtitle={subtitle}
199
- inverted
200
- control={
201
- <SnackbarProvider>
202
- <SnackbarConsumer>
203
- {({ createSnackbar }) => {
204
- return (
205
- <ListItem.IconButton
206
- partiallyInteractive
207
- onClick={async () => handleCopy(createSnackbar)}
208
- >
209
- <Documents />
210
- </ListItem.IconButton>
211
- );
212
- }}
213
- </SnackbarConsumer>
214
- </SnackbarProvider>
215
- }
216
- media={
217
- <ListItem.AvatarView
218
- imgSrc="../avatar-square-dude.webp"
219
- profileName="John Smith"
220
- size={48}
221
- />
222
- }
223
- />
224
- );
225
- },
226
- });