@transferwise/components 46.140.1 → 46.142.0
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/avatarLayout/AvatarLayout.js +15 -1
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +15 -1
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +6 -2
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +6 -2
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/avatarView/Dot.js +8 -0
- package/build/avatarView/Dot.js.map +1 -1
- package/build/avatarView/Dot.mjs +8 -0
- package/build/avatarView/Dot.mjs.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.js +3 -4
- package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.mjs +4 -5
- package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
- package/build/button/LegacyButton.js.map +1 -1
- package/build/button/LegacyButton.mjs.map +1 -1
- package/build/common/circle/Circle.js +6 -2
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +6 -2
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/common/hooks/useHasIntersected/useHasIntersected.js +6 -4
- package/build/common/hooks/useHasIntersected/useHasIntersected.js.map +1 -1
- package/build/common/hooks/useHasIntersected/useHasIntersected.mjs +6 -4
- package/build/common/hooks/useHasIntersected/useHasIntersected.mjs.map +1 -1
- package/build/common/liveRegion/LiveRegion.js +4 -1
- package/build/common/liveRegion/LiveRegion.js.map +1 -1
- package/build/common/liveRegion/LiveRegion.mjs +4 -1
- package/build/common/liveRegion/LiveRegion.mjs.map +1 -1
- package/build/dateInput/DateInput.js +10 -10
- package/build/dateInput/DateInput.js.map +1 -1
- package/build/dateInput/DateInput.mjs +10 -10
- package/build/dateInput/DateInput.mjs.map +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.js +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.js.map +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs.map +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.js +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.js.map +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs.map +1 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.js.map +1 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs.map +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.js +18 -12
- package/build/expressiveMoneyInput/amountInput/AmountInput.js.map +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs +19 -13
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs.map +1 -1
- package/build/expressiveMoneyInput/hooks/useInputStyle.js +8 -6
- package/build/expressiveMoneyInput/hooks/useInputStyle.js.map +1 -1
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs +9 -7
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs.map +1 -1
- package/build/field/Field.js +63 -32
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.messages.js +14 -0
- package/build/field/Field.messages.js.map +1 -0
- package/build/field/Field.messages.mjs +10 -0
- package/build/field/Field.messages.mjs.map +1 -0
- package/build/field/Field.mjs +65 -34
- package/build/field/Field.mjs.map +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/header/Header.mjs.map +1 -1
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.js.map +1 -1
- package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.mjs.map +1 -1
- package/build/inputs/SelectInput/Options/SelectInputOptions.js +34 -22
- package/build/inputs/SelectInput/Options/SelectInputOptions.js.map +1 -1
- package/build/inputs/SelectInput/Options/SelectInputOptions.mjs +35 -23
- package/build/inputs/SelectInput/Options/SelectInputOptions.mjs.map +1 -1
- package/build/inputs/SelectInput/Popover/SelectInputPopover.js.map +1 -1
- package/build/inputs/SelectInput/Popover/SelectInputPopover.mjs.map +1 -1
- package/build/inputs/SelectInput/SelectInput.js +8 -6
- package/build/inputs/SelectInput/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput/SelectInput.mjs +9 -7
- package/build/inputs/SelectInput/SelectInput.mjs.map +1 -1
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -1
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -1
- package/build/inputs/TextArea.js +5 -0
- package/build/inputs/TextArea.js.map +1 -1
- package/build/inputs/TextArea.mjs +6 -1
- package/build/inputs/TextArea.mjs.map +1 -1
- package/build/inputs/contexts.js +16 -0
- package/build/inputs/contexts.js.map +1 -1
- package/build/inputs/contexts.mjs +16 -2
- package/build/inputs/contexts.mjs.map +1 -1
- package/build/main.css +42 -8
- package/build/nudge/Nudge.js +31 -15
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +32 -16
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.js +9 -12
- package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs +9 -12
- package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
- package/build/promoCard/PromoCardGroup.js +34 -16
- package/build/promoCard/PromoCardGroup.js.map +1 -1
- package/build/promoCard/PromoCardGroup.mjs +35 -17
- package/build/promoCard/PromoCardGroup.mjs.map +1 -1
- package/build/segmentedControl/SegmentedControl.js +6 -1
- package/build/segmentedControl/SegmentedControl.js.map +1 -1
- package/build/segmentedControl/SegmentedControl.mjs +7 -2
- package/build/segmentedControl/SegmentedControl.mjs.map +1 -1
- package/build/styles/avatarView/AvatarView.css +4 -4
- package/build/styles/avatarView/Dot.css +4 -4
- package/build/styles/css/neptune.css +15 -1
- package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +2 -0
- package/build/styles/expressiveMoneyInput/amountInput/AmountInput.css +2 -0
- package/build/styles/field/Field.css +19 -3
- package/build/styles/main.css +42 -8
- package/build/styles/styles/less/neptune.css +15 -1
- package/build/tabs/Tabs.js +1 -1
- package/build/tabs/Tabs.js.map +1 -1
- package/build/tabs/Tabs.mjs +1 -1
- package/build/tabs/Tabs.mjs.map +1 -1
- package/build/tooltip/Tooltip.js +6 -3
- package/build/tooltip/Tooltip.js.map +1 -1
- package/build/tooltip/Tooltip.mjs +6 -3
- package/build/tooltip/Tooltip.mjs.map +1 -1
- package/build/types/avatarView/AvatarView.d.ts +1 -1
- package/build/types/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/avatarView/Dot.d.ts.map +1 -1
- package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
- package/build/types/common/circle/Circle.d.ts +1 -1
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/build/types/common/hooks/useHasIntersected/useHasIntersected.d.ts.map +1 -1
- package/build/types/common/liveRegion/LiveRegion.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts +2 -2
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts.map +1 -1
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/field/Field.messages.d.ts +8 -0
- package/build/types/field/Field.messages.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.d.ts.map +1 -1
- package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts.map +1 -1
- package/build/types/inputs/SelectInput/Popover/SelectInputPopover.d.ts.map +1 -1
- package/build/types/inputs/SelectInput/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +6 -0
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/build/types/nudge/Nudge.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/promoCard/PromoCardGroup.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
- package/build/uploadInput/UploadInput.js +29 -25
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +29 -25
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/package.json +3 -3
- package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.tsx +4 -0
- package/src/avatarView/AvatarView.css +4 -4
- package/src/avatarView/AvatarView.story.tsx +17 -13
- package/src/avatarView/AvatarView.tsx +5 -1
- package/src/avatarView/Dot.css +4 -4
- package/src/avatarView/Dot.less +6 -6
- package/src/avatarView/Dot.tsx +2 -0
- package/src/avatarWrapper/AvatarWrapper.test.tsx +33 -3
- package/src/avatarWrapper/AvatarWrapper.tsx +5 -6
- package/src/button/LegacyButton.tsx +1 -1
- package/src/button/_stories/Button.test.story.tsx +3 -3
- package/src/common/circle/Circle.tsx +5 -1
- package/src/common/hooks/useContainerSize.test.tsx +1 -1
- package/src/common/hooks/useHasIntersected/useHasIntersected.ts +12 -4
- package/src/common/liveRegion/LiveRegion.tsx +5 -2
- package/src/dateInput/DateInput.tsx +10 -10
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.tsx +1 -5
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.tsx +1 -1
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +2 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.test.story.tsx +43 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.tsx +1 -1
- package/src/expressiveMoneyInput/amountInput/AmountInput.css +2 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.less +2 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.tsx +23 -16
- package/src/expressiveMoneyInput/hooks/useInputStyle.ts +20 -8
- package/src/expressiveMoneyInput/hooks/useSelectionRange.ts +2 -0
- package/src/field/Field.css +19 -3
- package/src/field/Field.less +17 -3
- package/src/field/Field.messages.ts +8 -0
- package/src/field/Field.story.tsx +5 -1
- package/src/field/Field.test.tsx +90 -0
- package/src/field/Field.tsx +84 -37
- package/src/header/Header.tsx +2 -2
- package/src/i18n/en.json +1 -0
- package/src/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.tsx +4 -0
- package/src/inputs/SelectInput/Options/SelectInputOptions.tsx +43 -27
- package/src/inputs/SelectInput/Popover/SelectInputPopover.tsx +4 -0
- package/src/inputs/SelectInput/SelectInput.tsx +21 -15
- package/src/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +1 -1
- package/src/inputs/TextArea.story.tsx +97 -0
- package/src/inputs/TextArea.test.story.tsx +142 -0
- package/src/inputs/TextArea.tsx +7 -2
- package/src/inputs/contexts.tsx +18 -1
- package/src/main.css +42 -8
- package/src/nudge/Nudge.tsx +29 -20
- package/src/phoneNumberInput/PhoneNumberInput.test.tsx +16 -0
- package/src/phoneNumberInput/PhoneNumberInput.tsx +11 -13
- package/src/promoCard/PromoCard.story.tsx +3 -3
- package/src/promoCard/PromoCardGroup.tsx +39 -21
- package/src/segmentedControl/SegmentedControl.test.tsx +25 -0
- package/src/segmentedControl/SegmentedControl.tsx +7 -1
- package/src/select/Select.story.tsx +1 -1
- package/src/styles/less/core/_typography.less +28 -6
- package/src/styles/less/neptune.css +15 -1
- package/src/tabs/Tabs.tsx +1 -1
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +1 -0
- package/src/tooltip/Tooltip.tsx +3 -0
- package/src/uploadInput/UploadInput.test.tsx +19 -0
- package/src/uploadInput/UploadInput.tsx +28 -24
|
@@ -170,10 +170,10 @@ const UploadInput = ({
|
|
|
170
170
|
const inputAttributes = useInputAttributes({ nonLabelable: true });
|
|
171
171
|
const [markedFileForDelete, setMarkedFileForDelete] = useState<UploadedFile | null>(null);
|
|
172
172
|
const [lastAttemptedDeleteId, setLastAttemptedDeleteId] = useState<string | number | null>(null);
|
|
173
|
-
const
|
|
173
|
+
const mountedRef = useRef(false);
|
|
174
174
|
const { formatMessage } = useIntl();
|
|
175
175
|
const uploadInputRef = useRef<HTMLInputElement | null>(null);
|
|
176
|
-
|
|
176
|
+
const fileRefs = useRef<(HTMLDivElement | UploadItemRef | null)[]>([]);
|
|
177
177
|
|
|
178
178
|
const PROGRESS_STATUSES = new Set([Status.PENDING, Status.PROCESSING]);
|
|
179
179
|
|
|
@@ -196,7 +196,7 @@ const UploadInput = ({
|
|
|
196
196
|
updateFileList((list) =>
|
|
197
197
|
list.filter((fileInList) => file !== fileInList && file.id !== fileInList.id),
|
|
198
198
|
);
|
|
199
|
-
fileRefs = fileRefs.filter((ref) => ref && ref.id !== file.id);
|
|
199
|
+
fileRefs.current = fileRefs.current.filter((ref) => ref && ref.id !== file.id);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
function modifyFileInList(file: UploadedFile, updates: Partial<UploadedFile>) {
|
|
@@ -208,18 +208,18 @@ const UploadInput = ({
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
const removeFile = async (file: UploadedFile) => {
|
|
211
|
-
const { id, status } = file;
|
|
212
|
-
fileRefs = fileRefs.filter((item) => item && item.id !== file.id);
|
|
211
|
+
const { id: fileId, status } = file;
|
|
212
|
+
fileRefs.current = fileRefs.current.filter((item) => item && item.id !== file.id);
|
|
213
213
|
|
|
214
214
|
if (status === Status.FAILED) {
|
|
215
215
|
removeFileFromList(file);
|
|
216
216
|
return Promise.resolve();
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
if (onDeleteFile &&
|
|
219
|
+
if (onDeleteFile && fileId) {
|
|
220
220
|
modifyFileInList(file, { status: Status.PROCESSING, error: undefined });
|
|
221
221
|
|
|
222
|
-
return onDeleteFile(
|
|
222
|
+
return onDeleteFile(fileId)
|
|
223
223
|
.then(() => {
|
|
224
224
|
removeFileFromList(file);
|
|
225
225
|
})
|
|
@@ -248,6 +248,7 @@ const UploadInput = ({
|
|
|
248
248
|
|
|
249
249
|
function getNumberOfFilesUploaded() {
|
|
250
250
|
const uploadInitiatedStatus = new Set([Status.SUCCEEDED, Status.PENDING]);
|
|
251
|
+
|
|
251
252
|
const validFiles = uploadedFilesListReference.current.filter(
|
|
252
253
|
(file) => file.status && uploadInitiatedStatus.has(file.status),
|
|
253
254
|
);
|
|
@@ -321,14 +322,16 @@ const UploadInput = ({
|
|
|
321
322
|
};
|
|
322
323
|
|
|
323
324
|
useEffect(() => {
|
|
324
|
-
|
|
325
|
-
|
|
325
|
+
// Skip onFilesChange call on initial mount, only call on updates
|
|
326
|
+
if (!mountedRef.current) {
|
|
327
|
+
mountedRef.current = true;
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
326
330
|
|
|
327
|
-
|
|
328
|
-
if (onFilesChange && mounted) {
|
|
331
|
+
if (onFilesChange) {
|
|
329
332
|
onFilesChange([...uploadedFiles]);
|
|
330
333
|
}
|
|
331
|
-
}, [onFilesChange, uploadedFiles]);
|
|
334
|
+
}, [onFilesChange, uploadedFiles]);
|
|
332
335
|
|
|
333
336
|
type NextFocusable =
|
|
334
337
|
| HTMLDivElement
|
|
@@ -336,14 +339,14 @@ const UploadInput = ({
|
|
|
336
339
|
| { ref: HTMLDivElement | UploadItemRef; target: 'button' | 'link' }
|
|
337
340
|
| null;
|
|
338
341
|
|
|
339
|
-
const [nextFocusable, setNextFocusable] = useState<NextFocusable>(
|
|
342
|
+
const [nextFocusable, setNextFocusable] = useState<NextFocusable>(null);
|
|
340
343
|
|
|
341
344
|
const handleFocus = (fileId: string | number) => {
|
|
342
|
-
fileRefs = fileRefs.filter((ref) => {
|
|
345
|
+
fileRefs.current = fileRefs.current.filter((ref) => {
|
|
343
346
|
return ref && ref.id !== markedFileForDelete?.id;
|
|
344
347
|
});
|
|
345
348
|
|
|
346
|
-
const filesCount = fileRefs.length;
|
|
349
|
+
const filesCount = fileRefs.current.length;
|
|
347
350
|
let next: UploadItemRef | HTMLDivElement | null = uploadInputRef.current;
|
|
348
351
|
let focusTarget: 'button' | 'link' = 'button';
|
|
349
352
|
|
|
@@ -355,15 +358,15 @@ const UploadInput = ({
|
|
|
355
358
|
}
|
|
356
359
|
|
|
357
360
|
if (filesCount > 1) {
|
|
358
|
-
const currentFileIndex = fileRefs.findIndex((file) => file?.id === fileId);
|
|
359
|
-
const currentFileId = fileRefs?.[currentFileIndex]?.id;
|
|
360
|
-
const lastFileId = fileRefs?.[filesCount - 1]?.id;
|
|
361
|
+
const currentFileIndex = fileRefs.current.findIndex((file) => file?.id === fileId);
|
|
362
|
+
const currentFileId = fileRefs.current?.[currentFileIndex]?.id;
|
|
363
|
+
const lastFileId = fileRefs.current?.[filesCount - 1]?.id;
|
|
361
364
|
|
|
362
365
|
// if last file, select a previous one
|
|
363
366
|
if (currentFileId === lastFileId) {
|
|
364
|
-
next = fileRefs[filesCount - 2];
|
|
367
|
+
next = fileRefs.current[filesCount - 2];
|
|
365
368
|
} else {
|
|
366
|
-
next = fileRefs[currentFileIndex + 1];
|
|
369
|
+
next = fileRefs.current[currentFileIndex + 1];
|
|
367
370
|
}
|
|
368
371
|
|
|
369
372
|
// If next is an UploadItemRef, check if it has a URL (succeeded)
|
|
@@ -401,7 +404,7 @@ const UploadInput = ({
|
|
|
401
404
|
typeof uploadInputRef.current.focus === 'function'
|
|
402
405
|
) {
|
|
403
406
|
setTimeout(() => {
|
|
404
|
-
uploadInputRef.current
|
|
407
|
+
uploadInputRef.current?.focus();
|
|
405
408
|
}, 0);
|
|
406
409
|
} else if (
|
|
407
410
|
typeof focusTarget === 'object' &&
|
|
@@ -436,17 +439,17 @@ const UploadInput = ({
|
|
|
436
439
|
aria-relevant="all"
|
|
437
440
|
role="region"
|
|
438
441
|
>
|
|
439
|
-
{uploadedFiles.map((file
|
|
442
|
+
{uploadedFiles.map((file) => (
|
|
440
443
|
<UploadItem
|
|
441
444
|
key={file.id}
|
|
442
445
|
ref={(el: UploadItemRef | null) => {
|
|
443
446
|
if (
|
|
444
447
|
el &&
|
|
445
448
|
el.id !== markedFileForDelete?.id &&
|
|
446
|
-
!fileRefs.some((ref) => ref
|
|
449
|
+
!fileRefs.current.some((ref) => ref?.id === el.id) &&
|
|
447
450
|
el.status !== 'processing'
|
|
448
451
|
) {
|
|
449
|
-
fileRefs.push(el);
|
|
452
|
+
fileRefs.current.push(el);
|
|
450
453
|
}
|
|
451
454
|
}}
|
|
452
455
|
file={file}
|
|
@@ -478,6 +481,7 @@ const UploadInput = ({
|
|
|
478
481
|
ref={uploadInputRef}
|
|
479
482
|
id={id}
|
|
480
483
|
uploadButtonTitle={uploadButtonTitle}
|
|
484
|
+
// eslint-disable-next-line react-hooks/refs -- Function reads ref for file count check
|
|
481
485
|
disabled={areMaximumFilesUploadedAlready() || disabled}
|
|
482
486
|
multiple={multiple}
|
|
483
487
|
fileTypes={fileTypes}
|