@transferwise/components 45.14.2 → 45.15.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 (160) hide show
  1. package/build/i18n/en.json +8 -0
  2. package/build/index.esm.js +1001 -367
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +1003 -366
  5. package/build/index.js.map +1 -1
  6. package/build/main.css +1 -1
  7. package/build/styles/common/closeButton/CloseButton.css +1 -1
  8. package/build/styles/dateLookup/DateLookup.css +1 -1
  9. package/build/styles/inputs/Input.css +1 -1
  10. package/build/styles/inputs/InputGroup.css +1 -1
  11. package/build/styles/inputs/SelectInput.css +1 -0
  12. package/build/styles/inputs/TextArea.css +1 -1
  13. package/build/styles/main.css +1 -1
  14. package/build/styles/promoCard/PromoCard.css +1 -1
  15. package/build/styles/stepper/Stepper.css +1 -1
  16. package/build/types/avatarWrapper/AvatarWrapper.d.ts +14 -5
  17. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  18. package/build/types/common/Option/Option.d.ts.map +1 -1
  19. package/build/types/common/focusBoundary/FocusBoundary.d.ts +2 -2
  20. package/build/types/common/focusBoundary/FocusBoundary.d.ts.map +1 -1
  21. package/build/types/common/hooks/useMedia.d.ts +2 -0
  22. package/build/types/common/hooks/useMedia.d.ts.map +1 -0
  23. package/build/types/common/hooks/useScreenSize.d.ts +3 -0
  24. package/build/types/common/hooks/useScreenSize.d.ts.map +1 -0
  25. package/build/types/common/preventScroll/PreventScroll.d.ts +2 -0
  26. package/build/types/common/preventScroll/PreventScroll.d.ts.map +1 -0
  27. package/build/types/dateInput/DateInput.d.ts +2 -0
  28. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  29. package/build/types/dateLookup/DateLookup.messages.d.ts +65 -0
  30. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -0
  31. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +3 -1
  32. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  33. package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts +7 -7
  34. package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts.map +1 -1
  35. package/build/types/dateLookup/tableLink/TableLink.d.ts +4 -26
  36. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  37. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +4 -29
  38. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
  39. package/build/types/index.d.ts +4 -0
  40. package/build/types/index.d.ts.map +1 -1
  41. package/build/types/inputs/Input.d.ts +1 -0
  42. package/build/types/inputs/Input.d.ts.map +1 -1
  43. package/build/types/inputs/SearchInput.d.ts +10 -0
  44. package/build/types/inputs/SearchInput.d.ts.map +1 -0
  45. package/build/types/inputs/SelectInput.d.ts +41 -0
  46. package/build/types/inputs/SelectInput.d.ts.map +1 -0
  47. package/build/types/inputs/_BottomSheet.d.ts +17 -0
  48. package/build/types/inputs/_BottomSheet.d.ts.map +1 -0
  49. package/build/types/inputs/_ButtonInput.d.ts +6 -0
  50. package/build/types/inputs/_ButtonInput.d.ts.map +1 -0
  51. package/build/types/inputs/_Popover.d.ts +18 -0
  52. package/build/types/inputs/_Popover.d.ts.map +1 -0
  53. package/build/types/inputs/_common.d.ts.map +1 -1
  54. package/build/types/logo/Logo.d.ts.map +1 -1
  55. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  56. package/build/types/snackbar/Snackbar.d.ts.map +1 -1
  57. package/build/types/stepper/Stepper.d.ts.map +1 -1
  58. package/build/types/tabs/Tabs.d.ts.map +1 -1
  59. package/build/types/tile/Tile.d.ts.map +1 -1
  60. package/build/types/upload/steps/completeStep/completeStep.d.ts.map +1 -1
  61. package/build/types/upload/steps/processingStep/processingStep.d.ts.map +1 -1
  62. package/build/types/utilities/wrapInFragment.d.ts +3 -0
  63. package/build/types/utilities/wrapInFragment.d.ts.map +1 -0
  64. package/package.json +27 -20
  65. package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +6 -6
  66. package/src/avatarWrapper/AvatarWrapper.tsx +20 -8
  67. package/src/avatarWrapper/__snapshots__/AvatarWrapper.spec.tsx.snap +1 -1
  68. package/src/card/Card.spec.js +2 -2
  69. package/src/common/Option/Option.tsx +1 -7
  70. package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +8 -1
  71. package/src/common/closeButton/CloseButton.css +1 -1
  72. package/src/common/focusBoundary/FocusBoundary.tsx +9 -32
  73. package/src/common/hooks/useMedia.spec.ts +39 -0
  74. package/src/common/hooks/useMedia.ts +15 -0
  75. package/src/common/hooks/useScreenSize.ts +7 -0
  76. package/src/common/preventScroll/PreventScroll.tsx +6 -0
  77. package/src/dateInput/DateInput.js +6 -0
  78. package/src/dateInput/DateInput.story.tsx +2 -0
  79. package/src/dateLookup/DateLookup.css +1 -1
  80. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +3 -3
  81. package/src/dateLookup/DateLookup.less +4 -0
  82. package/src/dateLookup/DateLookup.messages.js +44 -0
  83. package/src/dateLookup/DateLookup.testingLibrary.spec.js +39 -0
  84. package/src/dateLookup/dateHeader/DateHeader.js +48 -26
  85. package/src/dateLookup/dateHeader/DateHeader.spec.js +37 -0
  86. package/src/dateLookup/dayCalendar/DayCalendar.js +3 -1
  87. package/src/dateLookup/dayCalendar/DayCalendar.spec.js +7 -1
  88. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +7 -3
  89. package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +1 -0
  90. package/src/dateLookup/monthCalendar/MonthCalendar.js +3 -1
  91. package/src/dateLookup/monthCalendar/MonthCalendar.spec.js +7 -1
  92. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +4 -5
  93. package/src/dateLookup/tableLink/TableLink.js +24 -3
  94. package/src/dateLookup/tableLink/TableLink.spec.js +60 -4
  95. package/src/dateLookup/yearCalendar/YearCalendar.js +16 -3
  96. package/src/dateLookup/yearCalendar/YearCalendar.spec.js +14 -1
  97. package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +4 -5
  98. package/src/decision/Decision.story.js +11 -11
  99. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +12 -12
  100. package/src/i18n/en.json +9 -0
  101. package/src/index.ts +8 -0
  102. package/src/inputs/Input.css +1 -1
  103. package/src/inputs/Input.less +14 -0
  104. package/src/inputs/Input.tsx +6 -2
  105. package/src/inputs/InputGroup.css +1 -1
  106. package/src/inputs/InputGroup.less +5 -0
  107. package/src/inputs/SearchInput.story.tsx +40 -0
  108. package/src/inputs/SearchInput.tsx +35 -0
  109. package/src/inputs/SelectInput.css +1 -0
  110. package/src/inputs/SelectInput.less +183 -0
  111. package/src/inputs/SelectInput.spec.tsx +120 -0
  112. package/src/inputs/SelectInput.story.tsx +264 -0
  113. package/src/inputs/SelectInput.tsx +565 -0
  114. package/src/inputs/TextArea.css +1 -1
  115. package/src/inputs/TextArea.less +5 -0
  116. package/src/inputs/_BottomSheet.less +107 -0
  117. package/src/inputs/_BottomSheet.tsx +128 -0
  118. package/src/inputs/_ButtonInput.less +7 -0
  119. package/src/inputs/_ButtonInput.tsx +27 -0
  120. package/src/inputs/_Popover.less +38 -0
  121. package/src/inputs/_Popover.tsx +118 -0
  122. package/src/inputs/_common.less +0 -4
  123. package/src/inputs/_common.ts +0 -1
  124. package/src/logo/Logo.js +3 -21
  125. package/src/logo/__snapshots__/Logo.spec.js.snap +78 -30
  126. package/src/main.css +1 -1
  127. package/src/main.less +4 -0
  128. package/src/phoneNumberInput/PhoneNumberInput.js +1 -0
  129. package/src/promoCard/PromoCard.css +1 -1
  130. package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +1 -1
  131. package/src/snackbar/Snackbar.js +6 -1
  132. package/src/snackbar/Snackbar.spec.js +1 -3
  133. package/src/ssr.spec.js +7 -0
  134. package/src/stepper/Stepper.css +1 -1
  135. package/src/stepper/Stepper.less +1 -9
  136. package/src/stepper/Stepper.spec.js +4 -4
  137. package/src/stepper/Stepper.tsx +2 -5
  138. package/src/tabs/Tabs.js +2 -1
  139. package/src/tile/Tile.js +5 -11
  140. package/src/tile/__snapshots__/Tile.spec.js.snap +7 -9
  141. package/src/upload/Upload.js +1 -1
  142. package/src/upload/steps/completeStep/completeStep.js +4 -1
  143. package/src/upload/steps/processingStep/processingStep.js +1 -0
  144. package/src/uploadInput/uploadItem/UploadItem.tsx +1 -1
  145. package/src/utilities/wrapInFragment.tsx +3 -0
  146. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts +0 -2
  147. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts.map +0 -1
  148. package/build/types/common/focusBoundary/utils/index.d.ts +0 -3
  149. package/build/types/common/focusBoundary/utils/index.d.ts.map +0 -1
  150. package/build/types/common/focusBoundary/utils/resetFocus.d.ts +0 -2
  151. package/build/types/common/focusBoundary/utils/resetFocus.d.ts.map +0 -1
  152. package/src/common/focusBoundary/FocusBoundary.spec.tsx +0 -66
  153. package/src/common/focusBoundary/__snapshots__/FocusBoundary.spec.tsx.snap +0 -16
  154. package/src/common/focusBoundary/utils/getFocusableElements.js +0 -25
  155. package/src/common/focusBoundary/utils/getFocusableElements.spec.js +0 -51
  156. package/src/common/focusBoundary/utils/index.js +0 -2
  157. package/src/common/focusBoundary/utils/resetFocus.js +0 -23
  158. package/src/common/focusBoundary/utils/resetFocus.spec.js +0 -103
  159. package/src/snackbar/__snapshots__/Snackbar.spec.js.snap +0 -5
  160. /package/src/dateLookup/dateTrigger/{DateTrigger.messages.js → DateTrigger.messages.ts} +0 -0
