@widergy/mobile-ui 2.1.0 → 2.1.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [2.1.2](https://github.com/widergy/mobile-ui/compare/v2.1.1...v2.1.2) (2025-10-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * [CX-1362] attachment name lost on back step ([c392792](https://github.com/widergy/mobile-ui/commit/c392792e941767072adad41c0701b672720c2745))
7
+
8
+ ## [2.1.1](https://github.com/widergy/mobile-ui/compare/v2.1.0...v2.1.1) (2025-10-20)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * attachment upload failure ([#461](https://github.com/widergy/mobile-ui/issues/461)) ([49ed4d1](https://github.com/widergy/mobile-ui/commit/49ed4d1a5100b259c579325cc6cf36af5e33ea04))
14
+
1
15
  # [2.1.0](https://github.com/widergy/mobile-ui/compare/v2.0.2...v2.1.0) (2025-10-17)
2
16
 
3
17
 
@@ -31,6 +31,13 @@ class FilePicker extends Component {
31
31
  allowedPDFUploadSizes,
32
32
  pdfFormatError
33
33
  } = this.props;
34
+
35
+ const getRealFileType = mimeType => {
36
+ if (!mimeType || typeof mimeType !== 'string') return null;
37
+ const parts = mimeType.split('/');
38
+ return parts[1]?.toLowerCase() || null;
39
+ };
40
+
34
41
  try {
35
42
  const normalizeTypes = types => {
36
43
  if (!types || types.length === 0) return DEFAULT_ALLOWED_TYPES;
@@ -71,7 +78,8 @@ class FilePicker extends Component {
71
78
  onMaxSizeError(document.size, maxFileByteSize);
72
79
  return;
73
80
  }
74
- const file = !avoidRetrieveFile && (await retrieveFile(document.uri, document.type));
81
+ const realFileType = getRealFileType(document.type);
82
+ const file = !avoidRetrieveFile && (await retrieveFile(document.uri, realFileType));
75
83
 
76
84
  if (file && isPDF && !isEmpty(allowedPDFUploadSizes)) {
77
85
  const isWrongFormat = await pdfAspectRatioValidation(file, allowedPDFUploadSizes);
@@ -85,7 +93,7 @@ class FilePicker extends Component {
85
93
  }
86
94
  }
87
95
  if (onChange) {
88
- onChange(avoidRetrieveFile ? { document } : { file: blobToFile(file, document.type) });
96
+ onChange(avoidRetrieveFile ? { document } : { file: blobToFile(file, realFileType) });
89
97
  }
90
98
  this.setState({ fileName: document.name });
91
99
  } catch (err) {
@@ -57,7 +57,14 @@ const ImagePickerComponent = ({
57
57
  onError('No se pudo obtener el archivo');
58
58
  return;
59
59
  }
60
- const file = !avoidRetrieveFile && (await retrieveFile(item.uri, item.type));
60
+ const getRealFileType = mimeType => {
61
+ if (!mimeType || typeof mimeType !== 'string') return null;
62
+ const parts = mimeType.split('/');
63
+ return parts[1]?.toLowerCase() || null;
64
+ };
65
+ const realFileType = getRealFileType(item.type);
66
+
67
+ const file = !avoidRetrieveFile && (await retrieveFile(item.uri, realFileType));
61
68
  if (!avoidRetrieveFile && !file) {
62
69
  onError(response.errorCode);
63
70
  return;
@@ -79,6 +79,12 @@ const MultipleFilePicker = ({
79
79
 
80
80
  const remainingSlots = () => Math.max((maxFiles || 0) - uploadedFiles.length, 0);
81
81
 
82
+ const getRealFileType = mimeType => {
83
+ if (!mimeType || typeof mimeType !== 'string') return null;
84
+ const parts = mimeType.split('/');
85
+ return parts[1]?.toLowerCase() || null;
86
+ };
87
+
82
88
  const handleAssets = async response => {
83
89
  if (!response || response.didCancel) {
84
90
  return;
@@ -89,7 +95,8 @@ const MultipleFilePicker = ({
89
95
  }
90
96
  closeDrawer();
91
97
  response.assets.forEach(async asset => {
92
- const file = await retrieveFile(asset.uri, asset.type);
98
+ const realFileType = getRealFileType(asset.mimeType);
99
+ const file = await retrieveFile(asset.uri, realFileType);
93
100
  if (!file) {
94
101
  onError(response.errorCode || 'No se pudo obtener el archivo');
95
102
  return;
@@ -98,7 +105,7 @@ const MultipleFilePicker = ({
98
105
  if (isFileSizeInvaid({ size: file.size }, maxFileByteSize, onMaxSizeError)) return;
99
106
  setNewFile({
100
107
  uploadFile: { name: file.data.name, size: file.data.size },
101
- rawFile: blobToFile(file, asset.type)
108
+ rawFile: blobToFile(file, realFileType)
102
109
  });
103
110
  });
104
111
  };
@@ -173,7 +180,7 @@ const MultipleFilePicker = ({
173
180
 
174
181
  setNewFile({
175
182
  uploadFile: { name: document.name, size: document.size },
176
- rawFile: blobToFile(file, document.type)
183
+ rawFile: blobToFile(file, document.type, document.name)
177
184
  });
178
185
  added += 1;
179
186
  }
@@ -150,8 +150,8 @@ export const getInitialValuesFrom = files =>
150
150
  files
151
151
  ?.map(fileBlob => {
152
152
  // eslint-disable-next-line no-underscore-dangle
153
- const fileData = fileBlob?.file?._data || {};
153
+ const fileData = fileBlob?._data || {};
154
154
 
155
- return fileData ? { name: fileData?.name, size: fileData?.size } : null;
155
+ return fileData ? { name: fileBlob?.name || fileData?.name, size: fileData?.size } : null;
156
156
  })
157
157
  .filter(file => file !== null) || [];
@@ -11,7 +11,8 @@ export const isImageByUri = uri => {
11
11
  return uCaseUri.includes('.JPG') || uCaseUri.includes('.JPEG') || uCaseUri.includes('PNG');
12
12
  };
13
13
 
14
- export const blobToFile = (blob, type) => new File([blob], blob.data.name, { type });
14
+ export const blobToFile = (blob, type, customName) =>
15
+ new File([blob], customName || blob.data?.name || blob.name || 'archivo', { type });
15
16
 
16
17
  // We use the XMLHttpRequest API since the fetch API does not behave correctly under new sdks on Android
17
18
  export const uriToBlob = uri => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "2.1.0",
5
+ "version": "2.1.2",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [