react-native-my-uploader-android 1.0.24 → 1.0.26
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/README.md +44 -176
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/myuploaderandroid/DownloadFileModule.kt +144 -0
- package/android/src/main/java/com/myuploaderandroid/MyUploaderPackage.kt +4 -1
- package/lib/commonjs/components/DownloadFile.js +103 -0
- package/lib/commonjs/components/DownloadFile.js.map +1 -0
- package/lib/commonjs/components/MyUploader.js +119 -0
- package/lib/commonjs/components/MyUploader.js.map +1 -0
- package/lib/commonjs/index.d.js.map +1 -1
- package/lib/commonjs/index.js +30 -108
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/components/DownloadFile.js +96 -0
- package/lib/module/components/DownloadFile.js.map +1 -0
- package/lib/module/components/MyUploader.js +112 -0
- package/lib/module/components/MyUploader.js.map +1 -0
- package/lib/module/index.d.js.map +1 -1
- package/lib/module/index.js +6 -109
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DownloadFile.tsx +106 -0
- package/src/{index.tsx → components/MyUploader.tsx} +2 -2
- package/src/index.d.ts +2 -2
- package/src/index.ts +10 -0
- package/src/types.ts +38 -0
package/lib/commonjs/index.js
CHANGED
|
@@ -3,117 +3,39 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
throw new Error(LINKING_ERROR);
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
pickFile: true,
|
|
8
|
+
DownloadFileAndroid: true
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "DownloadFileAndroid", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _DownloadFile.default;
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const {
|
|
23
|
-
multipleFiles = false,
|
|
24
|
-
maxFiles = 0,
|
|
25
|
-
...rest
|
|
26
|
-
} = options;
|
|
27
|
-
if (!multipleFiles && maxFiles > 1) {
|
|
28
|
-
throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
|
|
29
|
-
}
|
|
30
|
-
let effectiveMaxFiles = maxFiles;
|
|
31
|
-
if (multipleFiles && maxFiles === 0) {
|
|
32
|
-
effectiveMaxFiles = 3;
|
|
16
|
+
exports.default = void 0;
|
|
17
|
+
Object.defineProperty(exports, "pickFile", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _MyUploader.pickFile;
|
|
33
21
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const MyUploaderAndroid = ({
|
|
47
|
-
// DocumentPickerOptions
|
|
48
|
-
multipleFiles = false,
|
|
49
|
-
maxFiles = 0,
|
|
50
|
-
fileTypes = ['*/*'],
|
|
51
|
-
maxSize = 0,
|
|
52
|
-
excludedUris = [],
|
|
53
|
-
// UI Props with defaults
|
|
54
|
-
buttonPlaceHolder = 'Dosya Seçin...',
|
|
55
|
-
ButtonStyle,
|
|
56
|
-
ButtonTextStyle,
|
|
57
|
-
disabled = false,
|
|
58
|
-
// Callbacks
|
|
59
|
-
onSelect,
|
|
60
|
-
onError = error => console.error('MyUploader Error:', error)
|
|
61
|
-
}) => {
|
|
62
|
-
const handlePress = async () => {
|
|
63
|
-
try {
|
|
64
|
-
const options = {
|
|
65
|
-
multipleFiles,
|
|
66
|
-
maxFiles,
|
|
67
|
-
fileTypes,
|
|
68
|
-
maxSize,
|
|
69
|
-
excludedUris
|
|
70
|
-
};
|
|
71
|
-
const selectedFiles = await pickFile(options);
|
|
72
|
-
|
|
73
|
-
// Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
|
|
74
|
-
// Sadece doluysa callback'i tetikleyelim.
|
|
75
|
-
if (selectedFiles && selectedFiles.length > 0) {
|
|
76
|
-
onSelect(selectedFiles);
|
|
77
|
-
}
|
|
78
|
-
} catch (error) {
|
|
79
|
-
// Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
|
|
80
|
-
// bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
|
|
81
|
-
// Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
|
|
82
|
-
if (error.code !== 'E_PICKER_CANCELLED') {
|
|
83
|
-
onError(error);
|
|
84
|
-
}
|
|
22
|
+
});
|
|
23
|
+
var _MyUploader = _interopRequireWildcard(require("./components/MyUploader"));
|
|
24
|
+
var _DownloadFile = _interopRequireDefault(require("./components/DownloadFile"));
|
|
25
|
+
var _types = require("./types");
|
|
26
|
+
Object.keys(_types).forEach(function (key) {
|
|
27
|
+
if (key === "default" || key === "__esModule") return;
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
29
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
30
|
+
Object.defineProperty(exports, key, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _types[key];
|
|
85
34
|
}
|
|
86
|
-
};
|
|
87
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
|
|
88
|
-
style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
|
|
89
|
-
onPress: handlePress,
|
|
90
|
-
disabled: disabled
|
|
91
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
92
|
-
style: [styles.buttonText, ButtonTextStyle]
|
|
93
|
-
}, buttonPlaceHolder));
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// Varsayılan stiller
|
|
97
|
-
const styles = _reactNative.StyleSheet.create({
|
|
98
|
-
button: {
|
|
99
|
-
backgroundColor: '#007AFF',
|
|
100
|
-
paddingHorizontal: 20,
|
|
101
|
-
paddingVertical: 10,
|
|
102
|
-
borderRadius: 8,
|
|
103
|
-
alignItems: 'center',
|
|
104
|
-
justifyContent: 'center'
|
|
105
|
-
},
|
|
106
|
-
buttonText: {
|
|
107
|
-
color: '#FFFFFF',
|
|
108
|
-
fontSize: 16,
|
|
109
|
-
fontWeight: 'bold'
|
|
110
|
-
},
|
|
111
|
-
disabledButton: {
|
|
112
|
-
backgroundColor: '#A9A9A9'
|
|
113
|
-
}
|
|
35
|
+
});
|
|
114
36
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// Component'
|
|
118
|
-
var _default = exports.default =
|
|
37
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
38
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
39
|
+
// Component'leri ve fonksiyonları dışa aktar
|
|
40
|
+
var _default = exports.default = _MyUploader.default;
|
|
119
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_DownloadFile","_interopRequireDefault","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","set","getOwnPropertyDescriptor","_default","MyUploaderAndroid"],"sources":["index.ts"],"sourcesContent":["import MyUploaderAndroid from \"./components/MyUploader\";\r\nimport DownloadFileAndroid from \"./components/DownloadFile\";\r\nimport { pickFile } from './components/MyUploader';\r\n\r\n// Component'leri ve fonksiyonları dışa aktar\r\nexport { DownloadFileAndroid, pickFile };\r\nexport * from './types';\r\nexport default MyUploaderAndroid;\r\n\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAAAI,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAAwB,SAAAL,uBAAAc,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAjB,wBAAAiB,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAArB,uBAAA,YAAAA,CAAAiB,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAR,GAAA,CAAAC,CAAA,GAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAV,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAnB,MAAA,CAAAS,cAAA,KAAAT,MAAA,CAAAyB,wBAAA,CAAAb,CAAA,EAAAG,CAAA,OAAAK,CAAA,CAAAT,GAAA,IAAAS,CAAA,CAAAI,GAAA,IAAAL,CAAA,CAAAE,CAAA,EAAAN,CAAA,EAAAK,CAAA,IAAAC,CAAA,CAAAN,CAAA,IAAAH,CAAA,CAAAG,CAAA,WAAAM,CAAA,KAAAT,CAAA,EAAAG,CAAA;AAFxB;AAAA,IAAAW,QAAA,GAAAlB,OAAA,CAAAM,OAAA,GAGea,mBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n disabled?: boolean;\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n disabled?: boolean;\r\n}\r\n\r\n//download File Module Props\r\nexport interface DownloadedFileInfo {\r\n originalUrl: string;\r\n localUri: string; // Cihazdaki dosyanın URI'si\r\n}\r\n\r\n// YENİ: Atlanan dosyalar hakkında bilgi vermek için arayüz\r\nexport interface SkippedFileInfo {\r\n originalUrl: string;\r\n reason: string; // Neden atlandığı (örn: \"Dosya çok büyük\")\r\n}\r\n\r\n// YENİ: onSUCCESS callback'inin döndüreceği sonuç nesnesi\r\nexport interface DownloadResult {\r\n successful: DownloadedFileInfo[];\r\n skipped: SkippedFileInfo[];\r\n}\r\n\r\n// GÜNCELLENDİ: DownloadFileProps arayüzü\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n // YENİ PROPLAR\r\n multipleLoad?: boolean;\r\n disabled?: boolean;\r\n debug?: boolean; // Mevcut debug prop'u\r\n\r\n maxSize?: number;\r\n fileTypes?: string[];\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n \r\n // GÜNCELLENDİ: Callback daha zengin bir nesne döndürecek\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: Error) => void;\r\n}"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { NativeModules, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';
|
|
3
|
+
const {
|
|
4
|
+
DownloadFile: DownloadFileModule
|
|
5
|
+
} = NativeModules;
|
|
6
|
+
const DownloadFile = ({
|
|
7
|
+
files,
|
|
8
|
+
multipleLoad = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
debug = false,
|
|
11
|
+
maxSize = 0,
|
|
12
|
+
fileTypes = ['*/*'],
|
|
13
|
+
buttonPlaceHolder = 'Dosyaları İndir',
|
|
14
|
+
buttonIcon,
|
|
15
|
+
ButtonStyle,
|
|
16
|
+
ButtonTextStyle,
|
|
17
|
+
onSuccess = () => {},
|
|
18
|
+
onError = error => console.error('DownloadFile Error:', error)
|
|
19
|
+
}) => {
|
|
20
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
21
|
+
const handlePress = async () => {
|
|
22
|
+
if (!DownloadFileModule) {
|
|
23
|
+
onError(new Error("DownloadFile native module is not available."));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setIsLoading(true);
|
|
27
|
+
const downloadOptions = {
|
|
28
|
+
maxSize,
|
|
29
|
+
fileTypes,
|
|
30
|
+
debug
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
const filesToProcess = multipleLoad ? files : files.slice(0, 1);
|
|
34
|
+
const downloadPromises = filesToProcess.map(url => DownloadFileModule.downloadFile(url, downloadOptions));
|
|
35
|
+
const settledResults = await Promise.allSettled(downloadPromises);
|
|
36
|
+
const finalResult = {
|
|
37
|
+
successful: [],
|
|
38
|
+
skipped: []
|
|
39
|
+
};
|
|
40
|
+
settledResults.forEach((result, index) => {
|
|
41
|
+
// DÜZELTME: `filesToProcess[index]` ifadesinin sonuna `!` ekleyerek
|
|
42
|
+
// TypeScript'e bu değerin asla undefined olmayacağını bildiriyoruz.
|
|
43
|
+
const originalUrl = filesToProcess[index];
|
|
44
|
+
if (result.status === 'fulfilled') {
|
|
45
|
+
finalResult.successful.push({
|
|
46
|
+
originalUrl,
|
|
47
|
+
// Artık hata vermeyecek
|
|
48
|
+
localUri: result.value
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
finalResult.skipped.push({
|
|
52
|
+
originalUrl,
|
|
53
|
+
// Artık hata vermeyecek
|
|
54
|
+
reason: result.reason.message
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
onSuccess(finalResult);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
onError(error);
|
|
61
|
+
} finally {
|
|
62
|
+
setIsLoading(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const content = isLoading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
66
|
+
color: "#FFFFFF"
|
|
67
|
+
}) : buttonIcon || /*#__PURE__*/React.createElement(Text, {
|
|
68
|
+
style: [styles.buttonText, ButtonTextStyle]
|
|
69
|
+
}, buttonPlaceHolder);
|
|
70
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
71
|
+
style: [styles.button, ButtonStyle, (disabled || isLoading) && styles.disabledButton],
|
|
72
|
+
onPress: handlePress,
|
|
73
|
+
disabled: disabled || isLoading
|
|
74
|
+
}, content);
|
|
75
|
+
};
|
|
76
|
+
const styles = StyleSheet.create({
|
|
77
|
+
button: {
|
|
78
|
+
backgroundColor: '#008CBA',
|
|
79
|
+
paddingHorizontal: 20,
|
|
80
|
+
paddingVertical: 10,
|
|
81
|
+
borderRadius: 8,
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
flexDirection: 'row'
|
|
85
|
+
},
|
|
86
|
+
buttonText: {
|
|
87
|
+
color: '#FFFFFF',
|
|
88
|
+
fontSize: 16,
|
|
89
|
+
fontWeight: 'bold'
|
|
90
|
+
},
|
|
91
|
+
disabledButton: {
|
|
92
|
+
backgroundColor: '#A9A9A9'
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
export default DownloadFile;
|
|
96
|
+
//# sourceMappingURL=DownloadFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","NativeModules","TouchableOpacity","Text","StyleSheet","ActivityIndicator","DownloadFile","DownloadFileModule","files","multipleLoad","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","error","console","isLoading","setIsLoading","handlePress","Error","downloadOptions","filesToProcess","slice","downloadPromises","map","url","downloadFile","settledResults","Promise","allSettled","finalResult","successful","skipped","forEach","result","index","originalUrl","status","push","localUri","value","reason","message","content","createElement","color","style","styles","buttonText","button","disabledButton","onPress","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","flexDirection","fontSize","fontWeight"],"sources":["DownloadFile.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { NativeModules, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';\r\nimport type { DownloadFileProps, DownloadResult } from '../types';\r\n\r\nconst { DownloadFile: DownloadFileModule } = NativeModules;\r\n\r\nconst DownloadFile: React.FC<DownloadFileProps> = ({\r\n files,\r\n multipleLoad = false,\r\n disabled = false,\r\n debug = false,\r\n maxSize = 0,\r\n fileTypes = ['*/*'],\r\n buttonPlaceHolder = 'Dosyaları İndir',\r\n buttonIcon,\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n onSuccess = () => {},\r\n onError = (error) => console.error('DownloadFile Error:', error),\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (!DownloadFileModule) {\r\n onError(new Error(\"DownloadFile native module is not available.\"));\r\n return;\r\n }\r\n\r\n setIsLoading(true);\r\n const downloadOptions = { maxSize, fileTypes, debug };\r\n\r\n try {\r\n const filesToProcess = multipleLoad ? files : files.slice(0, 1);\r\n const downloadPromises = filesToProcess.map(url => \r\n DownloadFileModule.downloadFile(url, downloadOptions)\r\n );\r\n\r\n const settledResults = await Promise.allSettled(downloadPromises);\r\n\r\n const finalResult: DownloadResult = { successful: [], skipped: [] };\r\n\r\n settledResults.forEach((result, index) => {\r\n // DÜZELTME: `filesToProcess[index]` ifadesinin sonuna `!` ekleyerek\r\n // TypeScript'e bu değerin asla undefined olmayacağını bildiriyoruz.\r\n const originalUrl = filesToProcess[index]!;\r\n\r\n if (result.status === 'fulfilled') {\r\n finalResult.successful.push({\r\n originalUrl, // Artık hata vermeyecek\r\n localUri: result.value,\r\n });\r\n } else {\r\n finalResult.skipped.push({\r\n originalUrl, // Artık hata vermeyecek\r\n reason: result.reason.message,\r\n });\r\n }\r\n });\r\n \r\n onSuccess(finalResult);\r\n\r\n } catch (error: any) {\r\n onError(error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n const content = isLoading ? (\r\n <ActivityIndicator color=\"#FFFFFF\" />\r\n ) : (\r\n buttonIcon || <Text style={[styles.buttonText, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n );\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {content}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#008CBA',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n flexDirection: 'row',\r\n },\r\n buttonText: {\r\n color: '#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S,KAAK+B,MAAM,CAACG,cAAc,CAAE;IACtFC,OAAO,EAAEjC,WAAY;IACrBd,QAAQ,EAAEA,QAAQ,IAAIY;EAAU,GAE/B2B,OACe,CAAC;AAEvB,CAAC;AAED,MAAMI,MAAM,GAAGjD,UAAU,CAACsD,MAAM,CAAC;EAC7BH,MAAM,EAAE;IACNI,eAAe,EAAE,SAAS;IAC1BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,aAAa,EAAE;EACjB,CAAC;EACDX,UAAU,EAAE;IACVH,KAAK,EAAE,SAAS;IAChBe,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDX,cAAc,EAAE;IACdG,eAAe,EAAE;EACnB;AACJ,CAAC,CAAC;AAEF,eAAerD,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeModules, TouchableOpacity, Text, StyleSheet } from 'react-native';
|
|
3
|
+
const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
|
|
4
|
+
const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPicker : new Proxy({}, {
|
|
5
|
+
get() {
|
|
6
|
+
throw new Error(LINKING_ERROR);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.
|
|
11
|
+
// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.
|
|
12
|
+
async function pickFile(options = {}) {
|
|
13
|
+
var _options$excludedUris, _options$fileTypes, _options$maxSize;
|
|
14
|
+
const {
|
|
15
|
+
multipleFiles = false,
|
|
16
|
+
maxFiles = 0,
|
|
17
|
+
...rest
|
|
18
|
+
} = options;
|
|
19
|
+
if (!multipleFiles && maxFiles > 1) {
|
|
20
|
+
throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
|
|
21
|
+
}
|
|
22
|
+
let effectiveMaxFiles = maxFiles;
|
|
23
|
+
if (multipleFiles && maxFiles === 0) {
|
|
24
|
+
effectiveMaxFiles = 3;
|
|
25
|
+
}
|
|
26
|
+
const finalOptions = {
|
|
27
|
+
...rest,
|
|
28
|
+
multipleFiles,
|
|
29
|
+
maxFiles: effectiveMaxFiles,
|
|
30
|
+
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
|
|
31
|
+
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
32
|
+
maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
|
|
33
|
+
};
|
|
34
|
+
return DocumentPicker.openDocument(finalOptions);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// YENİ: MyUploader Component'i
|
|
38
|
+
const MyUploaderAndroid = ({
|
|
39
|
+
// DocumentPickerOptions
|
|
40
|
+
multipleFiles = false,
|
|
41
|
+
maxFiles = 0,
|
|
42
|
+
fileTypes = ['*/*'],
|
|
43
|
+
maxSize = 0,
|
|
44
|
+
excludedUris = [],
|
|
45
|
+
// UI Props with defaults
|
|
46
|
+
buttonPlaceHolder = 'Dosya Seçin...',
|
|
47
|
+
ButtonStyle,
|
|
48
|
+
ButtonTextStyle,
|
|
49
|
+
disabled = false,
|
|
50
|
+
// Callbacks
|
|
51
|
+
onSelect,
|
|
52
|
+
onError = error => console.error('MyUploader Error:', error)
|
|
53
|
+
}) => {
|
|
54
|
+
const handlePress = async () => {
|
|
55
|
+
try {
|
|
56
|
+
const options = {
|
|
57
|
+
multipleFiles,
|
|
58
|
+
maxFiles,
|
|
59
|
+
fileTypes,
|
|
60
|
+
maxSize,
|
|
61
|
+
excludedUris
|
|
62
|
+
};
|
|
63
|
+
const selectedFiles = await pickFile(options);
|
|
64
|
+
|
|
65
|
+
// Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
|
|
66
|
+
// Sadece doluysa callback'i tetikleyelim.
|
|
67
|
+
if (selectedFiles && selectedFiles.length > 0) {
|
|
68
|
+
onSelect(selectedFiles);
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
// Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
|
|
72
|
+
// bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
|
|
73
|
+
// Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
|
|
74
|
+
if (error.code !== 'E_PICKER_CANCELLED') {
|
|
75
|
+
onError(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
80
|
+
style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
|
|
81
|
+
onPress: handlePress,
|
|
82
|
+
disabled: disabled
|
|
83
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
84
|
+
style: [styles.buttonText, ButtonTextStyle]
|
|
85
|
+
}, buttonPlaceHolder));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Varsayılan stiller
|
|
89
|
+
const styles = StyleSheet.create({
|
|
90
|
+
button: {
|
|
91
|
+
backgroundColor: '#007AFF',
|
|
92
|
+
paddingHorizontal: 20,
|
|
93
|
+
paddingVertical: 10,
|
|
94
|
+
borderRadius: 8,
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
justifyContent: 'center'
|
|
97
|
+
},
|
|
98
|
+
buttonText: {
|
|
99
|
+
color: '#FFFFFF',
|
|
100
|
+
fontSize: 16,
|
|
101
|
+
fontWeight: 'bold'
|
|
102
|
+
},
|
|
103
|
+
disabledButton: {
|
|
104
|
+
backgroundColor: '#A9A9A9'
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// İhtiyaca göre pickFile'ı da export edebilirsiniz.
|
|
109
|
+
export { pickFile };
|
|
110
|
+
// Component'i varsayılan olarak export ediyoruz.
|
|
111
|
+
export default MyUploaderAndroid;
|
|
112
|
+
//# sourceMappingURL=MyUploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","NativeModules","TouchableOpacity","Text","StyleSheet","LINKING_ERROR","DocumentPicker","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument","MyUploaderAndroid","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","onSelect","onError","error","console","handlePress","selectedFiles","length","code","createElement","style","styles","button","disabledButton","onPress","buttonText","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight"],"sources":["MyUploader.tsx"],"sourcesContent":["import React from 'react';\r\nimport {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from '../types';\r\n\r\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? NativeModules.DocumentPicker\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\n// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.\r\n// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.\r\nasync function pickFile(\r\n options: DocumentPickerOptions = {}\r\n): Promise<FileInfo[]> {\r\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\r\n\r\n if (!multipleFiles && maxFiles > 1) {\r\n throw new Error(\r\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\r\n );\r\n }\r\n let effectiveMaxFiles = maxFiles;\r\n if (multipleFiles && maxFiles === 0) {\r\n effectiveMaxFiles = 3;\r\n }\r\n const finalOptions: DocumentPickerOptions = {\r\n ...rest,\r\n multipleFiles,\r\n maxFiles: effectiveMaxFiles,\r\n excludedUris: options.excludedUris ?? [],\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n maxSize: options.maxSize ?? 0,\r\n };\r\n return DocumentPicker.openDocument(finalOptions);\r\n}\r\n\r\n// YENİ: MyUploader Component'i\r\nconst MyUploaderAndroid: React.FC<MyUploaderProps> = ({\r\n // DocumentPickerOptions\r\n multipleFiles = false,\r\n maxFiles = 0,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n excludedUris = [],\r\n // UI Props with defaults\r\n buttonPlaceHolder = 'Dosya Seçin...',\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n // Callbacks\r\n onSelect,\r\n onError = (error) => console.error('MyUploader Error:', error),\r\n}) => {\r\n const handlePress = async () => {\r\n try {\r\n const options: DocumentPickerOptions = {\r\n multipleFiles,\r\n maxFiles,\r\n fileTypes,\r\n maxSize,\r\n excludedUris,\r\n };\r\n const selectedFiles = await pickFile(options);\r\n \r\n // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.\r\n // Sadece doluysa callback'i tetikleyelim.\r\n if (selectedFiles && selectedFiles.length > 0) {\r\n onSelect(selectedFiles);\r\n }\r\n\r\n } catch (error: any) {\r\n // Kullanıcının seçimi iptal etmesi bir \"hata\" sayılmamalı,\r\n // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.\r\n // Native kodunuz \"E_PICKER_CANCELLED\" koduyla reject ediyor.\r\n if (error.code !== 'E_PICKER_CANCELLED') {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, disabled && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled}\r\n >\r\n <Text style={[styles.buttonText, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\n// Varsayılan stiller\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#007AFF',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\n// İhtiyaca göre pickFile'ı da export edebilirsiniz.\r\nexport { pickFile };\r\nexport type { FileInfo, DocumentPickerOptions, MyUploaderProps } from \"../types\";\r\n\r\n// Component'i varsayılan olarak export ediyoruz.\r\nexport default MyUploaderAndroid;"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,aAAa,EAACC,gBAAgB,EAACC,IAAI,EAACC,UAAU,QAAO,cAAc;AAG3E,MAAMC,aAAa,GAAG,mEAAmE;AAEzF,MAAMC,cAAc,GAAGL,aAAa,CAACK,cAAc,GAC/CL,aAAa,CAACK,cAAc,GAC5B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACJ,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA,eAAeK,QAAQA,CACrBC,OAA8B,GAAG,CAAC,CAAC,EACd;EAAA,IAAAC,qBAAA,EAAAC,kBAAA,EAAAC,gBAAA;EACrB,MAAM;IAAEC,aAAa,GAAG,KAAK;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGN,OAAO;EAEhE,IAAI,CAACI,aAAa,IAAIC,QAAQ,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIP,KAAK,CACb,oEACF,CAAC;EACH;EACA,IAAIS,iBAAiB,GAAGF,QAAQ;EAChC,IAAID,aAAa,IAAIC,QAAQ,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AU,EAAE;MACnB;MACA;MACA;MACA,IAAIA,KAAK,CAACK,IAAI,KAAK,oBAAoB,EAAE;QACvCN,OAAO,CAACC,KAAK,CAAC;MAChB;IACF;EACF,CAAC;EAED,oBACE/B,KAAA,CAAAqC,aAAA,CAACnC,gBAAgB;IACfoC,KAAK,EAAE,CAACC,MAAM,CAACC,MAAM,EAAEd,WAAW,EAAEE,QAAQ,IAAIW,MAAM,CAACE,cAAc,CAAE;IACvEC,OAAO,EAAET,WAAY;IACrBL,QAAQ,EAAEA;EAAS,gBAEnB5B,KAAA,CAAAqC,aAAA,CAAClC,IAAI;IAACmC,KAAK,EAAE,CAACC,MAAM,CAACI,UAAU,EAAEhB,eAAe;EAAE,GAC/CF,iBACG,CACU,CAAC;AAEvB,CAAC;;AAED;AACA,MAAMc,MAAM,GAAGnC,UAAU,CAACwC,MAAM,CAAC;EAC/BJ,MAAM,EAAE;IACNK,eAAe,EAAE,SAAS;IAC1BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDP,UAAU,EAAE;IACVQ,KAAK,EAAE,SAAS;IAChBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDZ,cAAc,EAAE;IACdI,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;;AAEF;AACA,SAASnC,QAAQ;AAGjB;AACA,eAAec,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps,FileInfo } from './types';\r\n\r\nexport * from './types';\r\n\r\ndeclare const MyUploader: React.FC<MyUploaderProps>;\r\
|
|
1
|
+
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps,FileInfo,DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\ndeclare const MyUploader: React.FC<MyUploaderProps>;\r\nexport default MyUploader;\r\n\r\nexport declare const DownloadFile: React.FC<DownloadFileProps>;\r\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":"AAGA,cAAc,SAAS","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,112 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPicker : new Proxy({}, {
|
|
5
|
-
get() {
|
|
6
|
-
throw new Error(LINKING_ERROR);
|
|
7
|
-
}
|
|
8
|
-
});
|
|
1
|
+
import MyUploaderAndroid from "./components/MyUploader";
|
|
2
|
+
import DownloadFileAndroid from "./components/DownloadFile";
|
|
3
|
+
import { pickFile } from './components/MyUploader';
|
|
9
4
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _options$excludedUris, _options$fileTypes, _options$maxSize;
|
|
14
|
-
const {
|
|
15
|
-
multipleFiles = false,
|
|
16
|
-
maxFiles = 0,
|
|
17
|
-
...rest
|
|
18
|
-
} = options;
|
|
19
|
-
if (!multipleFiles && maxFiles > 1) {
|
|
20
|
-
throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
|
|
21
|
-
}
|
|
22
|
-
let effectiveMaxFiles = maxFiles;
|
|
23
|
-
if (multipleFiles && maxFiles === 0) {
|
|
24
|
-
effectiveMaxFiles = 3;
|
|
25
|
-
}
|
|
26
|
-
const finalOptions = {
|
|
27
|
-
...rest,
|
|
28
|
-
multipleFiles,
|
|
29
|
-
maxFiles: effectiveMaxFiles,
|
|
30
|
-
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
|
|
31
|
-
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
32
|
-
maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
|
|
33
|
-
};
|
|
34
|
-
return DocumentPicker.openDocument(finalOptions);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// YENİ: MyUploader Component'i
|
|
38
|
-
const MyUploaderAndroid = ({
|
|
39
|
-
// DocumentPickerOptions
|
|
40
|
-
multipleFiles = false,
|
|
41
|
-
maxFiles = 0,
|
|
42
|
-
fileTypes = ['*/*'],
|
|
43
|
-
maxSize = 0,
|
|
44
|
-
excludedUris = [],
|
|
45
|
-
// UI Props with defaults
|
|
46
|
-
buttonPlaceHolder = 'Dosya Seçin...',
|
|
47
|
-
ButtonStyle,
|
|
48
|
-
ButtonTextStyle,
|
|
49
|
-
disabled = false,
|
|
50
|
-
// Callbacks
|
|
51
|
-
onSelect,
|
|
52
|
-
onError = error => console.error('MyUploader Error:', error)
|
|
53
|
-
}) => {
|
|
54
|
-
const handlePress = async () => {
|
|
55
|
-
try {
|
|
56
|
-
const options = {
|
|
57
|
-
multipleFiles,
|
|
58
|
-
maxFiles,
|
|
59
|
-
fileTypes,
|
|
60
|
-
maxSize,
|
|
61
|
-
excludedUris
|
|
62
|
-
};
|
|
63
|
-
const selectedFiles = await pickFile(options);
|
|
64
|
-
|
|
65
|
-
// Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
|
|
66
|
-
// Sadece doluysa callback'i tetikleyelim.
|
|
67
|
-
if (selectedFiles && selectedFiles.length > 0) {
|
|
68
|
-
onSelect(selectedFiles);
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
// Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
|
|
72
|
-
// bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
|
|
73
|
-
// Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
|
|
74
|
-
if (error.code !== 'E_PICKER_CANCELLED') {
|
|
75
|
-
onError(error);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
80
|
-
style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
|
|
81
|
-
onPress: handlePress,
|
|
82
|
-
disabled: disabled
|
|
83
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
84
|
-
style: [styles.buttonText, ButtonTextStyle]
|
|
85
|
-
}, buttonPlaceHolder));
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// Varsayılan stiller
|
|
89
|
-
const styles = StyleSheet.create({
|
|
90
|
-
button: {
|
|
91
|
-
backgroundColor: '#007AFF',
|
|
92
|
-
paddingHorizontal: 20,
|
|
93
|
-
paddingVertical: 10,
|
|
94
|
-
borderRadius: 8,
|
|
95
|
-
alignItems: 'center',
|
|
96
|
-
justifyContent: 'center'
|
|
97
|
-
},
|
|
98
|
-
buttonText: {
|
|
99
|
-
color: '#FFFFFF',
|
|
100
|
-
fontSize: 16,
|
|
101
|
-
fontWeight: 'bold'
|
|
102
|
-
},
|
|
103
|
-
disabledButton: {
|
|
104
|
-
backgroundColor: '#A9A9A9'
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// İhtiyaca göre pickFile'ı da export edebilirsiniz.
|
|
109
|
-
export { pickFile };
|
|
110
|
-
// Component'i varsayılan olarak export ediyoruz.
|
|
5
|
+
// Component'leri ve fonksiyonları dışa aktar
|
|
6
|
+
export { DownloadFileAndroid, pickFile };
|
|
7
|
+
export * from './types';
|
|
111
8
|
export default MyUploaderAndroid;
|
|
112
9
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["MyUploaderAndroid","DownloadFileAndroid","pickFile"],"sources":["index.ts"],"sourcesContent":["import MyUploaderAndroid from \"./components/MyUploader\";\r\nimport DownloadFileAndroid from \"./components/DownloadFile\";\r\nimport { pickFile } from './components/MyUploader';\r\n\r\n// Component'leri ve fonksiyonları dışa aktar\r\nexport { DownloadFileAndroid, pickFile };\r\nexport * from './types';\r\nexport default MyUploaderAndroid;\r\n\r\n\r\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,yBAAyB;AACvD,OAAOC,mBAAmB,MAAM,2BAA2B;AAC3D,SAASC,QAAQ,QAAQ,yBAAyB;;AAElD;AACA,SAASD,mBAAmB,EAAEC,QAAQ;AACtC,cAAc,SAAS;AACvB,eAAeF,iBAAiB","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n disabled?: boolean;\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n disabled?: boolean;\r\n}\r\n\r\n//download File Module Props\r\nexport interface DownloadedFileInfo {\r\n originalUrl: string;\r\n localUri: string; // Cihazdaki dosyanın URI'si\r\n}\r\n\r\n// YENİ: Atlanan dosyalar hakkında bilgi vermek için arayüz\r\nexport interface SkippedFileInfo {\r\n originalUrl: string;\r\n reason: string; // Neden atlandığı (örn: \"Dosya çok büyük\")\r\n}\r\n\r\n// YENİ: onSUCCESS callback'inin döndüreceği sonuç nesnesi\r\nexport interface DownloadResult {\r\n successful: DownloadedFileInfo[];\r\n skipped: SkippedFileInfo[];\r\n}\r\n\r\n// GÜNCELLENDİ: DownloadFileProps arayüzü\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n // YENİ PROPLAR\r\n multipleLoad?: boolean;\r\n disabled?: boolean;\r\n debug?: boolean; // Mevcut debug prop'u\r\n\r\n maxSize?: number;\r\n fileTypes?: string[];\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n \r\n // GÜNCELLENDİ: Callback daha zengin bir nesne döndürecek\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: Error) => void;\r\n}"],"mappings":"","ignoreList":[]}
|