@transferwise/components 0.0.0-experimental-cb7b730 → 0.0.0-experimental-9463364
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/dateLookup/DateLookup.js +3 -2
- package/build/dateLookup/DateLookup.js.map +1 -1
- package/build/dateLookup/DateLookup.mjs +3 -2
- package/build/dateLookup/DateLookup.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/main.css +4 -95
- package/build/styles/accordion/Accordion.css +27 -16
- package/build/styles/avatar/Avatar.css +95 -50
- package/build/styles/dimmer/Dimmer.css +0 -1
- package/build/styles/inputs/Input.css +37 -21
- package/build/styles/inputs/TextArea.css +35 -20
- package/build/styles/loader/Loader.css +4 -90
- package/build/styles/main.css +4 -95
- package/build/styles/popover/Popover.css +19 -12
- package/build/styles/select/Select.css +131 -68
- package/build/styles/switch/Switch.css +27 -16
- package/build/styles/tile/Tile.css +31 -18
- package/build/types/dateLookup/DateLookup.d.ts +2 -2
- package/build/types/dateLookup/DateLookup.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/test-utils/story-config.d.ts +2 -3
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/build/types/upload/Upload.d.ts.map +1 -1
- package/build/types/upload/Upload.messages.d.ts +4 -0
- package/build/types/upload/Upload.messages.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/build/upload/Upload.js +13 -3
- package/build/upload/Upload.js.map +1 -1
- package/build/upload/Upload.messages.js +3 -0
- package/build/upload/Upload.messages.js.map +1 -1
- package/build/upload/Upload.messages.mjs +3 -0
- package/build/upload/Upload.messages.mjs.map +1 -1
- package/build/upload/Upload.mjs +13 -3
- package/build/upload/Upload.mjs.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.js +3 -0
- package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.mjs +3 -0
- package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
- package/package.json +8 -16
- package/src/accordion/Accordion.css +27 -16
- package/src/accordion/Accordion.story.tsx +1 -1
- package/src/actionButton/ActionButton.story.tsx +3 -2
- package/src/actionOption/ActionOption.story.tsx +2 -2
- package/src/alert/Alert.story.tsx +2 -2
- package/src/alert/Alert.tests.story.tsx +2 -2
- package/src/avatar/Avatar.css +95 -50
- package/src/avatar/Avatar.story.tsx +3 -2
- package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
- package/src/avatarView/AvatarView.story.tsx +1 -1
- package/src/avatarWrapper/AvatarWrapper.story.tsx +3 -2
- package/src/badge/Badge.story.tsx +49 -28
- package/src/button/Button.accessibility.docs.mdx +1 -1
- package/src/button/Button.story.tsx +2 -2
- package/src/button/Button.tests.story.tsx +2 -2
- package/src/button/LegacyButton.story.tsx +3 -2
- package/src/card/Card.story.tsx +2 -2
- package/src/carousel/Carousel.story.tsx +1 -1
- package/src/checkbox/Checkbox.story.tsx +2 -2
- package/src/checkboxButton/CheckboxButton.story.tsx +2 -2
- package/src/checkboxOption/CheckboxOption.story.tsx +35 -29
- package/src/chevron/Chevron.story.tsx +1 -1
- package/src/chips/Chips.story.tsx +1 -1
- package/src/circularButton/CircularButton.story.tsx +1 -1
- package/src/circularButton/CircularButton.tests.story.tsx +1 -1
- package/src/common/bottomSheet/BottomSheet.story.tsx +2 -2
- package/src/common/card/Card.story.tsx +1 -1
- package/src/common/circle/Circle.story.tsx +2 -2
- package/src/common/responsivePanel/ResponsivePanel.spec.js +8 -29
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +1 -1
- package/src/dateInput/DateInput.story.tsx +2 -2
- package/src/dateInput/DateInput.tests.story.tsx +2 -2
- package/src/dateLookup/DateLookup.story.tsx +43 -71
- package/src/dateLookup/DateLookup.tests.story.tsx +3 -3
- package/src/dateLookup/DateLookup.tsx +4 -1
- package/src/decision/Decision.story.tsx +24 -49
- package/src/definitionList/DefinitionList.story.tsx +1 -1
- package/src/dimmer/Dimmer.css +0 -1
- package/src/dimmer/Dimmer.less +0 -1
- package/src/dimmer/Dimmer.story.tsx +2 -2
- package/src/divider/Divider.accessibility.docs.mdx +1 -1
- package/src/divider/Divider.story.tsx +1 -1
- package/src/drawer/Drawer.story.tsx +13 -7
- package/src/dropFade/DropFade.story.tsx +1 -1
- package/src/emphasis/Emphasis.story.tsx +1 -1
- package/src/field/Field.story.tsx +3 -3
- package/src/flowNavigation/FlowNavigation.story.tsx +305 -260
- package/src/i18n/en.json +1 -0
- package/src/iconButton/IconButton.story.tsx +2 -2
- package/src/image/Image.story.tsx +27 -54
- package/src/info/Info.story.tsx +2 -2
- package/src/inlineAlert/InlineAlert.story.tsx +1 -1
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +2 -2
- package/src/inputs/Input.css +37 -21
- package/src/inputs/InputGroup.story.tsx +1 -1
- package/src/inputs/SearchInput.story.tsx +1 -1
- package/src/inputs/SelectInput.docs.mdx +1 -1
- package/src/inputs/SelectInput.story.tsx +2 -2
- package/src/inputs/TextArea.css +35 -20
- package/src/instructionsList/InstructionsList.story.tsx +2 -2
- package/src/legacylistItem/LegacyListItem.story.tsx +1 -1
- package/src/loader/Loader.css +4 -90
- package/src/loader/Loader.story.tsx +1 -1
- package/src/logo/Logo.story.tsx +1 -1
- package/src/main.css +4 -95
- package/src/markdown/Markdown.story.tsx +1 -1
- package/src/modal/Modal.story.tsx +2 -2
- package/src/money/Money.story.tsx +1 -1
- package/src/moneyInput/MoneyInput.docs.mdx +1 -1
- package/src/moneyInput/MoneyInput.story.tsx +2 -2
- package/src/navigationOption/NavigationOption.story.tsx +265 -226
- package/src/nudge/Nudge.story.tsx +1 -1
- package/src/overlayHeader/OverlayHeader.story.tsx +32 -24
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -1
- package/src/popover/Popover.css +19 -12
- package/src/popover/Popover.story.tsx +2 -2
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +2 -2
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +2 -2
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +2 -2
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +2 -2
- package/src/processIndicator/ProcessIndicator.story.tsx +1 -1
- package/src/progress/Progress.story.tsx +1 -1
- package/src/progressBar/ProgressBar.story.tsx +1 -1
- package/src/promoCard/PromoCard.story.tsx +1 -1
- package/src/promoCard/PromoCardGroup.story.tsx +1 -1
- package/src/provider/Provider.story.tsx +1 -1
- package/src/provider/theme/ThemeProvider.story.tsx +1 -1
- package/src/radio/Radio.story.tsx +59 -42
- package/src/radioGroup/RadioGroup.story.tsx +2 -2
- package/src/radioOption/RadioOption.story.tsx +73 -38
- package/src/segmentedControl/SegmentedControl.story.tsx +1 -1
- package/src/select/Select.css +131 -68
- package/src/select/Select.story.tsx +385 -397
- package/src/slidingPanel/SlidingPanel.story.tsx +30 -13
- package/src/snackbar/Snackbar.story.tsx +50 -36
- package/src/snackbar/Snackbar.tests.story.tsx +3 -2
- package/src/statusIcon/StatusIcon.docs.mdx +1 -1
- package/src/statusIcon/StatusIcon.story.tsx +1 -1
- package/src/stepper/Stepper.story.tsx +2 -2
- package/src/stepper/Stepper.tests.story.tsx +2 -2
- package/src/sticky/Sticky.story.tsx +1 -1
- package/src/summary/Summary.story.tsx +18 -17
- package/src/switch/Switch.css +27 -16
- package/src/switch/Switch.story.tsx +2 -2
- package/src/switchOption/SwitchOption.story.tsx +1 -1
- package/src/table/Table.story.tsx +1 -1
- package/src/test-utils/story-config.ts +9 -6
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +2 -2
- package/src/tile/Tile.css +31 -18
- package/src/tile/Tile.story.tsx +43 -43
- package/src/tooltip/Tooltip.story.tsx +2 -2
- package/src/typeahead/Typeahead.story.tsx +2 -2
- package/src/upload/Upload.messages.ts +4 -0
- package/src/upload/Upload.spec.tsx +6 -0
- package/src/upload/Upload.story.tsx +2 -2
- package/src/upload/Upload.tests.story.tsx +2 -2
- package/src/upload/Upload.tsx +17 -5
- package/src/uploadInput/UploadInput.story.tsx +1 -1
- package/src/uploadInput/UploadInput.tests.story.tsx +3 -3
- package/src/uploadInput/uploadButton/UploadButton.spec.tsx +6 -0
- package/src/uploadInput/uploadButton/UploadButton.tsx +4 -0
- package/src/withId/withId.docs.mdx +1 -1
- package/src/withId/withId.story.tsx +1 -1
- package/src/common/responsivePanel/__snapshots__/ResponsivePanel.spec.js.snap +0 -21
|
@@ -355,4 +355,10 @@ describe('Upload Component', () => {
|
|
|
355
355
|
expect(container.querySelector('.droppable-processing')).not.toBeInTheDocument();
|
|
356
356
|
expect(props.onStart).not.toHaveBeenCalled();
|
|
357
357
|
});
|
|
358
|
+
|
|
359
|
+
test('should handle when maxSize is the MAX_SAFE_INTEGER', async () => {
|
|
360
|
+
render(<Upload {...props} usPlaceholder={undefined} maxSize={Number.MAX_SAFE_INTEGER} />);
|
|
361
|
+
expect(await screen.findByText(/Drag and drop a file/i)).toBeInTheDocument();
|
|
362
|
+
expect(screen.queryByText(/less than/i)).not.toBeInTheDocument();
|
|
363
|
+
});
|
|
358
364
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { fn } from '
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn } from 'storybook/test';
|
|
3
3
|
|
|
4
4
|
import Upload from '.';
|
|
5
5
|
import { MAX_SIZE_DEFAULT } from './Upload';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { fn } from '
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn } from 'storybook/test';
|
|
3
3
|
|
|
4
4
|
import Upload from '.';
|
|
5
5
|
import { MAX_SIZE_DEFAULT } from './Upload';
|
package/src/upload/Upload.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import messages from './Upload.messages';
|
|
|
10
10
|
import { UploadImageStep, ProcessingStep, CompleteStep } from './steps';
|
|
11
11
|
import { postData, asyncFileRead, isSizeValid, isTypeValid, getFileType } from './utils';
|
|
12
12
|
import { PostDataFetcher, PostDataHTTPOptions, ResponseError } from './utils/postData/postData';
|
|
13
|
-
import { ProcessIndicatorStatus } from '../processIndicator';
|
|
14
13
|
|
|
15
14
|
export const MAX_SIZE_DEFAULT = 5000000;
|
|
16
15
|
|
|
@@ -344,6 +343,8 @@ export class Upload extends Component<UploadProps, UploadState> {
|
|
|
344
343
|
uploadedImage,
|
|
345
344
|
} = this.state;
|
|
346
345
|
|
|
346
|
+
const placeholder = getPlaceholder(intl, usPlaceholder, maxSize);
|
|
347
|
+
|
|
347
348
|
return (
|
|
348
349
|
<div
|
|
349
350
|
className={clsx('droppable-area', {
|
|
@@ -370,10 +371,7 @@ export class Upload extends Component<UploadProps, UploadState> {
|
|
|
370
371
|
usDisabled={usDisabled}
|
|
371
372
|
usHelpImage={usHelpImage}
|
|
372
373
|
usLabel={usLabel}
|
|
373
|
-
usPlaceholder={
|
|
374
|
-
usPlaceholder ||
|
|
375
|
-
intl.formatMessage(messages.usPlaceholder, { maxSize: roundFileSize(maxSize) })
|
|
376
|
-
}
|
|
374
|
+
usPlaceholder={placeholder}
|
|
377
375
|
/>
|
|
378
376
|
)}
|
|
379
377
|
|
|
@@ -456,3 +454,17 @@ const roundFileSize = (bytes: number) => {
|
|
|
456
454
|
}
|
|
457
455
|
return megabytes.toFixed(3);
|
|
458
456
|
};
|
|
457
|
+
|
|
458
|
+
const getPlaceholder = (
|
|
459
|
+
intl: WrappedComponentProps['intl'],
|
|
460
|
+
usPlaceholder: string | undefined,
|
|
461
|
+
maxSize: number,
|
|
462
|
+
): string => {
|
|
463
|
+
if (usPlaceholder) {
|
|
464
|
+
return usPlaceholder;
|
|
465
|
+
}
|
|
466
|
+
if (maxSize >= Number.MAX_SAFE_INTEGER) {
|
|
467
|
+
return intl.formatMessage(messages.usPlaceholderNoLimit);
|
|
468
|
+
}
|
|
469
|
+
return intl.formatMessage(messages.usPlaceholder, { maxSize: roundFileSize(maxSize) });
|
|
470
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { action } from '
|
|
2
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { action } from 'storybook/actions';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
3
|
|
|
4
4
|
import { Status } from '../common';
|
|
5
5
|
import UploadInput, { UploadInputProps } from './UploadInput';
|
|
6
6
|
import { UploadedFile, UploadResponse } from './types';
|
|
7
|
-
import { userEvent } from '
|
|
7
|
+
import { userEvent } from 'storybook/test';
|
|
8
8
|
|
|
9
9
|
const meta: Meta<typeof UploadInput> = {
|
|
10
10
|
title: 'Forms/UploadInput/Tests',
|
|
@@ -96,6 +96,12 @@ describe('UploadButton', () => {
|
|
|
96
96
|
expect(screen.getByText('All file types, less than 5MB')).toBeInTheDocument();
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
it('should show no file size limit if sizeLimit is set to Number.MAX_SAFE_INTEGER', () => {
|
|
100
|
+
renderComponent({ ...props, fileTypes: ['*'], sizeLimit: Number.MAX_SAFE_INTEGER });
|
|
101
|
+
expect(screen.getByText('All file types')).toBeInTheDocument();
|
|
102
|
+
expect(screen.queryByText(/less than/i)).not.toBeInTheDocument();
|
|
103
|
+
});
|
|
104
|
+
|
|
99
105
|
it('should show custom description if provided', () => {
|
|
100
106
|
const description = 'Test description';
|
|
101
107
|
renderComponent({ ...props, fileTypes: ['*'], description });
|
|
@@ -173,6 +173,10 @@ const UploadButton = forwardRef<HTMLInputElement | null, UploadButtonProps>(
|
|
|
173
173
|
const derivedFileDescription =
|
|
174
174
|
fileTypesDescription === '*' ? formatMessage(MESSAGES.allFileTypes) : fileTypesDescription;
|
|
175
175
|
|
|
176
|
+
if (sizeLimit >= Number.MAX_SAFE_INTEGER) {
|
|
177
|
+
return derivedFileDescription;
|
|
178
|
+
}
|
|
179
|
+
|
|
176
180
|
return formatMessage(MESSAGES.instructions, {
|
|
177
181
|
fileTypes: derivedFileDescription,
|
|
178
182
|
size: Math.round(sizeLimit / 1000),
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`ResponsivePanel on desktop renders Panel 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="np-panel np-panel--open"
|
|
7
|
-
>
|
|
8
|
-
children
|
|
9
|
-
</div>
|
|
10
|
-
</div>
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
exports[`ResponsivePanel on mobile renders bottomSheet 1`] = `
|
|
14
|
-
<div>
|
|
15
|
-
<div
|
|
16
|
-
class="np-bottom-sheet"
|
|
17
|
-
>
|
|
18
|
-
children
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
`;
|