@cloudparker/moldex.js 0.0.52 → 0.0.53
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.
|
@@ -66,8 +66,7 @@ export declare function openCropperDialog<T, R>({ outputWidth, outputFormat, out
|
|
|
66
66
|
* @param multiple - A boolean indicating if multiple files can be selected.
|
|
67
67
|
* @returns A promise that resolves to a File or an array of File objects, or null if no files were selected.
|
|
68
68
|
*/
|
|
69
|
-
export declare function openFilePickerDialog<T extends File | File[]>(
|
|
70
|
-
accepts: string | string[];
|
|
69
|
+
export declare function openFilePickerDialog<T extends File | File[]>(accepts?: string | string[], options?: {
|
|
71
70
|
multiple: boolean;
|
|
72
71
|
}): Promise<T | null>;
|
|
73
72
|
/**
|
|
@@ -77,7 +76,7 @@ export declare function openFilePickerDialog<T extends File | File[]>({ accepts,
|
|
|
77
76
|
* @param options - Additional options for capturing images (e.g., required resolution, file size, output format).
|
|
78
77
|
* @returns A promise that resolves to a processed File object or an array of File objects, or null if no file was selected.
|
|
79
78
|
*/
|
|
80
|
-
export declare function openImagePickerDialog(accepts?: string | string[], options?: {
|
|
79
|
+
export declare function openImagePickerDialog<T extends File | File[]>(accepts?: string | string[], options?: {
|
|
81
80
|
multiple?: boolean;
|
|
82
81
|
capture?: 'user' | 'environment';
|
|
83
82
|
maxWidth?: number;
|
|
@@ -85,4 +84,4 @@ export declare function openImagePickerDialog(accepts?: string | string[], optio
|
|
|
85
84
|
maxSizeInBytes?: number;
|
|
86
85
|
outputFormat?: 'image/webp' | 'image/jpeg' | 'image/png';
|
|
87
86
|
quality?: number;
|
|
88
|
-
}): Promise<
|
|
87
|
+
}): Promise<T | null>;
|
|
@@ -176,7 +176,7 @@ export async function openCropperDialog({ outputWidth, outputFormat = 'webp', ou
|
|
|
176
176
|
* @param multiple - A boolean indicating if multiple files can be selected.
|
|
177
177
|
* @returns A promise that resolves to a File or an array of File objects, or null if no files were selected.
|
|
178
178
|
*/
|
|
179
|
-
export async function openFilePickerDialog(
|
|
179
|
+
export async function openFilePickerDialog(accepts = '*/*', options = { multiple: false }) {
|
|
180
180
|
// Check if the browser supports the required File API and input element
|
|
181
181
|
if (typeof window === 'undefined' || typeof document === 'undefined' || !window.File || !window.FileList || !window.FileReader) {
|
|
182
182
|
console.error('File APIs are not fully supported in this browser.');
|
|
@@ -196,13 +196,13 @@ export async function openFilePickerDialog({ accepts = '*/*', multiple = false }
|
|
|
196
196
|
inputElement.accept = accepts;
|
|
197
197
|
}
|
|
198
198
|
// Set multiple attribute based on the parameter
|
|
199
|
-
inputElement.multiple = multiple;
|
|
199
|
+
inputElement.multiple = options.multiple;
|
|
200
200
|
// Listen for changes (i.e., when files are selected)
|
|
201
201
|
inputElement.addEventListener('change', () => {
|
|
202
202
|
// Check if files were selected
|
|
203
203
|
if (inputElement.files) {
|
|
204
204
|
// If multiple is true, return an array of File objects
|
|
205
|
-
if (multiple) {
|
|
205
|
+
if (options.multiple) {
|
|
206
206
|
resolve(Array.from(inputElement.files));
|
|
207
207
|
}
|
|
208
208
|
else {
|
|
@@ -261,7 +261,7 @@ export async function openImagePickerDialog(accepts = 'image/*', options) {
|
|
|
261
261
|
resolve(processedFiles);
|
|
262
262
|
}
|
|
263
263
|
else {
|
|
264
|
-
resolve(processedFiles[0] || null);
|
|
264
|
+
resolve((processedFiles[0] || null));
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
catch (error) {
|
|
@@ -37,15 +37,9 @@
|
|
|
37
37
|
inputFieldRef && inputFieldRef.select();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async function handleFileAttachment() {
|
|
40
|
+
async function handleFileAttachment<T extends File | File[]>() {
|
|
41
41
|
let res: File | File[] | null = null;
|
|
42
|
-
|
|
43
|
-
if (multiple) {
|
|
44
|
-
res = await openFilePickerDialog<File[]>({ accepts, multiple });
|
|
45
|
-
} else {
|
|
46
|
-
res = await openFilePickerDialog<File>({ accepts, multiple });
|
|
47
|
-
}
|
|
48
|
-
|
|
42
|
+
res = await openFilePickerDialog<T>(accepts, { multiple: multiple || false });
|
|
49
43
|
if (res) {
|
|
50
44
|
value = res;
|
|
51
45
|
if (multiple) {
|