@transferwise/components 0.0.0-experimental-e94d625 → 0.0.0-experimental-8e1de95
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/Snackbar/Snackbar.js +97 -101
- package/build/Snackbar/Snackbar.js.map +1 -1
- package/build/Snackbar/Snackbar.mjs +98 -102
- package/build/Snackbar/Snackbar.mjs.map +1 -1
- package/build/types/Carousel/_stories/constants.d.ts +25 -0
- package/build/types/Carousel/_stories/constants.d.ts.map +1 -1
- package/build/types/ListItem/_stories/variants/helpers.d.ts +38 -1
- package/build/types/ListItem/_stories/variants/helpers.d.ts.map +1 -1
- package/build/types/Snackbar/Snackbar.d.ts +1 -15
- package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Accordion/_stories/Accordion.test.story.tsx +74 -48
- package/src/AvatarLayout/_stories/AvatarLayout.test.story.tsx +46 -30
- package/src/Button/LegacyButton/_stories/LegacyButton.test.story.tsx +29 -19
- package/src/Calendar/_stories/Calendar.test.story.tsx +34 -21
- package/src/Carousel/_stories/Carousel.test.story.tsx +18 -8
- package/src/Carousel/_stories/constants.tsx +29 -4
- package/src/Checkbox/_stories/Checkbox.test.story.tsx +22 -13
- package/src/CheckboxButton/_stories/CheckboxButton.test.story.tsx +23 -14
- package/src/Chips/_stories/Chips.test.story.tsx +51 -36
- package/src/DateInput/_stories/DateInput.rtl.test.story.tsx +62 -12
- package/src/Decision/_stories/Decision.test.story.tsx +74 -58
- package/src/DefinitionList/_stories/DefinitionList.test.story.tsx +58 -42
- package/src/Drawer/_stories/Drawer.rtl.test.story.tsx +65 -38
- package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.rtl.test.story.tsx +107 -74
- package/src/Field/_stories/Field.test.story.tsx +1 -1
- package/src/FlowNavigation/_stories/FlowNavigation.rtl.test.story.tsx +81 -51
- package/src/Header/_stories/Header.test.story.tsx +30 -18
- package/src/Info/_stories/Info.rtl.test.story.tsx +124 -50
- package/src/Inputs/InputGroup/_stories/InputGroup.test.story.tsx +4 -2
- package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +106 -77
- package/src/InstructionsList/_stories/InstructionsList.test.story.tsx +43 -16
- package/src/Link/_stories/Link.test.story.tsx +27 -13
- package/src/ListItem/_stories/ListItem.rtl.test.story.tsx +126 -6
- package/src/ListItem/_stories/variants/helpers.tsx +174 -126
- package/src/Loader/_stories/Loader.test.story.tsx +17 -10
- package/src/Modal/_stories/Modal.rtl.test.story.tsx +58 -39
- package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +14 -2
- package/src/Nudge/_stories/Nudge.test.story.tsx +70 -21
- package/src/Popover/_stories/Popover.rtl.test.story.tsx +92 -49
- package/src/PromoCard/_stories/PromoCard.test.story.tsx +53 -29
- package/src/PromoCard/_stories/PromoCardGroup.test.story.tsx +60 -36
- package/src/Prompt/ActionPrompt/_stories/ActionPrompt.test.story.tsx +74 -38
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.test.story.tsx +68 -31
- package/src/Prompt/InfoPrompt/_stories/InfoPrompt.test.story.tsx +52 -22
- package/src/Prompt/InlinePrompt/_stories/InlinePrompt.test.story.tsx +36 -21
- package/src/Radio/_stories/Radio.test.story.tsx +60 -46
- package/src/RadioGroup/_stories/RadioGroup.test.story.tsx +70 -51
- package/src/Section/_stories/Section.test.story.tsx +30 -14
- package/src/SegmentedControl/_stories/SegmentedControl.test.story.tsx +38 -15
- package/src/SlidingPanel/_stories/SlidingPanel.rtl.test.story.tsx +58 -34
- package/src/Snackbar/Snackbar.tsx +90 -88
- package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +24 -12
- package/src/Stepper/_stories/Stepper.test.story.tsx +27 -9
- package/src/Switch/_stories/Switch.test.story.tsx +20 -12
- package/src/Table/_stories/Table.test.story.tsx +107 -86
- package/src/Tabs/_stories/Tabs.test.story.tsx +92 -52
- package/src/Tag/_stories/Tag.test.story.tsx +27 -16
- package/src/Tooltip/_stories/Tooltip.rtl.test.story.tsx +68 -25
- package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +3 -3
- package/src/Upload/_stories/Upload.rtl.test.story.tsx +49 -26
- package/src/UploadInput/_stories/UploadInput.test.story.tsx +63 -41
- package/src/_deprecated/Alert/_stories/Alert.test.story.tsx +45 -24
- package/src/_deprecated/Card/_stories/Card.test.story.tsx +47 -23
- package/src/_deprecated/CriticalBanner/_stories/CriticalCommsBanner.test.story.tsx +21 -15
- package/src/_deprecated/InlineAlert/_stories/InlineAlert.test.story.tsx +23 -12
- package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +76 -40
- package/src/common/BottomSheet/_stories/BottomSheet.test.story.tsx +38 -20
- package/src/common/Panel/_stories/Panel.rtl.test.story.tsx +135 -51
|
@@ -18,94 +18,116 @@ interface RtlCurrency {
|
|
|
18
18
|
name: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{ code: '
|
|
24
|
-
{ code: '
|
|
21
|
+
/** Currency codes stay Latin — only the full names are localised. */
|
|
22
|
+
const getRtlCurrencies = (i18n: Record<string, string>): RtlCurrency[] => [
|
|
23
|
+
{ code: 'USD', name: i18n.usDollar },
|
|
24
|
+
{ code: 'EUR', name: i18n.euro },
|
|
25
|
+
{ code: 'GBP', name: i18n.britishPound },
|
|
25
26
|
];
|
|
26
27
|
|
|
28
|
+
const currencyNames = {
|
|
29
|
+
usDollar: { en: 'United States Dollar', ar: 'الدولار الأمريكي' },
|
|
30
|
+
euro: { en: 'Euro', ar: 'اليورو' },
|
|
31
|
+
britishPound: { en: 'British pound', ar: 'الجنيه الإسترليني' },
|
|
32
|
+
};
|
|
33
|
+
|
|
27
34
|
export const TriggerVariants: Story = {
|
|
28
|
-
render: () =>
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
/>
|
|
35
|
+
render: () => {
|
|
36
|
+
const i18n = useRtlDiffI18n();
|
|
37
|
+
const rtlCurrencies = getRtlCurrencies(i18n);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
{/* sm — chevron position flips in RTL */}
|
|
42
|
+
<SelectInput
|
|
43
|
+
size="sm"
|
|
44
|
+
placeholder={i18n.selectCurrency}
|
|
45
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
46
|
+
renderValue={(currency) => <SelectInputOptionContent title={currency.code} />}
|
|
47
|
+
/>
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<SelectInputOptionContent
|
|
54
|
-
title={currency.code}
|
|
55
|
-
note={currency.name}
|
|
56
|
-
icon={<Flag code={currency.code} intrinsicSize={24} />}
|
|
57
|
-
/>
|
|
58
|
-
)}
|
|
59
|
-
/>
|
|
49
|
+
{/* md — chevron position flips in RTL */}
|
|
50
|
+
<SelectInput
|
|
51
|
+
size="md"
|
|
52
|
+
placeholder={i18n.selectCurrency}
|
|
53
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
54
|
+
renderValue={(currency) => <SelectInputOptionContent title={currency.code} />}
|
|
55
|
+
/>
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
57
|
+
{/* lg with value and leading icon — icon side and chevron flip in RTL */}
|
|
58
|
+
<SelectInput
|
|
59
|
+
size="lg"
|
|
60
|
+
placeholder={i18n.selectCurrency}
|
|
61
|
+
defaultValue={rtlCurrencies[0]}
|
|
62
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
63
|
+
renderValue={(currency) => (
|
|
64
|
+
<SelectInputOptionContent
|
|
65
|
+
title={currency.code}
|
|
66
|
+
note={currency.name}
|
|
67
|
+
icon={<Flag code={currency.code} intrinsicSize={24} />}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
{/* multiple — selected values on leading side, chevron on trailing side, both flip in RTL */}
|
|
73
|
+
<SelectInput
|
|
74
|
+
size="lg"
|
|
75
|
+
multiple
|
|
76
|
+
placeholder={i18n.chooseCurrencies}
|
|
77
|
+
defaultValue={[rtlCurrencies[0], rtlCurrencies[1]]}
|
|
78
|
+
items={rtlCurrencies.map((currency) => ({ type: 'option', value: currency }))}
|
|
79
|
+
renderValue={(currency, withinTrigger) =>
|
|
80
|
+
withinTrigger ? (
|
|
81
|
+
currency.code
|
|
82
|
+
) : (
|
|
83
|
+
<SelectInputOptionContent title={currency.code} note={currency.name} />
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
/>
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
...withRTLDiff({
|
|
91
|
+
i18n: {
|
|
92
|
+
...currencyNames,
|
|
93
|
+
selectCurrency: { en: 'Select currency', ar: 'اختر العملة' },
|
|
94
|
+
chooseCurrencies: { en: 'Choose currencies', ar: 'اختر العملات' },
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
79
97
|
};
|
|
80
98
|
|
|
81
|
-
const
|
|
82
|
-
{ code: 'CAD', name:
|
|
83
|
-
{ code: 'AUD', name:
|
|
84
|
-
{ code: 'JPY', name:
|
|
99
|
+
const getOtherCurrencies = (i18n: Record<string, string>): RtlCurrency[] => [
|
|
100
|
+
{ code: 'CAD', name: i18n.canadianDollar },
|
|
101
|
+
{ code: 'AUD', name: i18n.australianDollar },
|
|
102
|
+
{ code: 'JPY', name: i18n.japaneseYen },
|
|
85
103
|
];
|
|
86
104
|
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
type: '
|
|
93
|
-
|
|
94
|
-
|
|
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) => ({
|
|
105
|
+
const getGroupedItems = (i18n: Record<string, string>) => {
|
|
106
|
+
const rtlCurrencies = getRtlCurrencies(i18n);
|
|
107
|
+
|
|
108
|
+
return [
|
|
109
|
+
{
|
|
110
|
+
type: 'group' as const,
|
|
111
|
+
label: i18n.popularCurrencies,
|
|
112
|
+
options: rtlCurrencies.map((currency) => ({
|
|
103
113
|
type: 'option' as const,
|
|
104
114
|
value: currency,
|
|
105
115
|
filterMatchers: [currency.code, currency.name],
|
|
106
116
|
})),
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: 'group' as const,
|
|
120
|
+
label: i18n.allCurrencies,
|
|
121
|
+
options: [...rtlCurrencies, ...getOtherCurrencies(i18n)]
|
|
122
|
+
.sort((a, b) => a.code.localeCompare(b.code))
|
|
123
|
+
.map((currency) => ({
|
|
124
|
+
type: 'option' as const,
|
|
125
|
+
value: currency,
|
|
126
|
+
filterMatchers: [currency.code, currency.name],
|
|
127
|
+
})),
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
};
|
|
109
131
|
|
|
110
132
|
export const OpenDropdown: Story = {
|
|
111
133
|
render: () => {
|
|
@@ -115,9 +137,9 @@ export const OpenDropdown: Story = {
|
|
|
115
137
|
size="lg"
|
|
116
138
|
filterable
|
|
117
139
|
filterPlaceholder={i18n.filterPlaceholder}
|
|
118
|
-
placeholder=
|
|
119
|
-
defaultValue={
|
|
120
|
-
items={
|
|
140
|
+
placeholder={i18n.selectCurrency}
|
|
141
|
+
defaultValue={getRtlCurrencies(i18n)[0]}
|
|
142
|
+
items={getGroupedItems(i18n)}
|
|
121
143
|
renderValue={(currency, withinTrigger) => (
|
|
122
144
|
<SelectInputOptionContent
|
|
123
145
|
title={currency.code}
|
|
@@ -138,10 +160,17 @@ export const OpenDropdown: Story = {
|
|
|
138
160
|
renderAs: 'iframe',
|
|
139
161
|
width: '80%',
|
|
140
162
|
i18n: {
|
|
163
|
+
...currencyNames,
|
|
141
164
|
filterPlaceholder: {
|
|
142
165
|
en: 'Type a currency / country',
|
|
143
166
|
ar: 'اكتب عملة / دولة',
|
|
144
167
|
},
|
|
168
|
+
selectCurrency: { en: 'Select currency', ar: 'اختر العملة' },
|
|
169
|
+
popularCurrencies: { en: 'Popular currencies', ar: 'العملات الشائعة' },
|
|
170
|
+
allCurrencies: { en: 'All currencies', ar: 'جميع العملات' },
|
|
171
|
+
canadianDollar: { en: 'Canadian dollar', ar: 'الدولار الكندي' },
|
|
172
|
+
australianDollar: { en: 'Australian dollar', ar: 'الدولار الأسترالي' },
|
|
173
|
+
japaneseYen: { en: 'Japanese yen', ar: 'الين الياباني' },
|
|
145
174
|
},
|
|
146
175
|
}),
|
|
147
176
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
|
|
3
|
-
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
3
|
+
import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
4
|
import InstructionsList from '..';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
@@ -12,19 +12,46 @@ export default {
|
|
|
12
12
|
type Story = StoryObj<typeof InstructionsList>;
|
|
13
13
|
|
|
14
14
|
export const RTLDiff: Story = {
|
|
15
|
-
render: () =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
render: () => {
|
|
16
|
+
const i18n = useRtlDiffI18n();
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<InstructionsList
|
|
20
|
+
dos={[i18n.initialTransfer, i18n.inviteFriends]}
|
|
21
|
+
donts={[i18n.hiddenFees, i18n.badExchangeRate]}
|
|
22
|
+
sort="dosFirst"
|
|
23
|
+
/>
|
|
24
|
+
<InstructionsList
|
|
25
|
+
dos={[i18n.verifyProfile]}
|
|
26
|
+
donts={[i18n.shareCredentials]}
|
|
27
|
+
sort="dontsFirst"
|
|
28
|
+
/>
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
...withRTLDiff({
|
|
33
|
+
i18n: {
|
|
34
|
+
initialTransfer: {
|
|
35
|
+
en: 'Do an initial money transfer',
|
|
36
|
+
ar: 'قم بإجراء تحويل أموال أولي',
|
|
37
|
+
},
|
|
38
|
+
inviteFriends: {
|
|
39
|
+
en: 'Invite at least 3 friends to join',
|
|
40
|
+
ar: 'ادعُ 3 أصدقاء على الأقل للانضمام',
|
|
41
|
+
},
|
|
42
|
+
hiddenFees: {
|
|
43
|
+
en: 'Paying extra hidden fees for transfers',
|
|
44
|
+
ar: 'دفع رسوم خفية إضافية على التحويلات',
|
|
45
|
+
},
|
|
46
|
+
badExchangeRate: { en: 'Use bad exchange rate', ar: 'استخدام سعر صرف سيئ' },
|
|
47
|
+
verifyProfile: {
|
|
48
|
+
en: 'Complete your profile verification',
|
|
49
|
+
ar: 'أكمل التحقق من ملفك الشخصي',
|
|
50
|
+
},
|
|
51
|
+
shareCredentials: {
|
|
52
|
+
en: 'Share your login credentials with others',
|
|
53
|
+
ar: 'مشاركة بيانات تسجيل دخولك مع الآخرين',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
30
57
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
2
|
+
import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
3
3
|
import Link from '..';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
@@ -11,16 +11,30 @@ export default {
|
|
|
11
11
|
type Story = StoryObj<typeof Link>;
|
|
12
12
|
|
|
13
13
|
export const RTLDiff: Story = {
|
|
14
|
-
render: () =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
render: () => {
|
|
15
|
+
const i18n = useRtlDiffI18n();
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<Link href="#" target="_blank">
|
|
19
|
+
{i18n.externalLink}
|
|
20
|
+
</Link>
|
|
21
|
+
<br />
|
|
22
|
+
<Link href="#" target="_blank" type="link-large">
|
|
23
|
+
{i18n.largeExternalLink}
|
|
24
|
+
</Link>
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
...withRTLDiff({
|
|
29
|
+
i18n: {
|
|
30
|
+
externalLink: {
|
|
31
|
+
en: 'External link with navigate-away icon',
|
|
32
|
+
ar: 'رابط خارجي مع أيقونة الانتقال',
|
|
33
|
+
},
|
|
34
|
+
largeExternalLink: {
|
|
35
|
+
en: 'Large external link with navigate-away icon',
|
|
36
|
+
ar: 'رابط خارجي كبير مع أيقونة الانتقال',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
26
40
|
};
|
|
@@ -1,24 +1,144 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { Meta } from '@storybook/react-webpack5';
|
|
2
|
-
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
3
|
+
import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import Link from '../../Link';
|
|
5
|
+
import { lorem20 } from '../../test-utils';
|
|
3
6
|
import { ListItem, type ListItemProps } from '../ListItem';
|
|
4
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
SB_LIST_ITEM_CONTROLS as CONTROLS,
|
|
9
|
+
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
10
|
+
SB_ListItem_ControlType as ControlType,
|
|
11
|
+
} from './subcomponents';
|
|
12
|
+
import { VariantList, type VariantContent, type VariantStoryProps } from './variants/helpers';
|
|
13
|
+
|
|
14
|
+
/** Arabic stand-in for `lorem20`, of comparable word count so wrapping behaviour stays comparable. */
|
|
15
|
+
const arabicFiller =
|
|
16
|
+
'نص تجريبي يُستخدم لعرض شكل التصميم النهائي قبل إضافة المحتوى الفعلي، ويساعد في التحقق من سلوك التغليف والمحاذاة عند تجاوز السطر الواحد.';
|
|
17
|
+
|
|
18
|
+
const i18nMap = {
|
|
19
|
+
title: { en: 'This is a title', ar: 'هذا عنوان' },
|
|
20
|
+
subtitle: { en: 'And it also has a subtitle', ar: 'وله أيضًا عنوان فرعي' },
|
|
21
|
+
longTitle: { en: `This is a long title. ${lorem20}`, ar: `هذا عنوان طويل. ${arabicFiller}` },
|
|
22
|
+
longSubtitle: {
|
|
23
|
+
en: `And it also has a long subtitle. ${lorem20}`,
|
|
24
|
+
ar: `وله أيضًا عنوان فرعي طويل. ${arabicFiller}`,
|
|
25
|
+
},
|
|
26
|
+
valueTitleLine1: { en: 'This value title', ar: 'عنوان القيمة هذا' },
|
|
27
|
+
valueTitleLine2: { en: 'is made to span', ar: 'مُصمم ليمتد' },
|
|
28
|
+
valueTitleLine3: { en: 'across few lines', ar: 'على عدة أسطر' },
|
|
29
|
+
additionalInfo: {
|
|
30
|
+
en: 'Which is augmented with additional info.',
|
|
31
|
+
ar: 'والذي تمت إضافة معلومات إضافية إليه.',
|
|
32
|
+
},
|
|
33
|
+
additionalInfoAction: { en: 'Details about the subject.', ar: 'تفاصيل حول الموضوع.' },
|
|
34
|
+
prompt: { en: 'Finally, there is a prompt.', ar: 'وأخيرًا، هناك تنبيه.' },
|
|
35
|
+
promptStart: { en: 'Finally, there is a prompt', ar: 'وأخيرًا، هناك تنبيه' },
|
|
36
|
+
promptLink: { en: 'referencing some details', ar: 'يشير إلى بعض التفاصيل' },
|
|
37
|
+
promptEnd: { en: 'for your convenience.', ar: 'لتسهيل الأمر عليك.' },
|
|
38
|
+
controlLabel: { en: 'Click me', ar: 'انقر هنا' },
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type ListItemI18n = Record<keyof typeof i18nMap, string>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Amounts keep Latin digits and ISO currency codes in both columns — a bidi run inside RTL copy is
|
|
45
|
+
* exactly what these stories need to exercise.
|
|
46
|
+
*/
|
|
47
|
+
const getContent = (i18n: ListItemI18n): VariantContent => ({
|
|
48
|
+
text: {
|
|
49
|
+
title: i18n.title,
|
|
50
|
+
subtitle: i18n.subtitle,
|
|
51
|
+
valueTitle: '100 GBP',
|
|
52
|
+
valueSubtitle: '200 USD',
|
|
53
|
+
longTitle: i18n.longTitle,
|
|
54
|
+
longSubtitle: i18n.longSubtitle,
|
|
55
|
+
longValueTitle: (
|
|
56
|
+
<>
|
|
57
|
+
{i18n.valueTitleLine1}
|
|
58
|
+
<br />
|
|
59
|
+
{i18n.valueTitleLine2}
|
|
60
|
+
<br />
|
|
61
|
+
{i18n.valueTitleLine3}
|
|
62
|
+
</>
|
|
63
|
+
),
|
|
64
|
+
},
|
|
65
|
+
media: MEDIA.avatarSingle,
|
|
66
|
+
additionalInfo: {
|
|
67
|
+
interactive: (
|
|
68
|
+
<ListItem.AdditionalInfo
|
|
69
|
+
action={{
|
|
70
|
+
label: i18n.additionalInfoAction,
|
|
71
|
+
href: 'https://wise.com',
|
|
72
|
+
target: '_blank',
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{i18n.additionalInfo}
|
|
76
|
+
</ListItem.AdditionalInfo>
|
|
77
|
+
),
|
|
78
|
+
nonInteractive: <ListItem.AdditionalInfo>{i18n.additionalInfo}</ListItem.AdditionalInfo>,
|
|
79
|
+
},
|
|
80
|
+
prompt: {
|
|
81
|
+
interactive: (
|
|
82
|
+
<ListItem.Prompt sentiment="positive">
|
|
83
|
+
{i18n.promptStart}{' '}
|
|
84
|
+
<Link href="https://wise.com" target="_blank" rel="noreferrer">
|
|
85
|
+
{i18n.promptLink}
|
|
86
|
+
</Link>{' '}
|
|
87
|
+
{i18n.promptEnd}
|
|
88
|
+
</ListItem.Prompt>
|
|
89
|
+
),
|
|
90
|
+
nonInteractive: <ListItem.Prompt sentiment="positive">{i18n.prompt}</ListItem.Prompt>,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/** Only the four controls with visible copy need overriding; the rest are icon- or input-only. */
|
|
95
|
+
const getControls = (i18n: ListItemI18n): Record<ControlType, ReactNode> => ({
|
|
96
|
+
...CONTROLS,
|
|
97
|
+
button: <ListItem.Button onClick={() => {}}>{i18n.controlLabel}</ListItem.Button>,
|
|
98
|
+
buttonAsLink: <ListItem.Button href="https://wise.com">{i18n.controlLabel}</ListItem.Button>,
|
|
99
|
+
partialButton: (
|
|
100
|
+
<ListItem.Button partiallyInteractive onClick={() => {}}>
|
|
101
|
+
{i18n.controlLabel}
|
|
102
|
+
</ListItem.Button>
|
|
103
|
+
),
|
|
104
|
+
partialButtonAsLink: (
|
|
105
|
+
<ListItem.Button partiallyInteractive href="https://wise.com">
|
|
106
|
+
{i18n.controlLabel}
|
|
107
|
+
</ListItem.Button>
|
|
108
|
+
),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const LocalisedVariantList = ({ controlType, variant }: VariantStoryProps) => {
|
|
112
|
+
const i18n = useRtlDiffI18n<ListItemI18n>();
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<VariantList
|
|
116
|
+
controlType={controlType}
|
|
117
|
+
variant={variant}
|
|
118
|
+
content={getContent(i18n)}
|
|
119
|
+
controls={getControls(i18n)}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
5
123
|
|
|
6
124
|
export default {
|
|
7
125
|
component: ListItem,
|
|
8
126
|
title: 'Content/ListItem/Tests/RTL Diff',
|
|
9
127
|
tags: ['!autodocs', '!manifest'],
|
|
10
|
-
...withRTLDiff({ width: 'stretch' }),
|
|
128
|
+
...withRTLDiff({ width: 'stretch', i18n: i18nMap }),
|
|
11
129
|
} satisfies Meta<ListItemProps>;
|
|
12
130
|
|
|
13
131
|
const Default = {
|
|
14
|
-
|
|
132
|
+
render: ({ controlType, variant }: VariantStoryProps) => (
|
|
133
|
+
<LocalisedVariantList controlType={controlType} variant={variant} />
|
|
134
|
+
),
|
|
15
135
|
parameters: { variants: [] },
|
|
16
|
-
args: { variant: 'rtl' },
|
|
136
|
+
args: { variant: 'rtl' as const },
|
|
17
137
|
};
|
|
18
138
|
|
|
19
139
|
export const Button = {
|
|
20
140
|
...Default,
|
|
21
|
-
args: { ...Default.args,
|
|
141
|
+
args: { ...Default.args, controlType: 'button' },
|
|
22
142
|
};
|
|
23
143
|
export const ButtonAsLink = {
|
|
24
144
|
...Default,
|