@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.
Files changed (74) hide show
  1. package/build/alert/Alert.js +1 -1
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +1 -1
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/chips/Chip.js +3 -11
  6. package/build/chips/Chip.js.map +1 -1
  7. package/build/chips/Chip.mjs +3 -11
  8. package/build/chips/Chip.mjs.map +1 -1
  9. package/build/field/Field.js +6 -3
  10. package/build/field/Field.js.map +1 -1
  11. package/build/field/Field.mjs +6 -3
  12. package/build/field/Field.mjs.map +1 -1
  13. package/build/inlineAlert/InlineAlert.js +1 -7
  14. package/build/inlineAlert/InlineAlert.js.map +1 -1
  15. package/build/inlineAlert/InlineAlert.mjs +1 -7
  16. package/build/inlineAlert/InlineAlert.mjs.map +1 -1
  17. package/build/main.css +9 -1
  18. package/build/progressBar/ProgressBar.js +1 -5
  19. package/build/progressBar/ProgressBar.js.map +1 -1
  20. package/build/progressBar/ProgressBar.mjs +1 -5
  21. package/build/progressBar/ProgressBar.mjs.map +1 -1
  22. package/build/select/Select.js +1 -7
  23. package/build/select/Select.js.map +1 -1
  24. package/build/select/Select.mjs +1 -7
  25. package/build/select/Select.mjs.map +1 -1
  26. package/build/styles/field/Field.css +5 -1
  27. package/build/styles/main.css +9 -1
  28. package/build/styles/typeahead/Typeahead.css +4 -0
  29. package/build/typeahead/Typeahead.js +18 -6
  30. package/build/typeahead/Typeahead.js.map +1 -1
  31. package/build/typeahead/Typeahead.mjs +18 -6
  32. package/build/typeahead/Typeahead.mjs.map +1 -1
  33. package/build/types/alert/Alert.d.ts +1 -1
  34. package/build/types/alert/Alert.d.ts.map +1 -1
  35. package/build/types/chips/Chip.d.ts.map +1 -1
  36. package/build/types/field/Field.d.ts +8 -4
  37. package/build/types/field/Field.d.ts.map +1 -1
  38. package/build/types/inlineAlert/InlineAlert.d.ts +1 -7
  39. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  40. package/build/types/progressBar/ProgressBar.d.ts.map +1 -1
  41. package/build/types/select/Select.d.ts.map +1 -1
  42. package/build/types/typeahead/Typeahead.d.ts +4 -4
  43. package/build/types/typeahead/Typeahead.d.ts.map +1 -1
  44. package/build/types/upload/Upload.d.ts +1 -1
  45. package/build/upload/Upload.js.map +1 -1
  46. package/build/upload/Upload.mjs.map +1 -1
  47. package/build/upload/steps/uploadImageStep/uploadImageStep.js +3 -3
  48. package/build/upload/steps/uploadImageStep/uploadImageStep.js.map +1 -1
  49. package/build/upload/steps/uploadImageStep/uploadImageStep.mjs +3 -3
  50. package/build/upload/steps/uploadImageStep/uploadImageStep.mjs.map +1 -1
  51. package/package.json +3 -3
  52. package/src/alert/Alert.spec.tsx +1 -1
  53. package/src/alert/Alert.tsx +2 -2
  54. package/src/chips/Chip.tsx +5 -14
  55. package/src/chips/__snapshots__/Chips.spec.tsx.snap +31 -29
  56. package/src/field/Field.css +5 -1
  57. package/src/field/Field.less +7 -2
  58. package/src/field/Field.spec.tsx +19 -3
  59. package/src/field/Field.story.tsx +18 -0
  60. package/src/field/Field.tsx +16 -5
  61. package/src/inlineAlert/InlineAlert.story.tsx +4 -0
  62. package/src/inlineAlert/InlineAlert.tsx +1 -7
  63. package/src/main.css +9 -1
  64. package/src/progressBar/ProgressBar.tsx +1 -6
  65. package/src/select/Select.tsx +1 -2
  66. package/src/typeahead/Typeahead.css +4 -0
  67. package/src/typeahead/Typeahead.less +5 -1
  68. package/src/typeahead/Typeahead.spec.tsx +1 -1
  69. package/src/typeahead/Typeahead.story.tsx +80 -3
  70. package/src/typeahead/Typeahead.tsx +28 -8
  71. package/src/upload/Upload.story.tsx +1 -1
  72. package/src/upload/Upload.tests.story.tsx +36 -1
  73. package/src/upload/Upload.tsx +1 -1
  74. 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' }}>
@@ -55,7 +55,7 @@ export interface UploadProps extends WrappedComponentProps {
55
55
  usLabel?: string;
56
56
  usPlaceholder?: string;
57
57
  /**
58
- * Override for the [InlineAlert icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)
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 InlineAlert from '../../../inlineAlert';
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
- <InlineAlert type={Sentiment.NEGATIVE} iconLabel={errorIconLabel}>
108
+ <InlinePrompt sentiment={Sentiment.NEGATIVE} iconLabel={errorIconLabel}>
109
109
  {errorMessage}
110
- </InlineAlert>
110
+ </InlinePrompt>
111
111
  </div>
112
112
  </div>
113
113
  )}