@transferwise/components 46.86.2 → 46.86.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowedFileTypes.d.ts","sourceRoot":"","sources":["../../../../src/uploadInput/uploadButton/getAllowedFileTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,QAAA,MAAM,mBAAmB,cAAe,SAAS,QAAQ,EAAE,GAAG,SAAS,MAAM,EAAE,KAAG,MAAM,EAOrF,CAAC;AAEJ,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"getAllowedFileTypes.d.ts","sourceRoot":"","sources":["../../../../src/uploadInput/uploadButton/getAllowedFileTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAqBxC,QAAA,MAAM,mBAAmB,cAAe,SAAS,QAAQ,EAAE,GAAG,SAAS,MAAM,EAAE,KAAG,MAAM,EAcpF,CAAC;AAEL,eAAe,mBAAmB,CAAC"}
@@ -1,8 +1,28 @@
1
1
  'use strict';
2
2
 
3
- const getAllowedFileTypes = fileTypes => fileTypes.map(fileTypeDefinition => fileTypeDefinition.split(',').filter(extension => !extension.includes('/')) // Filter out mime types
4
- .map(extension => extension.replace('.', '').toUpperCase()) // Remove dot and convert extensions to uppercase to be displayed in the instructions
5
- .join(', '));
3
+ const parseFileType = fileType => {
4
+ if (fileType?.includes('.')) {
5
+ return fileType.replace('.', '').toUpperCase();
6
+ }
7
+ const mimeType = fileType?.split('/');
8
+ if (mimeType?.length > 1) {
9
+ let parsedType = mimeType[1];
10
+ if (parsedType.toLocaleLowerCase() === 'jpeg') {
11
+ parsedType = 'jpg, '.concat(parsedType).toUpperCase();
12
+ }
13
+ return parsedType.toUpperCase();
14
+ }
15
+ return fileType;
16
+ };
17
+ const getAllowedFileTypes = fileTypes => fileTypes.map(fileType => {
18
+ const splittedFileTypes = fileType?.split(',');
19
+ if (splittedFileTypes?.length > 1) {
20
+ // If `fileType` contains `format` and `mime` types, remove mime types, proceed only with format types
21
+ return splittedFileTypes.filter(splittedFileType => !splittedFileType?.includes('/')).map(splittedFileType => parseFileType(splittedFileType)).join(', ');
22
+ }
23
+ // If `fileType` contains only `format` or `mime` type, parse the type
24
+ return parseFileType(fileType);
25
+ });
6
26
 
7
27
  module.exports = getAllowedFileTypes;
8
28
  //# sourceMappingURL=getAllowedFileTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowedFileTypes.js","sources":["../../../src/uploadInput/uploadButton/getAllowedFileTypes.ts"],"sourcesContent":["import { FileType } from '../../common';\n\nconst getAllowedFileTypes = (fileTypes: readonly FileType[] | readonly string[]): string[] =>\n fileTypes.map((fileTypeDefinition: string) =>\n fileTypeDefinition\n .split(',')\n .filter((extension) => !extension.includes('/')) // Filter out mime types\n .map((extension) => extension.replace('.', '').toUpperCase()) // Remove dot and convert extensions to uppercase to be displayed in the instructions\n .join(', '),\n );\n\nexport default getAllowedFileTypes;\n"],"names":["getAllowedFileTypes","fileTypes","map","fileTypeDefinition","split","filter","extension","includes","replace","toUpperCase","join"],"mappings":";;AAEA,MAAMA,mBAAmB,GAAIC,SAAkD,IAC7EA,SAAS,CAACC,GAAG,CAAEC,kBAA0B,IACvCA,kBAAkB,CACfC,KAAK,CAAC,GAAG,CAAC,CACVC,MAAM,CAAEC,SAAS,IAAK,CAACA,SAAS,CAACC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAAC,CAChDL,GAAG,CAAEI,SAAS,IAAKA,SAAS,CAACE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAACC,WAAW,EAAE,CAAC;AAAC,CAC7DC,IAAI,CAAC,IAAI,CAAC;;;;"}
