@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.
- package/build/flowNavigation/animatedLabel/AnimatedLabel.js +2 -2
- package/build/flowNavigation/animatedLabel/AnimatedLabel.js.map +1 -1
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs +2 -2
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/{listItem → legacylistItem}/List.js +2 -3
- package/build/legacylistItem/List.js.map +1 -0
- package/build/{listItem → legacylistItem}/List.mjs +2 -3
- package/build/legacylistItem/List.mjs.map +1 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +2 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -1
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +2 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -1
- package/build/listItem/AvatarView/ListItemAvatarView.js +2 -0
- package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -1
- package/build/listItem/AvatarView/ListItemAvatarView.mjs +2 -0
- package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -1
- package/build/listItem/Image/ListItemImage.js +6 -2
- package/build/listItem/Image/ListItemImage.js.map +1 -1
- package/build/listItem/Image/ListItemImage.mjs +6 -2
- package/build/listItem/Image/ListItemImage.mjs.map +1 -1
- package/build/listItem/ListItem.js +16 -14
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs +16 -14
- package/build/listItem/ListItem.mjs.map +1 -1
- package/build/listItem/ListItemContext.js.map +1 -1
- package/build/listItem/ListItemContext.mjs.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.js +1 -1
- package/build/listItem/Navigation/ListItemNavigation.js.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -1
- package/build/listItem/_stories/images/landscape.svg +1 -0
- package/build/listItem/_stories/images/portrait.svg +1 -0
- package/build/listItem/useListItemMedia.js +21 -0
- package/build/listItem/useListItemMedia.js.map +1 -0
- package/build/listItem/useListItemMedia.mjs +19 -0
- package/build/listItem/useListItemMedia.mjs.map +1 -0
- package/build/main.css +64 -101
- package/build/styles/avatarView/AvatarView.css +1 -3
- package/build/styles/listItem/ListItem.css +63 -98
- package/build/styles/listItem/ListItem.grid.css +17 -11
- package/build/styles/main.css +64 -101
- package/build/types/index.d.ts +4 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/legacylistItem/List.d.ts +6 -0
- package/build/types/legacylistItem/List.d.ts.map +1 -0
- package/build/types/legacylistItem/index.d.ts +2 -0
- package/build/types/legacylistItem/index.d.ts.map +1 -1
- package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -1
- package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -1
- package/build/types/listItem/Image/ListItemImage.d.ts +1 -1
- package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -1
- package/build/types/listItem/ListItem.d.ts +1 -1
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/listItem/ListItemContext.d.ts +4 -0
- package/build/types/listItem/ListItemContext.d.ts.map +1 -1
- package/build/types/listItem/index.d.ts +0 -2
- package/build/types/listItem/index.d.ts.map +1 -1
- package/build/types/listItem/test-utils.d.ts +7 -0
- package/build/types/listItem/test-utils.d.ts.map +1 -0
- package/build/types/listItem/useListItemMedia.d.ts +6 -0
- package/build/types/listItem/useListItemMedia.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/avatarView/AvatarView.css +1 -3
- package/src/avatarView/AvatarView.less +1 -2
- package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +1 -1
- package/src/index.ts +4 -9
- package/src/legacylistItem/LegacyListItem.story.tsx +2 -2
- package/src/legacylistItem/LegacyListItem.tests.story.tsx +1 -2
- package/src/legacylistItem/List.tsx +10 -0
- package/src/legacylistItem/index.ts +2 -0
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +4 -5
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +3 -0
- package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +4 -5
- package/src/listItem/AvatarView/ListItemAvatarView.tsx +3 -0
- package/src/listItem/Button/ListItemButton.spec.tsx +10 -35
- package/src/listItem/Button/ListItemButton.story.tsx +8 -9
- package/src/listItem/IconButton/ListItemIconButton.story.tsx +8 -8
- package/src/listItem/Image/ListItemImage.spec.tsx +8 -5
- package/src/listItem/Image/ListItemImage.story.tsx +23 -6
- package/src/listItem/Image/ListItemImage.tsx +12 -4
- package/src/listItem/ListItem.css +63 -98
- package/src/listItem/ListItem.grid.css +17 -11
- package/src/listItem/ListItem.grid.less +24 -16
- package/src/listItem/ListItem.less +60 -113
- package/src/listItem/ListItem.tsx +24 -18
- package/src/listItem/ListItemContext.tsx +5 -0
- package/src/listItem/Navigation/ListItemNavigation.tsx +1 -1
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +7 -7
- package/src/listItem/Switch/ListItemSwitch.story.tsx +2 -3
- package/src/listItem/_stories/ListItem.layout.test.story.tsx +142 -2
- package/src/listItem/_stories/ListItem.story.tsx +7 -45
- package/src/listItem/_stories/ListItem.variants.test.story.tsx +11 -7
- package/src/listItem/_stories/images/landscape.svg +1 -0
- package/src/listItem/_stories/images/portrait.svg +1 -0
- package/src/listItem/index.ts +0 -3
- package/src/listItem/test-utils.tsx +33 -0
- package/src/listItem/useListItemMedia.tsx +13 -0
- package/src/main.css +64 -101
- package/build/listItem/List.js.map +0 -1
- package/build/listItem/List.mjs.map +0 -1
- package/build/types/listItem/List.d.ts +0 -7
- package/build/types/listItem/List.d.ts.map +0 -1
- package/src/listItem/List.tsx +0 -11
- 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
|
-
});
|