@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.
- package/build/i18n/en.json +8 -0
- package/build/index.esm.js +1001 -367
- package/build/index.esm.js.map +1 -1
- package/build/index.js +1003 -366
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/common/closeButton/CloseButton.css +1 -1
- package/build/styles/dateLookup/DateLookup.css +1 -1
- package/build/styles/inputs/Input.css +1 -1
- package/build/styles/inputs/InputGroup.css +1 -1
- package/build/styles/inputs/SelectInput.css +1 -0
- package/build/styles/inputs/TextArea.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/promoCard/PromoCard.css +1 -1
- package/build/styles/stepper/Stepper.css +1 -1
- package/build/types/avatarWrapper/AvatarWrapper.d.ts +14 -5
- package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
- package/build/types/common/Option/Option.d.ts.map +1 -1
- package/build/types/common/focusBoundary/FocusBoundary.d.ts +2 -2
- package/build/types/common/focusBoundary/FocusBoundary.d.ts.map +1 -1
- package/build/types/common/hooks/useMedia.d.ts +2 -0
- package/build/types/common/hooks/useMedia.d.ts.map +1 -0
- package/build/types/common/hooks/useScreenSize.d.ts +3 -0
- package/build/types/common/hooks/useScreenSize.d.ts.map +1 -0
- package/build/types/common/preventScroll/PreventScroll.d.ts +2 -0
- package/build/types/common/preventScroll/PreventScroll.d.ts.map +1 -0
- package/build/types/dateInput/DateInput.d.ts +2 -0
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.messages.d.ts +65 -0
- package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -0
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts +3 -1
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts +7 -7
- package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/TableLink.d.ts +4 -26
- package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +4 -29
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
- package/build/types/index.d.ts +4 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts +1 -0
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/SearchInput.d.ts +10 -0
- package/build/types/inputs/SearchInput.d.ts.map +1 -0
- package/build/types/inputs/SelectInput.d.ts +41 -0
- package/build/types/inputs/SelectInput.d.ts.map +1 -0
- package/build/types/inputs/_BottomSheet.d.ts +17 -0
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -0
- package/build/types/inputs/_ButtonInput.d.ts +6 -0
- package/build/types/inputs/_ButtonInput.d.ts.map +1 -0
- package/build/types/inputs/_Popover.d.ts +18 -0
- package/build/types/inputs/_Popover.d.ts.map +1 -0
- package/build/types/inputs/_common.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/snackbar/Snackbar.d.ts.map +1 -1
- package/build/types/stepper/Stepper.d.ts.map +1 -1
- package/build/types/tabs/Tabs.d.ts.map +1 -1
- package/build/types/tile/Tile.d.ts.map +1 -1
- package/build/types/upload/steps/completeStep/completeStep.d.ts.map +1 -1
- package/build/types/upload/steps/processingStep/processingStep.d.ts.map +1 -1
- package/build/types/utilities/wrapInFragment.d.ts +3 -0
- package/build/types/utilities/wrapInFragment.d.ts.map +1 -0
- package/package.json +27 -20
- package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +6 -6
- package/src/avatarWrapper/AvatarWrapper.tsx +20 -8
- package/src/avatarWrapper/__snapshots__/AvatarWrapper.spec.tsx.snap +1 -1
- package/src/card/Card.spec.js +2 -2
- package/src/common/Option/Option.tsx +1 -7
- package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +8 -1
- package/src/common/closeButton/CloseButton.css +1 -1
- package/src/common/focusBoundary/FocusBoundary.tsx +9 -32
- package/src/common/hooks/useMedia.spec.ts +39 -0
- package/src/common/hooks/useMedia.ts +15 -0
- package/src/common/hooks/useScreenSize.ts +7 -0
- package/src/common/preventScroll/PreventScroll.tsx +6 -0
- package/src/dateInput/DateInput.js +6 -0
- package/src/dateInput/DateInput.story.tsx +2 -0
- package/src/dateLookup/DateLookup.css +1 -1
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +3 -3
- package/src/dateLookup/DateLookup.less +4 -0
- package/src/dateLookup/DateLookup.messages.js +44 -0
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +39 -0
- package/src/dateLookup/dateHeader/DateHeader.js +48 -26
- package/src/dateLookup/dateHeader/DateHeader.spec.js +37 -0
- package/src/dateLookup/dayCalendar/DayCalendar.js +3 -1
- package/src/dateLookup/dayCalendar/DayCalendar.spec.js +7 -1
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +7 -3
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +1 -0
- package/src/dateLookup/monthCalendar/MonthCalendar.js +3 -1
- package/src/dateLookup/monthCalendar/MonthCalendar.spec.js +7 -1
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +4 -5
- package/src/dateLookup/tableLink/TableLink.js +24 -3
- package/src/dateLookup/tableLink/TableLink.spec.js +60 -4
- package/src/dateLookup/yearCalendar/YearCalendar.js +16 -3
- package/src/dateLookup/yearCalendar/YearCalendar.spec.js +14 -1
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +4 -5
- package/src/decision/Decision.story.js +11 -11
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +12 -12
- package/src/i18n/en.json +9 -0
- package/src/index.ts +8 -0
- package/src/inputs/Input.css +1 -1
- package/src/inputs/Input.less +14 -0
- package/src/inputs/Input.tsx +6 -2
- package/src/inputs/InputGroup.css +1 -1
- package/src/inputs/InputGroup.less +5 -0
- package/src/inputs/SearchInput.story.tsx +40 -0
- package/src/inputs/SearchInput.tsx +35 -0
- package/src/inputs/SelectInput.css +1 -0
- package/src/inputs/SelectInput.less +183 -0
- package/src/inputs/SelectInput.spec.tsx +120 -0
- package/src/inputs/SelectInput.story.tsx +264 -0
- package/src/inputs/SelectInput.tsx +565 -0
- package/src/inputs/TextArea.css +1 -1
- package/src/inputs/TextArea.less +5 -0
- package/src/inputs/_BottomSheet.less +107 -0
- package/src/inputs/_BottomSheet.tsx +128 -0
- package/src/inputs/_ButtonInput.less +7 -0
- package/src/inputs/_ButtonInput.tsx +27 -0
- package/src/inputs/_Popover.less +38 -0
- package/src/inputs/_Popover.tsx +118 -0
- package/src/inputs/_common.less +0 -4
- package/src/inputs/_common.ts +0 -1
- package/src/logo/Logo.js +3 -21
- package/src/logo/__snapshots__/Logo.spec.js.snap +78 -30
- package/src/main.css +1 -1
- package/src/main.less +4 -0
- package/src/phoneNumberInput/PhoneNumberInput.js +1 -0
- package/src/promoCard/PromoCard.css +1 -1
- package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +1 -1
- package/src/snackbar/Snackbar.js +6 -1
- package/src/snackbar/Snackbar.spec.js +1 -3
- package/src/ssr.spec.js +7 -0
- package/src/stepper/Stepper.css +1 -1
- package/src/stepper/Stepper.less +1 -9
- package/src/stepper/Stepper.spec.js +4 -4
- package/src/stepper/Stepper.tsx +2 -5
- package/src/tabs/Tabs.js +2 -1
- package/src/tile/Tile.js +5 -11
- package/src/tile/__snapshots__/Tile.spec.js.snap +7 -9
- package/src/upload/Upload.js +1 -1
- package/src/upload/steps/completeStep/completeStep.js +4 -1
- package/src/upload/steps/processingStep/processingStep.js +1 -0
- package/src/uploadInput/uploadItem/UploadItem.tsx +1 -1
- package/src/utilities/wrapInFragment.tsx +3 -0
- package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts +0 -2
- package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts.map +0 -1
- package/build/types/common/focusBoundary/utils/index.d.ts +0 -3
- package/build/types/common/focusBoundary/utils/index.d.ts.map +0 -1
- package/build/types/common/focusBoundary/utils/resetFocus.d.ts +0 -2
- package/build/types/common/focusBoundary/utils/resetFocus.d.ts.map +0 -1
- package/src/common/focusBoundary/FocusBoundary.spec.tsx +0 -66
- package/src/common/focusBoundary/__snapshots__/FocusBoundary.spec.tsx.snap +0 -16
- package/src/common/focusBoundary/utils/getFocusableElements.js +0 -25
- package/src/common/focusBoundary/utils/getFocusableElements.spec.js +0 -51
- package/src/common/focusBoundary/utils/index.js +0 -2
- package/src/common/focusBoundary/utils/resetFocus.js +0 -23
- package/src/common/focusBoundary/utils/resetFocus.spec.js +0 -103
- package/src/snackbar/__snapshots__/Snackbar.spec.js.snap +0 -5
- /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
|
+
};
|