1
+ {"version":3,"file":"getAllowedFileTypes.js","sources":["../../../src/uploadInput/uploadButton/getAllowedFileTypes.ts"],"sourcesContent":["import { FileType } from '../../common';\n\nconst parseFileType = (fileType: string): string => {\n if (fileType?.includes('.')) {\n return fileType.replace('.', '').toUpperCase();\n }\n\n const mimeType = fileType?.split('/');\n if (mimeType?.length > 1) {\n let parsedType = mimeType[1];\n\n if (parsedType.toLocaleLowerCase() === 'jpeg') {\n parsedType = 'jpg, '.concat(parsedType).toUpperCase();\n }\n\n return parsedType.toUpperCase();\n }\n\n return fileType;\n};\n\nconst getAllowedFileTypes = (fileTypes: readonly FileType[] | readonly string[]): string[] =>\n fileTypes.map((fileType: string) => {\n const splittedFileTypes = fileType?.split(',');\n\n if (splittedFileTypes?.length > 1) {\n // If `fileType` contains `format` and `mime` types, remove mime types, proceed only with format types\n return splittedFileTypes\n .filter((splittedFileType: string) => !splittedFileType?.includes('/'))\n .map((splittedFileType: string) => parseFileType(splittedFileType))\n .join(', ');\n }\n\n // If `fileType` contains only `format` or `mime` type, parse the type\n return parseFileType(fileType);\n });\n\nexport default getAllowedFileTypes;\n"],"names":["parseFileType","fileType","includes","replace","toUpperCase","mimeType","split","length","parsedType","toLocaleLowerCase","concat","getAllowedFileTypes","fileTypes","map","splittedFileTypes","filter","splittedFileType","join"],"mappings":";;AAEA,MAAMA,aAAa,GAAIC,QAAgB,IAAY;AACjD,EAAA,IAAIA,QAAQ,EAAEC,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC3B,OAAOD,QAAQ,CAACE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAACC,WAAW,EAAE,CAAA;AAChD,GAAA;AAEA,EAAA,MAAMC,QAAQ,GAAGJ,QAAQ,EAAEK,KAAK,CAAC,GAAG,CAAC,CAAA;AACrC,EAAA,IAAID,QAAQ,EAAEE,MAAM,GAAG,CAAC,EAAE;AACxB,IAAA,IAAIC,UAAU,GAAGH,QAAQ,CAAC,CAAC,CAAC,CAAA;AAE5B,IAAA,IAAIG,UAAU,CAACC,iBAAiB,EAAE,KAAK,MAAM,EAAE;MAC7CD,UAAU,GAAG,OAAO,CAACE,MAAM,CAACF,UAAU,CAAC,CAACJ,WAAW,EAAE,CAAA;AACvD,KAAA;AAEA,IAAA,OAAOI,UAAU,CAACJ,WAAW,EAAE,CAAA;AACjC,GAAA;AAEA,EAAA,OAAOH,QAAQ,CAAA;AACjB,CAAC,CAAA;AAEKU,MAAAA,mBAAmB,GAAIC,SAAkD,IAC7EA,SAAS,CAACC,GAAG,CAAEZ,QAAgB,IAAI;AACjC,EAAA,MAAMa,iBAAiB,GAAGb,QAAQ,EAAEK,KAAK,CAAC,GAAG,CAAC,CAAA;AAE9C,EAAA,IAAIQ,iBAAiB,EAAEP,MAAM,GAAG,CAAC,EAAE;AACjC;AACA,IAAA,OAAOO,iBAAiB,CACrBC,MAAM,CAAEC,gBAAwB,IAAK,CAACA,gBAAgB,EAAEd,QAAQ,CAAC,GAAG,CAAC,CAAC,CACtEW,GAAG,CAAEG,gBAAwB,IAAKhB,aAAa,CAACgB,gBAAgB,CAAC,CAAC,CAClEC,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,GAAA;AAEA;EACA,OAAOjB,aAAa,CAACC,QAAQ,CAAC,CAAA;AAChC,CAAC;;;;"}
@@ -1,6 +1,26 @@
1
- const getAllowedFileTypes = fileTypes => fileTypes.map(fileTypeDefinition => fileTypeDefinition.split(',').filter(extension => !extension.includes('/')) // Filter out mime types
2
- .map(extension => extension.replace('.', '').toUpperCase()) // Remove dot and convert extensions to uppercase to be displayed in the instructions
3
- .join(', '));
1
+ const parseFileType = fileType => {
2
+ if (fileType?.includes('.')) {
3
+ return fileType.replace('.', '').toUpperCase();
4
+ }
5
+ const mimeType = fileType?.split('/');
6
+ if (mimeType?.length > 1) {
7
+ let parsedType = mimeType[1];
8
+ if (parsedType.toLocaleLowerCase() === 'jpeg') {
9
+ parsedType = 'jpg, '.concat(parsedType).toUpperCase();
10
+ }
11
+ return parsedType.toUpperCase();
12
+ }
13
+ return fileType;
14
+ };
15
+ const getAllowedFileTypes = fileTypes => fileTypes.map(fileType => {
16
+ const splittedFileTypes = fileType?.split(',');
17
+ if (splittedFileTypes?.length > 1) {
18
+ // If `fileType` contains `format` and `mime` types, remove mime types, proceed only with format types
19
+ return splittedFileTypes.filter(splittedFileType => !splittedFileType?.includes('/')).map(splittedFileType => parseFileType(splittedFileType)).join(', ');
20
+ }
21
+ // If `fileType` contains only `format` or `mime` type, parse the type
22
+ return parseFileType(fileType);
23
+ });
4
24
 
