@transferwise/components 0.0.0-experimental-5f7dae1 → 0.0.0-experimental-20085a3
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/types/Body/Body.d.ts +2 -2
- package/build/types/IconButton/IconButton.d.ts +1 -1
- package/build/types/ListItem/_stories/variants/helpers.d.ts.map +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/Title/Title.d.ts +2 -2
- package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
- package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
- package/package.json +1 -1
- package/src/Accordion/_stories/Accordion.rtl.test.story.tsx +71 -0
- package/src/AvatarLayout/_stories/AvatarLayout.rtl.test.story.tsx +77 -0
- package/src/AvatarView/_stories/AvatarView.rtl.test.story.tsx +162 -0
- package/src/Button/LegacyButton/_stories/LegacyButton.rtl.test.story.tsx +32 -0
- package/src/Calendar/_stories/Calendar.rtl.test.story.tsx +52 -0
- package/src/Calendar/_stories/Calendar.test.story.tsx +28 -24
- package/src/Carousel/_stories/Carousel.rtl.test.story.tsx +61 -0
- package/src/Checkbox/_stories/Checkbox.rtl.test.story.tsx +31 -0
- package/src/CheckboxButton/_stories/CheckboxButton.rtl.test.story.tsx +27 -0
- package/src/CheckboxButton/_stories/CheckboxButton.test.story.tsx +0 -37
- package/src/Chevron/_stories/Chevron.rtl.test.story.tsx +26 -0
- package/src/Chips/_stories/Chips.rtl.test.story.tsx +49 -0
- package/src/Chips/_stories/Chips.test.story.tsx +0 -34
- package/src/CircularButton/_stories/CircularButton.test.story.tsx +0 -68
- package/src/DateInput/_stories/DateInput.rtl.test.story.tsx +25 -0
- package/src/DateLookup/_stories/DateLookup.rtl.test.story.tsx +88 -0
- package/src/Decision/_stories/Decision.rtl.test.story.tsx +79 -0
- package/src/DefinitionList/_stories/DefinitionList.rtl.test.story.tsx +63 -0
- package/src/Drawer/_stories/Drawer.rtl.test.story.tsx +58 -0
- package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.rtl.test.story.tsx +118 -0
- package/src/Field/_stories/Field.rtl.test.story.tsx +58 -0
- package/src/FlowNavigation/_stories/FlowNavigation.rtl.test.story.tsx +70 -0
- package/src/Header/_stories/Header.rtl.test.story.tsx +37 -0
- package/src/Info/_stories/Info.rtl.test.story.tsx +64 -0
- package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +135 -0
- package/src/Inputs/_stories/InputGroup.rtl.test.story.tsx +69 -0
- package/src/Inputs/_stories/SearchInput.rtl.test.story.tsx +32 -0
- package/src/Inputs/_stories/TextArea.rtl.test.story.tsx +38 -0
- package/src/InstructionsList/_stories/InstructionsList.rtl.test.story.tsx +30 -0
- package/src/Label/_stories/Label.rtl.test.story.tsx +36 -0
- package/src/Link/_stories/Link.rtl.test.story.tsx +26 -0
- package/src/ListItem/_stories/{variants/ListItem.rtl.test.story.tsx → ListItem.rtl.test.story.tsx} +6 -10
- package/src/ListItem/_stories/variants/helpers.tsx +2 -6
- package/src/Logo/_stories/Logo.rtl.test.story.tsx +56 -0
- package/src/Modal/_stories/Modal.rtl.test.story.tsx +59 -0
- package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +88 -0
- package/src/Nudge/_stories/Nudge.rtl.test.story.tsx +37 -0
- package/src/PhoneNumberInput/_stories/PhoneNumberInput.rtl.test.story.tsx +44 -0
- package/src/Popover/_stories/Popover.rtl.test.story.tsx +96 -0
- package/src/Progress/_stories/Progress.rtl.test.story.tsx +27 -0
- package/src/ProgressBar/_stories/ProgressBar.rtl.test.story.tsx +33 -0
- package/src/PromoCard/_stories/PromoCard.rtl.test.story.tsx +42 -0
- package/src/PromoCard/_stories/PromoCardGroup.rtl.test.story.tsx +51 -0
- package/src/Prompt/ActionPrompt/_stories/ActionPrompt.rtl.test.story.tsx +53 -0
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.rtl.test.story.tsx +46 -0
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.test.story.tsx +0 -30
- package/src/Prompt/InfoPrompt/_stories/InfoPrompt.rtl.test.story.tsx +36 -0
- package/src/Prompt/InlinePrompt/_stories/InlinePrompt.rtl.test.story.tsx +38 -0
- package/src/Radio/_stories/Radio.rtl.test.story.tsx +61 -0
- package/src/RadioGroup/_stories/RadioGroup.rtl.test.story.tsx +66 -0
- package/src/Section/_stories/Section.rtl.test.story.tsx +29 -0
- package/src/SegmentedControl/_stories/SegmentedControl.rtl.test.story.tsx +45 -0
- package/src/SlidingPanel/_stories/SlidingPanel.rtl.test.story.tsx +70 -0
- package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +45 -0
- package/src/Snackbar/_stories/Snackbar.test.story.tsx +0 -31
- package/src/Stepper/_stories/Stepper.rtl.test.story.tsx +24 -0
- package/src/Switch/_stories/Switch.rtl.test.story.tsx +32 -0
- package/src/Switch/_stories/Switch.test.story.tsx +0 -26
- package/src/Table/_stories/Table.rtl.test.story.tsx +104 -0
- package/src/Tabs/_stories/Tabs.rtl.test.story.tsx +72 -0
- package/src/TextareaWithDisplayFormat/_stories/TextareaWithDisplayFormat.rtl.test.story.tsx +48 -0
- package/src/Tooltip/_stories/Tooltip.rtl.test.story.tsx +79 -0
- package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +90 -0
- package/src/Upload/_stories/Upload.rtl.test.story.tsx +53 -0
- package/src/UploadInput/_stories/UploadInput.rtl.test.story.tsx +59 -0
- package/src/_deprecated/Alert/_stories/Alert.rtl.test.story.tsx +37 -0
- package/src/_deprecated/Card/_stories/Card.rtl.test.story.tsx +38 -0
- package/src/_deprecated/CriticalBanner/_stories/CriticalCommsBanner.rtl.test.story.tsx +28 -0
- package/src/_deprecated/InlineAlert/_stories/InlineAlert.rtl.test.story.tsx +26 -0
- package/src/_deprecated/OverlayHeader/_stories/OverlayHeader.rtl.test.story.tsx +42 -0
- package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +71 -0
- package/src/common/BottomSheet/_stories/BottomSheet.rtl.test.story.tsx +39 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn, userEvent, within } from 'storybook/test';
|
|
3
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import ExpressiveMoneyInput from '..';
|
|
5
|
+
import { Rewards } from '@transferwise/icons';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
component: ExpressiveMoneyInput,
|
|
9
|
+
title: 'Forms/ExpressiveMoneyInput/Tests/RTL Diff',
|
|
10
|
+
tags: ['!autodocs', '!manifest'],
|
|
11
|
+
} satisfies Meta<typeof ExpressiveMoneyInput>;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof ExpressiveMoneyInput>;
|
|
14
|
+
|
|
15
|
+
const currencySelectorOptions = [
|
|
16
|
+
{
|
|
17
|
+
title: 'Popular',
|
|
18
|
+
currencies: [
|
|
19
|
+
{ code: 'GBP', label: 'British Pound', keywords: ['british'] },
|
|
20
|
+
{ code: 'EUR', label: 'Euro', keywords: ['euro'] },
|
|
21
|
+
{ code: 'USD', label: 'US Dollar', keywords: ['dollar'] },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export const TriggerVariants: Story = {
|
|
27
|
+
render: () => (
|
|
28
|
+
<>
|
|
29
|
+
{/* Currency selector on leading side — flips in RTL */}
|
|
30
|
+
<ExpressiveMoneyInput
|
|
31
|
+
label="You send"
|
|
32
|
+
currency="GBP"
|
|
33
|
+
amount={1234.56}
|
|
34
|
+
currencySelector={{
|
|
35
|
+
options: currencySelectorOptions,
|
|
36
|
+
onChange: fn(),
|
|
37
|
+
onSearchChange: fn(),
|
|
38
|
+
onOpen: fn(),
|
|
39
|
+
}}
|
|
40
|
+
onAmountChange={fn()}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
{/* Chevron on trailing side — flips in RTL */}
|
|
44
|
+
<ExpressiveMoneyInput
|
|
45
|
+
label="You send"
|
|
46
|
+
currency="EUR"
|
|
47
|
+
amount={0}
|
|
48
|
+
showChevron
|
|
49
|
+
currencySelector={{
|
|
50
|
+
options: currencySelectorOptions,
|
|
51
|
+
onChange: fn(),
|
|
52
|
+
onSearchChange: fn(),
|
|
53
|
+
onOpen: fn(),
|
|
54
|
+
}}
|
|
55
|
+
onAmountChange={fn()}
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
{/* InlinePrompt with media icon — icon on leading end of prompt */}
|
|
59
|
+
<ExpressiveMoneyInput
|
|
60
|
+
label="You send"
|
|
61
|
+
currency="USD"
|
|
62
|
+
amount={500}
|
|
63
|
+
currencySelector={{
|
|
64
|
+
options: currencySelectorOptions,
|
|
65
|
+
onChange: fn(),
|
|
66
|
+
onSearchChange: fn(),
|
|
67
|
+
onOpen: fn(),
|
|
68
|
+
}}
|
|
69
|
+
inlinePrompt={{
|
|
70
|
+
message: 'Great rate available',
|
|
71
|
+
sentiment: 'positive',
|
|
72
|
+
media: <Rewards />,
|
|
73
|
+
}}
|
|
74
|
+
onAmountChange={fn()}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
{/* Secondary avatar addon in currency selector */}
|
|
78
|
+
<ExpressiveMoneyInput
|
|
79
|
+
label="You send"
|
|
80
|
+
currency="GBP"
|
|
81
|
+
amount={750}
|
|
82
|
+
currencySelector={{
|
|
83
|
+
options: currencySelectorOptions,
|
|
84
|
+
addons: [{ profileName: 'Mikkael Jordan' }],
|
|
85
|
+
onChange: fn(),
|
|
86
|
+
onSearchChange: fn(),
|
|
87
|
+
onOpen: fn(),
|
|
88
|
+
}}
|
|
89
|
+
onAmountChange={fn()}
|
|
90
|
+
/>
|
|
91
|
+
</>
|
|
92
|
+
),
|
|
93
|
+
...withRTLDiff({ width: 'stretch' }),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const OpenDropdown: Story = {
|
|
97
|
+
render: () => (
|
|
98
|
+
<ExpressiveMoneyInput
|
|
99
|
+
label="You send"
|
|
100
|
+
currency="GBP"
|
|
101
|
+
amount={1234.56}
|
|
102
|
+
currencySelector={{
|
|
103
|
+
options: currencySelectorOptions,
|
|
104
|
+
onChange: fn(),
|
|
105
|
+
onSearchChange: fn(),
|
|
106
|
+
onOpen: fn(),
|
|
107
|
+
}}
|
|
108
|
+
onAmountChange={fn()}
|
|
109
|
+
/>
|
|
110
|
+
),
|
|
111
|
+
play: async ({ canvasElement }) => {
|
|
112
|
+
const canvas = within(canvasElement);
|
|
113
|
+
const trigger = canvas.queryByRole('combobox');
|
|
114
|
+
if (!trigger) return;
|
|
115
|
+
await userEvent.click(trigger);
|
|
116
|
+
},
|
|
117
|
+
...withRTLDiff({ renderAs: 'iframe', width: '80%' }),
|
|
118
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
|
|
3
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import { Input } from '../../Inputs/Input/Input';
|
|
5
|
+
import { TextArea } from '../../Inputs/TextArea/TextArea';
|
|
6
|
+
import { lorem10 } from '../../test-utils';
|
|
7
|
+
import Field from '..';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: Field,
|
|
11
|
+
title: 'Forms/Field/Tests',
|
|
12
|
+
tags: ['!autodocs', '!manifest'],
|
|
13
|
+
} satisfies Meta<typeof Field>;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof Field>;
|
|
16
|
+
|
|
17
|
+
export const RTLDiff: Story = {
|
|
18
|
+
render: () => (
|
|
19
|
+
<>
|
|
20
|
+
{/* Required label (default) — label text aligns to start */}
|
|
21
|
+
<Field label="Required field">
|
|
22
|
+
<Input defaultValue="Input value" />
|
|
23
|
+
</Field>
|
|
24
|
+
|
|
25
|
+
{/* Optional label — "(optional)" suffix uses directional margin-left */}
|
|
26
|
+
<Field label="Optional field" required={false}>
|
|
27
|
+
<Input defaultValue="Input value" />
|
|
28
|
+
</Field>
|
|
29
|
+
|
|
30
|
+
{/* Label + description + message — full vertical layout with directional icon */}
|
|
31
|
+
<Field
|
|
32
|
+
label="Field with description and message"
|
|
33
|
+
required={false}
|
|
34
|
+
description={lorem10}
|
|
35
|
+
message="This is a validation message"
|
|
36
|
+
sentiment="negative"
|
|
37
|
+
>
|
|
38
|
+
<Input defaultValue="Input value" />
|
|
39
|
+
</Field>
|
|
40
|
+
|
|
41
|
+
{/* Message only (no label) — InlinePrompt icon+text layout visible */}
|
|
42
|
+
<Field message="A helpful message" sentiment="positive">
|
|
43
|
+
<Input defaultValue="Input value" />
|
|
44
|
+
</Field>
|
|
45
|
+
|
|
46
|
+
{/* Loading message — spinner replaces icon but layout structure is identical */}
|
|
47
|
+
<Field label="Field with loading message" message="Saving…" messageLoading>
|
|
48
|
+
<Input defaultValue="Input value" />
|
|
49
|
+
</Field>
|
|
50
|
+
|
|
51
|
+
{/* Textarea with char counter — counter uses text-align:right + margin-left:auto */}
|
|
52
|
+
<Field label="Textarea with char counter" required={false} description="Max 100 characters">
|
|
53
|
+
<TextArea maxLength={100} defaultValue="Textarea value" />
|
|
54
|
+
</Field>
|
|
55
|
+
</>
|
|
56
|
+
),
|
|
57
|
+
...withRTLDiff(),
|
|
58
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
|
|
3
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import AvatarView from '../../AvatarView';
|
|
5
|
+
import { ProfileType } from '../../common';
|
|
6
|
+
import Logo from '../../Logo';
|
|
7
|
+
import FlowNavigation from '..';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: FlowNavigation,
|
|
11
|
+
title: 'Navigation/FlowNavigation/Tests',
|
|
12
|
+
tags: ['!autodocs', '!manifest'],
|
|
13
|
+
} satisfies Meta<typeof FlowNavigation>;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof FlowNavigation>;
|
|
16
|
+
|
|
17
|
+
const noop = () => {};
|
|
18
|
+
|
|
19
|
+
const steps = [
|
|
20
|
+
{ label: 'Amount', hoverLabel: '100 GBP', onClick: noop },
|
|
21
|
+
{ label: 'You', hoverLabel: 'Elena Durante', onClick: noop },
|
|
22
|
+
{ label: 'Review', onClick: noop },
|
|
23
|
+
{ label: 'Pay', onClick: noop },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* FlowNavigation has directional layout: back button on inline-start,
|
|
28
|
+
* close button and avatar on inline-end, and a stepper progress bar that
|
|
29
|
+
* flows in the reading direction. All of these flip in RTL.
|
|
30
|
+
*/
|
|
31
|
+
export const RTLDiff: Story = {
|
|
32
|
+
render: () => (
|
|
33
|
+
<>
|
|
34
|
+
{/* With stepper, back button, close button, and avatar */}
|
|
35
|
+
<FlowNavigation
|
|
36
|
+
activeStep={2}
|
|
37
|
+
avatar={<AvatarView profileType={ProfileType.PERSONAL} />}
|
|
38
|
+
logo={<Logo />}
|
|
39
|
+
steps={steps}
|
|
40
|
+
onClose={noop}
|
|
41
|
+
onGoBack={noop}
|
|
42
|
+
/>
|
|
43
|
+
{/* Without stepper — logo left, close button right */}
|
|
44
|
+
<FlowNavigation
|
|
45
|
+
avatar={<AvatarView profileType={ProfileType.PERSONAL} />}
|
|
46
|
+
logo={<Logo />}
|
|
47
|
+
onClose={noop}
|
|
48
|
+
/>
|
|
49
|
+
{/* Composable variant with stepper */}
|
|
50
|
+
<FlowNavigation
|
|
51
|
+
composable
|
|
52
|
+
activeStep={1}
|
|
53
|
+
avatar={<AvatarView profileType={ProfileType.PERSONAL} />}
|
|
54
|
+
logo={<Logo />}
|
|
55
|
+
steps={steps}
|
|
56
|
+
onClose={noop}
|
|
57
|
+
onGoBack={noop}
|
|
58
|
+
/>
|
|
59
|
+
{/* Done state — no stepper, logo and close button only */}
|
|
60
|
+
<FlowNavigation
|
|
61
|
+
done
|
|
62
|
+
avatar={<AvatarView profileType={ProfileType.PERSONAL} />}
|
|
63
|
+
logo={<Logo />}
|
|
64
|
+
steps={steps}
|
|
65
|
+
onClose={noop}
|
|
66
|
+
/>
|
|
67
|
+
</>
|
|
68
|
+
),
|
|
69
|
+
...withRTLDiff(),
|
|
70
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
3
|
+
import Header from '..';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
component: Header,
|
|
7
|
+
title: 'Typography/Header/Tests',
|
|
8
|
+
tags: ['!autodocs', '!manifest'],
|
|
9
|
+
} satisfies Meta<typeof Header>;
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof Header>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The Header uses a CSS grid layout (1fr auto) that places the action on the
|
|
15
|
+
* inline-end side. In RTL the action should appear on the left instead of the
|
|
16
|
+
* right. Both level variants are included to cover the border-bottom alignment
|
|
17
|
+
* difference.
|
|
18
|
+
*/
|
|
19
|
+
export const RTLDiff: Story = {
|
|
20
|
+
render: () => (
|
|
21
|
+
<>
|
|
22
|
+
<Header title="Group level without action" level="group" />
|
|
23
|
+
<Header
|
|
24
|
+
title="Group level with action"
|
|
25
|
+
level="group"
|
|
26
|
+
action={{ 'aria-label': 'View all', text: 'View all', href: '#' }}
|
|
27
|
+
/>
|
|
28
|
+
<Header title="Section level without action" level="section" />
|
|
29
|
+
<Header
|
|
30
|
+
title="Section level with action"
|
|
31
|
+
level="section"
|
|
32
|
+
action={{ 'aria-label': 'Learn more', text: 'Learn more', href: '#' }}
|
|
33
|
+
/>
|
|
34
|
+
</>
|
|
35
|
+
),
|
|
36
|
+
...withRTLDiff(),
|
|
37
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { userEvent, within } from 'storybook/test';
|
|
3
|
+
|
|
4
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
5
|
+
import Info from '..';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
component: Info,
|
|
9
|
+
title: 'Dialogs/Info/Tests/RTL Diff',
|
|
10
|
+
tags: ['!autodocs', '!manifest'],
|
|
11
|
+
} satisfies Meta<typeof Info>;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof Info>;
|
|
14
|
+
|
|
15
|
+
const iframeDiff = withRTLDiff({ renderAs: 'iframe' });
|
|
16
|
+
|
|
17
|
+
const openInfo = async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
18
|
+
const canvas = within(canvasElement);
|
|
19
|
+
const button = canvas.queryByRole('button');
|
|
20
|
+
if (!button) return;
|
|
21
|
+
await userEvent.click(button);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Popover: Story = {
|
|
25
|
+
render: () => (
|
|
26
|
+
<Info
|
|
27
|
+
aria-label="Info trigger"
|
|
28
|
+
title="Information"
|
|
29
|
+
content="This is some descriptive content inside the info component."
|
|
30
|
+
presentation="POPOVER"
|
|
31
|
+
size="sm"
|
|
32
|
+
/>
|
|
33
|
+
),
|
|
34
|
+
play: openInfo,
|
|
35
|
+
...iframeDiff,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const PopoverLarge: Story = {
|
|
39
|
+
render: () => (
|
|
40
|
+
<Info
|
|
41
|
+
aria-label="Info trigger"
|
|
42
|
+
title="Information"
|
|
43
|
+
content="This is some descriptive content inside the info component."
|
|
44
|
+
presentation="POPOVER"
|
|
45
|
+
size="lg"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
play: openInfo,
|
|
49
|
+
...iframeDiff,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Modal: Story = {
|
|
53
|
+
render: () => (
|
|
54
|
+
<Info
|
|
55
|
+
aria-label="Info trigger"
|
|
56
|
+
title="Information"
|
|
57
|
+
content="This is some descriptive content inside the info component."
|
|
58
|
+
presentation="MODAL"
|
|
59
|
+
size="sm"
|
|
60
|
+
/>
|
|
61
|
+
),
|
|
62
|
+
play: openInfo,
|
|
63
|
+
...iframeDiff,
|
|
64
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { userEvent, within } from 'storybook/test';
|
|
3
|
+
import { Flag } from '@wise/art';
|
|
4
|
+
|
|
5
|
+
import { withRTLDiff } from '../../../../.storybook/decorators/RtlDiffDecorator';
|
|
6
|
+
import { SelectInput, SelectInputOptionContent } from '..';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
component: SelectInput,
|
|
10
|
+
title: 'Forms/SelectInput/Tests/RTL Diff',
|
|
11
|
+
tags: ['!autodocs', '!manifest'],
|
|
12
|
+
} satisfies Meta<typeof SelectInput>;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof SelectInput>;
|
|
15
|
+
|
|
16
|
+
interface RtlCurrency {
|
|
17
|
+
code: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const rtlCurrencies: RtlCurrency[] = [
|
|
22
|
+
{ code: 'USD', name: 'United States Dollar' },
|
|
23
|
+
{ code: 'EUR', name: 'Euro' },
|
|
24
|
+
{ code: 'GBP', name: 'British pound' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export const TriggerVariants: Story = {
|
|
28
|
+
render: () => (
|
|
29
|
+
<>
|
|
30
|
+
{/* sm — chevron position flips in RTL */}
|
|
31
|
+
<SelectInput
|
|
32
|
+
size="sm"
|
|
33
|
+
placeholder="Select currency"
|
|
34
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
35
|
+
renderValue={(currency) => <SelectInputOptionContent title={currency.code} />}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
{/* md — chevron position flips in RTL */}
|
|
39
|
+
<SelectInput
|
|
40
|
+
size="md"
|
|
41
|
+
placeholder="Select currency"
|
|
42
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
43
|
+
renderValue={(currency) => <SelectInputOptionContent title={currency.code} />}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
{/* lg with value and leading icon — icon side and chevron flip in RTL */}
|
|
47
|
+
<SelectInput
|
|
48
|
+
size="lg"
|
|
49
|
+
placeholder="Select currency"
|
|
50
|
+
defaultValue={rtlCurrencies[0]}
|
|
51
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
52
|
+
renderValue={(currency) => (
|
|
53
|
+
<SelectInputOptionContent
|
|
54
|
+
title={currency.code}
|
|
55
|
+
note={currency.name}
|
|
56
|
+
icon={<Flag code={currency.code} intrinsicSize={24} />}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
{/* multiple — selected values on leading side, chevron on trailing side, both flip in RTL */}
|
|
62
|
+
<SelectInput
|
|
63
|
+
size="lg"
|
|
64
|
+
multiple
|
|
65
|
+
placeholder="Choose currencies"
|
|
66
|
+
defaultValue={[rtlCurrencies[0], rtlCurrencies[1]]}
|
|
67
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
68
|
+
renderValue={(currency, withinTrigger) =>
|
|
69
|
+
withinTrigger ? (
|
|
70
|
+
currency.code
|
|
71
|
+
) : (
|
|
72
|
+
<SelectInputOptionContent title={currency.code} note={currency.name} />
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
/>
|
|
76
|
+
</>
|
|
77
|
+
),
|
|
78
|
+
...withRTLDiff(),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const otherCurrencies: RtlCurrency[] = [
|
|
82
|
+
{ code: 'CAD', name: 'Canadian dollar' },
|
|
83
|
+
{ code: 'AUD', name: 'Australian dollar' },
|
|
84
|
+
{ code: 'JPY', name: 'Japanese yen' },
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
const groupedItems = [
|
|
88
|
+
{
|
|
89
|
+
type: 'group' as const,
|
|
90
|
+
label: 'Popular currencies',
|
|
91
|
+
options: rtlCurrencies.map((currency) => ({
|
|
92
|
+
type: 'option' as const,
|
|
93
|
+
value: currency,
|
|
94
|
+
filterMatchers: [currency.code, currency.name],
|
|
95
|
+
})),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: 'group' as const,
|
|
99
|
+
label: 'All currencies',
|
|
100
|
+
options: [...rtlCurrencies, ...otherCurrencies]
|
|
101
|
+
.sort((a, b) => a.code.localeCompare(b.code))
|
|
102
|
+
.map((currency) => ({
|
|
103
|
+
type: 'option' as const,
|
|
104
|
+
value: currency,
|
|
105
|
+
filterMatchers: [currency.code, currency.name],
|
|
106
|
+
})),
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
export const OpenDropdown: Story = {
|
|
111
|
+
render: () => (
|
|
112
|
+
<SelectInput
|
|
113
|
+
size="lg"
|
|
114
|
+
filterable
|
|
115
|
+
filterPlaceholder="Type a currency / country"
|
|
116
|
+
placeholder="Select currency"
|
|
117
|
+
defaultValue={rtlCurrencies[0]}
|
|
118
|
+
items={groupedItems}
|
|
119
|
+
renderValue={(currency, withinTrigger) => (
|
|
120
|
+
<SelectInputOptionContent
|
|
121
|
+
title={currency.code}
|
|
122
|
+
note={withinTrigger ? undefined : currency.name}
|
|
123
|
+
icon={<Flag code={currency.code} intrinsicSize={24} />}
|
|
124
|
+
/>
|
|
125
|
+
)}
|
|
126
|
+
/>
|
|
127
|
+
),
|
|
128
|
+
play: async ({ canvasElement }) => {
|
|
129
|
+
const canvas = within(canvasElement);
|
|
130
|
+
const trigger = canvas.queryByRole('combobox');
|
|
131
|
+
if (!trigger) return;
|
|
132
|
+
await userEvent.click(trigger);
|
|
133
|
+
},
|
|
134
|
+
...withRTLDiff({ renderAs: 'iframe', width: '80%' }),
|
|
135
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { Search } from '@transferwise/icons';
|
|
3
|
+
|
|
4
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
5
|
+
import Button from '../../Button';
|
|
6
|
+
import { Input } from '../Input/Input';
|
|
7
|
+
import { InputGroup } from '../InputGroup/InputGroup';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: InputGroup,
|
|
11
|
+
title: 'Forms/InputGroup/Tests',
|
|
12
|
+
tags: ['!autodocs', '!manifest'],
|
|
13
|
+
} satisfies Meta<typeof InputGroup>;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof InputGroup>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* InputGroup positions addons at the logical start or end of an input.
|
|
19
|
+
* In RTL mode the start and end sides are mirrored, so an addonStart icon
|
|
20
|
+
* should appear on the right and an addonEnd button should appear on the left.
|
|
21
|
+
* All three placement combinations are included to verify each case.
|
|
22
|
+
*/
|
|
23
|
+
export const RTLDiff: Story = {
|
|
24
|
+
render: () => (
|
|
25
|
+
<>
|
|
26
|
+
<InputGroup
|
|
27
|
+
addonStart={{
|
|
28
|
+
content: <Search size={24} />,
|
|
29
|
+
initialContentWidth: 24,
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<Input placeholder="addonStart only" />
|
|
33
|
+
</InputGroup>
|
|
34
|
+
|
|
35
|
+
<InputGroup
|
|
36
|
+
addonEnd={{
|
|
37
|
+
content: (
|
|
38
|
+
<Button v2 size="sm">
|
|
39
|
+
Copy
|
|
40
|
+
</Button>
|
|
41
|
+
),
|
|
42
|
+
interactive: true,
|
|
43
|
+
padding: 'sm',
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<Input placeholder="addonEnd only" />
|
|
47
|
+
</InputGroup>
|
|
48
|
+
|
|
49
|
+
<InputGroup
|
|
50
|
+
addonStart={{
|
|
51
|
+
content: <Search size={24} />,
|
|
52
|
+
initialContentWidth: 24,
|
|
53
|
+
}}
|
|
54
|
+
addonEnd={{
|
|
55
|
+
content: (
|
|
56
|
+
<Button v2 size="sm">
|
|
57
|
+
Clear
|
|
58
|
+
</Button>
|
|
59
|
+
),
|
|
60
|
+
interactive: true,
|
|
61
|
+
padding: 'sm',
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<Input placeholder="addonStart and addonEnd" />
|
|
65
|
+
</InputGroup>
|
|
66
|
+
</>
|
|
67
|
+
),
|
|
68
|
+
...withRTLDiff(),
|
|
69
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
|
|
3
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import { Size } from '../../common';
|
|
5
|
+
import { SearchInput } from '../SearchInput/SearchInput';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
component: SearchInput,
|
|
9
|
+
title: 'Forms/SearchInput/Tests',
|
|
10
|
+
tags: ['!autodocs', '!manifest'],
|
|
11
|
+
} satisfies Meta<typeof SearchInput>;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof SearchInput>;
|
|
14
|
+
|
|
15
|
+
export const RTLDiff: Story = {
|
|
16
|
+
render: () => (
|
|
17
|
+
<>
|
|
18
|
+
{/* sm — search icon (addonStart) position flips to trailing side in RTL */}
|
|
19
|
+
<SearchInput size={Size.SMALL} shape="pill" placeholder="Search" />
|
|
20
|
+
|
|
21
|
+
{/* md — search icon (addonStart) position flips to trailing side in RTL */}
|
|
22
|
+
<SearchInput size={Size.MEDIUM} shape="pill" placeholder="Search" />
|
|
23
|
+
|
|
24
|
+
{/* sm rectangle — icon flip with rectangle shape */}
|
|
25
|
+
<SearchInput size={Size.SMALL} shape="rectangle" placeholder="Search" />
|
|
26
|
+
|
|
27
|
+
{/* md rectangle — icon flip with rectangle shape */}
|
|
28
|
+
<SearchInput size={Size.MEDIUM} shape="rectangle" placeholder="Search" />
|
|
29
|
+
</>
|
|
30
|
+
),
|
|
31
|
+
...withRTLDiff(),
|
|
32
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
3
|
+
import Field from '../../Field';
|
|
4
|
+
import { Sentiment } from '../../common';
|
|
5
|
+
import { TextArea } from '../TextArea/TextArea';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
component: TextArea,
|
|
9
|
+
title: 'Forms/TextArea/Tests',
|
|
10
|
+
tags: ['!autodocs', '!manifest'],
|
|
11
|
+
} satisfies Meta<typeof TextArea>;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof TextArea>;
|
|
14
|
+
|
|
15
|
+
export const RTLDiff: Story = {
|
|
16
|
+
render: () => (
|
|
17
|
+
<>
|
|
18
|
+
<Field label="Message" required={false}>
|
|
19
|
+
<TextArea placeholder="Type something..." />
|
|
20
|
+
</Field>
|
|
21
|
+
<Field label="Message" required={false}>
|
|
22
|
+
<TextArea value="This is some entered text content in the textarea field." readOnly />
|
|
23
|
+
</Field>
|
|
24
|
+
<Field
|
|
25
|
+
label="Message"
|
|
26
|
+
required={false}
|
|
27
|
+
sentiment={Sentiment.NEGATIVE}
|
|
28
|
+
message="This field has an error message"
|
|
29
|
+
>
|
|
30
|
+
<TextArea value="Invalid input text" readOnly />
|
|
31
|
+
</Field>
|
|
32
|
+
<Field label="Message with character count" required={false}>
|
|
33
|
+
<TextArea maxLength={200} value="Text with a character counter displayed below." readOnly />
|
|
34
|
+
</Field>
|
|
35
|
+
</>
|
|
36
|
+
),
|
|
37
|
+
...withRTLDiff(),
|
|
38
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
|
|
3
|
+
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import InstructionsList from '..';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
component: InstructionsList,
|
|
8
|
+
title: 'Typography/InstructionsList/Tests',
|
|
9
|
+
tags: ['!autodocs', '!manifest'],
|
|
10
|
+
} satisfies Meta<typeof InstructionsList>;
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof InstructionsList>;
|
|
13
|
+
|
|
14
|
+
export const RTLDiff: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<>
|
|
17
|
+
<InstructionsList
|
|
18
|
+
dos={['Do an initial money transfer', 'Invite at least 3 friends to join']}
|
|
19
|
+
donts={['Paying extra hidden fees for transfers', 'Use bad exchange rate']}
|
|
20
|
+
sort="dosFirst"
|
|
21
|
+
/>
|
|
22
|
+
<InstructionsList
|
|
23
|
+
dos={['Complete your profile verification']}
|
|
24
|
+
donts={['Share your login credentials with others']}
|
|
25
|
+
sort="dontsFirst"
|
|
26
|
+
/>
|
|
27
|
+
</>
|
|
28
|
+
),
|
|
29
|
+
...withRTLDiff(),
|
|
30
|
+
};
|