@transferwise/components 0.0.0-experimental-faee41b → 0.0.0-experimental-96d193a

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 (112) hide show
  1. package/build/alert/Alert.js +3 -1
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +3 -1
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/dimmer/Dimmer.js +1 -3
  6. package/build/dimmer/Dimmer.js.map +1 -1
  7. package/build/dimmer/Dimmer.mjs +1 -3
  8. package/build/dimmer/Dimmer.mjs.map +1 -1
  9. package/build/drawer/Drawer.js +0 -2
  10. package/build/drawer/Drawer.js.map +1 -1
  11. package/build/drawer/Drawer.mjs +0 -2
  12. package/build/drawer/Drawer.mjs.map +1 -1
  13. package/build/field/Field.js +2 -0
  14. package/build/field/Field.js.map +1 -1
  15. package/build/field/Field.mjs +2 -0
  16. package/build/field/Field.mjs.map +1 -1
  17. package/build/i18n/en.json +5 -0
  18. package/build/i18n/en.json.js +5 -0
  19. package/build/i18n/en.json.js.map +1 -1
  20. package/build/i18n/en.json.mjs +5 -0
  21. package/build/i18n/en.json.mjs.map +1 -1
  22. package/build/inlineAlert/InlineAlert.js +3 -1
  23. package/build/inlineAlert/InlineAlert.js.map +1 -1
  24. package/build/inlineAlert/InlineAlert.mjs +3 -1
  25. package/build/inlineAlert/InlineAlert.mjs.map +1 -1
  26. package/build/modal/Modal.js +0 -3
  27. package/build/modal/Modal.js.map +1 -1
  28. package/build/modal/Modal.mjs +0 -3
  29. package/build/modal/Modal.mjs.map +1 -1
  30. package/build/statusIcon/StatusIcon.js +50 -16
  31. package/build/statusIcon/StatusIcon.js.map +1 -1
  32. package/build/statusIcon/StatusIcon.messages.js +24 -0
  33. package/build/statusIcon/StatusIcon.messages.js.map +1 -0
  34. package/build/statusIcon/StatusIcon.messages.mjs +22 -0
  35. package/build/statusIcon/StatusIcon.messages.mjs.map +1 -0
  36. package/build/statusIcon/StatusIcon.mjs +48 -14
  37. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  38. package/build/types/alert/Alert.d.ts +6 -1
  39. package/build/types/alert/Alert.d.ts.map +1 -1
  40. package/build/types/dimmer/Dimmer.d.ts +1 -2
  41. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  42. package/build/types/drawer/Drawer.d.ts +1 -2
  43. package/build/types/drawer/Drawer.d.ts.map +1 -1
  44. package/build/types/field/Field.d.ts +6 -1
  45. package/build/types/field/Field.d.ts.map +1 -1
  46. package/build/types/inlineAlert/InlineAlert.d.ts +2 -1
  47. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  48. package/build/types/modal/Modal.d.ts +1 -2
  49. package/build/types/modal/Modal.d.ts.map +1 -1
  50. package/build/types/statusIcon/StatusIcon.d.ts +6 -1
  51. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  52. package/build/types/statusIcon/StatusIcon.messages.d.ts +29 -0
  53. package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -0
  54. package/build/types/upload/Upload.d.ts +5 -0
  55. package/build/types/upload/Upload.d.ts.map +1 -1
  56. package/build/types/upload/steps/uploadImageStep/uploadImageStep.d.ts +1 -0
  57. package/build/types/upload/steps/uploadImageStep/uploadImageStep.d.ts.map +1 -1
  58. package/build/types/uploadInput/UploadInput.d.ts +0 -9
  59. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  60. package/build/types/uploadInput/uploadItem/UploadItem.d.ts +1 -16
  61. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  62. package/build/types/uploadInput/uploadItem/UploadItemLink.d.ts.map +1 -1
  63. package/build/upload/Upload.js +4 -2
  64. package/build/upload/Upload.js.map +1 -1
  65. package/build/upload/Upload.mjs +4 -2
  66. package/build/upload/Upload.mjs.map +1 -1
  67. package/build/upload/steps/uploadImageStep/uploadImageStep.js +4 -2
  68. package/build/upload/steps/uploadImageStep/uploadImageStep.js.map +1 -1
  69. package/build/upload/steps/uploadImageStep/uploadImageStep.mjs +4 -2
  70. package/build/upload/steps/uploadImageStep/uploadImageStep.mjs.map +1 -1
  71. package/build/uploadInput/UploadInput.js +66 -71
  72. package/build/uploadInput/UploadInput.js.map +1 -1
  73. package/build/uploadInput/UploadInput.mjs +67 -72
  74. package/build/uploadInput/UploadInput.mjs.map +1 -1
  75. package/build/uploadInput/uploadItem/UploadItem.js +4 -13
  76. package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
  77. package/build/uploadInput/uploadItem/UploadItem.mjs +4 -13
  78. package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
  79. package/build/uploadInput/uploadItem/UploadItemLink.js +0 -1
  80. package/build/uploadInput/uploadItem/UploadItemLink.js.map +1 -1
  81. package/build/uploadInput/uploadItem/UploadItemLink.mjs +0 -1
  82. package/build/uploadInput/uploadItem/UploadItemLink.mjs.map +1 -1
  83. package/package.json +3 -3
  84. package/src/alert/Alert.spec.tsx +10 -0
  85. package/src/alert/Alert.tsx +7 -1
  86. package/src/dimmer/Dimmer.spec.js +0 -8
  87. package/src/dimmer/Dimmer.tsx +0 -4
  88. package/src/drawer/Drawer.spec.js +6 -25
  89. package/src/drawer/Drawer.tsx +1 -3
  90. package/src/field/Field.spec.tsx +19 -0
  91. package/src/field/Field.story.tsx +20 -4
  92. package/src/field/Field.tsx +7 -1
  93. package/src/i18n/en.json +5 -0
  94. package/src/inlineAlert/InlineAlert.spec.tsx +12 -1
  95. package/src/inlineAlert/InlineAlert.tsx +5 -1
  96. package/src/modal/Modal.spec.js +1 -19
  97. package/src/modal/Modal.tsx +0 -4
  98. package/src/statusIcon/StatusIcon.docs.mdx +22 -0
  99. package/src/statusIcon/StatusIcon.messages.ts +34 -0
  100. package/src/statusIcon/StatusIcon.spec.tsx +31 -4
  101. package/src/statusIcon/StatusIcon.story.tsx +2 -5
  102. package/src/statusIcon/StatusIcon.tsx +59 -14
  103. package/src/upload/Upload.spec.js +19 -0
  104. package/src/upload/Upload.tsx +7 -0
  105. package/src/upload/steps/uploadImageStep/uploadImageStep.spec.js +13 -0
  106. package/src/upload/steps/uploadImageStep/uploadImageStep.tsx +14 -3
  107. package/src/uploadInput/UploadInput.spec.tsx +9 -121
  108. package/src/uploadInput/UploadInput.tests.story.tsx +140 -209
  109. package/src/uploadInput/UploadInput.tsx +77 -110
  110. package/src/uploadInput/uploadItem/UploadItem.spec.tsx +0 -1
  111. package/src/uploadInput/uploadItem/UploadItem.tsx +6 -30
  112. package/src/uploadInput/uploadItem/UploadItemLink.tsx +1 -9
