@transferwise/components 46.164.0 → 46.165.1

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.
Files changed (102) hide show
  1. package/build/ListItem/ListItem.js +2 -0
  2. package/build/ListItem/ListItem.js.map +1 -1
  3. package/build/ListItem/ListItem.mjs +2 -0
  4. package/build/ListItem/ListItem.mjs.map +1 -1
  5. package/build/Snackbar/Snackbar.js +98 -101
  6. package/build/Snackbar/Snackbar.js.map +1 -1
  7. package/build/Snackbar/Snackbar.mjs +99 -102
  8. package/build/Snackbar/Snackbar.mjs.map +1 -1
  9. package/build/main.css +5 -0
  10. package/build/styles/ListItem/ListItem.css +5 -0
  11. package/build/styles/main.css +5 -0
  12. package/build/types/Body/Body.d.ts +2 -2
  13. package/build/types/Carousel/_stories/constants.d.ts +25 -0
  14. package/build/types/Carousel/_stories/constants.d.ts.map +1 -1
  15. package/build/types/IconButton/IconButton.d.ts +1 -1
  16. package/build/types/ListItem/ListItem.d.ts +6 -1
  17. package/build/types/ListItem/ListItem.d.ts.map +1 -1
  18. package/build/types/ListItem/_stories/variants/helpers.d.ts +38 -1
  19. package/build/types/ListItem/_stories/variants/helpers.d.ts.map +1 -1
  20. package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
  21. package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
  22. package/build/types/Snackbar/Snackbar.d.ts +1 -15
  23. package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
  24. package/build/types/Title/Title.d.ts +2 -2
  25. package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
  26. package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
  27. package/package.json +1 -1
  28. package/src/Accordion/_stories/Accordion.test.story.tsx +74 -48
  29. package/src/AvatarLayout/_stories/AvatarLayout.test.story.tsx +46 -30
  30. package/src/Button/LegacyButton/_stories/LegacyButton.test.story.tsx +29 -19
  31. package/src/Button/_stories/Button.test.story.tsx +96 -62
  32. package/src/Calendar/_stories/Calendar.test.story.tsx +34 -21
  33. package/src/Carousel/_stories/Carousel.test.story.tsx +18 -8
  34. package/src/Carousel/_stories/constants.tsx +29 -4
  35. package/src/Checkbox/_stories/Checkbox.test.story.tsx +22 -13
  36. package/src/CheckboxButton/_stories/CheckboxButton.test.story.tsx +23 -14
  37. package/src/Chips/_stories/Chips.test.story.tsx +51 -36
  38. package/src/DateInput/_stories/DateInput.rtl.test.story.tsx +62 -12
  39. package/src/DateLookup/_stories/DateLookup.rtl.test.story.tsx +2 -2
  40. package/src/Decision/_stories/Decision.test.story.tsx +74 -58
  41. package/src/DefinitionList/_stories/DefinitionList.test.story.tsx +58 -42
  42. package/src/Drawer/_stories/Drawer.rtl.test.story.tsx +65 -38
  43. package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.rtl.test.story.tsx +107 -74
  44. package/src/Field/_stories/Field.test.story.tsx +18 -18
  45. package/src/FlowNavigation/_stories/FlowNavigation.rtl.test.story.tsx +81 -51
  46. package/src/Header/_stories/Header.test.story.tsx +30 -18
  47. package/src/Info/_stories/Info.rtl.test.story.tsx +124 -50
  48. package/src/InputWithDisplayFormat/_stories/InputWithDisplayFormat.test.story.tsx +4 -4
  49. package/src/Inputs/InputGroup/_stories/InputGroup.test.story.tsx +9 -8
  50. package/src/Inputs/SearchInput/_stories/SearchInput.test.story.tsx +5 -3
  51. package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +108 -79
  52. package/src/Inputs/TextArea/_stories/TextArea.test.story.tsx +10 -10
  53. package/src/InstructionsList/_stories/InstructionsList.test.story.tsx +43 -16
  54. package/src/Label/_stories/Label.test.story.tsx +7 -7
  55. package/src/Link/_stories/Link.test.story.tsx +27 -13
  56. package/src/ListItem/ListItem.css +5 -0
  57. package/src/ListItem/ListItem.less +4 -0
  58. package/src/ListItem/ListItem.test.tsx +17 -0
  59. package/src/ListItem/ListItem.tsx +7 -0
  60. package/src/ListItem/_stories/ListItem.layout.test.story.tsx +23 -0
  61. package/src/ListItem/_stories/ListItem.rtl.test.story.tsx +126 -6
  62. package/src/ListItem/_stories/ListItem.story.tsx +8 -0
  63. package/src/ListItem/_stories/variants/helpers.tsx +174 -126
  64. package/src/Loader/_stories/Loader.test.story.tsx +17 -10
  65. package/src/Modal/_stories/Modal.rtl.test.story.tsx +58 -39
  66. package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +21 -3
  67. package/src/Nudge/_stories/Nudge.test.story.tsx +70 -21
  68. package/src/PhoneNumberInput/_stories/PhoneNumberInput.rtl.test.story.tsx +1 -1
  69. package/src/Popover/_stories/Popover.rtl.test.story.tsx +92 -49
  70. package/src/ProgressBar/_stories/ProgressBar.test.story.tsx +6 -6
  71. package/src/PromoCard/_stories/PromoCard.test.story.tsx +53 -29
  72. package/src/PromoCard/_stories/PromoCardGroup.test.story.tsx +60 -36
  73. package/src/Prompt/ActionPrompt/_stories/ActionPrompt.test.story.tsx +74 -38
  74. package/src/Prompt/CriticalBanner/_stories/CriticalBanner.test.story.tsx +68 -31
  75. package/src/Prompt/InfoPrompt/_stories/InfoPrompt.test.story.tsx +52 -22
  76. package/src/Prompt/InlinePrompt/_stories/InlinePrompt.test.story.tsx +36 -21
  77. package/src/Radio/_stories/Radio.test.story.tsx +60 -46
  78. package/src/RadioGroup/_stories/RadioGroup.test.story.tsx +70 -51
  79. package/src/Section/_stories/Section.test.story.tsx +30 -14
  80. package/src/SegmentedControl/_stories/SegmentedControl.test.story.tsx +38 -15
  81. package/src/SlidingPanel/_stories/SlidingPanel.rtl.test.story.tsx +58 -34
  82. package/src/Snackbar/Snackbar.test.tsx +16 -0
  83. package/src/Snackbar/Snackbar.tsx +91 -88
  84. package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +24 -12
  85. package/src/Stepper/_stories/Stepper.test.story.tsx +27 -9
  86. package/src/Switch/_stories/Switch.test.story.tsx +20 -12
  87. package/src/Table/_stories/Table.test.story.tsx +107 -86
  88. package/src/Tabs/_stories/Tabs.test.story.tsx +92 -52
  89. package/src/Tag/_stories/Tag.test.story.tsx +27 -16
  90. package/src/TextareaWithDisplayFormat/_stories/TextareaWithDisplayFormat.test.story.tsx +4 -4
  91. package/src/Tooltip/_stories/Tooltip.rtl.test.story.tsx +68 -25
  92. package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +4 -4
  93. package/src/Upload/_stories/Upload.rtl.test.story.tsx +49 -26
  94. package/src/UploadInput/_stories/UploadInput.test.story.tsx +63 -41
  95. package/src/_deprecated/Alert/_stories/Alert.test.story.tsx +45 -24
  96. package/src/_deprecated/Card/_stories/Card.test.story.tsx +47 -23
  97. package/src/_deprecated/CriticalBanner/_stories/CriticalCommsBanner.test.story.tsx +21 -15
  98. package/src/_deprecated/InlineAlert/_stories/InlineAlert.test.story.tsx +23 -12
  99. package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +78 -42
  100. package/src/common/BottomSheet/_stories/BottomSheet.test.story.tsx +38 -20
  101. package/src/common/Panel/_stories/Panel.rtl.test.story.tsx +135 -51
  102. package/src/main.css +5 -0
