@transferwise/components 46.165.0 → 46.165.2

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 (99) hide show
  1. package/build/Snackbar/Snackbar.js +98 -101
  2. package/build/Snackbar/Snackbar.js.map +1 -1
  3. package/build/Snackbar/Snackbar.mjs +99 -102
  4. package/build/Snackbar/Snackbar.mjs.map +1 -1
  5. package/build/Snackbar/SnackbarProvider.js +2 -6
  6. package/build/Snackbar/SnackbarProvider.js.map +1 -1
  7. package/build/Snackbar/SnackbarProvider.mjs +2 -6
  8. package/build/Snackbar/SnackbarProvider.mjs.map +1 -1
  9. package/build/index.js +0 -2
  10. package/build/index.js.map +1 -1
  11. package/build/index.mjs +0 -1
  12. package/build/index.mjs.map +1 -1
  13. package/build/types/Body/Body.d.ts +2 -2
  14. package/build/types/Carousel/_stories/constants.d.ts +25 -0
  15. package/build/types/Carousel/_stories/constants.d.ts.map +1 -1
  16. package/build/types/IconButton/IconButton.d.ts +1 -1
  17. package/build/types/ListItem/_stories/variants/helpers.d.ts +38 -1
  18. package/build/types/ListItem/_stories/variants/helpers.d.ts.map +1 -1
  19. package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
  20. package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
  21. package/build/types/Snackbar/Snackbar.d.ts +2 -16
  22. package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
  23. package/build/types/Snackbar/SnackbarProvider.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/build/types/index.d.ts +0 -1
  28. package/build/types/index.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/src/Accordion/_stories/Accordion.test.story.tsx +74 -48
  31. package/src/AvatarLayout/_stories/AvatarLayout.test.story.tsx +46 -30
  32. package/src/Button/LegacyButton/_stories/LegacyButton.test.story.tsx +29 -19
  33. package/src/Button/_stories/Button.test.story.tsx +96 -62
  34. package/src/Calendar/_stories/Calendar.test.story.tsx +34 -21
  35. package/src/Carousel/_stories/Carousel.test.story.tsx +18 -8
  36. package/src/Carousel/_stories/constants.tsx +29 -4
  37. package/src/Checkbox/_stories/Checkbox.test.story.tsx +22 -13
  38. package/src/CheckboxButton/_stories/CheckboxButton.test.story.tsx +23 -14
  39. package/src/Chips/_stories/Chips.test.story.tsx +51 -36
  40. package/src/DateInput/_stories/DateInput.rtl.test.story.tsx +62 -12
  41. package/src/DateLookup/_stories/DateLookup.rtl.test.story.tsx +2 -2
  42. package/src/Decision/_stories/Decision.test.story.tsx +74 -58
  43. package/src/DefinitionList/_stories/DefinitionList.test.story.tsx +58 -42
  44. package/src/Drawer/_stories/Drawer.rtl.test.story.tsx +65 -38
  45. package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.rtl.test.story.tsx +107 -74
  46. package/src/Field/_stories/Field.test.story.tsx +18 -18
  47. package/src/FlowNavigation/_stories/FlowNavigation.rtl.test.story.tsx +81 -51
  48. package/src/Header/_stories/Header.test.story.tsx +30 -18
  49. package/src/Info/_stories/Info.rtl.test.story.tsx +124 -50
  50. package/src/InputWithDisplayFormat/_stories/InputWithDisplayFormat.test.story.tsx +4 -4
  51. package/src/Inputs/InputGroup/_stories/InputGroup.test.story.tsx +9 -8
  52. package/src/Inputs/SearchInput/_stories/SearchInput.test.story.tsx +5 -3
  53. package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +108 -79
  54. package/src/Inputs/TextArea/_stories/TextArea.test.story.tsx +10 -10
  55. package/src/InstructionsList/_stories/InstructionsList.test.story.tsx +43 -16
  56. package/src/Label/_stories/Label.test.story.tsx +7 -7
  57. package/src/Link/_stories/Link.test.story.tsx +27 -13
  58. package/src/ListItem/_stories/ListItem.rtl.test.story.tsx +126 -6
  59. package/src/ListItem/_stories/variants/helpers.tsx +174 -126
  60. package/src/Loader/_stories/Loader.test.story.tsx +17 -10
  61. package/src/Modal/_stories/Modal.rtl.test.story.tsx +58 -39
  62. package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +21 -3
  63. package/src/Nudge/_stories/Nudge.test.story.tsx +70 -21
  64. package/src/PhoneNumberInput/_stories/PhoneNumberInput.rtl.test.story.tsx +1 -1
  65. package/src/Popover/_stories/Popover.rtl.test.story.tsx +92 -49
  66. package/src/ProgressBar/_stories/ProgressBar.test.story.tsx +6 -6
  67. package/src/PromoCard/_stories/PromoCard.test.story.tsx +53 -29
  68. package/src/PromoCard/_stories/PromoCardGroup.test.story.tsx +60 -36
  69. package/src/Prompt/ActionPrompt/_stories/ActionPrompt.test.story.tsx +74 -38
  70. package/src/Prompt/CriticalBanner/_stories/CriticalBanner.test.story.tsx +68 -31
  71. package/src/Prompt/InfoPrompt/_stories/InfoPrompt.test.story.tsx +52 -22
  72. package/src/Prompt/InlinePrompt/_stories/InlinePrompt.test.story.tsx +36 -21
  73. package/src/Radio/_stories/Radio.test.story.tsx +60 -46
  74. package/src/RadioGroup/_stories/RadioGroup.test.story.tsx +70 -51
  75. package/src/Section/_stories/Section.test.story.tsx +30 -14
  76. package/src/SegmentedControl/_stories/SegmentedControl.test.story.tsx +38 -15
  77. package/src/SlidingPanel/_stories/SlidingPanel.rtl.test.story.tsx +58 -34
  78. package/src/Snackbar/Snackbar.test.tsx +16 -0
  79. package/src/Snackbar/Snackbar.tsx +93 -90
  80. package/src/Snackbar/SnackbarProvider.tsx +4 -10
  81. package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +24 -12
  82. package/src/Stepper/_stories/Stepper.test.story.tsx +27 -9
  83. package/src/Switch/_stories/Switch.test.story.tsx +20 -12
  84. package/src/Table/_stories/Table.test.story.tsx +107 -86
  85. package/src/Tabs/_stories/Tabs.test.story.tsx +92 -52
  86. package/src/Tag/_stories/Tag.test.story.tsx +27 -16
  87. package/src/TextareaWithDisplayFormat/_stories/TextareaWithDisplayFormat.test.story.tsx +4 -4
  88. package/src/Tooltip/_stories/Tooltip.rtl.test.story.tsx +68 -25
  89. package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +4 -4
  90. package/src/Upload/_stories/Upload.rtl.test.story.tsx +49 -26
  91. package/src/UploadInput/_stories/UploadInput.test.story.tsx +63 -41
  92. package/src/_deprecated/Alert/_stories/Alert.test.story.tsx +45 -24
  93. package/src/_deprecated/Card/_stories/Card.test.story.tsx +47 -23
  94. package/src/_deprecated/CriticalBanner/_stories/CriticalCommsBanner.test.story.tsx +21 -15
  95. package/src/_deprecated/InlineAlert/_stories/InlineAlert.test.story.tsx +23 -12
  96. package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +78 -42
  97. package/src/common/BottomSheet/_stories/BottomSheet.test.story.tsx +38 -20
  98. package/src/common/Panel/_stories/Panel.rtl.test.story.tsx +135 -51
  99. package/src/index.ts +0 -1