@@ -1,52 +1,52 @@
1
1
  import { action } from '@storybook/addon-actions';
2
- import { Meta, StoryObj } from '@storybook/react';
2
+ import { StoryFn, Meta } from '@storybook/react';
3
3
 
4
4
  import { Status } from '../common';
5
+
5
6
  import UploadInput, { UploadInputProps } from './UploadInput';
6
7
  import { UploadedFile, UploadResponse } from './types';
7
- import { userEvent, within } from '@storybook/test';
8
8
 
9
9
  const meta: Meta<typeof UploadInput> = {
10
10
  title: 'Forms/UploadInput/Tests',
11
11
  component: UploadInput,
12
12
  };
13
- export default meta;
14
13
 
15
- type Story = StoryObj<UploadInputProps>;
14
+ export default meta;
15
+ type Story = StoryFn<UploadInputProps>;
16
16
 
17
- const files: UploadedFile[] = [
17
+ const files = [
18
18
  {
19
- id: '0hd8hf8',
19
+ id: 1,
20
20
  filename: 'purchase-receipt-0.pdf',
21
21
  url: 'https://wise.com/public-resources/assets/logos/wise/brand_logo_inverse.svg',
22
22
  },
23
23
  {
24
- id: '1r7hgc83',
24
+ id: 2,
25
25
  filename: 'purchase-receipt-1.pdf',
26
26
  },
27
27
  {
28
- id: '2nhc7387hc8h',
28
+ id: 3,
29
29
  filename: 'purchase-receipt-2.pdf',
30
30
  url: 'https://wise.com/public-resources/assets/logos/wise/brand_logo_inverse.svg',
31
31
  },
32
32
  {
33
- id: '39wd8uc',
33
+ id: 4,
34
34
  filename: 'receipt failed.png',
35
35
  status: Status.FAILED,
36
36
  },
37
37
  {
38
- id: '437yyf8hf',
38
+ id: 5,
39
39
  filename: 'receipt failed With error string.png',
40
40
  status: Status.FAILED,
41
41
  error: 'Something went wrong',
42
42
  },
43
43
  {
44
- id: '5biehveifh',
44
+ id: 6,
45
45
  filename: 'receipt failed With error object.png',
46
46
  status: Status.FAILED,
47
47
  error: { message: 'Something went wrong' },
48
48
  },
49
- ];
49
+ ] satisfies UploadedFile[];
50
50
 
