@widergy/mobile-ui 0.32.4 → 0.33.0
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 +7 -0
- package/lib/components/FilePicker/index.js +10 -16
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [0.33.0](https://github.com/widergy/mobile-ui/compare/v0.32.4...v0.33.0) (2022-03-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* allow any mime type ([#217](https://github.com/widergy/mobile-ui/issues/217)) ([9b99614](https://github.com/widergy/mobile-ui/commit/9b99614b93d98e14a57c409f0e7674c5832d1b58))
|
|
7
|
+
|
|
1
8
|
## [0.32.4](https://github.com/widergy/mobile-ui/compare/v0.32.3...v0.32.4) (2022-03-07)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -26,37 +26,31 @@ class FilePicker extends Component {
|
|
|
26
26
|
onError,
|
|
27
27
|
onChange,
|
|
28
28
|
maxFileByteSize,
|
|
29
|
+
avoidRetrieveFile,
|
|
29
30
|
fileTypeError,
|
|
30
31
|
allowedPDFUploadSizes,
|
|
31
32
|
pdfFormatError
|
|
32
33
|
} = this.props;
|
|
33
|
-
const promisePicker = new Promise(async (resolve, reject) => {
|
|
34
|
-
try {
|
|
35
|
-
const picker = await DocumentPicker.pick({
|
|
36
|
-
type: allowedTypes && !onlyPDFAllowed(allowedTypes) ? allowedTypes : DocumentPicker.types.allFiles
|
|
37
|
-
});
|
|
38
|
-
return resolve(picker[0]);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
return reject(error);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
34
|
try {
|
|
44
|
-
const
|
|
35
|
+
const documents = await DocumentPicker.pick({
|
|
36
|
+
type: allowedTypes && !onlyPDFAllowed(allowedTypes) ? allowedTypes : DocumentPicker.types.allFiles
|
|
37
|
+
});
|
|
38
|
+
const document = documents[0];
|
|
45
39
|
const isPDF = document.type.includes('pdf');
|
|
46
40
|
const isImage = document.type.includes('image');
|
|
47
41
|
if (onlyPDFAllowed(allowedTypes) && !isPDF) {
|
|
48
42
|
throw new Error(fileTypeError || 'El tipo de archivo debe ser PDF.');
|
|
49
43
|
}
|
|
50
|
-
if (!isImage && !isImageByUri(document.uri) && !isPDF) {
|
|
44
|
+
if (allowedTypes && !isImage && !isImageByUri(document.uri) && !isPDF) {
|
|
51
45
|
throw new Error(fileTypeError || 'Tipo de archivo inválido.');
|
|
52
46
|
}
|
|
53
|
-
if (document.size > maxFileByteSize) {
|
|
47
|
+
if (maxFileByteSize && document.size > maxFileByteSize) {
|
|
54
48
|
onMaxSizeError(document.size, maxFileByteSize);
|
|
55
49
|
return;
|
|
56
50
|
}
|
|
57
|
-
const file = await retrieveFile(document.uri, document.type);
|
|
51
|
+
const file = !avoidRetrieveFile && (await retrieveFile(document.uri, document.type));
|
|
58
52
|
|
|
59
|
-
if (isPDF && !isEmpty(allowedPDFUploadSizes)) {
|
|
53
|
+
if (file && isPDF && !isEmpty(allowedPDFUploadSizes)) {
|
|
60
54
|
const isWrongFormat = await pdfAspectRatioValidation(file, allowedPDFUploadSizes);
|
|
61
55
|
if (isWrongFormat) {
|
|
62
56
|
throw new Error(
|
|
@@ -68,7 +62,7 @@ class FilePicker extends Component {
|
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
64
|
if (onChange) {
|
|
71
|
-
onChange({ file });
|
|
65
|
+
onChange(avoidRetrieveFile ? { document } : { file });
|
|
72
66
|
}
|
|
73
67
|
this.setState({ fileName: document.name });
|
|
74
68
|
} catch (err) {
|
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": "0.
|
|
5
|
+
"version": "0.33.0",
|
|
6
6
|
"repository": "https://github.com/widergy/mobile-ui.git",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"files": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react": "*",
|
|
27
27
|
"react-native": "*",
|
|
28
28
|
"react-native-document-picker": "^3.4.0",
|
|
29
|
-
"react-native-image-picker": "
|
|
29
|
+
"react-native-image-picker": "4.x.x",
|
|
30
30
|
"react-native-image-resizer": "^1.2.2",
|
|
31
31
|
"react-native-svg": "*",
|
|
32
32
|
"react-native-vector-icons": "*"
|