@transferwise/components 0.0.0-experimental-c8d90fc → 0.0.0-experimental-2118b34
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/alert/Alert.js +1 -1
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +1 -1
- package/build/alert/Alert.mjs.map +1 -1
- package/build/chips/Chip.js +3 -11
- package/build/chips/Chip.js.map +1 -1
- package/build/chips/Chip.mjs +3 -11
- package/build/chips/Chip.mjs.map +1 -1
- package/build/field/Field.js +6 -3
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +6 -3
- package/build/field/Field.mjs.map +1 -1
- package/build/inlineAlert/InlineAlert.js +1 -7
- package/build/inlineAlert/InlineAlert.js.map +1 -1
- package/build/inlineAlert/InlineAlert.mjs +1 -7
- package/build/inlineAlert/InlineAlert.mjs.map +1 -1
- package/build/main.css +9 -1
- package/build/progressBar/ProgressBar.js +1 -5
- package/build/progressBar/ProgressBar.js.map +1 -1
- package/build/progressBar/ProgressBar.mjs +1 -5
- package/build/progressBar/ProgressBar.mjs.map +1 -1
- package/build/select/Select.js +1 -7
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -7
- package/build/select/Select.mjs.map +1 -1
- package/build/styles/field/Field.css +5 -1
- package/build/styles/main.css +9 -1
- package/build/styles/typeahead/Typeahead.css +4 -0
- package/build/typeahead/Typeahead.js +18 -6
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +18 -6
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/alert/Alert.d.ts +1 -1
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/chips/Chip.d.ts.map +1 -1
- package/build/types/field/Field.d.ts +8 -4
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts +1 -7
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/build/types/progressBar/ProgressBar.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +4 -4
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/upload/Upload.d.ts +1 -1
- package/build/upload/Upload.js.map +1 -1
- package/build/upload/Upload.mjs.map +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.js +3 -3
- package/build/upload/steps/uploadImageStep/uploadImageStep.js.map +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.mjs +3 -3
- package/build/upload/steps/uploadImageStep/uploadImageStep.mjs.map +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.spec.tsx +1 -1
- package/src/alert/Alert.tsx +2 -2
- package/src/chips/Chip.tsx +5 -14
- package/src/chips/__snapshots__/Chips.spec.tsx.snap +31 -29
- package/src/field/Field.css +5 -1
- package/src/field/Field.less +7 -2
- package/src/field/Field.spec.tsx +19 -3
- package/src/field/Field.story.tsx +18 -0
- package/src/field/Field.tsx +16 -5
- package/src/inlineAlert/InlineAlert.story.tsx +4 -0
- package/src/inlineAlert/InlineAlert.tsx +1 -7
- package/src/main.css +9 -1
- package/src/progressBar/ProgressBar.tsx +1 -6
- package/src/select/Select.tsx +1 -2
- package/src/typeahead/Typeahead.css +4 -0
- package/src/typeahead/Typeahead.less +5 -1
- package/src/typeahead/Typeahead.spec.tsx +1 -1
- package/src/typeahead/Typeahead.story.tsx +80 -3
- package/src/typeahead/Typeahead.tsx +28 -8
- package/src/upload/Upload.story.tsx +1 -1
- package/src/upload/Upload.tests.story.tsx +36 -1
- package/src/upload/Upload.tsx +1 -1
- package/src/upload/steps/uploadImageStep/uploadImageStep.tsx +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Meta } from '@storybook/react-webpack5';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { userEvent, within, waitFor } from 'storybook/test';
|
|
2
3
|
|
|
3
4
|
import Upload from '.';
|
|
4
5
|
import { Field } from '../field/Field';
|
|
@@ -73,6 +74,40 @@ export const MaxSizes = () => {
|
|
|
73
74
|
);
|
|
74
75
|
};
|
|
75
76
|
|
|
77
|
+
export const WithError: StoryObj<typeof meta> = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<Field label="Upload a file">
|
|
80
|
+
<Upload
|
|
81
|
+
usAccept="*"
|
|
82
|
+
usLabel="Upload a file"
|
|
83
|
+
usPlaceholder="Maximum filesize is 1B"
|
|
84
|
+
usDisabled={false}
|
|
85
|
+
maxSize={1}
|
|
86
|
+
errorIconLabel="File too large error"
|
|
87
|
+
httpOptions={{
|
|
88
|
+
url: 'https://httpbin.org/post',
|
|
89
|
+
method: 'POST',
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
</Field>
|
|
93
|
+
),
|
|
94
|
+
play: async ({ canvasElement }) => {
|
|
95
|
+
const canvas = within(canvasElement);
|
|
96
|
+
const fileInput = canvasElement.querySelector<HTMLInputElement>('input[type="file"]');
|
|
97
|
+
|
|
98
|
+
if (!fileInput) {
|
|
99
|
+
throw new Error('File input not found');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const file = new File(['This file content is definitely more than 1 byte'], 'test-file.txt', {
|
|
103
|
+
type: 'text/plain',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
await userEvent.upload(fileInput, file);
|
|
107
|
+
await waitFor(async () => canvas.findByText(/Maximum filesize is/i), { timeout: 3000 });
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
76
111
|
export const AllVariants = () => {
|
|
77
112
|
return (
|
|
78
113
|
<div style={{ display: 'flex', gap: '1rem' }}>
|
package/src/upload/Upload.tsx
CHANGED
|
@@ -55,7 +55,7 @@ export interface UploadProps extends WrappedComponentProps {
|
|
|
55
55
|
usLabel?: string;
|
|
56
56
|
usPlaceholder?: string;
|
|
57
57
|
/**
|
|
58
|
-
* Override for the [
|
|
58
|
+
* Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)
|
|
59
59
|
* announced by the screen readers
|
|
60
60
|
* */
|
|
61
61
|
errorIconLabel?: string;
|
|
@@ -2,7 +2,7 @@ import { Upload as UploadIcon } from '@transferwise/icons';
|
|
|
2
2
|
import { createRef, PureComponent } from 'react';
|
|
3
3
|
import StatusIcon from '../../../statusIcon';
|
|
4
4
|
import { Sentiment, Size } from '../../../common';
|
|
5
|
-
import
|
|
5
|
+
import { InlinePrompt } from '../../../prompt/InlinePrompt/InlinePrompt';
|
|
6
6
|
|
|
7
7
|
export interface UploadImageStepProps {
|
|
8
8
|
fileDropped: (file: File) => void;
|
|
@@ -105,9 +105,9 @@ export default class UploadImageStep extends PureComponent<UploadImageStepProps>
|
|
|
105
105
|
{errorMessage && (
|
|
106
106
|
<div className="upload-error-message">
|
|
107
107
|
<div className="m-t-3 has-error">
|
|
108
|
-
<
|
|
108
|
+
<InlinePrompt sentiment={Sentiment.NEGATIVE} iconLabel={errorIconLabel}>
|
|
109
109
|
{errorMessage}
|
|
110
|
-
</
|
|
110
|
+
</InlinePrompt>
|
|
111
111
|
</div>
|
|
112
112
|
</div>
|
|
113
113
|
)}
|