@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.
- package/build/button/Button.js +1 -0
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +1 -0
- package/build/button/Button.mjs.map +1 -1
- package/build/common/RadioButton/RadioButton.js +5 -2
- package/build/common/RadioButton/RadioButton.js.map +1 -1
- package/build/common/RadioButton/RadioButton.mjs +5 -2
- package/build/common/RadioButton/RadioButton.mjs.map +1 -1
- package/build/i18n/en.json +2 -0
- package/build/i18n/en.json.js +2 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +2 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/iconButton/IconButton.js.map +1 -1
- package/build/iconButton/IconButton.mjs.map +1 -1
- package/build/image/Image.js.map +1 -1
- package/build/image/Image.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +56 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +1 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +54 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +1 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +21 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +19 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -0
- package/build/listItem/AvatarView/ListItemAvatarView.js +21 -0
- package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -0
- package/build/listItem/AvatarView/ListItemAvatarView.mjs +19 -0
- package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -0
- package/build/listItem/Button/ListItemButton.js +43 -0
- package/build/listItem/Button/ListItemButton.js.map +1 -0
- package/build/listItem/Button/ListItemButton.mjs +41 -0
- package/build/listItem/Button/ListItemButton.mjs.map +1 -0
- package/build/listItem/Checkbox/ListItemCheckbox.js +30 -0
- package/build/listItem/Checkbox/ListItemCheckbox.js.map +1 -0
- package/build/listItem/Checkbox/ListItemCheckbox.mjs +28 -0
- package/build/listItem/Checkbox/ListItemCheckbox.mjs.map +1 -0
- package/build/listItem/IconButton/ListItemIconButton.js +42 -0
- package/build/listItem/IconButton/ListItemIconButton.js.map +1 -0
- package/build/listItem/IconButton/ListItemIconButton.mjs +40 -0
- package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -0
- package/build/listItem/Image/ListItemImage.js +27 -0
- package/build/listItem/Image/ListItemImage.js.map +1 -0
- package/build/listItem/Image/ListItemImage.mjs +25 -0
- package/build/listItem/Image/ListItemImage.mjs.map +1 -0
- package/build/listItem/ListItem.js +302 -0
- package/build/listItem/ListItem.js.map +1 -0
- package/build/listItem/ListItem.mjs +297 -0
- package/build/listItem/ListItem.mjs.map +1 -0
- package/build/listItem/ListItemContext.js +8 -0
- package/build/listItem/ListItemContext.js.map +1 -0
- package/build/listItem/ListItemContext.mjs +6 -0
- package/build/listItem/ListItemContext.mjs.map +1 -0
- package/build/listItem/Navigation/ListItemNavigation.js +45 -0
- package/build/listItem/Navigation/ListItemNavigation.js.map +1 -0
- package/build/listItem/Navigation/ListItemNavigation.mjs +43 -0
- package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -0
- package/build/listItem/Prompt/ListItemPrompt.js +59 -0
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -0
- package/build/listItem/Prompt/ListItemPrompt.mjs +54 -0
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -0
- package/build/listItem/Radio/ListItemRadio.js +30 -0
- package/build/listItem/Radio/ListItemRadio.js.map +1 -0
- package/build/listItem/Radio/ListItemRadio.mjs +28 -0
- package/build/listItem/Radio/ListItemRadio.mjs.map +1 -0
- package/build/listItem/Switch/ListItemSwitch.js +30 -0
- package/build/listItem/Switch/ListItemSwitch.js.map +1 -0
- package/build/listItem/Switch/ListItemSwitch.mjs +28 -0
- package/build/listItem/Switch/ListItemSwitch.mjs.map +1 -0
- package/build/listItem/useListItemControl.js +22 -0
- package/build/listItem/useListItemControl.js.map +1 -0
- package/build/listItem/useListItemControl.mjs +20 -0
- package/build/listItem/useListItemControl.mjs.map +1 -0
- package/build/main.css +657 -0
- package/build/styles/listItem/ListItem.css +657 -0
- package/build/styles/listItem/ListItem.grid.css +362 -0
- package/build/styles/main.css +657 -0
- package/build/switch/Switch.js +2 -0
- package/build/switch/Switch.js.map +1 -1
- package/build/switch/Switch.mjs +2 -0
- package/build/switch/Switch.mjs.map +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.types.d.ts +1 -1
- package/build/types/button/Button.types.d.ts.map +1 -1
- package/build/types/button/index.d.ts +1 -1
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/common/RadioButton/RadioButton.d.ts +3 -1
- package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
- package/build/types/iconButton/IconButton.d.ts +2 -2
- package/build/types/iconButton/IconButton.d.ts.map +1 -1
- package/build/types/image/Image.d.ts +3 -0
- package/build/types/image/Image.d.ts.map +1 -1
- package/build/types/image/index.d.ts +1 -0
- package/build/types/image/index.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts +15 -0
- package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts.map +1 -0
- package/build/types/listItem/AdditionalInfo/index.d.ts +3 -0
- package/build/types/listItem/AdditionalInfo/index.d.ts.map +1 -0
- package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts +18 -0
- package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -0
- package/build/types/listItem/AvatarLayout/index.d.ts +3 -0
- package/build/types/listItem/AvatarLayout/index.d.ts.map +1 -0
- package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts +16 -0
- package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -0
- package/build/types/listItem/AvatarView/index.d.ts +3 -0
- package/build/types/listItem/AvatarView/index.d.ts.map +1 -0
- package/build/types/listItem/Button/ListItemButton.d.ts +20 -0
- package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -0
- package/build/types/listItem/Button/index.d.ts +3 -0
- package/build/types/listItem/Button/index.d.ts.map +1 -0
- package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts +14 -0
- package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts.map +1 -0
- package/build/types/listItem/Checkbox/index.d.ts +3 -0
- package/build/types/listItem/Checkbox/index.d.ts.map +1 -0
- package/build/types/listItem/IconButton/ListItemIconButton.d.ts +18 -0
- package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -0
- package/build/types/listItem/IconButton/index.d.ts +3 -0
- package/build/types/listItem/IconButton/index.d.ts.map +1 -0
- package/build/types/listItem/Image/ListItemImage.d.ts +25 -0
- package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -0
- package/build/types/listItem/Image/index.d.ts +3 -0
- package/build/types/listItem/Image/index.d.ts.map +1 -0
- package/build/types/listItem/ListItem.d.ts +113 -0
- package/build/types/listItem/ListItem.d.ts.map +1 -0
- package/build/types/listItem/ListItemContext.d.ts +18 -0
- package/build/types/listItem/ListItemContext.d.ts.map +1 -0
- package/build/types/listItem/Navigation/ListItemNavigation.d.ts +15 -0
- package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -0
- package/build/types/listItem/Navigation/index.d.ts +3 -0
- package/build/types/listItem/Navigation/index.d.ts.map +1 -0
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts +16 -0
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -0
- package/build/types/listItem/Prompt/index.d.ts +3 -0
- package/build/types/listItem/Prompt/index.d.ts.map +1 -0
- package/build/types/listItem/Radio/ListItemRadio.d.ts +14 -0
- package/build/types/listItem/Radio/ListItemRadio.d.ts.map +1 -0
- package/build/types/listItem/Radio/index.d.ts +3 -0
- package/build/types/listItem/Radio/index.d.ts.map +1 -0
- package/build/types/listItem/Switch/ListItemSwitch.d.ts +14 -0
- package/build/types/listItem/Switch/ListItemSwitch.d.ts.map +1 -0
- package/build/types/listItem/Switch/index.d.ts +3 -0
- package/build/types/listItem/Switch/index.d.ts.map +1 -0
- package/build/types/listItem/_stories/subcomponents.d.ts +18 -0
- package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -0
- package/build/types/listItem/index.d.ts +14 -0
- package/build/types/listItem/index.d.ts.map +1 -0
- package/build/types/listItem/useListItemControl.d.ts +5 -0
- package/build/types/listItem/useListItemControl.d.ts.map +1 -0
- package/build/types/switch/Switch.d.ts +2 -0
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +4 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/types/upload/Upload.d.ts +6 -2
- package/build/types/upload/Upload.d.ts.map +1 -1
- package/build/types/upload/Upload.messages.d.ts +8 -0
- package/build/types/upload/Upload.messages.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts +4 -2
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/build/upload/Upload.js +16 -9
- package/build/upload/Upload.js.map +1 -1
- package/build/upload/Upload.messages.js +6 -0
- package/build/upload/Upload.messages.js.map +1 -1
- package/build/upload/Upload.messages.mjs +6 -0
- package/build/upload/Upload.messages.mjs.map +1 -1
- package/build/upload/Upload.mjs +16 -9
- package/build/upload/Upload.mjs.map +1 -1
- package/build/uploadInput/UploadInput.js +1 -1
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.js +7 -4
- package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.mjs +7 -4
- package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
- package/package.json +1 -1
- package/src/button/Button.spec.tsx +18 -0
- package/src/button/Button.tsx +5 -1
- package/src/button/Button.types.ts +1 -1
- package/src/button/index.ts +1 -1
- package/src/checkboxButton/CheckboxButton.story.tsx +4 -4
- package/src/common/RadioButton/RadioButton.tsx +6 -1
- package/src/i18n/en.json +2 -0
- package/src/iconButton/IconButton.story.tsx +1 -1
- package/src/iconButton/IconButton.tsx +1 -1
- package/src/image/Image.tsx +3 -0
- package/src/image/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +145 -0
- package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.tsx +36 -0
- package/src/listItem/AdditionalInfo/index.ts +2 -0
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +118 -0
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +24 -0
- package/src/listItem/AvatarLayout/index.ts +2 -0
- package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +318 -0
- package/src/listItem/AvatarView/ListItemAvatarView.tsx +24 -0
- package/src/listItem/AvatarView/index.ts +2 -0
- package/src/listItem/Button/ListItemButton.spec.tsx +93 -0
- package/src/listItem/Button/ListItemButton.story.tsx +408 -0
- package/src/listItem/Button/ListItemButton.tsx +56 -0
- package/src/listItem/Button/index.ts +2 -0
- package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +107 -0
- package/src/listItem/Checkbox/ListItemCheckbox.tsx +33 -0
- package/src/listItem/Checkbox/index.ts +2 -0
- package/src/listItem/IconButton/ListItemIconButton.story.tsx +236 -0
- package/src/listItem/IconButton/ListItemIconButton.tsx +56 -0
- package/src/listItem/IconButton/index.ts +2 -0
- package/src/listItem/Image/ListItemImage.story.tsx +39 -0
- package/src/listItem/Image/ListItemImage.tsx +40 -0
- package/src/listItem/Image/index.ts +2 -0
- package/src/listItem/ListItem.css +657 -0
- package/src/listItem/ListItem.grid.css +362 -0
- package/src/listItem/ListItem.grid.less +612 -0
- package/src/listItem/ListItem.less +312 -0
- package/src/listItem/ListItem.spec.tsx +97 -0
- package/src/listItem/ListItem.tsx +428 -0
- package/src/listItem/ListItemContext.tsx +22 -0
- package/src/listItem/Navigation/ListItemNavigation.story.tsx +106 -0
- package/src/listItem/Navigation/ListItemNavigation.tsx +40 -0
- package/src/listItem/Navigation/index.ts +2 -0
- package/src/listItem/Prompt/ListItemPrompt.spec.tsx +49 -0
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +199 -0
- package/src/listItem/Prompt/ListItemPrompt.tsx +32 -0
- package/src/listItem/Prompt/index.ts +2 -0
- package/src/listItem/Radio/ListItemRadio.story.tsx +98 -0
- package/src/listItem/Radio/ListItemRadio.tsx +33 -0
- package/src/listItem/Radio/index.ts +2 -0
- package/src/listItem/Switch/ListItemSwitch.story.tsx +69 -0
- package/src/listItem/Switch/ListItemSwitch.tsx +33 -0
- package/src/listItem/Switch/index.ts +2 -0
- package/src/listItem/_stories/ListItem.focus.test.story.tsx +250 -0
- package/src/listItem/_stories/ListItem.layout.test.story.tsx +169 -0
- package/src/listItem/_stories/ListItem.story.tsx +670 -0
- package/src/listItem/_stories/ListItem.variants.test.story.tsx +266 -0
- package/src/listItem/_stories/subcomponents.tsx +139 -0
- package/src/listItem/index.ts +14 -0
- package/src/listItem/useListItemControl.tsx +18 -0
- package/src/main.css +657 -0
- package/src/main.less +1 -0
- package/src/switch/Switch.tsx +4 -0
- package/src/upload/Upload.messages.ts +8 -0
- package/src/upload/Upload.spec.tsx +6 -0
- package/src/upload/Upload.story.tsx +118 -3
- package/src/upload/Upload.tests.story.tsx +5 -3
- package/src/upload/Upload.tsx +24 -15
- package/src/uploadInput/UploadInput.tests.story.tsx +7 -0
- package/src/uploadInput/UploadInput.tsx +2 -2
- package/src/uploadInput/uploadButton/UploadButton.spec.tsx +6 -0
- package/src/uploadInput/uploadButton/UploadButton.tsx +12 -6
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import Link from '../../link';
|
|
3
|
+
import { ListItem, Props as ItemProps } from '../ListItem';
|
|
4
|
+
import { expect, userEvent, within, waitFor } from 'storybook/test';
|
|
5
|
+
|
|
6
|
+
const waitForFocus = async (assertion: () => Promise<void>, timeout = 3000) => {
|
|
7
|
+
await waitFor(assertion, { timeout });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const waitForListItem = async (canvas: ReturnType<typeof within>, timeout = 3000) => {
|
|
11
|
+
await waitFor(
|
|
12
|
+
async () => {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
14
|
+
await expect(canvas.getByRole('listitem')).toBeInTheDocument();
|
|
15
|
+
},
|
|
16
|
+
{ timeout },
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
component: ListItem,
|
|
22
|
+
title: 'Content/ListItem/tests/focus',
|
|
23
|
+
tags: ['!autodocs'],
|
|
24
|
+
parameters: {
|
|
25
|
+
controls: { disable: true },
|
|
26
|
+
actions: { disable: true },
|
|
27
|
+
a11y: { disable: true },
|
|
28
|
+
knobs: { disable: true },
|
|
29
|
+
},
|
|
30
|
+
} satisfies Meta<ItemProps>;
|
|
31
|
+
type Story = StoryObj<ItemProps>;
|
|
32
|
+
|
|
33
|
+
const title = {
|
|
34
|
+
full: 'Fully interactive',
|
|
35
|
+
partial: 'Partially interactive',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const subtitle = {
|
|
39
|
+
full: 'Whole item should be focusable, control should not.',
|
|
40
|
+
partial: 'Only control should be focusable, not whole item.',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const additionalInfo = {
|
|
44
|
+
static: (
|
|
45
|
+
<ListItem.AdditionalInfo>
|
|
46
|
+
Fully interactive ListItems don't allow any nested interactive elements like links or
|
|
47
|
+
buttons within AdditionalInfo.
|
|
48
|
+
</ListItem.AdditionalInfo>
|
|
49
|
+
),
|
|
50
|
+
interactive: (
|
|
51
|
+
<ListItem.AdditionalInfo
|
|
52
|
+
action={{ label: 'appended to the end.', href: 'https://wise.com', target: '_blank' }}
|
|
53
|
+
>
|
|
54
|
+
This additional info has a focusable link
|
|
55
|
+
</ListItem.AdditionalInfo>
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const prompt = {
|
|
60
|
+
static: <ListItem.Prompt sentiment="positive">Non-interactive prompt.</ListItem.Prompt>,
|
|
61
|
+
interactive: (
|
|
62
|
+
<ListItem.Prompt sentiment="positive">
|
|
63
|
+
This prompt has a{' '}
|
|
64
|
+
<Link href="https://wise.com" target="_blank" rel="noreferrer">
|
|
65
|
+
single interactive element
|
|
66
|
+
</Link>{' '}
|
|
67
|
+
that spreads across the whole prompt area.
|
|
68
|
+
</ListItem.Prompt>
|
|
69
|
+
),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const button = {
|
|
73
|
+
full: (
|
|
74
|
+
<ListItem.Button priority="secondary-neutral" onClick={() => {}}>
|
|
75
|
+
Click me
|
|
76
|
+
</ListItem.Button>
|
|
77
|
+
),
|
|
78
|
+
partial: (
|
|
79
|
+
<ListItem.Button partiallyInteractive priority="secondary-neutral" onClick={() => {}}>
|
|
80
|
+
Click me
|
|
81
|
+
</ListItem.Button>
|
|
82
|
+
),
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const FullyInteractive: Story = {
|
|
86
|
+
play: async ({ canvasElement }) => {
|
|
87
|
+
const canvas = within(canvasElement);
|
|
88
|
+
await waitForListItem(canvas);
|
|
89
|
+
await userEvent.tab();
|
|
90
|
+
await waitForFocus(async () => {
|
|
91
|
+
await expect(canvas.getByRole('button')).toHaveFocus();
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
render: () => (
|
|
95
|
+
<ListItem
|
|
96
|
+
title={title.full}
|
|
97
|
+
subtitle={subtitle.full}
|
|
98
|
+
additionalInfo={additionalInfo.static}
|
|
99
|
+
control={button.full}
|
|
100
|
+
prompt={prompt.static}
|
|
101
|
+
/>
|
|
102
|
+
),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const FullyInteractiveFocusedOnPrompt: Story = {
|
|
106
|
+
play: async ({ canvasElement }) => {
|
|
107
|
+
const canvas = within(canvasElement);
|
|
108
|
+
await waitForListItem(canvas);
|
|
109
|
+
|
|
110
|
+
await userEvent.tab();
|
|
111
|
+
await waitForFocus(async () => {
|
|
112
|
+
await expect(canvas.getByRole('button')).toHaveFocus();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await userEvent.tab();
|
|
116
|
+
await waitForFocus(async () => {
|
|
117
|
+
await expect(canvas.getByRole('link', { name: /^single interactive element/ })).toHaveFocus();
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
render: () => (
|
|
121
|
+
<ListItem
|
|
122
|
+
title={title.full}
|
|
123
|
+
subtitle={subtitle.full}
|
|
124
|
+
additionalInfo={additionalInfo.static}
|
|
125
|
+
control={button.full}
|
|
126
|
+
prompt={prompt.interactive}
|
|
127
|
+
/>
|
|
128
|
+
),
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const PartiallyInteractiveFocusedOnControl: Story = {
|
|
132
|
+
play: async ({ canvasElement }) => {
|
|
133
|
+
const canvas = within(canvasElement);
|
|
134
|
+
await waitForListItem(canvas);
|
|
135
|
+
await userEvent.tab();
|
|
136
|
+
await waitForFocus(async () => {
|
|
137
|
+
await expect(canvas.getByRole('button')).toHaveFocus();
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
render: () => (
|
|
141
|
+
<ListItem
|
|
142
|
+
title={title.partial}
|
|
143
|
+
subtitle={subtitle.partial}
|
|
144
|
+
additionalInfo={additionalInfo.interactive}
|
|
145
|
+
control={button.partial}
|
|
146
|
+
prompt={prompt.interactive}
|
|
147
|
+
/>
|
|
148
|
+
),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const PartiallyInteractiveFocusedOnAdditionInfo: Story = {
|
|
152
|
+
play: async ({ canvasElement }) => {
|
|
153
|
+
const canvas = within(canvasElement);
|
|
154
|
+
await waitForListItem(canvas);
|
|
155
|
+
|
|
156
|
+
await userEvent.tab();
|
|
157
|
+
await waitForFocus(async () => {
|
|
158
|
+
await expect(canvas.getByRole('button')).toHaveFocus();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await userEvent.tab();
|
|
162
|
+
await waitForFocus(async () => {
|
|
163
|
+
await expect(canvas.getByRole('link', { name: /^appended to the end/ })).toHaveFocus();
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
render: () => (
|
|
167
|
+
<ListItem
|
|
168
|
+
title={title.partial}
|
|
169
|
+
subtitle={subtitle.partial}
|
|
170
|
+
additionalInfo={additionalInfo.interactive}
|
|
171
|
+
control={button.partial}
|
|
172
|
+
prompt={prompt.interactive}
|
|
173
|
+
/>
|
|
174
|
+
),
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const PartiallyInteractiveFocusedOnPrompt: Story = {
|
|
178
|
+
play: async ({ canvasElement }) => {
|
|
179
|
+
const canvas = within(canvasElement);
|
|
180
|
+
await waitForListItem(canvas);
|
|
181
|
+
|
|
182
|
+
await userEvent.tab();
|
|
183
|
+
await waitForFocus(async () => {
|
|
184
|
+
await expect(canvas.getByRole('button')).toHaveFocus();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
await userEvent.tab();
|
|
188
|
+
await waitForFocus(async () => {
|
|
189
|
+
await expect(canvas.getByRole('link', { name: /^appended to the end/ })).toHaveFocus();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
await userEvent.tab();
|
|
193
|
+
await waitForFocus(async () => {
|
|
194
|
+
await expect(canvas.getByRole('link', { name: /^single interactive element/ })).toHaveFocus();
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
render: () => (
|
|
198
|
+
<ListItem
|
|
199
|
+
title={title.partial}
|
|
200
|
+
subtitle={subtitle.partial}
|
|
201
|
+
additionalInfo={additionalInfo.interactive}
|
|
202
|
+
control={button.partial}
|
|
203
|
+
prompt={prompt.interactive}
|
|
204
|
+
/>
|
|
205
|
+
),
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export const FullyInteractiveDisabled: Story = {
|
|
209
|
+
play: async ({ canvasElement }) => {
|
|
210
|
+
const canvas = within(canvasElement);
|
|
211
|
+
await waitForListItem(canvas);
|
|
212
|
+
|
|
213
|
+
await userEvent.tab();
|
|
214
|
+
await waitForFocus(async () => {
|
|
215
|
+
await expect(canvas.getByRole('button')).not.toHaveFocus();
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
render: () => (
|
|
219
|
+
<ListItem
|
|
220
|
+
disabled
|
|
221
|
+
title={title.full}
|
|
222
|
+
subtitle={subtitle.full}
|
|
223
|
+
additionalInfo={additionalInfo.static}
|
|
224
|
+
control={button.full}
|
|
225
|
+
prompt={prompt.static}
|
|
226
|
+
/>
|
|
227
|
+
),
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const PartiallyInteractiveDisabled: Story = {
|
|
231
|
+
play: async ({ canvasElement }) => {
|
|
232
|
+
const canvas = within(canvasElement);
|
|
233
|
+
await waitForListItem(canvas);
|
|
234
|
+
|
|
235
|
+
await userEvent.tab();
|
|
236
|
+
await waitForFocus(async () => {
|
|
237
|
+
await expect(canvas.getByRole('button')).not.toHaveFocus();
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
render: () => (
|
|
241
|
+
<ListItem
|
|
242
|
+
disabled
|
|
243
|
+
title={title.partial}
|
|
244
|
+
subtitle={subtitle.partial}
|
|
245
|
+
additionalInfo={additionalInfo.interactive}
|
|
246
|
+
control={button.partial}
|
|
247
|
+
prompt={prompt.interactive}
|
|
248
|
+
/>
|
|
249
|
+
),
|
|
250
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { Bank, FastFlag, MultiCurrency, Receipt, Savings } from '@transferwise/icons';
|
|
3
|
+
import Link from '../../link';
|
|
4
|
+
import { ListItem, Props as ItemProps } from '../ListItem';
|
|
5
|
+
import { lorem5 } from '../../test-utils';
|
|
6
|
+
|
|
7
|
+
const withSizedContainer = (width: number) => (Story: any) => (
|
|
8
|
+
<ol
|
|
9
|
+
className="list-unstyled"
|
|
10
|
+
style={{
|
|
11
|
+
width,
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
gap: 16,
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<Story />
|
|
18
|
+
</ol>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
component: ListItem,
|
|
23
|
+
title: 'Content/ListItem/tests/layout',
|
|
24
|
+
tags: ['!autodocs'],
|
|
25
|
+
parameters: {
|
|
26
|
+
controls: { disable: true },
|
|
27
|
+
actions: { disable: true },
|
|
28
|
+
a11y: { disable: true },
|
|
29
|
+
knobs: { disable: true },
|
|
30
|
+
},
|
|
31
|
+
} satisfies Meta<ItemProps>;
|
|
32
|
+
type Story = StoryObj<ItemProps>;
|
|
33
|
+
|
|
34
|
+
const variants = [
|
|
35
|
+
<ListItem
|
|
36
|
+
key="button"
|
|
37
|
+
title="Button only"
|
|
38
|
+
control={
|
|
39
|
+
<ListItem.Button priority="secondary-neutral" onClick={() => {}}>
|
|
40
|
+
Click me
|
|
41
|
+
</ListItem.Button>
|
|
42
|
+
}
|
|
43
|
+
/>,
|
|
44
|
+
<ListItem
|
|
45
|
+
key="media"
|
|
46
|
+
title="With media"
|
|
47
|
+
subtitle="Short subtitle"
|
|
48
|
+
additionalInfo={<ListItem.AdditionalInfo>{lorem5}</ListItem.AdditionalInfo>}
|
|
49
|
+
media={
|
|
50
|
+
<ListItem.AvatarView>
|
|
51
|
+
<FastFlag />
|
|
52
|
+
</ListItem.AvatarView>
|
|
53
|
+
}
|
|
54
|
+
/>,
|
|
55
|
+
<ListItem key="value" title="With value" valueTitle="100 GBP" valueSubtitle="100 USD" />,
|
|
56
|
+
<ListItem
|
|
57
|
+
key="prompt"
|
|
58
|
+
title="With prompt"
|
|
59
|
+
prompt={
|
|
60
|
+
<ListItem.Prompt sentiment="positive">
|
|
61
|
+
This is a prompt with <Link href="https://wise.com">a link</Link>.
|
|
62
|
+
</ListItem.Prompt>
|
|
63
|
+
}
|
|
64
|
+
/>,
|
|
65
|
+
<ListItem
|
|
66
|
+
key="button-media"
|
|
67
|
+
title="Button + media"
|
|
68
|
+
media={
|
|
69
|
+
<ListItem.AvatarView>
|
|
70
|
+
<MultiCurrency />
|
|
71
|
+
</ListItem.AvatarView>
|
|
72
|
+
}
|
|
73
|
+
control={
|
|
74
|
+
<ListItem.Button priority="primary" onClick={() => {}}>
|
|
75
|
+
Action
|
|
76
|
+
</ListItem.Button>
|
|
77
|
+
}
|
|
78
|
+
/>,
|
|
79
|
+
<ListItem
|
|
80
|
+
key="button-value"
|
|
81
|
+
title="Button + value"
|
|
82
|
+
valueTitle="42 EUR"
|
|
83
|
+
control={
|
|
84
|
+
<ListItem.Button priority="secondary-neutral" onClick={() => {}}>
|
|
85
|
+
Pay
|
|
86
|
+
</ListItem.Button>
|
|
87
|
+
}
|
|
88
|
+
/>,
|
|
89
|
+
<ListItem
|
|
90
|
+
key="media-value"
|
|
91
|
+
valueColumnWidth={80}
|
|
92
|
+
title="Media + value"
|
|
93
|
+
subtitle="this column is 20% wide"
|
|
94
|
+
media={
|
|
95
|
+
<ListItem.AvatarView>
|
|
96
|
+
<Bank />
|
|
97
|
+
</ListItem.AvatarView>
|
|
98
|
+
}
|
|
99
|
+
valueTitle="1,000 USD"
|
|
100
|
+
/>,
|
|
101
|
+
<ListItem
|
|
102
|
+
key="prompt-value"
|
|
103
|
+
title="Prompt + value"
|
|
104
|
+
valueTitle="10 GBP"
|
|
105
|
+
prompt={<ListItem.Prompt sentiment="warning">Warning prompt!</ListItem.Prompt>}
|
|
106
|
+
/>,
|
|
107
|
+
<ListItem
|
|
108
|
+
key="media-prompt"
|
|
109
|
+
title="Media + prompt"
|
|
110
|
+
media={
|
|
111
|
+
<ListItem.AvatarView>
|
|
112
|
+
<Receipt />
|
|
113
|
+
</ListItem.AvatarView>
|
|
114
|
+
}
|
|
115
|
+
prompt={<ListItem.Prompt sentiment="positive">Discount available!</ListItem.Prompt>}
|
|
116
|
+
/>,
|
|
117
|
+
<ListItem
|
|
118
|
+
key="most"
|
|
119
|
+
title="Everything but button"
|
|
120
|
+
subtitle="No control"
|
|
121
|
+
media={
|
|
122
|
+
<ListItem.AvatarView>
|
|
123
|
+
<Savings />
|
|
124
|
+
</ListItem.AvatarView>
|
|
125
|
+
}
|
|
126
|
+
valueTitle="999 GBP"
|
|
127
|
+
prompt={
|
|
128
|
+
<ListItem.Prompt sentiment="positive">
|
|
129
|
+
<Link href="https://wise.com">See details</Link>
|
|
130
|
+
</ListItem.Prompt>
|
|
131
|
+
}
|
|
132
|
+
/>,
|
|
133
|
+
<ListItem
|
|
134
|
+
key="all"
|
|
135
|
+
title="All together"
|
|
136
|
+
subtitle="Everything in one"
|
|
137
|
+
media={
|
|
138
|
+
<ListItem.AvatarView>
|
|
139
|
+
<Savings />
|
|
140
|
+
</ListItem.AvatarView>
|
|
141
|
+
}
|
|
142
|
+
valueTitle="999 GBP"
|
|
143
|
+
prompt={
|
|
144
|
+
<ListItem.Prompt sentiment="positive">
|
|
145
|
+
<Link href="https://wise.com">See details</Link>
|
|
146
|
+
</ListItem.Prompt>
|
|
147
|
+
}
|
|
148
|
+
control={
|
|
149
|
+
<ListItem.Button priority="secondary-neutral" onClick={() => {}}>
|
|
150
|
+
Go
|
|
151
|
+
</ListItem.Button>
|
|
152
|
+
}
|
|
153
|
+
/>,
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
export const Under320: Story = {
|
|
157
|
+
render: () => <>{variants}</>,
|
|
158
|
+
decorators: [withSizedContainer(320)],
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const Between321And399: Story = {
|
|
162
|
+
render: () => <>{variants}</>,
|
|
163
|
+
decorators: [withSizedContainer(360)],
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const Over400: Story = {
|
|
167
|
+
render: () => <>{variants}</>,
|
|
168
|
+
decorators: [withSizedContainer(400)],
|
|
169
|
+
};
|