@@ -1,7 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { userEvent, within } from 'storybook/test';
3
3
 
4
- import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
4
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
5
5
  import Info from '..';
6
6
 
7
7
  export default {
@@ -20,70 +20,144 @@ const openInfo = async ({ canvasElement }: { canvasElement: HTMLElement }) => {
20
20
  };
21
21
 
22
22
  export const PlacementTop: Story = {
23
- render: () => (
24
- <Info
25
- aria-label="Info trigger"
26
- title="Information"
27
- content="This is some descriptive content inside the info component."
28
- presentation="POPOVER"
29
- preferredPlacement="top"
30
- />
31
- ),
23
+ render: () => {
24
+ const i18n = useRtlDiffI18n();
25
+ return (
26
+ <Info
27
+ aria-label={i18n.trigger}
28
+ title={i18n.title}
29
+ content={i18n.content}
30
+ presentation="POPOVER"
31
+ preferredPlacement="top"
32
+ />
33
+ );
34
+ },
32
35
  play: openInfo,
33
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'bottom' }),
36
+ ...withRTLDiff({
37
+ renderAs: 'iframe',
38
+ hAlign: 'center',
39
+ vAlign: 'bottom',
40
+ i18n: {
41
+ trigger: { en: 'Info trigger', ar: 'زر المعلومات' },
42
+ title: { en: 'Information', ar: 'معلومات' },
43
+ content: {
44
+ en: 'This is some descriptive content inside the info component.',
45
+ ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.',
46
+ },
47
+ },
48
+ }),
34
49
  };
