@codeleap/mobile 3.10.2 → 3.10.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.
package/package.json
CHANGED
|
@@ -41,10 +41,10 @@ const pickerDefaults = {
|
|
|
41
41
|
cropping: true,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function parsePickerData(data:
|
|
44
|
+
function parsePickerData(data:ImageOrVideo):FileResult {
|
|
45
45
|
|
|
46
46
|
const filePathData = parseFilePathData(data.path)
|
|
47
|
-
const d:
|
|
47
|
+
const d:MobileFile = {
|
|
48
48
|
...data,
|
|
49
49
|
name: filePathData.name,
|
|
50
50
|
size: data.size,
|
|
@@ -78,27 +78,22 @@ const _FileInput = forwardRef<
|
|
|
78
78
|
onOpenFileSystem = null,
|
|
79
79
|
onError,
|
|
80
80
|
} = fileInputProps
|
|
81
|
-
const resolveWithFile = useRef<(file:
|
|
81
|
+
const resolveWithFile = useRef<(file:FileResult[]) => any>()
|
|
82
82
|
const { logger } = useCodeleapContext()
|
|
83
83
|
|
|
84
|
-
const resolveFiles = (files) => {
|
|
85
|
-
if (resolveWithFile.current) {
|
|
86
|
-
resolveWithFile.current(files ?? [])
|
|
87
|
-
resolveWithFile.current = undefined
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
84
|
async function openFileSystem() {
|
|
92
85
|
try {
|
|
93
86
|
let files = await DocumentPicker.pick(options)
|
|
94
|
-
|
|
95
87
|
if (!Array.isArray(files)) {
|
|
96
88
|
files = [files]
|
|
97
89
|
}
|
|
98
90
|
|
|
99
91
|
const filesWithPreview = files.map((file) => ({ preview: file.uri, file }))
|
|
100
92
|
|
|
101
|
-
|
|
93
|
+
if (resolveWithFile.current) {
|
|
94
|
+
resolveWithFile.current(filesWithPreview)
|
|
95
|
+
resolveWithFile.current = undefined
|
|
96
|
+
}
|
|
102
97
|
onFileSelect?.(filesWithPreview)
|
|
103
98
|
} catch (err) {
|
|
104
99
|
handleError(err)
|
|
@@ -118,17 +113,13 @@ const _FileInput = forwardRef<
|
|
|
118
113
|
} as Options
|
|
119
114
|
|
|
120
115
|
const handlePickerResolution = (data: ImageOrVideo | ImageOrVideo[]) => {
|
|
121
|
-
let imageArray:
|
|
116
|
+
let imageArray:ImageOrVideo[] = []
|
|
122
117
|
if (!Array.isArray(data)) {
|
|
123
118
|
imageArray = [data]
|
|
124
119
|
} else {
|
|
125
120
|
imageArray = data
|
|
126
121
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
resolveFiles(images)
|
|
130
|
-
|
|
131
|
-
onFileSelect?.(images)
|
|
122
|
+
onFileSelect(imageArray.map(parsePickerData))
|
|
132
123
|
}
|
|
133
124
|
const onPress = (open?: FileInputImageSource, options?: Options) => {
|
|
134
125
|
if (open == 'fs') {
|
|
@@ -175,7 +166,7 @@ const _FileInput = forwardRef<
|
|
|
175
166
|
{
|
|
176
167
|
text: 'Cancel',
|
|
177
168
|
style: 'cancel',
|
|
178
|
-
onPress: () => {
|
|
169
|
+
onPress: () => {},
|
|
179
170
|
...alertProps?.options?.[0],
|
|
180
171
|
},
|
|
181
172
|
],
|
|
@@ -209,7 +200,7 @@ export const FileInput = _FileInput as unknown as ((props: FileInputProps) => JS
|
|
|
209
200
|
export const useFileInput = () => {
|
|
210
201
|
const inputRef = useRef<FileInputRef>(null)
|
|
211
202
|
|
|
212
|
-
const openFilePicker = (imageSource:
|
|
203
|
+
const openFilePicker = (imageSource:FileInputImageSource = null):Promise<FileResult[]> => {
|
|
213
204
|
return inputRef.current?.openFilePicker(imageSource)
|
|
214
205
|
}
|
|
215
206
|
|