@transferwise/components 46.160.5 → 46.160.6

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 (93) hide show
  1. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.js +2 -0
  2. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.js.map +1 -1
  3. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.mjs +2 -0
  4. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.mjs.map +1 -1
  5. package/build/ExpressiveMoneyInput/hooks/useInputStyle.js +1 -1
  6. package/build/ExpressiveMoneyInput/hooks/useInputStyle.js.map +1 -1
  7. package/build/ExpressiveMoneyInput/hooks/useInputStyle.mjs +1 -1
  8. package/build/ExpressiveMoneyInput/hooks/useInputStyle.mjs.map +1 -1
  9. package/build/Inputs/Input/Input.js +1 -0
  10. package/build/Inputs/Input/Input.js.map +1 -1
  11. package/build/Inputs/Input/Input.mjs +1 -0
  12. package/build/Inputs/Input/Input.mjs.map +1 -1
  13. package/build/Inputs/TextArea/TextArea.js +1 -0
  14. package/build/Inputs/TextArea/TextArea.js.map +1 -1
  15. package/build/Inputs/TextArea/TextArea.mjs +1 -0
  16. package/build/Inputs/TextArea/TextArea.mjs.map +1 -1
  17. package/build/MoneyInput/MoneyInput.js +1 -0
  18. package/build/MoneyInput/MoneyInput.js.map +1 -1
  19. package/build/MoneyInput/MoneyInput.mjs +1 -0
  20. package/build/MoneyInput/MoneyInput.mjs.map +1 -1
  21. package/build/PhoneNumberInput/PhoneNumberInput.js +3 -2
  22. package/build/PhoneNumberInput/PhoneNumberInput.js.map +1 -1
  23. package/build/PhoneNumberInput/PhoneNumberInput.messages.js +3 -0
  24. package/build/PhoneNumberInput/PhoneNumberInput.messages.js.map +1 -1
  25. package/build/PhoneNumberInput/PhoneNumberInput.messages.mjs +3 -0
  26. package/build/PhoneNumberInput/PhoneNumberInput.messages.mjs.map +1 -1
  27. package/build/PhoneNumberInput/PhoneNumberInput.mjs +3 -2
  28. package/build/PhoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  29. package/build/Typeahead/TypeaheadInput/TypeaheadInput.js +50 -20
  30. package/build/Typeahead/TypeaheadInput/TypeaheadInput.js.map +1 -1
  31. package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs +50 -20
  32. package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs.map +1 -1
  33. package/build/i18n/en.json +1 -0
  34. package/build/i18n/en.json.js +1 -0
  35. package/build/i18n/en.json.js.map +1 -1
  36. package/build/i18n/en.json.mjs +1 -0
  37. package/build/i18n/en.json.mjs.map +1 -1
  38. package/build/main.css +51 -1
  39. package/build/styles/ExpressiveMoneyInput/AmountInput/AmountInput.css +6 -0
  40. package/build/styles/ExpressiveMoneyInput/ExpressiveMoneyInput.css +6 -0
  41. package/build/styles/Inputs/Input/Input.css +19 -0
  42. package/build/styles/Inputs/TextArea/TextArea.css +16 -1
  43. package/build/styles/MoneyInput/MoneyInput.css +3 -0
  44. package/build/styles/PhoneNumberInput/PhoneNumberInput.css +7 -0
  45. package/build/styles/main.css +51 -1
  46. package/build/types/ExpressiveMoneyInput/AmountInput/AmountInput.d.ts.map +1 -1
  47. package/build/types/ExpressiveMoneyInput/hooks/useInputStyle.d.ts.map +1 -1
  48. package/build/types/Inputs/Input/Input.d.ts.map +1 -1
  49. package/build/types/Inputs/TextArea/TextArea.d.ts.map +1 -1
  50. package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
  51. package/build/types/PhoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  52. package/build/types/PhoneNumberInput/PhoneNumberInput.messages.d.ts +5 -0
  53. package/build/types/PhoneNumberInput/PhoneNumberInput.messages.d.ts.map +1 -1
  54. package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts +1 -1
  55. package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts.map +1 -1
  56. package/build/types/test-utils/index.d.ts +2 -0
  57. package/build/types/test-utils/index.d.ts.map +1 -1
  58. package/package.json +1 -1
  59. package/src/ExpressiveMoneyInput/AmountInput/AmountInput.css +6 -0
  60. package/src/ExpressiveMoneyInput/AmountInput/AmountInput.less +7 -0
  61. package/src/ExpressiveMoneyInput/AmountInput/AmountInput.tsx +2 -1
  62. package/src/ExpressiveMoneyInput/ExpressiveMoneyInput.css +6 -0
  63. package/src/ExpressiveMoneyInput/hooks/useInputStyle.ts +1 -2
  64. package/src/Field/_stories/Field.test.story.tsx +27 -0
  65. package/src/Inputs/Input/Input.css +19 -0
  66. package/src/Inputs/Input/Input.less +16 -0
  67. package/src/Inputs/Input/Input.tsx +1 -0
  68. package/src/Inputs/{_stories → InputGroup/_stories}/InputGroup.story.tsx +9 -9
  69. package/src/Inputs/InputGroup/_stories/InputGroup.test.story.tsx +80 -0
  70. package/src/Inputs/{_stories → SearchInput/_stories}/SearchInput.story.tsx +4 -4
  71. package/src/Inputs/SearchInput/_stories/SearchInput.test.story.tsx +38 -0
  72. package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +31 -19
  73. package/src/Inputs/TextArea/TextArea.css +16 -1
  74. package/src/Inputs/TextArea/TextArea.less +6 -1
  75. package/src/Inputs/TextArea/TextArea.tsx +1 -0
  76. package/src/Inputs/{_stories → TextArea/_stories}/TextArea.story.tsx +4 -4
  77. package/src/Inputs/{_stories → TextArea/_stories}/TextArea.test.story.tsx +50 -26
  78. package/src/MoneyInput/MoneyInput.css +3 -0
  79. package/src/MoneyInput/MoneyInput.less +6 -0
  80. package/src/MoneyInput/MoneyInput.tsx +1 -0
  81. package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +14 -10
  82. package/src/PhoneNumberInput/PhoneNumberInput.css +7 -0
  83. package/src/PhoneNumberInput/PhoneNumberInput.less +13 -0
  84. package/src/PhoneNumberInput/PhoneNumberInput.messages.ts +5 -0
  85. package/src/PhoneNumberInput/PhoneNumberInput.tsx +3 -2
  86. package/src/PhoneNumberInput/_stories/PhoneNumberInput.rtl.test.story.tsx +15 -7
  87. package/src/TextareaWithDisplayFormat/_stories/TextareaWithDisplayFormat.test.story.tsx +49 -34
  88. package/src/Typeahead/TypeaheadInput/TypeaheadInput.tsx +31 -20
  89. package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +90 -57
  90. package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +8 -1
  91. package/src/main.css +51 -1
  92. package/src/Inputs/_stories/InputGroup.test.story.tsx +0 -69
  93. package/src/Inputs/_stories/SearchInput.test.story.tsx +0 -32