35
50
 
36
51
  export const PlacementRight: Story = {
37
- render: () => (
38
- <Info
39
- aria-label="Info trigger"
40
- title="Information"
41
- content="This is some descriptive content inside the info component."
42
- presentation="POPOVER"
43
- preferredPlacement="right"
44
- />
45
- ),
52
+ render: () => {
53
+ const i18n = useRtlDiffI18n();
54
+ return (
55
+ <Info
56
+ aria-label={i18n.trigger}
57
+ title={i18n.title}
58
+ content={i18n.content}
59
+ presentation="POPOVER"
60
+ preferredPlacement="right"
61
+ />
62
+ );
63
+ },
46
64
  play: openInfo,
47
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center' }),
65
+ ...withRTLDiff({
66
+ renderAs: 'iframe',
67
+ hAlign: 'left',
68
+ vAlign: 'center',
69
+ i18n: {
70
+ trigger: { en: 'Info trigger', ar: 'زر المعلومات' },
71
+ title: { en: 'Information', ar: 'معلومات' },
72
+ content: {
73
+ en: 'This is some descriptive content inside the info component.',
74
+ ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.',
75
+ },
76
+ },
77
+ }),
48
78
  };
49
79
 
50
80
  export const PlacementBottom: Story = {
51
- render: () => (
52
- <Info
53
- aria-label="Info trigger"
54
- title="Information"
55
- content="This is some descriptive content inside the info component."
56
- presentation="POPOVER"
57
- preferredPlacement="bottom"
58
- />
59
- ),
81
+ render: () => {
82
+ const i18n = useRtlDiffI18n();
83
+ return (
84
+ <Info
85
+ aria-label={i18n.trigger}
86
+ title={i18n.title}
87
+ content={i18n.content}
88
+ presentation="POPOVER"
89
+ preferredPlacement="bottom"
90
+ />
91
+ );
92
+ },
60
93
  play: openInfo,
61
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center' }),
94
+ ...withRTLDiff({
95
+ renderAs: 'iframe',
96
+ hAlign: 'center',
97
+ i18n: {
98
+ trigger: { en: 'Info trigger', ar: 'زر المعلومات' },
99
+ title: { en: 'Information', ar: 'معلومات' },
100
+ content: {
101
+ en: 'This is some descriptive content inside the info component.',
102
+ ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.',
103
+ },
104
+ },
105
+ }),
62
106
  };
63
107
 
64
108
  export const PlacementLeft: Story = {
65
- render: () => (
66
- <Info
67
- aria-label="Info trigger"
68
- title="Information"
69
- content="This is some descriptive content inside the info component."
70
- presentation="POPOVER"
71
- preferredPlacement="left"
72
- />
73
- ),
109
+ render: () => {
110
+ const i18n = useRtlDiffI18n();
111
+ return (
112
+ <Info
113
+ aria-label={i18n.trigger}
114
+ title={i18n.title}
115
+ content={i18n.content}
116
+ presentation="POPOVER"
117
+ preferredPlacement="left"
118
+ />
119
+ );
120
+ },
74
121
  play: openInfo,
75
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center' }),
122
+ ...withRTLDiff({
123
+ renderAs: 'iframe',
124
+ hAlign: 'right',
125
+ vAlign: 'center',
126
+ i18n: {
127
+ trigger: { en: 'Info trigger', ar: 'زر المعلومات' },
128
+ title: { en: 'Information', ar: 'معلومات' },
129
+ content: {
130
+ en: 'This is some descriptive content inside the info component.',
131
+ ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.',
132
+ },
133
+ },
134
+ }),
76
135
  };