51
51
  const createDelayedPromise = async ({
52
52
  successful = true,
@@ -65,232 +65,163 @@ const createDelayedPromise = async ({
65
65
  });
66
66
 
67
67
  const props = {
68
- onUploadFile: async (formData: FormData) => createDelayedPromise(),
69
- onDeleteFile: async (id: string | number) => createDelayedPromise(),
70
- };
71
-
72
- export const UploadInputWithDescriptionFromProps: Story = {
73
- args: {
74
- ...props,
75
- multiple: true,
76
- description: 'Custom file description from prop',
68
+ onUploadFile: async (formData: FormData) => {
69
+ return createDelayedPromise();
77
70
  },
78
- };
79
-
80
- export const Disabled: Story = {
81
- args: {
82
- ...props,
83
- disabled: true,
71
+ onDeleteFile: async (id: string | number) => {
72
+ return createDelayedPromise();
84
73
  },
85
74
  };
86
75
 
87
- export const WithAnyFileType: Story = {
88
- args: {
89
- ...props,
90
- fileTypes: '*',
91
- },
92
- };
76
+ const Template: Story = (args: UploadInputProps) => <UploadInput {...args} />;
93
77
 
94
- export const WithSingleFileType: Story = {
95
- args: {
96
- ...props,
97
- fileTypes: '.zip,application/zip',
98
- },
78
+ export const UploadInputWithDescriptionFromProps: Story = Template.bind({});
79
+ UploadInputWithDescriptionFromProps.args = {
80
+ ...props,
81
+ multiple: true,
82
+ description: 'Custom file description from prop',
99
83
  };
100
84
 
101
- export const WithMultipleExistingFiles: Story = {
102
- args: {
103
- ...props,
104
- files,
105
- multiple: true,
106
- },
107
- };
85
+ export const Disabled: Story = Template.bind({});
86
+ Disabled.args = { ...props, disabled: true };
108
87
 
109
- export const WithFileErrors: Story = {
110
- args: {
111
- ...props,
112
- files: [
113
- { id: 1, filename: 'Error with default message.png', status: Status.FAILED },
114
- {
115
- id: 2,
116
- filename: 'Error with `string` error.png',
117
- status: Status.FAILED,
118
- error: 'Single string error',
119
- },
120
- {
121
- id: 3,
122
- filename: 'Error with `obj` error ({ message : `string` }).png',
123
- status: Status.FAILED,
124
- error: { message: 'Single obj error' },
125
- },
126
- {
127
- id: 4,
128
- filename: 'Error with single error passed in `array`.png',
129
- status: Status.FAILED,
130
- errors: ['Single error in array'],
131
- },
132
- {
133
- id: 5,
134
- filename: 'Error with multiple `string` errors passed in `array`.png',
135
- status: Status.FAILED,
136
- errors: [
137
- 'Error 1',
138
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
139
- 'Error 3',
140
- ],
141
- },
142
- {
143
- id: 6,
144
- filename: 'Error with multiple `obj` errors passed in `array`.png',
145
- status: Status.FAILED,
146
- errors: [
147
- { message: 'Error 1' },
148
- {
149
- message:
150
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
151
- },
152
- { message: 'Error 3' },
153
- ],
154
- },
155
- ],
156
- multiple: true,
157
- },
158
- };
88
+ export const WithAnyFileType: Story = Template.bind({});
89
+ WithAnyFileType.args = { ...props, fileTypes: '*' };
159
90
 
160
- export const WithoutDelete: Story = {
161
- args: {
162
- ...props,
163
- files,
164
- onDeleteFile: undefined,
165
- multiple: true,
166
- },
167
- };
91
+ export const WithSingleFileType: Story = Template.bind({});
92
+ WithSingleFileType.args = { ...props, fileTypes: '.zip,application/zip' };
168
93
 
169
- export const WithUploadFailed: Story = {
170
- args: {
171
- ...props,
172
- files: files.slice(0),
173
- onUploadFile: async () => createDelayedPromise({ successful: false }),
174
- multiple: true,
175
- },
94
+ export const WithMultipleExistingFiles: Story = Template.bind({});
95
+ WithMultipleExistingFiles.args = {
96
+ ...props,
97
+ files,
98
+ multiple: true,
176
99
  };
177
100
 
178
- export const WithDeleteFailed: Story = {
179
- args: {
180
- ...props,
181
- files: files.slice(0),
182
- onDeleteFile: async () => createDelayedPromise({ successful: false }),
183
- multiple: true,
184
- },
101
+ export const WithFileErrors: Story = Template.bind({});
102
+ WithFileErrors.args = {
103
+ ...props,
104
+ files: [
105
+ {
106
+ id: 1,
107
+ filename: 'Error with default message.png',
108
+ status: Status.FAILED,
109
+ },
110
+ {
111
+ id: 2,
112
+ filename: 'Error with `string` error.png',
113
+ status: Status.FAILED,
114
+ error: 'Single string error',
115
+ },
116
+ {
117
+ id: 3,
118
+ filename: 'Error with `obj` error ({ message : `string` }).png',
119
+ status: Status.FAILED,
120
+ error: { message: 'Single obj error' },
121
+ },
122
+ {
123
+ id: 4,
124
+ filename: 'Error with single error passed in `array`.png',
125
+ status: Status.FAILED,
126
+ errors: ['Single error in array'],
127
+ },
128
+ {
129
+ id: 5,
130
+ filename: 'Error with multiple `string` errors passed in `array`.png',
131
+ status: Status.FAILED,
132
+ errors: [
133
+ 'Error 1',
134
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
135
+ 'Error 3',
136
+ ],
137
+ },
138
+ {
139
+ id: 6,
140
+ filename: 'Error with multiple `obj` errors passed in `array`.png',
141
+ status: Status.FAILED,
142
+ errors: [
143
+ { message: 'Error 1' },
144
+ {
145
+ message:
146
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
147
+ },
148
+ { message: 'Error 3' },
149
+ ],
150
+ },
151
+ ],
152
+ multiple: true,
185
153
  };
186
154
 
187
- export const CustomConfirmMessage: Story = {
188
- args: {
189
- ...props,
190
- files: files.slice(0),
191
- deleteConfirm: {
192
- title: 'Sure you want to remove this invoice?',
193
- body: (
194
- <img
195
- alt="brand logo"
196
- src="https://wise.com/public-resources/assets/logos/wise/brand_logo.svg"
197
- />
198
- ),
199
- },
200
- },
155
+ export const WithoutDelete: Story = Template.bind({});
156
+ WithoutDelete.args = {
157
+ ...props,
158
+ files,
159
+ onDeleteFile: undefined,
160
+ multiple: true,
201
161
  };
202
162
 
203
- export const WithManualDownloadHandler: Story = {
204
- args: {
205
- ...props,
206
- files,
207
- onDownload: action('Manual download handler'),
208
- },
163
+ export const WithUploadFailed: Story = Template.bind({});
164
+ WithUploadFailed.args = {
165
+ ...props,
166
+ files: files.slice(0),
167
+ onUploadFile: async () => createDelayedPromise({ successful: false }),
168
+ multiple: true,
209
169
  };
210
170
 
211
- export const WithFilesChangeHandler: Story = {
212
- args: {
213
- ...props,
214
- files,
215
- onFilesChange: action('Files change handler'),
216
- },
171
+ export const WithDeleteFailed: Story = Template.bind({});
172
+ WithDeleteFailed.args = {
173
+ ...props,
174
+ files: files.slice(0),
175
+ onDeleteFile: async () => createDelayedPromise({ successful: false }),
176
+ multiple: true,
217
177
  };
218
178
 
219
- export const WithMaxFilesToUploadLimit: Story = {
220
- args: {
221
- ...props,
222
- multiple: true,
223
- maxFiles: 5,
224
- maxFilesErrorMessage: "Can't upload as maximum number of files allowed are already uploaded",
179
+ export const CustomConfirmMessage: Story = Template.bind({});
180
+ CustomConfirmMessage.args = {
181
+ ...props,
182
+ files: files.slice(0),
183
+ deleteConfirm: {
184
+ title: 'Sure you want to remove this invoice?',
185
+ body: (
186
+ <img
187
+ alt="brand logo"
188
+ src="https://wise.com/public-resources/assets/logos/wise/brand_logo.svg"
189
+ />
190
+ ),
225
191
  },
226
192
  };
227
193
 
228
- export const WithFileSizeErrorMessage: Story = {
229
- args: {
230
- ...props,
231
- sizeLimit: 1,
232
- sizeLimitErrorMessage: 'The file is oversized',
233
- },
194
+ export const WithManualDownloadHandler: Story = Template.bind({});
195
+ WithManualDownloadHandler.args = {
196
+ ...props,
197
+ files,
198
+ onDownload: action('Manual download handler'),
234
199
  };
235
200
 
236
- export const WithCustomUploadButtonTitle: Story = {
237
- args: {
238
- ...props,
239
- uploadButtonTitle: 'Upload the VAT receipts for FY 2022-23',
240
- },
201
+ export const WithFilesChangeHandler: Story = Template.bind({});
202
+ WithFilesChangeHandler.args = {
203
+ ...props,
204
+ files,
205
+ onFilesChange: action('Files change handler'),
241
206
  };
242
207
 
243
- const triggerModalAndConfirm = async ({ isLink = true } = {}) => {
244
- if (isLink) {
245
- await wait();
246
- await userEvent.tab();
247
- }
248
- await wait();
249
- await userEvent.keyboard('{Enter}');
250
- await wait();
251
- await userEvent.tab();
252
- await wait();
253
- await userEvent.tab();
254
- await wait();
255
- await userEvent.tab();
256
- await wait();
257
- await userEvent.keyboard('{Enter}');
208
+ export const WithMaxFilesToUploadLimit: Story = Template.bind({});
209
+ WithMaxFilesToUploadLimit.args = {
210
+ ...props,
211
+ multiple: true,
212
+ maxFiles: 5,
213
+ maxFilesErrorMessage: "Can't upload as maximum number of files allowed are already uploaded",
258
214
  };
259
- const wait = async (time = 250) =>
260
- new Promise((resolve) => {
261
- setTimeout(resolve, time);
262
- });
263
215
 
264
- export const DeletingTop: Story = {
265
- args: {
266
- ...props,
267
- files: [files[0], files[1], files[2]],
268
- multiple: true,
269
- },
270
- play: async ({ canvasElement }) => {
271
- await userEvent.tab();
272
- await triggerModalAndConfirm();
273
- await triggerModalAndConfirm({ isLink: false });
274
- await userEvent.tab();
275
- await triggerModalAndConfirm();
276
- },
216
+ export const WithFileSizeErrorMessage: Story = Template.bind({});
217
+ WithFileSizeErrorMessage.args = {
218
+ ...props,
219
+ sizeLimit: 1,
220
+ sizeLimitErrorMessage: 'The file is oversized',
277
221
  };
278
222
 
279
- export const DeletingBottom: Story = {
280
- args: {
281
- ...props,
282
- files: [files[0], files[1], files[2]],
283
- multiple: true,
284
- },
285
- play: async ({ canvasElement }) => {
286
- await userEvent.tab();
287
- await userEvent.tab();
288
- await userEvent.tab();
289
- await userEvent.tab();
290
- await triggerModalAndConfirm();
291
- await triggerModalAndConfirm();
292
- await wait();
293
- await userEvent.tab();
294
- await triggerModalAndConfirm();
295
- },
223
+ export const WithCustomUploadButtonTitle: Story = Template.bind({});
224
+ WithCustomUploadButtonTitle.args = {
225
+ ...props,
226
+ uploadButtonTitle: 'Upload the VAT receipts for FY 2022-23',
296
227
  };