@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,199 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn } from 'storybook/test';
|
|
3
|
+
import { lorem10, lorem5 } from '../../test-utils';
|
|
4
|
+
import Link from '../../link';
|
|
5
|
+
import { Sentiment as Sentiments } from '../../common';
|
|
6
|
+
import { ListItem } from '../..';
|
|
7
|
+
import { Prompt, ListItemPromptProps } from './ListItemPrompt';
|
|
8
|
+
import {
|
|
9
|
+
SB_LIST_ITEM_CONTROLS as CONTROLS,
|
|
10
|
+
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
11
|
+
} from '../_stories/subcomponents';
|
|
12
|
+
|
|
13
|
+
const meta: Meta<ListItemPromptProps> = {
|
|
14
|
+
component: Prompt,
|
|
15
|
+
title: 'Content/ListItem/ListItem.Prompt',
|
|
16
|
+
parameters: {
|
|
17
|
+
docs: {
|
|
18
|
+
toc: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
sentiment: undefined,
|
|
23
|
+
children: 'You have done a terrible thing',
|
|
24
|
+
},
|
|
25
|
+
argTypes: {
|
|
26
|
+
sentiment: {
|
|
27
|
+
options: [
|
|
28
|
+
'unset (undefined)',
|
|
29
|
+
Sentiments.POSITIVE,
|
|
30
|
+
Sentiments.NEGATIVE,
|
|
31
|
+
Sentiments.NEUTRAL,
|
|
32
|
+
Sentiments.WARNING,
|
|
33
|
+
],
|
|
34
|
+
mapping: {
|
|
35
|
+
'unset (undefined)': undefined,
|
|
36
|
+
},
|
|
37
|
+
control: { type: 'radio' },
|
|
38
|
+
},
|
|
39
|
+
children: {
|
|
40
|
+
table: {
|
|
41
|
+
type: { summary: 'ReactNode' },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default meta;
|
|
48
|
+
|
|
49
|
+
type Story = StoryObj<ListItemPromptProps>;
|
|
50
|
+
|
|
51
|
+
export const Playground: Story = {
|
|
52
|
+
tags: ['!autodocs'],
|
|
53
|
+
parameters: {
|
|
54
|
+
docs: {
|
|
55
|
+
source: 'dynamic',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
render: (args) => (
|
|
59
|
+
<ListItem
|
|
60
|
+
title={lorem5}
|
|
61
|
+
subtitle={lorem10}
|
|
62
|
+
media={MEDIA.avatarSingle}
|
|
63
|
+
control={CONTROLS.switch}
|
|
64
|
+
prompt={<Prompt {...args} />}
|
|
65
|
+
/>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Sentiment: Story = {
|
|
70
|
+
parameters: {
|
|
71
|
+
controls: { disable: true },
|
|
72
|
+
actions: { disable: true },
|
|
73
|
+
a11y: { disable: true },
|
|
74
|
+
knobs: { disable: true },
|
|
75
|
+
},
|
|
76
|
+
render: (args) => (
|
|
77
|
+
<ol className="list-unstyled">
|
|
78
|
+
<ListItem
|
|
79
|
+
title={lorem5}
|
|
80
|
+
subtitle={lorem10}
|
|
81
|
+
media={MEDIA.avatarSingle}
|
|
82
|
+
control={CONTROLS.switch}
|
|
83
|
+
prompt={<Prompt sentiment={Sentiments.NEUTRAL}>This is a neutral prompt.</Prompt>}
|
|
84
|
+
/>
|
|
85
|
+
<ListItem
|
|
86
|
+
title={lorem5}
|
|
87
|
+
subtitle={lorem10}
|
|
88
|
+
media={MEDIA.avatarSingle}
|
|
89
|
+
control={CONTROLS.switch}
|
|
90
|
+
prompt={<Prompt sentiment={Sentiments.POSITIVE}>This is a positive prompt.</Prompt>}
|
|
91
|
+
/>
|
|
92
|
+
<ListItem
|
|
93
|
+
title={lorem5}
|
|
94
|
+
subtitle={lorem10}
|
|
95
|
+
media={MEDIA.avatarSingle}
|
|
96
|
+
control={CONTROLS.switch}
|
|
97
|
+
prompt={<Prompt sentiment={Sentiments.WARNING}>This is a warning prompt.</Prompt>}
|
|
98
|
+
/>
|
|
99
|
+
<ListItem
|
|
100
|
+
title={lorem5}
|
|
101
|
+
subtitle={lorem10}
|
|
102
|
+
media={MEDIA.avatarSingle}
|
|
103
|
+
control={CONTROLS.switch}
|
|
104
|
+
prompt={<Prompt sentiment={Sentiments.NEGATIVE}>This is a negative prompt.</Prompt>}
|
|
105
|
+
/>
|
|
106
|
+
</ol>
|
|
107
|
+
),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* `ListItem.Prompt` is rendered on a separate branch of the Accessibility Tree from the item's
|
|
112
|
+
* control, so it can include a single instance of `Link` component, which can be rendered as
|
|
113
|
+
* either HTML anchor or button. That element will spread across the whole surface of the Prompt
|
|
114
|
+
* so it's easily accessible for all users.
|
|
115
|
+
*/
|
|
116
|
+
export const Interactivity: Story = {
|
|
117
|
+
argTypes: {
|
|
118
|
+
children: {
|
|
119
|
+
table: {
|
|
120
|
+
disable: true,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
render: (args) => (
|
|
125
|
+
<ol className="list-unstyled">
|
|
126
|
+
<ListItem
|
|
127
|
+
title={lorem5}
|
|
128
|
+
subtitle={lorem10}
|
|
129
|
+
media={MEDIA.avatarSingle}
|
|
130
|
+
control={CONTROLS.switch}
|
|
131
|
+
prompt={
|
|
132
|
+
<Prompt sentiment={args.sentiment}>
|
|
133
|
+
This prompt includes a{' '}
|
|
134
|
+
<Link href="https://wise.com" target="_blank" rel="noreferrer">
|
|
135
|
+
link to some resource
|
|
136
|
+
</Link>{' '}
|
|
137
|
+
to help the user in their journey.
|
|
138
|
+
</Prompt>
|
|
139
|
+
}
|
|
140
|
+
/>
|
|
141
|
+
|
|
142
|
+
<ListItem
|
|
143
|
+
title={lorem5}
|
|
144
|
+
subtitle={lorem10}
|
|
145
|
+
media={MEDIA.avatarSingle}
|
|
146
|
+
control={CONTROLS.switch}
|
|
147
|
+
prompt={
|
|
148
|
+
<Prompt sentiment={args.sentiment}>
|
|
149
|
+
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
|
|
150
|
+
This prompt includes an <Link onClick={fn()}>inline button</Link> than can e.g. trigger
|
|
151
|
+
a modal.
|
|
152
|
+
</Prompt>
|
|
153
|
+
}
|
|
154
|
+
/>
|
|
155
|
+
</ol>
|
|
156
|
+
),
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* By default, the Prompt will try to occupy as little space as possible, but as soon as you make it more than 1 line long, it will stretch to the full available width.
|
|
161
|
+
*
|
|
162
|
+
* **NB:** While Prompt supports multi-line text, its content should be concise and have no more than 2 short sentences so users can quickly understand the message.
|
|
163
|
+
*/
|
|
164
|
+
export const Sizing: Story = {
|
|
165
|
+
parameters: {
|
|
166
|
+
docs: {
|
|
167
|
+
canvas: {
|
|
168
|
+
sourceState: 'hidden',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
render: (args) => (
|
|
173
|
+
<ol className="list-unstyled">
|
|
174
|
+
<ListItem
|
|
175
|
+
title={lorem5}
|
|
176
|
+
subtitle={lorem10}
|
|
177
|
+
media={MEDIA.image}
|
|
178
|
+
control={CONTROLS.switch}
|
|
179
|
+
prompt={
|
|
180
|
+
<ListItem.Prompt sentiment={Sentiments.POSITIVE}>This is a short text</ListItem.Prompt>
|
|
181
|
+
}
|
|
182
|
+
/>
|
|
183
|
+
<ListItem
|
|
184
|
+
title={lorem5}
|
|
185
|
+
subtitle={lorem10}
|
|
186
|
+
media={MEDIA.image}
|
|
187
|
+
control={CONTROLS.switch}
|
|
188
|
+
prompt={
|
|
189
|
+
<ListItem.Prompt sentiment={Sentiments.WARNING}>
|
|
190
|
+
This is a very, very, very, very, very long text that will wrap into more than 1 line
|
|
191
|
+
and will make the prompt stretch to a full available width. Technically it can be as
|
|
192
|
+
long as Vim manual, but we recommend keeping it concise and no more than 2 short
|
|
193
|
+
sentences.
|
|
194
|
+
</ListItem.Prompt>
|
|
195
|
+
}
|
|
196
|
+
/>
|
|
197
|
+
</ol>
|
|
198
|
+
),
|
|
199
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { Sentiment } from '../../common';
|
|
4
|
+
import StatusIcon from '../../statusIcon';
|
|
5
|
+
import Body from '../../body';
|
|
6
|
+
import { ListItemContext, type ListItemContextData } from '../ListItemContext';
|
|
7
|
+
|
|
8
|
+
export type ListItemPromptProps = {
|
|
9
|
+
sentiment?: `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This component allows for rendering an Inline Prompt. <br />In the future it will be a thin wrapper around a standalone component.<br />
|
|
15
|
+
*
|
|
16
|
+
* Please refer to the [Design documentation](https://wise.design/components/list-item#prompt) for details.
|
|
17
|
+
*/
|
|
18
|
+
export const Prompt = ({ sentiment = Sentiment.NEUTRAL, children }: ListItemPromptProps) => {
|
|
19
|
+
const { ids } = useContext<ListItemContextData>(ListItemContext);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div id={ids.prompt} className={clsx('wds-list-item-prompt', sentiment)}>
|
|
23
|
+
<div className="np-prompt-icon">
|
|
24
|
+
<StatusIcon size={16} sentiment={sentiment} />
|
|
25
|
+
</div>
|
|
26
|
+
<Body>{children}</Body>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Prompt.displayName = 'ListItem.Prompt';
|
|
32
|
+
export default Prompt;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ListItem } from '../ListItem';
|
|
4
|
+
import {
|
|
5
|
+
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
6
|
+
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
7
|
+
} from '../_stories/subcomponents';
|
|
8
|
+
import type { ListItemRadioProps } from './ListItemRadio';
|
|
9
|
+
import { fn } from 'storybook/test';
|
|
10
|
+
import { ProfileType } from '../../common';
|
|
11
|
+
|
|
12
|
+
const meta: Meta<ListItemRadioProps> = {
|
|
13
|
+
component: ListItem.Radio,
|
|
14
|
+
title: 'Content/ListItem/ListItem.Radio',
|
|
15
|
+
parameters: {
|
|
16
|
+
docs: {
|
|
17
|
+
toc: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
args: {
|
|
21
|
+
name: 'radio-group',
|
|
22
|
+
value: 'option1',
|
|
23
|
+
checked: false,
|
|
24
|
+
onChange: fn(),
|
|
25
|
+
},
|
|
26
|
+
} satisfies Meta<ListItemRadioProps>;
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
|
|
30
|
+
type Story = StoryObj<ListItemRadioProps>;
|
|
31
|
+
|
|
32
|
+
export const Playground: Story = {
|
|
33
|
+
tags: ['!autodocs'],
|
|
34
|
+
render: (args: ListItemRadioProps) => {
|
|
35
|
+
return (
|
|
36
|
+
<ListItem
|
|
37
|
+
title="List item with radio"
|
|
38
|
+
subtitle="Select this option"
|
|
39
|
+
media={MEDIA.avatarSingle}
|
|
40
|
+
control={<ListItem.Radio {...args} />}
|
|
41
|
+
additionalInfo={INFO.nonInteractive}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Radio controls follow the native HTML behaviour and can be grouped using the `name` prop.
|
|
49
|
+
*/
|
|
50
|
+
export const RadioGroup: Story = {
|
|
51
|
+
render: function Render() {
|
|
52
|
+
const [selectedValue, setSelectedValue] = useState('2');
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ol className="list-unstyled">
|
|
56
|
+
<ListItem
|
|
57
|
+
control={
|
|
58
|
+
<ListItem.Radio
|
|
59
|
+
name="group"
|
|
60
|
+
value="1"
|
|
61
|
+
checked={selectedValue === '1'}
|
|
62
|
+
onChange={setSelectedValue}
|
|
63
|
+
/>
|
|
64
|
+
}
|
|
65
|
+
title="First option"
|
|
66
|
+
subtitle="This is the first choice"
|
|
67
|
+
media={<ListItem.AvatarView profileType={ProfileType.BUSINESS} />}
|
|
68
|
+
/>
|
|
69
|
+
<ListItem
|
|
70
|
+
control={
|
|
71
|
+
<ListItem.Radio
|
|
72
|
+
name="group"
|
|
73
|
+
value="2"
|
|
74
|
+
checked={selectedValue === '2'}
|
|
75
|
+
onChange={setSelectedValue}
|
|
76
|
+
/>
|
|
77
|
+
}
|
|
78
|
+
title="Second option"
|
|
79
|
+
subtitle="This is the second choice"
|
|
80
|
+
media={<ListItem.AvatarView profileType={ProfileType.BUSINESS} />}
|
|
81
|
+
/>
|
|
82
|
+
<ListItem
|
|
83
|
+
control={
|
|
84
|
+
<ListItem.Radio
|
|
85
|
+
name="group"
|
|
86
|
+
value="3"
|
|
87
|
+
checked={selectedValue === '3'}
|
|
88
|
+
onChange={setSelectedValue}
|
|
89
|
+
/>
|
|
90
|
+
}
|
|
91
|
+
title="Third option"
|
|
92
|
+
subtitle="This is the third choice"
|
|
93
|
+
media={<ListItem.AvatarView profileType={ProfileType.BUSINESS} />}
|
|
94
|
+
/>
|
|
95
|
+
</ol>
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import RadioButton, { type RadioButtonProps } from '../../common/RadioButton/RadioButton';
|
|
3
|
+
import { useListItemControl } from '../useListItemControl';
|
|
4
|
+
import { ListItemContext } from '../ListItemContext';
|
|
5
|
+
|
|
6
|
+
export type ListItemRadioProps = Omit<
|
|
7
|
+
RadioButtonProps,
|
|
8
|
+
'disabled' | 'readOnly' | 'className' | 'id'
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This component allows for rendering a Button control. It's a thin wrapper around the
|
|
13
|
+
* [Button component](https://storybook.wise.design/?path=/docs/content-button--docs), but offers only
|
|
14
|
+
* a subset of its features in line with the ListItem's constraints. <br />
|
|
15
|
+
* <br />
|
|
16
|
+
* Please refer to the [Design documentation](https://wise.design/components/list-item---button) for details.
|
|
17
|
+
*/
|
|
18
|
+
export const Radio = function (props: ListItemRadioProps) {
|
|
19
|
+
const { baseItemProps } = useListItemControl('radio', { ...props });
|
|
20
|
+
const { ids, describedByIds } = useContext(ListItemContext);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<RadioButton
|
|
24
|
+
{...props}
|
|
25
|
+
aria-describedby={describedByIds}
|
|
26
|
+
className="wds-list-item-control"
|
|
27
|
+
disabled={baseItemProps.disabled}
|
|
28
|
+
id={ids.control}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
Radio.displayName = 'ListItem.Radio';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ListItem } from '../ListItem';
|
|
4
|
+
import {
|
|
5
|
+
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
6
|
+
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
7
|
+
} from '../_stories/subcomponents';
|
|
8
|
+
import type { ListItemSwitchProps } from './ListItemSwitch';
|
|
9
|
+
import { fn } from 'storybook/test';
|
|
10
|
+
import { lorem10, lorem5 } from '../../test-utils';
|
|
11
|
+
|
|
12
|
+
const meta: Meta<ListItemSwitchProps> = {
|
|
13
|
+
component: ListItem.Switch,
|
|
14
|
+
title: 'Content/ListItem/ListItem.Switch',
|
|
15
|
+
parameters: {
|
|
16
|
+
docs: {
|
|
17
|
+
toc: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
args: {
|
|
21
|
+
checked: false,
|
|
22
|
+
onClick: fn(),
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
checked: {
|
|
26
|
+
control: 'boolean',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<ListItemSwitchProps>;
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<ListItemSwitchProps>;
|
|
34
|
+
|
|
35
|
+
export const Playground: Story = {
|
|
36
|
+
tags: ['!autodocs'],
|
|
37
|
+
render: (args: ListItemSwitchProps) => {
|
|
38
|
+
return (
|
|
39
|
+
<ListItem
|
|
40
|
+
title="List item with switch"
|
|
41
|
+
subtitle="Toggle this setting"
|
|
42
|
+
media={MEDIA.avatarSingle}
|
|
43
|
+
control={<ListItem.Switch {...args} />}
|
|
44
|
+
additionalInfo={INFO.nonInteractive}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const States: Story = {
|
|
51
|
+
render: (args) => {
|
|
52
|
+
return (
|
|
53
|
+
<ol className="list-unstyled">
|
|
54
|
+
<ListItem
|
|
55
|
+
title={lorem5}
|
|
56
|
+
subtitle={lorem10}
|
|
57
|
+
media={MEDIA.avatarSingle}
|
|
58
|
+
control={<ListItem.Switch {...args} checked />}
|
|
59
|
+
/>
|
|
60
|
+
<ListItem
|
|
61
|
+
key={lorem5}
|
|
62
|
+
title={lorem10}
|
|
63
|
+
media={MEDIA.avatarSingle}
|
|
64
|
+
control={<ListItem.Switch {...args} />}
|
|
65
|
+
/>
|
|
66
|
+
</ol>
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import SwitchComp, { type SwitchProps } from '../../switch';
|
|
3
|
+
import { useListItemControl } from '../useListItemControl';
|
|
4
|
+
import { ListItemContext } from '../ListItemContext';
|
|
5
|
+
|
|
6
|
+
export type ListItemSwitchProps = Omit<
|
|
7
|
+
SwitchProps,
|
|
8
|
+
'disabled' | 'id' | 'aria-labelledby' | 'aria-label'
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This component allows for rendering a switch control within a fully interactive ListItem. <br />It's a thin wrapper around the
|
|
13
|
+
* [CheckboxButton component](https://storybook.wise.design/?path=/docs/actions-switch--docs),
|
|
14
|
+
* but offers only a subset of its features in line with the ListItem's constraints. <br />
|
|
15
|
+
*
|
|
16
|
+
* Please refer to the [Design documentation](https://wise.design/components/list-item---switch) for details.
|
|
17
|
+
*/
|
|
18
|
+
export const Switch = function (props: ListItemSwitchProps) {
|
|
19
|
+
const { baseItemProps } = useListItemControl('switch', { ...props });
|
|
20
|
+
const { ids, describedByIds } = useContext(ListItemContext);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<SwitchComp
|
|
24
|
+
{...props}
|
|
25
|
+
aria-describedby={describedByIds}
|
|
26
|
+
className="wds-list-item-control"
|
|
27
|
+
disabled={baseItemProps.disabled}
|
|
28
|
+
id={ids.control}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
Switch.displayName = 'ListItem.Switch';
|