77
136
 
78
137
  export const Modal: Story = {
79
- render: () => (
80
- <Info
81
- aria-label="Info trigger"
82
- title="Information"
83
- content="This is some descriptive content inside the info component."
84
- presentation="MODAL"
85
- />
86
- ),
138
+ render: () => {
139
+ const i18n = useRtlDiffI18n();
140
+ return (
141
+ <Info
142
+ aria-label={i18n.trigger}
143
+ title={i18n.title}
144
+ content={i18n.content}
145
+ presentation="MODAL"
146
+ />
147
+ );
148
+ },
87
149
  play: openInfo,
88
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'center' }),
150
+ ...withRTLDiff({
151
+ renderAs: 'iframe',
152
+ hAlign: 'center',
153
+ vAlign: 'center',
154
+ i18n: {
155
+ trigger: { en: 'Info trigger', ar: 'زر المعلومات' },
156
+ title: { en: 'Information', ar: 'معلومات' },
157
+ content: {
158
+ en: 'This is some descriptive content inside the info component.',
159
+ ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.',
160
+ },
161
+ },
162
+ }),
89
163
  };
@@ -73,12 +73,12 @@ export const RTLDiff: StoryObj<typeof InputWithDisplayFormat> = {
73
73
  width: 'stretch',
74
74
  i18n: {
75
75
  value: {
76
- ltr: 'XKQMRTBWJNFL',
77
- rtl: 'خكقمرتبوجنفل',
76
+ en: 'XKQMRTBWJNFL',
77
+ ar: 'خكقمرتبوجنفل',
78
78
  },
79
79
  placeholder: {
80
- ltr: 'Enter code',
81
- rtl: 'أدخل الرمز',
80
+ en: 'Enter code',
81
+ ar: 'أدخل الرمز',
82
82
  },
83
83
  },
84
84
  }),