5
25
  export { getAllowedFileTypes as default };
6
26
  //# sourceMappingURL=getAllowedFileTypes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowedFileTypes.mjs","sources":["../../../src/uploadInput/uploadButton/getAllowedFileTypes.ts"],"sourcesContent":["import { FileType } from '../../common';\n\nconst getAllowedFileTypes = (fileTypes: readonly FileType[] | readonly string[]): string[] =>\n fileTypes.map((fileTypeDefinition: string) =>\n fileTypeDefinition\n .split(',')\n .filter((extension) => !extension.includes('/')) // Filter out mime types\n .map((extension) => extension.replace('.', '').toUpperCase()) // Remove dot and convert extensions to uppercase to be displayed in the instructions\n .join(', '),\n );\n\nexport default getAllowedFileTypes;\n"],"names":["getAllowedFileTypes","fileTypes","map","fileTypeDefinition","split","filter","extension","includes","replace","toUpperCase","join"],"mappings":"AAEA,MAAMA,mBAAmB,GAAIC,SAAkD,IAC7EA,SAAS,CAACC,GAAG,CAAEC,kBAA0B,IACvCA,kBAAkB,CACfC,KAAK,CAAC,GAAG,CAAC,CACVC,MAAM,CAAEC,SAAS,IAAK,CAACA,SAAS,CAACC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAAC,CAChDL,GAAG,CAAEI,SAAS,IAAKA,SAAS,CAACE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAACC,WAAW,EAAE,CAAC;AAAC,CAC7DC,IAAI,CAAC,IAAI,CAAC;;;;"}