@@ -2,7 +2,11 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { userEvent, within } from 'storybook/test';
3
3
  import { Search as SearchIcon } from '@transferwise/icons';
4
4
 
5
- import { forEachColumn, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
5
+ import {
6
+ forEachColumn,
7
+ useRtlDiffI18n,
8
+ withRTLDiff,
9
+ } from '../../../.storybook/decorators/RtlDiffDecorator';
6
10
  import { Size } from '../../common';
7
11
  import Typeahead from '..';
8
12
 
@@ -14,70 +18,99 @@ export default {
14
18
 
15
19
  type Story = StoryObj<typeof Typeahead>;
16
20
 
17
- const baseOptions = [
18
- { label: 'British pound', note: 'GBP' },
19
- { label: 'Euro', note: 'EUR' },
20
- { label: 'US Dollar', note: 'USD' },
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: 'ابحث عن العملات...' },
26
+ };
22
27
 
23
28
  export const TriggerVariants: Story = {
24
- render: () => (
25
- <>
26
- <Typeahead
27
- id="rtl-addon-md"
28
- name="rtl-addon-md"
29
- placeholder="Search currencies…"
30
- size={Size.MEDIUM}
31
- addon={<SearchIcon size={24} />}
32
- clearable
33
- options={baseOptions}
34
- initialValue={[{ label: 'British pound', note: 'GBP' }]}
35
- onChange={() => {}}
36
- />
29
+ render: () => {
30
+ const i18n = useRtlDiffI18n();
31
+
32
+ const baseOptions = [
33
+ { label: i18n.gbp, note: 'GBP' },
34
+ { label: i18n.eur, note: 'EUR' },
35
+ { label: i18n.usd, note: 'USD' },
36
+ ];
37
+
38
+ return (
39
+ <>
40
+ <Typeahead
41
+ id="rtl-addon-placeholder"
42
+ name="rtl-addon-placeholder"
43
+ placeholder={i18n.placeholder}
44
+ size={Size.MEDIUM}
45
+ addon={<SearchIcon size={24} />}
46
+ clearable
47
+ options={baseOptions}
48
+ onChange={() => {}}
49
+ />
50
+ <Typeahead
51
+ id="rtl-addon-md"
52
+ name="rtl-addon-md"
53
+ placeholder={i18n.placeholder}
54
+ size={Size.MEDIUM}
55
+ addon={<SearchIcon size={24} />}
56
+ clearable
57
+ options={baseOptions}
58
+ initialValue={[{ label: i18n.gbp, note: 'GBP' }]}
59
+ onChange={() => {}}
60
+ />
61
+ <Typeahead
62
+ id="rtl-addon-lg"
63
+ name="rtl-addon-lg"
64
+ placeholder={i18n.placeholder}
65
+ size={Size.LARGE}
66
+ addon={<SearchIcon size={24} />}
67
+ clearable
68
+ options={baseOptions}
69
+ initialValue={[{ label: i18n.eur, note: 'EUR' }]}
70
+ onChange={() => {}}
71
+ />
72
+ <Typeahead
73
+ id="rtl-multiple"
74
+ name="rtl-multiple"
75
+ placeholder={i18n.placeholder}
76
+ size={Size.MEDIUM}
77
+ addon={<SearchIcon size={24} />}
78
+ multiple
79
+ clearable
80
+ options={baseOptions}
81
+ initialValue={[
82
+ { label: i18n.gbp, note: 'GBP' },
83
+ { label: i18n.eur, note: 'EUR' },
84
+ ]}
85
+ onChange={() => {}}
86
+ />
87
+ </>
88
+ );
89
+ },
90
+ ...withRTLDiff({ width: '80%', i18n: localisedStrings }),
91
+ };
92
+
93
+ export const OpenDropdown: Story = {
94
+ render: () => {
95
+ const i18n = useRtlDiffI18n();
96
+
97
+ return (
37
98
  <Typeahead
38
- id="rtl-addon-lg"
39
- name="rtl-addon-lg"
40
- placeholder="Search currencies…"
99
+ id="rtl-open"
100
+ name="rtl-open"
101
+ placeholder={i18n.placeholder}
41
102
  size={Size.LARGE}
42
103
  addon={<SearchIcon size={24} />}
43
104
  clearable
44
- options={baseOptions}
45
- initialValue={[{ label: 'Euro', note: 'EUR' }]}
46
- onChange={() => {}}
47
- />
48
- <Typeahead
49
- id="rtl-multiple"
50
- name="rtl-multiple"
51
- placeholder="Search currencies…"
52
- size={Size.MEDIUM}
53
- addon={<SearchIcon size={24} />}
54
- multiple
55
- clearable
56
- options={baseOptions}
57
- initialValue={[
58
- { label: 'British pound', note: 'GBP' },
59
- { label: 'Euro', note: 'EUR' },
105
+ options={[
106
+ { label: i18n.gbp, note: 'GBP' },
107
+ { label: i18n.eur, note: 'EUR' },
108
+ { label: i18n.usd, note: 'USD' },
60
109
  ]}
61
110
  onChange={() => {}}
62
111
  />
63
- </>
64
- ),
65
- ...withRTLDiff({ width: '80%' }),
66
- };
67
-
68
- export const OpenDropdown: Story = {
69
- render: () => (
70
- <Typeahead
71
- id="rtl-open"
72
- name="rtl-open"
73
- placeholder="Search currencies…"
74
- size={Size.LARGE}
75
- addon={<SearchIcon size={24} />}
76
- clearable
77
- options={baseOptions}
78
- onChange={() => {}}
79
- />
80
- ),
112
+ );
113
+ },
81
114
  play: async ({ canvasElement }) => {
82
115
  await forEachColumn(canvasElement, async (column) => {
83
116
  const scope = within(column);
@@ -86,5 +119,5 @@ export const OpenDropdown: Story = {
86
119
  await userEvent.keyboard('Brit');
87
120
  });
88
121
  },
89
- ...withRTLDiff({ width: '80%' }),
122
+ ...withRTLDiff({ width: '80%', i18n: localisedStrings }),
90
123
  };
@@ -67,5 +67,12 @@ export const OpenDropdown: Story = {
67
67
  if (!trigger) return;
68
68
  await userEvent.click(trigger);
69
69
  },
70
- ...withRTLDiff({ renderAs: 'iframe', width: '80%' }),
70
+ ...withRTLDiff({
71
+ renderAs: 'iframe',
72
+ width: '80%',
73
+ i18n: {
74
+ searchPlaceholder: { ltr: 'Type a currency', rtl: 'اكتب عملة' },
75
+ placeholder: { ltr: 'Select currency', rtl: 'اختر العملة' },
76
+ },
77
+ }),
71
78
  };
package/src/main.css CHANGED
@@ -22607,6 +22607,25 @@ button.np-option {
22607
22607
  color: #768e9c;
22608
22608
  color: var(--color-content-tertiary);
22609
22609
  }
22610
+ [dir="rtl"] .np-input::-moz-placeholder {
22611
+ direction: rtl !important;
22612
+ }
22613
+ [dir="rtl"] .np-input:-moz-placeholder {
22614
+ direction: rtl !important;
22615
+ }
22616
+ [dir="rtl"] .np-input::placeholder,
22617
+ [dir="rtl"] .np-input:placeholder-shown {
22618
+ direction: rtl !important;
22619
+ }
22620
+ [dir="rtl"] .np-input:-moz-placeholder[type="email"], [dir="rtl"] .np-input:-moz-placeholder[type="tel"], [dir="rtl"] .np-input:-moz-placeholder[type="number"], [dir="rtl"] .np-input:-moz-placeholder[type="url"] {
22621
+ direction: ltr !important;
22622
+ }
22623
+ [dir="rtl"] .np-input:placeholder-shown[type="email"],
22624
+ [dir="rtl"] .np-input:placeholder-shown[type="tel"],
22625
+ [dir="rtl"] .np-input:placeholder-shown[type="number"],
22626
+ [dir="rtl"] .np-input:placeholder-shown[type="url"] {
22627
+ direction: ltr !important;
22628
+ }
22610
22629
  .np-input--shape-rectangle {
22611
22630
  border-radius: 10px !important;
22612
22631
  border-radius: var(--radius-small) !important;
@@ -23794,10 +23813,25 @@ button.np-option {
23794
23813
  color: #768e9c;
23795
23814
  color: var(--color-content-tertiary);
23796
23815
  }
23797
- .np-text-area::placeholder {
23816
+ .np-text-area:-moz-placeholder {
23798
23817
  color: #768e9c;
23799
23818
  color: var(--color-content-tertiary);
23800
23819
  }
23820
+ .np-text-area::placeholder,
23821
+ .np-text-area:placeholder-shown {
23822
+ color: #768e9c;
23823
+ color: var(--color-content-tertiary);
23824
+ }
23825
+ [dir="rtl"] .np-text-area::-moz-placeholder {
23826
+ direction: rtl !important;
23827
+ }
23828
+ [dir="rtl"] .np-text-area:-moz-placeholder {
23829
+ direction: rtl !important;
23830
+ }
23831
+ [dir="rtl"] .np-text-area::placeholder,
23832
+ [dir="rtl"] .np-text-area:placeholder-shown {
23833
+ direction: rtl !important;
23834
+ }
23801
23835
  .tw-instructions {
23802
23836
  /* Reset */
23803
23837
  margin: 0;
@@ -24208,6 +24242,9 @@ button.np-link {
24208
24242
  font-weight: 600;
24209
24243
  font-weight: var(--font-weight-semi-bold);
24210
24244
  }
24245
+ [dir="rtl"] .tw-money-input .money-input__number-input {
24246
+ text-align: end;
24247
+ }
24211
24248
  .tw-money-input .money-input-currency-flag {
24212
24249
  display: flex;
24213
24250
  align-items: center;
@@ -24276,6 +24313,10 @@ button.np-link {
24276
24313
  overflow: hidden;
24277
24314
  margin-block-end: 0 !important;
24278
24315
  }
24316
+ [dir="rtl"] .wds-amount-input-input-container {
24317
+ display: inline-grid;
24318
+ grid-template-columns: auto 1fr;
24319
+ }
24279
24320
  @media (prefers-reduced-motion: reduce) {
24280
24321
  .wds-amount-input-input-container {
24281
24322
  transition: none;
@@ -24288,6 +24329,8 @@ button.np-link {
24288
24329
  text-align: end;
24289
24330
  background-color: transparent;
24290
24331
  line-height: inherit;
24332
+ field-sizing: content;
24333
+ block-size: inherit;
24291
24334
  }
24292
24335
  .wds-amount-input-input:focus-visible {
24293
24336
  outline: none;
@@ -24552,6 +24595,9 @@ button.np-link {
24552
24595
  margin-inline-start: 12px;
24553
24596
  margin-inline-start: var(--size-12);
24554
24597
  }
24598
+ [dir="rtl"] .tw-telephone__number-input-field {
24599
+ text-align: end;
24600
+ }
24555
24601
  .tw-telephone__country-select {
24556
24602
  flex-basis: 120px;
24557
24603
  flex-shrink: 0;
@@ -24559,6 +24605,10 @@ button.np-link {
24559
24605
  .tw-telephone__country-select .np-input-group {
24560
24606
  inline-size: 100%;
24561
24607
  }
24608
+ [dir="rtl"] .tw-telephone__country-select .np-select-input-content {
24609
+ text-align: end;
24610
+ direction: ltr;
24611
+ }
24562
24612
  .tw-telephone__country-select--with-input-group-addon-start .np-button-input {
24563
24613
  padding-inline-start: 48px;
24564
24614
  padding-inline-start: var(--size-48);
@@ -1,69 +0,0 @@
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
- };
@@ -1,32 +0,0 @@
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
- };