@@ -3,7 +3,7 @@ import { expect, userEvent, within } from 'storybook/test';
3
3
  import { useState } from 'react';
4
4
 
5
5
  import { withVariantConfig } from '../../../.storybook/helpers';
6
- import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
6
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
7
7
  import Field from '../../Field/Field';
8
8
  import Switch from '../Switch';
9
9
 
@@ -103,15 +103,23 @@ export const Zoom400: Story = {
103
103
  * the thumb direction flips correctly between writing modes.
104
104
  */
105
105
  export const RTLDiff: Story = {
106
- render: () => (
107
- <>
108
- <Field label="Unchecked">
109
- <Switch checked={false} onClick={() => {}} />
110
- </Field>
111
- <Field label="Checked">
112
- <Switch checked onClick={() => {}} />
113
- </Field>
114
- </>
115
- ),
116
- ...withRTLDiff(),
106
+ render: () => {
107
+ const i18n = useRtlDiffI18n();
108
+ return (
109
+ <>
110
+ <Field label={i18n.unchecked}>
111
+ <Switch checked={false} onClick={() => {}} />
112
+ </Field>
113
+ <Field label={i18n.checked}>
114
+ <Switch checked onClick={() => {}} />
115
+ </Field>
116
+ </>
117
+ );
118
+ },
119
+ ...withRTLDiff({
120
+ i18n: {
121
+ unchecked: { en: 'Unchecked', ar: 'غير محدد' },
122
+ checked: { en: 'Checked', ar: 'محدد' },
123
+ },
124
+ }),
117
125
  };
@@ -1,79 +1,11 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { DirectDebits } from '@transferwise/icons';
3
3
 
4
- import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
4
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
5
5
  import Table from '..';
6
6
  import { TableHeaderType } from '../Header/TableHeader';
7
7
  import { TableRowType, TableRowClickableType } from '../Row/TableRow';
8
8
 
9
- const headers: TableHeaderType[] = [
10
- { header: 'Employee', width: '200px' },
11
- { header: 'Location' },
12
- { header: 'Payment', alignment: 'right' },
13
- { header: 'Status' },
14
- ];
15
-
16
- const rows: TableRowType[] = [
17
- {
18
- cells: [
19
- {
20
- cell: {
21
- type: 'leading',
22
- primaryText: 'Bob Brown',
23
- secondaryText: 'Software Engineer',
24
- avatar: { profileName: 'Bob Brown', badge: { flagCode: 'GBP' } },
25
- },
26
- },
27
- { cell: { type: 'text', text: 'FR, Paris' } },
28
- {
29
- cell: {
30
- type: 'currency',
31
- primaryCurrency: { amount: 12345.67, currency: 'eur' },
32
- secondaryCurrency: { amount: 11000.0, currency: 'gbp' },
33
- },
34
- alignment: 'right',
35
- },
36
- {
37
- cell: {
38
- type: 'status',
39
- primaryText: 'Cancelled',
40
- secondaryText: '1 day ago',
41
- sentiment: 'negative',
42
- },
43
- },
44
- ],
45
- },
46
- {
47
- cells: [
48
- {
49
- cell: {
50
- type: 'leading',
51
- primaryText: 'Jan Kowalski',
52
- secondaryText: 'Product Manager',
53
- avatar: { asset: <DirectDebits />, badge: { status: 'warning' } },
54
- },
55
- },
56
- { cell: { type: 'text', text: 'US, New York' } },
57
- {
58
- cell: {
59
- type: 'currency',
60
- primaryCurrency: { amount: 23456.78, currency: 'usd' },
61
- secondaryCurrency: { amount: 21000.0, currency: 'gbp' },
62
- },
63
- alignment: 'right',
64
- },
65
- {
66
- cell: {
67
- type: 'status',
68
- primaryText: 'Paid',
69
- secondaryText: 'Yesterday',
70
- sentiment: 'positive',
71
- },
72
- },
73
- ],
74
- },
75
- ];
76
-
77
9
  export default {
78
10
  component: Table,
79
11
  title: 'Content/Table/Tests',
@@ -83,22 +15,111 @@ export default {
83
15
  type Story = StoryObj<typeof Table>;
84
16
 
85
17
  export const RTLDiff: Story = {
86
- render: () => (
87
- <>
88
- <Table data={{ headers, rows }} />
89
- <Table
90
- data={{
91
- headers,
92
- rows,
93
- onRowClick: (rowData: TableRowType | TableRowClickableType) => {
94
- void rowData;
18
+ render: () => {
19
+ const i18n = useRtlDiffI18n();
20
+
21
+ const headers: TableHeaderType[] = [
22
+ { header: i18n.employeeHeader, width: '200px' },
23
+ { header: i18n.locationHeader },
24
+ { header: i18n.paymentHeader, alignment: 'right' },
25
+ { header: i18n.statusHeader },
26
+ ];
27
+
28
+ const rows: TableRowType[] = [
29
+ {
30
+ cells: [
31
+ {
32
+ cell: {
33
+ type: 'leading',
34
+ primaryText: i18n.employeeOneName,
35
+ secondaryText: i18n.employeeOneRole,
36
+ avatar: { profileName: i18n.employeeOneName, badge: { flagCode: 'GBP' } },
37
+ },
38
+ },
39
+ { cell: { type: 'text', text: i18n.employeeOneLocation } },
40
+ {
41
+ cell: {
42
+ type: 'currency',
43
+ primaryCurrency: { amount: 12345.67, currency: 'eur' },
44
+ secondaryCurrency: { amount: 11000.0, currency: 'gbp' },
45
+ },
46
+ alignment: 'right',
47
+ },
48
+ {
49
+ cell: {
50
+ type: 'status',
51
+ primaryText: i18n.employeeOneStatus,
52
+ secondaryText: i18n.employeeOneStatusTime,
53
+ sentiment: 'negative',
54
+ },
55
+ },
56
+ ],
57
+ },
58
+ {
59
+ cells: [
60
+ {
61
+ cell: {
62
+ type: 'leading',
63
+ primaryText: i18n.employeeTwoName,
64
+ secondaryText: i18n.employeeTwoRole,
65
+ avatar: { asset: <DirectDebits />, badge: { status: 'warning' } },
66
+ },
67
+ },
68
+ { cell: { type: 'text', text: i18n.employeeTwoLocation } },
69
+ {
70
+ cell: {
71
+ type: 'currency',
72
+ primaryCurrency: { amount: 23456.78, currency: 'usd' },
73
+ secondaryCurrency: { amount: 21000.0, currency: 'gbp' },
74
+ },
75
+ alignment: 'right',
76
+ },
77
+ {
78
+ cell: {
79
+ type: 'status',
80
+ primaryText: i18n.employeeTwoStatus,
81
+ secondaryText: i18n.employeeTwoStatusTime,
82
+ sentiment: 'positive',
83
+ },
95
84
  },
96
- }}
97
- />
98
- <Table data={{ headers, rows }} fullWidth={false} />
99
- <Table data={{ headers, rows: [] }} />
100
- <Table data={{ headers, rows }} loading />
101
- </>
102
- ),
103
- ...withRTLDiff(),
85
+ ],
86
+ },
87
+ ];
88
+
89
+ return (
90
+ <>
91
+ <Table data={{ headers, rows }} />
92
+ <Table
93
+ data={{
94
+ headers,
95
+ rows,
96
+ onRowClick: (rowData: TableRowType | TableRowClickableType) => {
97
+ void rowData;
98
+ },
99
+ }}
100
+ />
101
+ <Table data={{ headers, rows }} fullWidth={false} />
102
+ <Table data={{ headers, rows: [] }} />
103
+ <Table data={{ headers, rows }} loading />
104
+ </>
105
+ );
106
+ },
107
+ ...withRTLDiff({
108
+ i18n: {
109
+ employeeHeader: { en: 'Employee', ar: 'الموظف' },
110
+ locationHeader: { en: 'Location', ar: 'الموقع' },
111
+ paymentHeader: { en: 'Payment', ar: 'الدفعة' },
112
+ statusHeader: { en: 'Status', ar: 'الحالة' },
113
+ employeeOneName: { en: 'Bob Brown', ar: 'بوب براون' },
114
+ employeeOneRole: { en: 'Software Engineer', ar: 'مهندس برمجيات' },
115
+ employeeOneLocation: { en: 'FR, Paris', ar: 'فرنسا، باريس' },
116
+ employeeOneStatus: { en: 'Cancelled', ar: 'ملغى' },
117
+ employeeOneStatusTime: { en: '1 day ago', ar: 'منذ يوم واحد' },
118
+ employeeTwoName: { en: 'Jan Kowalski', ar: 'يان كوفالسكي' },
119
+ employeeTwoRole: { en: 'Product Manager', ar: 'مدير المنتج' },
120
+ employeeTwoLocation: { en: 'US, New York', ar: 'أمريكا، نيويورك' },
121
+ employeeTwoStatus: { en: 'Paid', ar: 'مدفوع' },
122
+ employeeTwoStatusTime: { en: 'Yesterday', ar: 'أمس' },
123
+ },
124
+ }),
104
125
  };
@@ -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 { Width } from '../../common';
5
5
  import Tabs from '..';
6
6
 
@@ -12,61 +12,101 @@ export default {
12
12
 
13
13
  type Story = StoryObj<typeof Tabs>;
14
14
 
15
- const defaultTabs = [
16
- { title: 'First tab', disabled: false, content: <div className="p-a-2">First content</div> },
17
- { title: 'Second tab', disabled: false, content: <div className="p-a-2">Second content</div> },
18
- { title: 'Third tab', disabled: false, content: <div className="p-a-2">Third content</div> },
19
- ];
20
-
21
15
  /**
22
16
  * The tab list is horizontal: tab order, the active indicator translateX, and
23
17
  * swipe direction all flip between LTR and RTL. The indicator uses a negated
24
18
  * translateX in RTL mode. This diff verifies the layout mirrors correctly.
25
19
  */
26
20
  export const RTLDiff: Story = {
27
- render: () => (
28
- <>
29
- <div style={{ marginBottom: 32 }}>
30
- <h4>Block width — first tab selected</h4>
31
- <Tabs
32
- name="rtl-block-first"
33
- tabs={defaultTabs}
34
- selected={0}
35
- headerWidth={Width.BLOCK}
36
- onTabSelect={() => {}}
37
- />
38
- </div>
39
- <div style={{ marginBottom: 32 }}>
40
- <h4>Block width — second tab selected</h4>
41
- <Tabs
42
- name="rtl-block-second"
43
- tabs={defaultTabs}
44
- selected={1}
45
- headerWidth={Width.BLOCK}
46
- onTabSelect={() => {}}
47
- />
48
- </div>
49
- <div style={{ marginBottom: 32 }}>
50
- <h4>Auto width — first tab selected</h4>
51
- <Tabs
52
- name="rtl-auto-first"
53
- tabs={defaultTabs}
54
- selected={0}
55
- headerWidth={Width.AUTO}
56
- onTabSelect={() => {}}
57
- />
58
- </div>
59
- <div style={{ marginBottom: 32 }}>
60
- <h4>Auto width — second tab selected</h4>
61
- <Tabs
62
- name="rtl-auto-second"
63
- tabs={defaultTabs}
64
- selected={1}
65
- headerWidth={Width.AUTO}
66
- onTabSelect={() => {}}
67
- />
68
- </div>
69
- </>
70
- ),
71
- ...withRTLDiff(),
21
+ render: () => {
22
+ const i18n = useRtlDiffI18n();
23
+ const defaultTabs = [
24
+ {
25
+ title: i18n.firstTab,
26
+ disabled: false,
27
+ content: <div className="p-a-2">{i18n.firstContent}</div>,
28
+ },
29
+ {
30
+ title: i18n.secondTab,
31
+ disabled: false,
32
+ content: <div className="p-a-2">{i18n.secondContent}</div>,
33
+ },
34
+ {
35
+ title: i18n.thirdTab,
36
+ disabled: false,
37
+ content: <div className="p-a-2">{i18n.thirdContent}</div>,
38
+ },
39
+ ];
40
+
41
+ return (
42
+ <>
43
+ <div style={{ marginBottom: 32 }}>
44
+ <h4>{i18n.blockFirstSelected}</h4>
45
+ <Tabs
46
+ name="rtl-block-first"
47
+ tabs={defaultTabs}
48
+ selected={0}
49
+ headerWidth={Width.BLOCK}
50
+ onTabSelect={() => {}}
51
+ />
52
+ </div>
53
+ <div style={{ marginBottom: 32 }}>
54
+ <h4>{i18n.blockSecondSelected}</h4>
55
+ <Tabs
56
+ name="rtl-block-second"
57
+ tabs={defaultTabs}
58
+ selected={1}
59
+ headerWidth={Width.BLOCK}
60
+ onTabSelect={() => {}}
61
+ />
62
+ </div>
63
+ <div style={{ marginBottom: 32 }}>
64
+ <h4>{i18n.autoFirstSelected}</h4>
65
+ <Tabs
66
+ name="rtl-auto-first"
67
+ tabs={defaultTabs}
68
+ selected={0}
69
+ headerWidth={Width.AUTO}
70
+ onTabSelect={() => {}}
71
+ />
72
+ </div>
73
+ <div style={{ marginBottom: 32 }}>
74
+ <h4>{i18n.autoSecondSelected}</h4>
75
+ <Tabs
76
+ name="rtl-auto-second"
77
+ tabs={defaultTabs}
78
+ selected={1}
79
+ headerWidth={Width.AUTO}
80
+ onTabSelect={() => {}}
81
+ />
82
+ </div>
83
+ </>
84
+ );
85
+ },
86
+ ...withRTLDiff({
87
+ i18n: {
88
+ firstTab: { en: 'First tab', ar: 'التبويب الأول' },
89
+ secondTab: { en: 'Second tab', ar: 'التبويب الثاني' },
90
+ thirdTab: { en: 'Third tab', ar: 'التبويب الثالث' },
91
+ firstContent: { en: 'First content', ar: 'المحتوى الأول' },
92
+ secondContent: { en: 'Second content', ar: 'المحتوى الثاني' },
93
+ thirdContent: { en: 'Third content', ar: 'المحتوى الثالث' },
94
+ blockFirstSelected: {
95
+ en: 'Block width — first tab selected',
96
+ ar: 'عرض كامل — التبويب الأول محدد',
97
+ },
98
+ blockSecondSelected: {
99
+ en: 'Block width — second tab selected',
100
+ ar: 'عرض كامل — التبويب الثاني محدد',
101
+ },
102
+ autoFirstSelected: {
103
+ en: 'Auto width — first tab selected',
104
+ ar: 'عرض تلقائي — التبويب الأول محدد',
105
+ },
106
+ autoSecondSelected: {
107
+ en: 'Auto width — second tab selected',
108
+ ar: 'عرض تلقائي — التبويب الثاني محدد',
109
+ },
110
+ },
111
+ }),
72
112
  };
@@ -1,7 +1,7 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
3
3
 
4
- import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
4
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
5
5
  import { allModes } from '../../../.storybook/modes';
6
6
  import Tag from '..';
7
7
  import type { TagProps } from '..';
@@ -72,21 +72,32 @@ export const AllThemesAndSentiments: Story = {
72
72
  * The tag's horizontal padding is asymmetric and long copy truncates, so both need to mirror.
73
73
  */
74
74
  export const RTLDiff: Story = {
75
- render: () => (
76
- <div
77
- style={{
78
- alignItems: 'flex-start',
79
- display: 'flex',
80
- flexDirection: 'column',
81
- gap: '0.5rem',
82
- }}
83
- >
84
- <Tag label="Tag copy" />
85
- <Tag label="Tag copy" size="large" sentiment="success" emphasis="elevated" />
86
- <Tag label="A tag with copy far too long to fit within its maximum width" />
87
- </div>
88
- ),
89
- ...withRTLDiff(),
75
+ render: () => {
76
+ const i18n = useRtlDiffI18n();
77
+ return (
78
+ <div
79
+ style={{
80
+ alignItems: 'flex-start',
81
+ display: 'flex',
82
+ flexDirection: 'column',
83
+ gap: '0.5rem',
84
+ }}
85
+ >
86
+ <Tag label={i18n.tagCopy} />
87
+ <Tag label={i18n.tagCopy} size="large" sentiment="success" emphasis="elevated" />
88
+ <Tag label={i18n.longCopy} />
89
+ </div>
90
+ );
91
+ },
92
+ ...withRTLDiff({
93
+ i18n: {
94
+ tagCopy: { en: 'Tag copy', ar: 'نص الوسم' },
95
+ longCopy: {
96
+ en: 'A tag with copy far too long to fit within its maximum width',
97
+ ar: 'وسم يحتوي على نص طويل جدًا بحيث لا يتسع داخل الحد الأقصى لعرضه',
98
+ },
99
+ },
100
+ }),
90
101
  };
91
102
 
92
103
  /**
@@ -51,12 +51,12 @@ export const RTLDiff: Story = {
51
51
  ...withRTLDiff({
52
52
  i18n: {
53
53
  value: {
54
- ltr: 'XKQMRTBWJNFL',
55
- rtl: 'خكقمرتبوجنفل',
54
+ en: 'XKQMRTBWJNFL',
55
+ ar: 'خكقمرتبوجنفل',
56
56
  },
57
57
  placeholder: {
58
- ltr: 'Enter code',
59
- rtl: 'أدخل الرمز',
58
+ en: 'Enter code',
59
+ ar: 'أدخل الرمز',
60
60
  },
61
61
  },
62
62
  }),
@@ -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 Button from '../../Button';
6
6
  import Tooltip from '../Tooltip';
7
7
 
@@ -21,41 +21,84 @@ const hoverTrigger = async ({ canvasElement }: { canvasElement: HTMLElement }) =
21
21
  };
22
22
 
23
23
  export const PositionTop: Story = {
24
- render: () => (
25
- <Tooltip label="Top positioned tooltip" position="top">
26
- <Button>Top</Button>
27
- </Tooltip>
28
- ),
24
+ render: () => {
25
+ const i18n = useRtlDiffI18n();
26
+ return (
27
+ <Tooltip label={i18n.tooltip} position="top">
28
+ <Button>{i18n.trigger}</Button>
29
+ </Tooltip>
30
+ );
31
+ },
29
32
  play: hoverTrigger,
30
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'bottom' }),
33
+ ...withRTLDiff({
34
+ renderAs: 'iframe',
35
+ hAlign: 'center',
36
+ vAlign: 'bottom',
37
+ i18n: {
38
+ tooltip: { en: 'Top positioned tooltip', ar: 'تلميح في الأعلى' },
39
+ trigger: { en: 'Top', ar: 'أعلى' },
40
+ },
41
+ }),
31
42
  };
32
43
 
33
44
  export const PositionBottom: Story = {
34
- render: () => (
35
- <Tooltip label="Bottom positioned tooltip" position="bottom">
36
- <Button>Bottom</Button>
37
- </Tooltip>
38
- ),
45
+ render: () => {
46
+ const i18n = useRtlDiffI18n();
47
+ return (
48
+ <Tooltip label={i18n.tooltip} position="bottom">
49
+ <Button>{i18n.trigger}</Button>
50
+ </Tooltip>
51
+ );
52
+ },
39
53
  play: hoverTrigger,
40
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center' }),
54
+ ...withRTLDiff({
55
+ renderAs: 'iframe',
56
+ hAlign: 'center',
57
+ i18n: {
58
+ tooltip: { en: 'Bottom positioned tooltip', ar: 'تلميح في الأسفل' },
59
+ trigger: { en: 'Bottom', ar: 'أسفل' },
60
+ },
61
+ }),
41
62
  };
42
63
 
43
64
  export const PositionRight: Story = {
44
- render: () => (
45
- <Tooltip label="Right positioned tooltip" position="right">
46
- <Button>Right</Button>
47
- </Tooltip>
48
- ),
65
+ render: () => {
66
+ const i18n = useRtlDiffI18n();
67
+ return (
68
+ <Tooltip label={i18n.tooltip} position="right">
69
+ <Button>{i18n.trigger}</Button>
70
+ </Tooltip>
71
+ );
72
+ },
49
73
  play: hoverTrigger,
50
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center' }),
74
+ ...withRTLDiff({
75
+ renderAs: 'iframe',
76
+ hAlign: 'left',
77
+ vAlign: 'center',
78
+ i18n: {
79
+ tooltip: { en: 'Right positioned tooltip', ar: 'تلميح على اليمين' },
80
+ trigger: { en: 'Right', ar: 'يمين' },
81
+ },
82
+ }),
51
83
  };
52
84
 
53
85
  export const PositionLeft: Story = {
54
- render: () => (
55
- <Tooltip label="Left positioned tooltip" position="left">
56
- <Button>Left</Button>
57
- </Tooltip>
58
- ),
86
+ render: () => {
87
+ const i18n = useRtlDiffI18n();
88
+ return (
89
+ <Tooltip label={i18n.tooltip} position="left">
90
+ <Button>{i18n.trigger}</Button>
91
+ </Tooltip>
92
+ );
93
+ },
59
94
  play: hoverTrigger,
60
- ...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center' }),
95
+ ...withRTLDiff({
96
+ renderAs: 'iframe',
97
+ hAlign: 'right',
98
+ vAlign: 'center',
99
+ i18n: {
100
+ tooltip: { en: 'Left positioned tooltip', ar: 'تلميح على اليسار' },
101
+ trigger: { en: 'Left', ar: 'يسار' },
102
+ },
103
+ }),
61
104
  };
@@ -19,10 +19,10 @@ export default {
19
19
  type Story = StoryObj<typeof Typeahead>;
20
20
 
21
21
  const localisedStrings = {
22
- gbp: { ltr: 'British pound', rtl: 'جنيه إسترليني' },
23
- eur: { ltr: 'Euro', rtl: 'يورو' },
24
- usd: { ltr: 'US Dollar', rtl: 'دولار أمريكي' },
25
- placeholder: { ltr: 'Search currencies…', rtl: 'ابحث عن العملات...' },
22
+ gbp: { en: 'British pound', ar: 'الجنيه الإسترليني' },
23
+ eur: { en: 'Euro', ar: 'اليورو' },
24
+ usd: { en: 'US Dollar', ar: 'الدولار الأمريكي' },
25
+ placeholder: { en: 'Search currencies…', ar: 'ابحث عن العملات...' },
26
26
  };
27
27
 
28
28
  export const TriggerVariants: Story = {