@@ -0,0 +1,264 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { Calendar } from '@transferwise/icons';
3
+ import { Flag } from '@wise/art';
4
+ import { useState } from 'react';
5
+
6
+ import { getMonthNames } from '../common/dateUtils';
7
+
8
+ import { SelectInput, type SelectInputItem, SelectInputOptionContent } from './SelectInput';
9
+
10
+ export default {
11
+ component: SelectInput,
12
+ } satisfies Meta<typeof SelectInput>;
13
+
14
+ interface TestMonth {
15
+ id: number;
16
+ name: string;
17
+ unavailable: boolean;
18
+ }
19
+
20
+ const testMonths: TestMonth[] = getMonthNames('en-US').map((name, index) => ({
21
+ id: index + 1,
22
+ name,
23
+ unavailable: index % 6 === 2,
24
+ }));
25
+
26
+ const testQuarters = [
27
+ testMonths.slice(0, 3),
28
+ testMonths.slice(3, 6),
29
+ testMonths.slice(6, 9),
30
+ testMonths.slice(9, 12),
31
+ ] as const;
32
+
33
+ export const Basic: StoryObj<{
34
+ filterable: boolean;
35
+ filterPlaceholder: string;
36
+ clearable: boolean;
37
+ invalid: boolean;
38
+ disabled: boolean;
39
+ onChange: (value: TestMonth | null) => void;
40
+ onClear: () => void;
41
+ }> = {
42
+ render: function Story({
43
+ filterable,
44
+ filterPlaceholder,
45
+ clearable,
46
+ disabled,
47
+ onChange,
48
+ onClear,
49
+ }) {
50
+ const [selectedMonth, setSelectedMonth] = useState<TestMonth | null>(null);
51
+
52
+ return (
53
+ <div className="d-flex flex-column">
54
+ {/* TODO:
55
+ <Field
56
+ label="Label"
57
+ hint="Information message."
58
+ error={invalid ? "Error message." : undefined}
59
+ >
60
+ */}
61
+ <SelectInput
62
+ placeholder="Month"
63
+ items={testQuarters
64
+ .flatMap<SelectInputItem<TestMonth>>((quarterMonths, index) => [
65
+ {
66
+ type: 'group',
67
+ label: `Quarter #${index + 1}`,
68
+ options: quarterMonths.map((month) => ({
69
+ type: 'option',
70
+ value: month,
71
+ filterMatchers: [month.name],
72
+ disabled: month.unavailable,
73
+ })),
74
+ },
75
+ { type: 'separator' },
76
+ ])
77
+ .slice(0, -1)}
78
+ value={selectedMonth}
79
+ renderValue={(month, compact) => (
80
+ <SelectInputOptionContent
81
+ title={month.name}
82
+ note="Note"
83
+ description={compact ? undefined : `Month #${month.id}`}
84
+ icon={<Calendar size={24} />}
85
+ />
86
+ )}
87
+ filterable={filterable}
88
+ filterPlaceholder={filterPlaceholder}
89
+ disabled={disabled}
90
+ onChange={(month) => {
91
+ setSelectedMonth(month);
92
+ onChange(month);
93
+ }}
94
+ onClear={
95
+ clearable
96
+ ? () => {
97
+ setSelectedMonth(null);
98
+ onClear();
99
+ }
100
+ : undefined
101
+ }
102
+ />
103
+ </div>
104
+ );
105
+ },
106
+ args: {
107
+ filterable: true,
108
+ filterPlaceholder: 'Type a month’s name',
109
+ clearable: true,
110
+ invalid: false,
111
+ disabled: false,
112
+ },
113
+ argTypes: {
114
+ onChange: {
115
+ action: 'changed',
116
+ },
117
+ onClear: {
118
+ action: 'cleared',
119
+ },
120
+ },
121
+ };
122
+
123
+ interface Month {
124
+ id: number;
125
+ name: string;
126
+ }
127
+
128
+ const months: Month[] = getMonthNames('en-US').map((name, index) => ({
129
+ id: index + 1,
130
+ name,
131
+ }));
132
+
133
+ export const Months: StoryObj<{
134
+ onChange: (value: Month | null) => void;
135
+ onClear: () => void;
136
+ }> = {
137
+ render: function Story({ onChange, onClear }) {
138
+ const [selectedMonth, setSelectedMonth] = useState<Month | null>(null);
139
+
140
+ return (
141
+ <div className="d-flex flex-column">
142
+ <SelectInput
143
+ placeholder="Month"
144
+ items={months.map((month) => ({
145
+ type: 'option',
146
+ value: month,
147
+ }))}
148
+ value={selectedMonth}
149
+ renderValue={(month) => <SelectInputOptionContent title={month.name} />}
150
+ onChange={(month) => {
151
+ setSelectedMonth(month);
152
+ onChange(month);
153
+ }}
154
+ onClear={() => {
155
+ setSelectedMonth(null);
156
+ onClear();
157
+ }}
158
+ />
159
+ </div>
160
+ );
161
+ },
162
+ argTypes: {
163
+ onChange: {
164
+ action: 'changed',
165
+ },
166
+ onClear: {
167
+ action: 'cleared',
168
+ },
169
+ },
170
+ };
171
+
172
+ interface Currency {
173
+ code: string;
174
+ name: string;
175
+ countries?: string[];
176
+ }
177
+
178
+ const popularCurrencies: Currency[] = [
179
+ {
180
+ code: 'USD',
181
+ name: 'United States dollar',
182
+ countries: ['Hong Kong', 'Saudi Arabia'],
183
+ },
184
+ {
185
+ code: 'EUR',
186
+ name: 'Euro',
187
+ countries: ['Spain', 'Germany', 'France', 'Austria', 'Estonia'],
188
+ },
189
+ {
190
+ code: 'GBP',
191
+ name: 'British pound',
192
+ countries: ['England', 'Scotland', 'Wales'],
193
+ },
194
+ ];
195
+
196
+ const otherCurrencies: Currency[] = [
197
+ {
198
+ code: 'CAD',
199
+ name: 'Canadian dollar',
200
+ countries: ['Canada'],
201
+ },
202
+ {
203
+ code: 'AUD',
204
+ name: 'Australian dollar',
205
+ },
206
+ ];
207
+
208
+ const allCurrencies: Currency[] = [...popularCurrencies, ...otherCurrencies].sort((a, b) =>
209
+ a.code.localeCompare(b.code),
210
+ );
211
+
212
+ function currencyOption(currency: Currency) {
213
+ return {
214
+ type: 'option',
215
+ value: currency,
216
+ filterMatchers: [currency.code, currency.name, ...(currency.countries ?? [])],
217
+ } satisfies SelectInputItem<Currency>;
218
+ }
219
+
220
+ export const Currencies: StoryObj<{
221
+ onChange: (value: Currency) => void;
222
+ }> = {
223
+ render: function Story({ onChange }) {
224
+ const [selectedCurrency, setSelectedCurrency] = useState<Currency>(popularCurrencies[0]);
225
+
226
+ return (
227
+ <div className="d-flex flex-column">
228
+ <SelectInput
229
+ items={[
230
+ {
231
+ type: 'group',
232
+ label: 'Popular currencies',
233
+ options: popularCurrencies.map((currency) => currencyOption(currency)),
234
+ },
235
+ {
236
+ type: 'group',
237
+ label: 'All currencies',
238
+ options: allCurrencies.map((currency) => currencyOption(currency)),
239
+ },
240
+ ]}
241
+ value={selectedCurrency}
242
+ renderValue={(currency) => (
243
+ <SelectInputOptionContent
244
+ title={currency.code}
245
+ note={currency.name}
246
+ icon={<Flag code={currency.code} intrinsicSize={24} />}
247
+ />
248
+ )}
249
+ filterable
250
+ filterPlaceholder="Type a currency / country"
251
+ onChange={(currency) => {
252
+ setSelectedCurrency(currency);
253
+ onChange(currency);
254
+ }}
255
+ />
256
+ </div>
257
+ );
258
+ },
259
+ argTypes: {
260
+ onChange: {
261
+ action: 'changed',
262
+ },
263
+ },
264
+ };