@transferwise/components 0.0.0-experimental-2d4d50d → 0.0.0-experimental-ddde990
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/index.esm.js +6 -6
- package/build/index.esm.js.map +1 -1
- package/build/index.js +6 -6
- package/build/index.js.map +1 -1
- package/build/types/accordion/Accordion.d.ts +1 -1
- package/build/types/accordion/Accordion.d.ts.map +1 -1
- package/build/types/chips/Chips.d.ts +2 -2
- package/build/types/chips/Chips.d.ts.map +1 -1
- package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts +1 -1
- package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +1 -1
- package/build/types/decision/Decision.d.ts +1 -1
- package/build/types/decision/Decision.d.ts.map +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts +1 -1
- package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
- package/build/types/instructionsList/InstructionsList.d.ts +4 -4
- package/build/types/instructionsList/InstructionsList.d.ts.map +1 -1
- package/build/types/markdown/Markdown.d.ts +2 -2
- package/build/types/markdown/Markdown.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts.map +1 -1
- package/build/types/radioGroup/RadioGroup.d.ts +1 -1
- package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts +3 -3
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/build/types/stepper/Stepper.d.ts +1 -1
- package/build/types/stepper/Stepper.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +5 -5
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts +1 -1
- package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/getAllowedFileTypes.d.ts +1 -1
- package/build/types/uploadInput/uploadButton/getAllowedFileTypes.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/Accordion.tsx +1 -1
- package/src/chips/Chips.story.tsx +2 -2
- package/src/chips/Chips.tsx +2 -2
- package/src/dateLookup/dateTrigger/DateTrigger.js +1 -1
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +11 -3
- package/src/dateLookup/getFocusableTime/getFocusableTime.tsx +1 -1
- package/src/decision/Decision.tsx +1 -1
- package/src/flowNavigation/FlowNavigation.tsx +1 -1
- package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +1 -1
- package/src/instructionsList/InstructionsList.tsx +4 -4
- package/src/markdown/Markdown.tsx +3 -3
- package/src/moneyInput/MoneyInput.tsx +3 -3
- package/src/phoneNumberInput/PhoneNumberInput.tsx +1 -1
- package/src/phoneNumberInput/utils/excludeCountries/excludeCountries.ts +2 -5
- package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.ts +1 -1
- package/src/phoneNumberInput/utils/longestMatchingPrefix/index.ts +1 -1
- package/src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.ts +1 -1
- package/src/promoCard/PromoCardGroup.tsx +1 -1
- package/src/radioGroup/RadioGroup.tsx +1 -1
- package/src/segmentedControl/SegmentedControl.tsx +3 -3
- package/src/stepper/Stepper.tsx +1 -1
- package/src/typeahead/Typeahead.tsx +6 -6
- package/src/typeahead/typeaheadInput/TypeaheadInput.tsx +1 -1
- package/src/uploadInput/UploadInput.tsx +6 -6
- package/src/uploadInput/uploadButton/UploadButton.tsx +7 -5
- package/src/uploadInput/uploadButton/getAllowedFileTypes.ts +1 -1
|
@@ -462,7 +462,7 @@ function filterCurrenciesForQuery(
|
|
|
462
462
|
return sortOptionsLabelsToFirst(filteredOptions, query);
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
-
function removeDuplicateValueOptions(options:
|
|
465
|
+
function removeDuplicateValueOptions(options: CurrencyOptionItem[]) {
|
|
466
466
|
const uniqueValues = new Set<string>();
|
|
467
467
|
return options.filter((option) => {
|
|
468
468
|
if (!uniqueValues.has(option.value)) {
|
|
@@ -489,8 +489,8 @@ function contains(property: string | undefined, query: string) {
|
|
|
489
489
|
return property && property.toLowerCase().includes(query.toLowerCase());
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
function sortOptionsLabelsToFirst(options:
|
|
493
|
-
return
|
|
492
|
+
function sortOptionsLabelsToFirst(options: CurrencyOptionItem[], query: string) {
|
|
493
|
+
return options.sort((first, second) => {
|
|
494
494
|
const firstContains = contains(first.label, query);
|
|
495
495
|
const secondContains = contains(second.label, query);
|
|
496
496
|
|
|
@@ -34,7 +34,7 @@ export interface PhoneNumberInputProps {
|
|
|
34
34
|
placeholder?: string;
|
|
35
35
|
selectProps?: Partial<SelectInputProps<string | null>>;
|
|
36
36
|
/** List of iso3 codes of countries to remove from the list */
|
|
37
|
-
disabledCountries?:
|
|
37
|
+
disabledCountries?: string[];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const defaultSelectProps = {} satisfies PhoneNumberInputProps['selectProps'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Country } from '../../data/countries';
|
|
2
2
|
|
|
3
3
|
// Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
|
|
4
|
-
const filterCountriesByIso3 = (countries:
|
|
4
|
+
const filterCountriesByIso3 = (countries: Country[], iso3Codes: string[]) => {
|
|
5
5
|
const iso3CodesSet = new Set(iso3Codes);
|
|
6
6
|
return countries.filter((country) => !iso3CodesSet.has(country.iso3));
|
|
7
7
|
};
|
|
@@ -12,10 +12,7 @@ const filterCountriesByIso3 = (countries: readonly Country[], iso3Codes: readonl
|
|
|
12
12
|
* @param countries list of country metadata objects
|
|
13
13
|
* @param disabledCountries list of iso3 country codes to remove from the list
|
|
14
14
|
*/
|
|
15
|
-
export const excludeCountries = (
|
|
16
|
-
countries: readonly Country[],
|
|
17
|
-
disabledCountries: readonly string[],
|
|
18
|
-
) => {
|
|
15
|
+
export const excludeCountries = (countries: Country[], disabledCountries: string[]) => {
|
|
19
16
|
return disabledCountries.length > 0
|
|
20
17
|
? filterCountriesByIso3(countries, disabledCountries)
|
|
21
18
|
: countries;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Country } from '../../data/countries';
|
|
2
2
|
|
|
3
|
-
export const groupCountriesByPrefix = (countries:
|
|
3
|
+
export const groupCountriesByPrefix = (countries: Country[]) => {
|
|
4
4
|
const countriesByPrefix = new Map<string, Country[]>();
|
|
5
5
|
countries.forEach((country) => {
|
|
6
6
|
countriesByPrefix.set(country.phone, [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Country } from '../../data/countries';
|
|
2
2
|
|
|
3
|
-
export const longestMatchingPrefix = (matchingCodes:
|
|
3
|
+
export const longestMatchingPrefix = (matchingCodes: Country[]) =>
|
|
4
4
|
matchingCodes.reduce((a, b) => (a.phone.length > b.phone.length ? a : b));
|
|
@@ -106,7 +106,7 @@ const PromoCardGroup: FunctionComponent<PromoCardGroupProps> = ({
|
|
|
106
106
|
setState(defaultChecked);
|
|
107
107
|
|
|
108
108
|
// Collect an array of types from the children PromoCard components
|
|
109
|
-
const types =
|
|
109
|
+
const types: ('radio' | 'checkbox')[] =
|
|
110
110
|
React.Children.map(children, (child) => {
|
|
111
111
|
if (React.isValidElement<PromoCardProps>(child) && child.props.type) {
|
|
112
112
|
return child.props.type;
|
|
@@ -5,7 +5,7 @@ import { RadioProps } from '../radio/Radio';
|
|
|
5
5
|
|
|
6
6
|
export interface RadioGroupProps<T extends string | number = string> {
|
|
7
7
|
name: string;
|
|
8
|
-
radios:
|
|
8
|
+
radios: Omit<RadioProps<T>, 'name' | 'checked' | 'onChange' | 'className'>[];
|
|
9
9
|
selectedValue?: T; // TODO: `NoInfer<T>` from TypeScript 5.4
|
|
10
10
|
onChange: NonNullable<RadioProps<T>['onChange']>;
|
|
11
11
|
}
|
|
@@ -9,7 +9,7 @@ type SegmentBase = { id: string; label: string; value: string };
|
|
|
9
9
|
type Segment = SegmentBase & { controls?: never };
|
|
10
10
|
type SegmentWithControls = SegmentBase & { controls: string };
|
|
11
11
|
|
|
12
|
-
export type Segments =
|
|
12
|
+
export type Segments = Segment[] | SegmentWithControls[];
|
|
13
13
|
|
|
14
14
|
type SegmentedControlPropsBase = {
|
|
15
15
|
name: string;
|
|
@@ -20,12 +20,12 @@ type SegmentedControlPropsBase = {
|
|
|
20
20
|
|
|
21
21
|
type SegmentedControlViewProps = {
|
|
22
22
|
mode: 'view';
|
|
23
|
-
segments:
|
|
23
|
+
segments: SegmentWithControls[];
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
type SegmentedControlInputProps = {
|
|
27
27
|
mode: 'input';
|
|
28
|
-
segments:
|
|
28
|
+
segments: Segment[];
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export type SegmentedControlProps = SegmentedControlPropsBase &
|
package/src/stepper/Stepper.tsx
CHANGED
|
@@ -43,16 +43,16 @@ export interface TypeaheadProps<T> {
|
|
|
43
43
|
allowNew?: boolean;
|
|
44
44
|
autoFillOnBlur?: boolean;
|
|
45
45
|
autoFocus?: boolean;
|
|
46
|
-
chipSeparators?:
|
|
46
|
+
chipSeparators?: string[];
|
|
47
47
|
clearable?: boolean;
|
|
48
48
|
footer?: ReactNode;
|
|
49
|
-
initialValue?:
|
|
49
|
+
initialValue?: TypeaheadOption<T>[];
|
|
50
50
|
inputAutoComplete?: string;
|
|
51
51
|
maxHeight?: number;
|
|
52
52
|
minQueryLength?: number;
|
|
53
53
|
placeholder?: string;
|
|
54
54
|
multiple?: boolean;
|
|
55
|
-
options:
|
|
55
|
+
options: TypeaheadOption<T>[];
|
|
56
56
|
searchDelay?: number;
|
|
57
57
|
showSuggestions?: boolean;
|
|
58
58
|
showNewEntry?: boolean;
|
|
@@ -67,7 +67,7 @@ export interface TypeaheadProps<T> {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
type TypeaheadState<T> = {
|
|
70
|
-
selected:
|
|
70
|
+
selected: TypeaheadOption<T>[];
|
|
71
71
|
keyboardFocusedOptionIndex: number | null;
|
|
72
72
|
errorState: boolean;
|
|
73
73
|
query: string;
|
|
@@ -311,12 +311,12 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
311
311
|
);
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
-
updateSelectedValue = (selected:
|
|
314
|
+
updateSelectedValue = (selected: TypeaheadOption<T>[]) => {
|
|
315
315
|
const { onChange, validateChip } = this.props;
|
|
316
316
|
|
|
317
317
|
const errorState = selected.some((chip) => !validateChip(chip));
|
|
318
318
|
this.setState({ selected, errorState }, () => {
|
|
319
|
-
onChange(
|
|
319
|
+
onChange(selected);
|
|
320
320
|
});
|
|
321
321
|
};
|
|
322
322
|
|
|
@@ -12,7 +12,7 @@ const DEFAULT_INPUT_MIN_WIDTH = 10;
|
|
|
12
12
|
export type TypeaheadInputProps<T> = {
|
|
13
13
|
typeaheadId: string;
|
|
14
14
|
value: string;
|
|
15
|
-
selected:
|
|
15
|
+
selected: TypeaheadOption<T>[];
|
|
16
16
|
optionsShown?: boolean;
|
|
17
17
|
autoComplete: string;
|
|
18
18
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
@@ -19,7 +19,7 @@ export type UploadInputProps = {
|
|
|
19
19
|
/**
|
|
20
20
|
* List of already existing, failed or in progress files
|
|
21
21
|
*/
|
|
22
|
-
files?:
|
|
22
|
+
files?: UploadedFile[];
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* The key of the file in the returned FormData object (default: file)
|
|
@@ -135,14 +135,14 @@ const UploadInput = ({
|
|
|
135
135
|
|
|
136
136
|
const PROGRESS_STATUSES = new Set([Status.PENDING, Status.PROCESSING]);
|
|
137
137
|
|
|
138
|
-
const [uploadedFiles, setUploadedFiles] = useState<
|
|
138
|
+
const [uploadedFiles, setUploadedFiles] = useState<UploadedFile[]>(
|
|
139
139
|
multiple || files.length === 0 ? files : [files[0]],
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
const uploadedFilesListReference = useRef(multiple || files.length === 0 ? files : [files[0]]);
|
|
143
143
|
|
|
144
144
|
function addFileToList(recentUploadedFile: UploadedFile) {
|
|
145
|
-
function addToList(listToAddTo:
|
|
145
|
+
function addToList(listToAddTo: UploadedFile[]) {
|
|
146
146
|
return [...listToAddTo, recentUploadedFile];
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -151,7 +151,7 @@ const UploadInput = ({
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
const removeFileFromList = (file: UploadedFile) => {
|
|
154
|
-
function filterOutFrom(listToFilterFrom:
|
|
154
|
+
function filterOutFrom(listToFilterFrom: UploadedFile[]) {
|
|
155
155
|
return listToFilterFrom.filter(
|
|
156
156
|
(fileInList) => file !== fileInList && file.id !== fileInList.id,
|
|
157
157
|
);
|
|
@@ -162,7 +162,7 @@ const UploadInput = ({
|
|
|
162
162
|
};
|
|
163
163
|
|
|
164
164
|
const modifyFileInList = (file: UploadedFile, updates: Partial<UploadedFile>) => {
|
|
165
|
-
const updateListItem = (listToUpdate:
|
|
165
|
+
const updateListItem = (listToUpdate: UploadedFile[]) =>
|
|
166
166
|
listToUpdate.map((fileInList) => {
|
|
167
167
|
return fileInList === file || fileInList.id === file.id
|
|
168
168
|
? { ...file, ...updates }
|
|
@@ -295,7 +295,7 @@ const UploadInput = ({
|
|
|
295
295
|
|
|
296
296
|
useEffect(() => {
|
|
297
297
|
if (onFilesChange && mounted) {
|
|
298
|
-
onFilesChange(
|
|
298
|
+
onFilesChange(uploadedFiles);
|
|
299
299
|
}
|
|
300
300
|
}, [onFilesChange, uploadedFiles]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
301
301
|
|
|
@@ -12,7 +12,7 @@ import MESSAGES from './UploadButton.messages';
|
|
|
12
12
|
import { DEFAULT_SIZE_LIMIT, imageFileTypes } from './defaults';
|
|
13
13
|
import getAllowedFileTypes from './getAllowedFileTypes';
|
|
14
14
|
|
|
15
|
-
type AllowedFileTypes = string |
|
|
15
|
+
type AllowedFileTypes = string | string[] | FileType[];
|
|
16
16
|
export type UploadButtonProps = {
|
|
17
17
|
/**
|
|
18
18
|
* Disable the upload button if your app is not yet ready to accept uploads
|
|
@@ -144,7 +144,9 @@ const UploadButton = ({
|
|
|
144
144
|
return fileTypes;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
return
|
|
147
|
+
return Array.isArray(fileTypes)
|
|
148
|
+
? getAllowedFileTypes(fileTypes).join(', ')
|
|
149
|
+
: getAllowedFileTypes([fileTypes]).join(', ');
|
|
148
150
|
};
|
|
149
151
|
|
|
150
152
|
function getDescription() {
|
|
@@ -163,18 +165,18 @@ const UploadButton = ({
|
|
|
163
165
|
});
|
|
164
166
|
}
|
|
165
167
|
|
|
166
|
-
function getAcceptedTypes()
|
|
168
|
+
function getAcceptedTypes() {
|
|
167
169
|
const areAllFilesAllowed = getFileTypesDescription() === '*';
|
|
168
170
|
|
|
169
171
|
if (areAllFilesAllowed) {
|
|
170
|
-
return
|
|
172
|
+
return null; //file input by default allows all files
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
if (Array.isArray(fileTypes)) {
|
|
174
176
|
return { accept: fileTypes.join(',') };
|
|
175
177
|
}
|
|
176
178
|
|
|
177
|
-
return { accept: fileTypes
|
|
179
|
+
return { accept: fileTypes };
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
function renderDescription() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileType } from '../../common';
|
|
2
2
|
|
|
3
|
-
const getAllowedFileTypes = (fileTypes:
|
|
3
|
+
const getAllowedFileTypes = (fileTypes: FileType[] | string[]): string[] =>
|
|
4
4
|
fileTypes.map((fileTypeDefinition: string) =>
|
|
5
5
|
fileTypeDefinition
|
|
6
6
|
.split(',')
|