@codeleap/mobile 3.11.0 → 3.12.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/package.json
CHANGED
|
@@ -41,10 +41,10 @@ const pickerDefaults = {
|
|
|
41
41
|
cropping: true,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function parsePickerData(data:ImageOrVideo):FileResult {
|
|
44
|
+
function parsePickerData(data: ImageOrVideo): FileResult {
|
|
45
45
|
|
|
46
46
|
const filePathData = parseFilePathData(data.path)
|
|
47
|
-
const d:MobileFile = {
|
|
47
|
+
const d: MobileFile = {
|
|
48
48
|
...data,
|
|
49
49
|
name: filePathData.name,
|
|
50
50
|
size: data.size,
|
|
@@ -78,9 +78,17 @@ const _FileInput = forwardRef<
|
|
|
78
78
|
onOpenFileSystem = null,
|
|
79
79
|
onError,
|
|
80
80
|
} = fileInputProps
|
|
81
|
-
const resolveWithFile = useRef<(file:FileResult[]) => any>()
|
|
81
|
+
const resolveWithFile = useRef<(file: FileResult[]) => any>()
|
|
82
82
|
const { logger } = useCodeleapContext()
|
|
83
83
|
|
|
84
|
+
const handleResolve = (files: Array<FileResult>) => {
|
|
85
|
+
if (resolveWithFile.current) {
|
|
86
|
+
resolveWithFile?.current?.(files)
|
|
87
|
+
resolveWithFile.current = null
|
|
88
|
+
}
|
|
89
|
+
onFileSelect?.(files)
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
async function openFileSystem() {
|
|
85
93
|
try {
|
|
86
94
|
let files = await DocumentPicker.pick(options)
|
|
@@ -88,13 +96,9 @@ const _FileInput = forwardRef<
|
|
|
88
96
|
files = [files]
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
const filesWithPreview = files.map((file) => ({ preview: file.uri, file }))
|
|
99
|
+
const filesWithPreview = files.map((file) => ({ preview: file.uri, file })) as FileResult[]
|
|
92
100
|
|
|
93
|
-
|
|
94
|
-
resolveWithFile.current(filesWithPreview)
|
|
95
|
-
resolveWithFile.current = undefined
|
|
96
|
-
}
|
|
97
|
-
onFileSelect?.(filesWithPreview)
|
|
101
|
+
handleResolve?.(filesWithPreview)
|
|
98
102
|
} catch (err) {
|
|
99
103
|
handleError(err)
|
|
100
104
|
}
|
|
@@ -113,13 +117,13 @@ const _FileInput = forwardRef<
|
|
|
113
117
|
} as Options
|
|
114
118
|
|
|
115
119
|
const handlePickerResolution = (data: ImageOrVideo | ImageOrVideo[]) => {
|
|
116
|
-
let imageArray:ImageOrVideo[] = []
|
|
120
|
+
let imageArray: ImageOrVideo[] = []
|
|
117
121
|
if (!Array.isArray(data)) {
|
|
118
122
|
imageArray = [data]
|
|
119
123
|
} else {
|
|
120
124
|
imageArray = data
|
|
121
125
|
}
|
|
122
|
-
|
|
126
|
+
handleResolve?.(imageArray.map(parsePickerData))
|
|
123
127
|
}
|
|
124
128
|
const onPress = (open?: FileInputImageSource, options?: Options) => {
|
|
125
129
|
if (open == 'fs') {
|
|
@@ -166,7 +170,7 @@ const _FileInput = forwardRef<
|
|
|
166
170
|
{
|
|
167
171
|
text: 'Cancel',
|
|
168
172
|
style: 'cancel',
|
|
169
|
-
onPress: () => {},
|
|
173
|
+
onPress: () => { },
|
|
170
174
|
...alertProps?.options?.[0],
|
|
171
175
|
},
|
|
172
176
|
],
|
|
@@ -200,7 +204,7 @@ export const FileInput = _FileInput as unknown as ((props: FileInputProps) => JS
|
|
|
200
204
|
export const useFileInput = () => {
|
|
201
205
|
const inputRef = useRef<FileInputRef>(null)
|
|
202
206
|
|
|
203
|
-
const openFilePicker = (imageSource:FileInputImageSource = null):Promise<FileResult[]> => {
|
|
207
|
+
const openFilePicker = (imageSource: FileInputImageSource = null): Promise<FileResult[]> => {
|
|
204
208
|
return inputRef.current?.openFilePicker(imageSource)
|
|
205
209
|
}
|
|
206
210
|
|
|
@@ -42,12 +42,15 @@ const OuterInput:ValueBoundSelectProps<any, boolean>['outerInputComponent'] = (p
|
|
|
42
42
|
styles,
|
|
43
43
|
style,
|
|
44
44
|
placeholder,
|
|
45
|
+
disabled = false,
|
|
45
46
|
} = props
|
|
46
47
|
|
|
48
|
+
|
|
47
49
|
return <TextInput
|
|
48
50
|
value={TypeGuards.isString(currentValueLabel) ? currentValueLabel : null}
|
|
49
51
|
rightIcon={clearIcon}
|
|
50
|
-
onPress={() => toggle()}
|
|
52
|
+
onPress={disabled ? null : () => toggle()}
|
|
53
|
+
disabled={disabled}
|
|
51
54
|
label={label}
|
|
52
55
|
debugName={debugName}
|
|
53
56
|
styles={styles}
|
|
@@ -120,6 +123,7 @@ export const Select = <T extends string|number = string, Multi extends boolean =
|
|
|
120
123
|
getLabel,
|
|
121
124
|
searchInputProps,
|
|
122
125
|
outerInputComponent,
|
|
126
|
+
disabled = false,
|
|
123
127
|
...modalProps
|
|
124
128
|
} = allProps
|
|
125
129
|
|
|
@@ -314,7 +318,7 @@ export const Select = <T extends string|number = string, Multi extends boolean =
|
|
|
314
318
|
|
|
315
319
|
clearIcon={{
|
|
316
320
|
icon: inputIcon as IconPlaceholder,
|
|
317
|
-
onPress: onPressInputIcon,
|
|
321
|
+
onPress: disabled ? null : onPressInputIcon,
|
|
318
322
|
}}
|
|
319
323
|
|
|
320
324
|
currentValueLabel={currentValueLabel}
|
|
@@ -59,6 +59,7 @@ export type ValueBoundSelectProps<
|
|
|
59
59
|
getLabel?: (forOption: Multi extends true ? FormTypes.Options<T> : FormTypes.Options<T>[number]) => FormTypes.Label
|
|
60
60
|
outerInputComponent?: OuterInputComponent<T, Multi>
|
|
61
61
|
inputProps?: Partial<SelectOuterInputProps<T, Multi>>
|
|
62
|
+
disabled?: boolean
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export type ReplaceSelectProps<Props, T, Multi extends boolean = false> = Omit<
|