@@ -39,7 +39,7 @@ export const RTLDiff: Story = {
39
39
  addonEnd={{
40
40
  content: (
41
41
  <Button v2 size="sm">
42
- Copy
42
+ {i18n.copy}
43
43
  </Button>
44
44
  ),
45
45
  interactive: true,
@@ -57,7 +57,7 @@ export const RTLDiff: Story = {
57
57
  addonEnd={{
58
58
  content: (
59
59
  <Button v2 size="sm">
60
- Clear
60
+ {i18n.clear}
61
61
  </Button>
62
62
  ),
63
63
  interactive: true,
@@ -70,11 +70,12 @@ export const RTLDiff: Story = {
70
70
  );
71
71
  },
72
72
  ...withRTLDiff({
73
- i18n:{
74
- placeholder_both: { ltr: 'addonStart and addonEnd', rtl: 'البادئة والنهاية' },
75
- placeholder_start: { ltr: 'addonStart only', rtl: 'البادئة فقط' },
76
- placeholder_end: { ltr: 'addonEnd only', rtl: 'النهاية فقط' },
77
-
78
- }
73
+ i18n: {
74
+ placeholder_both: { en: 'addonStart and addonEnd', ar: 'البادئة والنهاية' },
75
+ placeholder_start: { en: 'addonStart only', ar: 'البادئة فقط' },
76
+ placeholder_end: { en: 'addonEnd only', ar: 'النهاية فقط' },
77
+ copy: { en: 'Copy', ar: 'نسخ' },
78
+ clear: { en: 'Clear', ar: 'مسح' },
79
+ },
79
80
  }),
80
81
  };
@@ -32,7 +32,9 @@ export const RTLDiff: Story = {
32
32
  </>
33
33
  );
34
34
  },
35
- ...withRTLDiff({i18n:{
36
- placeholder: { ltr: 'Search', rtl: 'بحث' },
37
- }}),
35
+ ...withRTLDiff({
36
+ i18n: {
37
+ placeholder: { en: 'Search', ar: 'بحث' },
38
+ },
39
+ }),
38
40
  };
@@ -18,94 +18,116 @@ interface RtlCurrency {
18
18
  name: string;
19
19
  }
20
20
 
21
- const rtlCurrencies: RtlCurrency[] = [
22
- { code: 'USD', name: 'United States Dollar' },
23
- { code: 'EUR', name: 'Euro' },
24
- { code: 'GBP', name: 'British pound' },
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
- {/* 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
- />
35
+ render: () => {
36
+ const i18n = useRtlDiffI18n();
37
+ const rtlCurrencies = getRtlCurrencies(i18n);
37
38
 
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
- />
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
- {/* 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
- />
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
- {/* 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(),
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 otherCurrencies: RtlCurrency[] = [
82
- { code: 'CAD', name: 'Canadian dollar' },
83
- { code: 'AUD', name: 'Australian dollar' },
84
- { code: 'JPY', name: 'Japanese yen' },
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 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) => ({
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="Select currency"
119
- defaultValue={rtlCurrencies[0]}
120
- items={groupedItems}
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
- ltr: 'Type a currency / country',
143
- rtl: 'اكتب عملة / دولة',
165
+ en: 'Type a currency / country',
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
  };
@@ -170,23 +170,23 @@ export const RTLDiff: Story = {
170
170
  ...withRTLDiff({
171
171
  width: 'stretch',
172
172
  i18n: {
173
- placeholder: { ltr: 'Translated placeholder...', rtl: 'نص بديل مترجم...' },
173
+ placeholder: { en: 'Translated placeholder...', ar: 'نص بديل مترجم...' },
174
174
  value_en: {
175
- ltr: 'This is LTR text content in the RTL textarea field, showing the input adapting to the content rather than page setting.',
176
- rtl: 'This is LTR text content in the RTL textarea field, showing the input adapting to the content rather than page setting.',
175
+ en: 'This is LTR text content in the RTL textarea field, showing the input adapting to the content rather than page setting.',
176
+ ar: 'This is LTR text content in the RTL textarea field, showing the input adapting to the content rather than page setting.',
177
177
  },
178
178
  value_ar: {
179
- ltr: 'This is some entered text content in the textarea field.',
180
- rtl: 'هذا هو بعض المحتوى النصي المدخل في حقل منطقة النص.',
179
+ en: 'This is some entered text content in the textarea field.',
180
+ ar: 'هذا هو بعض المحتوى النصي المدخل في حقل منطقة النص.',
181
181
  },
182
182
  errorMessage: {
183
- ltr: 'This field has an error message',
184
- rtl: 'هذا الحقل يحتوي على رسالة خطأ',
183
+ en: 'This field has an error message',
184
+ ar: 'هذا الحقل يحتوي على رسالة خطأ',
185
185
  },
186
- invalidInputText: { ltr: 'Invalid input text', rtl: 'نص الإدخال غير صالح' },
186
+ invalidInputText: { en: 'Invalid input text', ar: 'نص الإدخال غير صالح' },
187
187
  characterCounter: {
188
- ltr: 'Text with a character counter displayed below.',
189
- rtl: 'نص مع عداد أحرف معروض أدناه.',
188
+ en: 'Text with a character counter displayed below.',
189
+ ar: 'نص مع عداد أحرف معروض أدناه.',
190
190
  },
191
191
  },
192
192
  }),
@@ -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
- <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(),
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
  };
@@ -35,15 +35,15 @@ export const RTLDiff: Story = {
35
35
  },
36
36
  ...withRTLDiff({
37
37
  i18n: {
38
- plain: { ltr: 'Plain label text', rtl: 'نص التسمية العادي' },
39
- optional: { ltr: 'Label with optional marker', rtl: 'تسمية مع علامة اختيارية' },
40
- withInfo: { ltr: 'Label with info icon', rtl: 'تسمية مع أيقونة معلومات' },
38
+ plain: { en: 'Plain label text', ar: 'نص التسمية العادي' },
39
+ optional: { en: 'Label with optional marker', ar: 'تسمية مع علامة اختيارية' },
40
+ withInfo: { en: 'Label with info icon', ar: 'تسمية مع أيقونة معلومات' },
41
41
  optionalWithInfo: {
42
- ltr: 'Label with optional and info icon',
43
- rtl: 'تسمية مع اختيارية وأيقونة معلومات',
42
+ en: 'Label with optional and info icon',
43
+ ar: 'تسمية مع اختيارية وأيقونة معلومات',
44
44
  },
45
- tooltip: { ltr: 'Helpful tooltip content', rtl: 'محتوى تلميح مفيد' },
46
- moreInfo: { ltr: 'More information', rtl: 'مزيد من المعلومات' },
45
+ tooltip: { en: 'Helpful tooltip content', ar: 'محتوى تلميح مفيد' },
46
+ moreInfo: { en: 'More information', ar: 'مزيد من المعلومات' },
47
47
  },
48
48
  }),
49
49
  };