1
+ {"version":3,"file":"getAllowedFileTypes.mjs","sources":["../../../src/uploadInput/uploadButton/getAllowedFileTypes.ts"],"sourcesContent":["import { FileType } from '../../common';\n\nconst parseFileType = (fileType: string): string => {\n if (fileType?.includes('.')) {\n return fileType.replace('.', '').toUpperCase();\n }\n\n const mimeType = fileType?.split('/');\n if (mimeType?.length > 1) {\n let parsedType = mimeType[1];\n\n if (parsedType.toLocaleLowerCase() === 'jpeg') {\n parsedType = 'jpg, '.concat(parsedType).toUpperCase();\n }\n\n return parsedType.toUpperCase();\n }\n\n return fileType;\n};\n\nconst getAllowedFileTypes = (fileTypes: readonly FileType[] | readonly string[]): string[] =>\n fileTypes.map((fileType: string) => {\n const splittedFileTypes = fileType?.split(',');\n\n if (splittedFileTypes?.length > 1) {\n // If `fileType` contains `format` and `mime` types, remove mime types, proceed only with format types\n return splittedFileTypes\n .filter((splittedFileType: string) => !splittedFileType?.includes('/'))\n .map((splittedFileType: string) => parseFileType(splittedFileType))\n .join(', ');\n }\n\n // If `fileType` contains only `format` or `mime` type, parse the type\n return parseFileType(fileType);\n });\n\nexport default getAllowedFileTypes;\n"],"names":["parseFileType","fileType","includes","replace","toUpperCase","mimeType","split","length","parsedType","toLocaleLowerCase","concat","getAllowedFileTypes","fileTypes","map","splittedFileTypes","filter","splittedFileType","join"],"mappings":"AAEA,MAAMA,aAAa,GAAIC,QAAgB,IAAY;AACjD,EAAA,IAAIA,QAAQ,EAAEC,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC3B,OAAOD,QAAQ,CAACE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAACC,WAAW,EAAE,CAAA;AAChD,GAAA;AAEA,EAAA,MAAMC,QAAQ,GAAGJ,QAAQ,EAAEK,KAAK,CAAC,GAAG,CAAC,CAAA;AACrC,EAAA,IAAID,QAAQ,EAAEE,MAAM,GAAG,CAAC,EAAE;AACxB,IAAA,IAAIC,UAAU,GAAGH,QAAQ,CAAC,CAAC,CAAC,CAAA;AAE5B,IAAA,IAAIG,UAAU,CAACC,iBAAiB,EAAE,KAAK,MAAM,EAAE;MAC7CD,UAAU,GAAG,OAAO,CAACE,MAAM,CAACF,UAAU,CAAC,CAACJ,WAAW,EAAE,CAAA;AACvD,KAAA;AAEA,IAAA,OAAOI,UAAU,CAACJ,WAAW,EAAE,CAAA;AACjC,GAAA;AAEA,EAAA,OAAOH,QAAQ,CAAA;AACjB,CAAC,CAAA;AAEKU,MAAAA,mBAAmB,GAAIC,SAAkD,IAC7EA,SAAS,CAACC,GAAG,CAAEZ,QAAgB,IAAI;AACjC,EAAA,MAAMa,iBAAiB,GAAGb,QAAQ,EAAEK,KAAK,CAAC,GAAG,CAAC,CAAA;AAE9C,EAAA,IAAIQ,iBAAiB,EAAEP,MAAM,GAAG,CAAC,EAAE;AACjC;AACA,IAAA,OAAOO,iBAAiB,CACrBC,MAAM,CAAEC,gBAAwB,IAAK,CAACA,gBAAgB,EAAEd,QAAQ,CAAC,GAAG,CAAC,CAAC,CACtEW,GAAG,CAAEG,gBAAwB,IAAKhB,aAAa,CAACgB,gBAAgB,CAAC,CAAC,CAClEC,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,GAAA;AAEA;EACA,OAAOjB,aAAa,CAACC,QAAQ,CAAC,CAAA;AAChC,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.86.2",
3
+ "version": "46.86.3",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -92,8 +92,8 @@
92
92
  "rollup-preserve-directives": "^1.1.1",
93
93
  "storybook": "^8.2.2",
94
94
  "@transferwise/less-config": "3.1.0",
95
- "@wise/components-theming": "1.6.1",
96
- "@transferwise/neptune-css": "14.20.1"
95
+ "@transferwise/neptune-css": "14.20.1",
96
+ "@wise/components-theming": "1.6.1"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "@transferwise/icons": "^3.13.1",
@@ -4,7 +4,7 @@ import { Meta, StoryObj } from '@storybook/react';
4
4
  import { Status } from '../common';
5
5
  import UploadInput, { UploadInputProps } from './UploadInput';
6
6
  import { UploadedFile, UploadResponse } from './types';
7
- import { userEvent, within } from '@storybook/test';
7
+ import { userEvent } from '@storybook/test';
8
8
 
9
9
  const meta: Meta<typeof UploadInput> = {
10
10
  title: 'Forms/UploadInput/Tests',
@@ -65,8 +65,8 @@ const createDelayedPromise = async ({
65
65
  });
66
66
 
67
67
  const props = {
68
- onUploadFile: async (formData: FormData) => createDelayedPromise(),
69
- onDeleteFile: async (id: string | number) => createDelayedPromise(),
68
+ onUploadFile: async () => createDelayedPromise(),
69
+ onDeleteFile: async () => createDelayedPromise(),
70
70
  };
71
71
 
72
72
  export const UploadInputWithDescriptionFromProps: Story = {
@@ -268,7 +268,7 @@ export const DeletingTop: Story = {
268
268
  files: [files[0], files[1], files[2]],
269
269
  multiple: true,
270
270
  },
271
- play: async ({ canvasElement }) => {
271
+ play: async () => {
272
272
  await userEvent.tab();
273
273
  await triggerModalAndConfirm();
274
274
  await triggerModalAndConfirm({ isLink: false });
@@ -282,7 +282,7 @@ export const DeletingBottom: Story = {
282
282
  files: [files[0], files[1], files[2]],
283
283
  multiple: true,
284
284
  },
285
- play: async ({ canvasElement }) => {
285
+ play: async () => {
286
286
  await userEvent.tab();
287
287
  await userEvent.tab();
288
288
  await userEvent.tab();
@@ -38,4 +38,16 @@ describe('getAllowedFileTypes', () => {
38
38
  expect(allowedFileTypes).toStrictEqual(['*']);
39
39
  });
40
40
  });
41
+
42
+ describe('using only mime types', () => {
43
+ const mimeTypes = ['application/json', 'image/jpeg'];
44
+
45
+ beforeAll(() => {
46
+ allowedFileTypes = getAllowedFileTypes(mimeTypes);
47
+ });
48
+
49
+ it('returns the original mime types', () => {
50
+ expect(allowedFileTypes).toStrictEqual(['JSON', 'JPG, JPEG']);
51
+ });
52
+ });
41
53
  });
@@ -1,12 +1,38 @@
1
1
  import { FileType } from '../../common';
2
2
 
3
+ const parseFileType = (fileType: string): string => {
4
+ if (fileType?.includes('.')) {
5
+ return fileType.replace('.', '').toUpperCase();
6
+ }
7
+
8
+ const mimeType = fileType?.split('/');
9
+ if (mimeType?.length > 1) {
10
+ let parsedType = mimeType[1];
11
+
12
+ if (parsedType.toLocaleLowerCase() === 'jpeg') {
13
+ parsedType = 'jpg, '.concat(parsedType).toUpperCase();
14
+ }
15
+
16
+ return parsedType.toUpperCase();
17
+ }
18
+
19
+ return fileType;
20
+ };
21
+
3
22
  const getAllowedFileTypes = (fileTypes: readonly FileType[] | readonly string[]): string[] =>
4
- fileTypes.map((fileTypeDefinition: string) =>
5
- fileTypeDefinition
6
- .split(',')
7
- .filter((extension) => !extension.includes('/')) // Filter out mime types
8
- .map((extension) => extension.replace('.', '').toUpperCase()) // Remove dot and convert extensions to uppercase to be displayed in the instructions
9
- .join(', '),
10
- );
23
+ fileTypes.map((fileType: string) => {
24
+ const splittedFileTypes = fileType?.split(',');
25
+
26
+ if (splittedFileTypes?.length > 1) {
27
+ // If `fileType` contains `format` and `mime` types, remove mime types, proceed only with format types
28
+ return splittedFileTypes
29
+ .filter((splittedFileType: string) => !splittedFileType?.includes('/'))
30
+ .map((splittedFileType: string) => parseFileType(splittedFileType))
31
+ .join(', ');
32
+ }
33
+
34
+ // If `fileType` contains only `format` or `mime` type, parse the type
35
+ return parseFileType(fileType);
36
+ });
11
37
 
12
38
  export default getAllowedFileTypes;