@caprionlinesrl/puck-plugin-media 0.1.4
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/LICENSE +21 -0
- package/README.md +422 -0
- package/dist/index.css +2288 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +479 -0
- package/dist/index.d.ts +479 -0
- package/dist/index.js +3029 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2990 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Language configuration for multilingual fields
|
|
6
|
+
*/
|
|
7
|
+
interface Language {
|
|
8
|
+
code: string;
|
|
9
|
+
label: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Default languages when not specified
|
|
13
|
+
*/
|
|
14
|
+
declare const DEFAULT_LANGUAGES: Language[];
|
|
15
|
+
/**
|
|
16
|
+
* Localized string value (e.g., { en: 'Hello', it: 'Ciao' })
|
|
17
|
+
*/
|
|
18
|
+
type LocalizedString = Record<string, string | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Image item - used both for API responses and stored values in Puck JSON
|
|
21
|
+
*/
|
|
22
|
+
interface ImageItem {
|
|
23
|
+
/** Unique identifier */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Full URL to the image file */
|
|
26
|
+
url: string;
|
|
27
|
+
/** Original filename */
|
|
28
|
+
filename?: string;
|
|
29
|
+
/** Alt text (multilingual) */
|
|
30
|
+
alt?: LocalizedString;
|
|
31
|
+
/** Image width in pixels */
|
|
32
|
+
width?: number;
|
|
33
|
+
/** Image height in pixels */
|
|
34
|
+
height?: number;
|
|
35
|
+
/** File size in bytes */
|
|
36
|
+
size?: number;
|
|
37
|
+
/** Thumbnail URL for faster loading in picker (falls back to url if not provided) */
|
|
38
|
+
thumbnailUrl?: string;
|
|
39
|
+
/** Creation date (useful for cache invalidation) */
|
|
40
|
+
createdAt?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Document item - used both for API responses and stored values in Puck JSON
|
|
44
|
+
*/
|
|
45
|
+
interface DocumentItem {
|
|
46
|
+
/** Unique identifier */
|
|
47
|
+
id: string;
|
|
48
|
+
/** Full URL to the document file */
|
|
49
|
+
url: string;
|
|
50
|
+
/** Original filename */
|
|
51
|
+
filename: string;
|
|
52
|
+
/** Display title (multilingual) */
|
|
53
|
+
title?: LocalizedString;
|
|
54
|
+
/** MIME type (e.g., 'application/pdf') */
|
|
55
|
+
mimeType: string;
|
|
56
|
+
/** File size in bytes */
|
|
57
|
+
size: number;
|
|
58
|
+
/** File extension (e.g., 'pdf', 'docx') */
|
|
59
|
+
extension: string;
|
|
60
|
+
/** Creation date (useful for cache invalidation) */
|
|
61
|
+
createdAt?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gallery item - used both for API responses and stored values in Puck JSON
|
|
65
|
+
*/
|
|
66
|
+
interface GalleryItem {
|
|
67
|
+
/** Unique identifier */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Gallery name */
|
|
70
|
+
name: string;
|
|
71
|
+
/** Cover image for preview */
|
|
72
|
+
coverImage?: ImageItem;
|
|
73
|
+
/** Images in the gallery */
|
|
74
|
+
images: ImageItem[];
|
|
75
|
+
/** Number of images in the gallery (optional, can be calculated from images.length) */
|
|
76
|
+
imageCount?: number;
|
|
77
|
+
/** Creation date (useful for cache invalidation) */
|
|
78
|
+
createdAt?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parameters passed to fetchList functions
|
|
82
|
+
*/
|
|
83
|
+
interface FetchListParams {
|
|
84
|
+
/** Search query string */
|
|
85
|
+
query?: string;
|
|
86
|
+
/** Page number (1-indexed) */
|
|
87
|
+
page?: number;
|
|
88
|
+
/** Items per page */
|
|
89
|
+
pageSize?: number;
|
|
90
|
+
/** Additional filters */
|
|
91
|
+
filters?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Result from fetchList - paginated result
|
|
95
|
+
*/
|
|
96
|
+
interface FetchListResult<T> {
|
|
97
|
+
/** Array of items */
|
|
98
|
+
items: T[];
|
|
99
|
+
/** Total number of items (for pagination) */
|
|
100
|
+
total?: number;
|
|
101
|
+
/** Whether there are more items to load */
|
|
102
|
+
hasMore?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Generic fetch list function type
|
|
106
|
+
*/
|
|
107
|
+
type FetchListFn<T> = (params: FetchListParams) => Promise<T[] | FetchListResult<T>>;
|
|
108
|
+
/**
|
|
109
|
+
* Callbacks passed to upload functions
|
|
110
|
+
*/
|
|
111
|
+
interface UploadCallbacks {
|
|
112
|
+
/** Called with upload progress (0-100) */
|
|
113
|
+
onProgress: (percent: number) => void;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Upload function that handles single or multiple files
|
|
117
|
+
*/
|
|
118
|
+
type UploadFn<T> = (files: File | File[], callbacks: UploadCallbacks) => Promise<T | T[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Configuration for file uploads
|
|
121
|
+
*/
|
|
122
|
+
interface UploadConfig {
|
|
123
|
+
/**
|
|
124
|
+
* Accepted file types (MIME types or extensions)
|
|
125
|
+
* @default 'image/*' for images, '*' for documents
|
|
126
|
+
*/
|
|
127
|
+
accept?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Maximum file size in bytes
|
|
130
|
+
* @default 10485760 (10MB)
|
|
131
|
+
*/
|
|
132
|
+
maxSize?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Allow multiple file uploads
|
|
135
|
+
* @default true
|
|
136
|
+
*/
|
|
137
|
+
multiple?: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Status of a file being uploaded
|
|
141
|
+
*/
|
|
142
|
+
type UploadStatus = 'pending' | 'uploading' | 'completed' | 'error';
|
|
143
|
+
/**
|
|
144
|
+
* State of a file in the upload queue
|
|
145
|
+
*/
|
|
146
|
+
interface UploadingFile {
|
|
147
|
+
/** Unique ID for this upload */
|
|
148
|
+
id: string;
|
|
149
|
+
/** The file being uploaded */
|
|
150
|
+
file: File;
|
|
151
|
+
/** Upload progress (0-100) */
|
|
152
|
+
progress: number;
|
|
153
|
+
/** Current upload status */
|
|
154
|
+
status: UploadStatus;
|
|
155
|
+
/** Error message if status is 'error' */
|
|
156
|
+
error?: string;
|
|
157
|
+
/** Resulting item if status is 'completed' */
|
|
158
|
+
result?: ImageItem | DocumentItem;
|
|
159
|
+
/** Preview URL for the file (blob URL) */
|
|
160
|
+
previewUrl?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Image-related callbacks
|
|
164
|
+
*/
|
|
165
|
+
interface ImageOptions {
|
|
166
|
+
/** Function to fetch image list from your API */
|
|
167
|
+
fetchList: FetchListFn<ImageItem>;
|
|
168
|
+
/** Function to upload images (optional) */
|
|
169
|
+
upload?: UploadFn<ImageItem>;
|
|
170
|
+
/** Function to update image metadata (alt text) */
|
|
171
|
+
update?: (id: string, data: {
|
|
172
|
+
alt?: LocalizedString;
|
|
173
|
+
}) => Promise<ImageItem>;
|
|
174
|
+
/** Function to delete an image (optional) */
|
|
175
|
+
delete?: (id: string) => Promise<void>;
|
|
176
|
+
/** Configuration for file uploads */
|
|
177
|
+
uploadConfig?: UploadConfig;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Gallery-related callbacks
|
|
181
|
+
*/
|
|
182
|
+
interface GalleryOptions {
|
|
183
|
+
/** Function to fetch gallery list from your API (required) */
|
|
184
|
+
fetchList: FetchListFn<GalleryItem>;
|
|
185
|
+
/** Function to fetch a single gallery by ID */
|
|
186
|
+
fetch: (id: string) => Promise<GalleryItem>;
|
|
187
|
+
/** Function to create a new gallery */
|
|
188
|
+
create: (name: string) => Promise<GalleryItem>;
|
|
189
|
+
/** Function to delete a gallery */
|
|
190
|
+
delete: (id: string) => Promise<void>;
|
|
191
|
+
/** Function to upload images to a gallery */
|
|
192
|
+
upload: (galleryId: string, files: File | File[], callbacks: UploadCallbacks) => Promise<ImageItem | ImageItem[]>;
|
|
193
|
+
/** Function to remove an image from a gallery */
|
|
194
|
+
removeImage: (galleryId: string, imageId: string) => Promise<void>;
|
|
195
|
+
/** Function to update image metadata within a gallery (optional - hides alt editing if not provided) */
|
|
196
|
+
updateImage?: (galleryId: string, imageId: string, data: {
|
|
197
|
+
alt?: LocalizedString;
|
|
198
|
+
}) => Promise<ImageItem>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Document-related callbacks
|
|
202
|
+
*/
|
|
203
|
+
interface DocumentOptions {
|
|
204
|
+
/** Function to fetch document list from your API */
|
|
205
|
+
fetchList: FetchListFn<DocumentItem>;
|
|
206
|
+
/** Function to upload documents (optional - hides upload area if not provided) */
|
|
207
|
+
upload?: UploadFn<DocumentItem>;
|
|
208
|
+
/** Function to update document metadata (title) (optional - hides edit icon if not provided) */
|
|
209
|
+
update?: (id: string, data: {
|
|
210
|
+
title?: LocalizedString;
|
|
211
|
+
}) => Promise<DocumentItem>;
|
|
212
|
+
/** Function to delete a document (optional - hides manage button if not provided) */
|
|
213
|
+
delete?: (id: string) => Promise<void>;
|
|
214
|
+
/** Configuration for file uploads */
|
|
215
|
+
uploadConfig?: UploadConfig;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Plugin configuration options
|
|
219
|
+
*/
|
|
220
|
+
interface MediaPluginOptions {
|
|
221
|
+
/**
|
|
222
|
+
* Languages for multilingual fields (alt, title)
|
|
223
|
+
* @default [{ code: 'it', label: 'Italiano' }, { code: 'en', label: 'English' }]
|
|
224
|
+
*/
|
|
225
|
+
languages?: Language[];
|
|
226
|
+
/**
|
|
227
|
+
* Image-related configuration (required)
|
|
228
|
+
*/
|
|
229
|
+
image: ImageOptions;
|
|
230
|
+
/**
|
|
231
|
+
* Gallery-related configuration (optional)
|
|
232
|
+
*/
|
|
233
|
+
gallery?: GalleryOptions;
|
|
234
|
+
/**
|
|
235
|
+
* Document-related configuration (optional)
|
|
236
|
+
*/
|
|
237
|
+
document?: DocumentOptions;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Internal props passed to ImageField component
|
|
241
|
+
*/
|
|
242
|
+
interface ImageFieldProps {
|
|
243
|
+
name: string;
|
|
244
|
+
value: ImageItem | null;
|
|
245
|
+
onChange: (value: ImageItem | null) => void;
|
|
246
|
+
field: {
|
|
247
|
+
label?: string;
|
|
248
|
+
[key: string]: unknown;
|
|
249
|
+
};
|
|
250
|
+
languages: Language[];
|
|
251
|
+
imageOptions: ImageOptions;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Internal props passed to GalleryField component
|
|
255
|
+
*/
|
|
256
|
+
interface GalleryFieldProps {
|
|
257
|
+
name: string;
|
|
258
|
+
value: GalleryItem | null;
|
|
259
|
+
onChange: (value: GalleryItem | null) => void;
|
|
260
|
+
field: {
|
|
261
|
+
label?: string;
|
|
262
|
+
[key: string]: unknown;
|
|
263
|
+
};
|
|
264
|
+
languages: Language[];
|
|
265
|
+
galleryOptions: GalleryOptions;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Internal props passed to DocumentField component
|
|
269
|
+
*/
|
|
270
|
+
interface DocumentFieldProps {
|
|
271
|
+
name: string;
|
|
272
|
+
value: DocumentItem | null;
|
|
273
|
+
onChange: (value: DocumentItem | null) => void;
|
|
274
|
+
field: {
|
|
275
|
+
label?: string;
|
|
276
|
+
[key: string]: unknown;
|
|
277
|
+
};
|
|
278
|
+
languages: Language[];
|
|
279
|
+
documentOptions: DocumentOptions;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Props for ImagePickerModal component
|
|
283
|
+
*/
|
|
284
|
+
interface ImagePickerModalProps {
|
|
285
|
+
languages: Language[];
|
|
286
|
+
imageOptions: ImageOptions;
|
|
287
|
+
title?: string;
|
|
288
|
+
selectedImage?: ImageItem | null;
|
|
289
|
+
onSelect?: (item: ImageItem) => void;
|
|
290
|
+
onClose: () => void;
|
|
291
|
+
/** When false, hides the "Select Image" button. Useful for media library mode. Default: true */
|
|
292
|
+
selectable?: boolean;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Props for GalleryPickerModal component
|
|
296
|
+
*/
|
|
297
|
+
interface GalleryPickerModalProps {
|
|
298
|
+
languages: Language[];
|
|
299
|
+
galleryOptions: GalleryOptions;
|
|
300
|
+
title?: string;
|
|
301
|
+
selectedGallery?: GalleryItem | null;
|
|
302
|
+
onSelect?: (gallery: GalleryItem) => void;
|
|
303
|
+
onClose: () => void;
|
|
304
|
+
/** When false, hides the "Select Gallery" button. Useful for media library mode. Default: true */
|
|
305
|
+
selectable?: boolean;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Props for DocumentPickerModal component
|
|
309
|
+
*/
|
|
310
|
+
interface DocumentPickerModalProps {
|
|
311
|
+
languages: Language[];
|
|
312
|
+
documentOptions: DocumentOptions;
|
|
313
|
+
title?: string;
|
|
314
|
+
selectedDocument?: DocumentItem | null;
|
|
315
|
+
onSelect?: (item: DocumentItem) => void;
|
|
316
|
+
onClose: () => void;
|
|
317
|
+
/** When false, hides the "Select Document" button. Useful for media library mode. Default: true */
|
|
318
|
+
selectable?: boolean;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Props for ImageGrid component
|
|
322
|
+
*/
|
|
323
|
+
interface ImageGridProps {
|
|
324
|
+
items: ImageItem[];
|
|
325
|
+
onSelect: (item: ImageItem) => void;
|
|
326
|
+
selectedId?: string;
|
|
327
|
+
loading?: boolean;
|
|
328
|
+
/** Callback when user clicks edit icon */
|
|
329
|
+
onEditAlt?: (item: ImageItem) => void;
|
|
330
|
+
/** Whether manage mode is active (for bulk delete) */
|
|
331
|
+
manageMode?: boolean;
|
|
332
|
+
/** Set of selected item IDs for bulk operations */
|
|
333
|
+
selectedIds?: Set<string>;
|
|
334
|
+
/** Callback when user toggles selection in manage mode */
|
|
335
|
+
onToggleSelect?: (item: ImageItem) => void;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Puck Plugin type
|
|
339
|
+
*/
|
|
340
|
+
interface PuckPlugin {
|
|
341
|
+
name: string;
|
|
342
|
+
label?: string;
|
|
343
|
+
icon?: ReactNode;
|
|
344
|
+
render?: () => ReactNode;
|
|
345
|
+
overrides?: {
|
|
346
|
+
fieldTypes?: Record<string, (props: unknown) => ReactNode>;
|
|
347
|
+
[key: string]: unknown;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Create a Puck plugin for media library integration
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```tsx
|
|
356
|
+
* import { createMediaPlugin } from '@onda-suite/puck-plugin-media';
|
|
357
|
+
*
|
|
358
|
+
* const mediaPlugin = createMediaPlugin({
|
|
359
|
+
* // Optional: configure languages for alt/title fields
|
|
360
|
+
* languages: [
|
|
361
|
+
* { code: 'it', label: 'Italiano' },
|
|
362
|
+
* { code: 'en', label: 'English' },
|
|
363
|
+
* ],
|
|
364
|
+
*
|
|
365
|
+
* // Image configuration (required)
|
|
366
|
+
* image: {
|
|
367
|
+
* fetchList: async ({ query, page, pageSize }) => {
|
|
368
|
+
* const res = await fetch(`/api/images?q=${query}&page=${page}`);
|
|
369
|
+
* return res.json();
|
|
370
|
+
* },
|
|
371
|
+
* upload: async (file, { onProgress }) => {
|
|
372
|
+
* // Upload with progress tracking...
|
|
373
|
+
* return uploadedImageItem;
|
|
374
|
+
* },
|
|
375
|
+
* update: async (id, { alt }) => {
|
|
376
|
+
* // Update alt text
|
|
377
|
+
* return updatedImageItem;
|
|
378
|
+
* },
|
|
379
|
+
* delete: async (id) => {
|
|
380
|
+
* // Delete image (enables "Select Items" mode)
|
|
381
|
+
* },
|
|
382
|
+
* uploadConfig: {
|
|
383
|
+
* accept: 'image/*',
|
|
384
|
+
* maxSize: 10 * 1024 * 1024, // 10MB
|
|
385
|
+
* multiple: true,
|
|
386
|
+
* },
|
|
387
|
+
* },
|
|
388
|
+
*
|
|
389
|
+
* // Gallery configuration (optional)
|
|
390
|
+
* gallery: {
|
|
391
|
+
* fetchList: async ({ query, page }) => { ... },
|
|
392
|
+
* fetch: async (id) => { ... },
|
|
393
|
+
* create: async (name) => { ... },
|
|
394
|
+
* delete: async (id) => { ... },
|
|
395
|
+
* upload: async (galleryId, file, { onProgress }) => { ... },
|
|
396
|
+
* removeImage: async (galleryId, imageId) => { ... },
|
|
397
|
+
* updateImage: async (galleryId, imageId, { alt }) => { ... },
|
|
398
|
+
* },
|
|
399
|
+
*
|
|
400
|
+
* // Document configuration (optional)
|
|
401
|
+
* document: {
|
|
402
|
+
* fetchList: async ({ query, page }) => { ... },
|
|
403
|
+
* upload: async (file, { onProgress }) => { ... },
|
|
404
|
+
* update: async (id, { title }) => { ... },
|
|
405
|
+
* delete: async (id) => {
|
|
406
|
+
* // Delete document (enables "Select Items" mode)
|
|
407
|
+
* },
|
|
408
|
+
* uploadConfig: {
|
|
409
|
+
* accept: '.pdf,.doc,.docx,.xls,.xlsx',
|
|
410
|
+
* maxSize: 20 * 1024 * 1024, // 20MB
|
|
411
|
+
* multiple: true,
|
|
412
|
+
* },
|
|
413
|
+
* },
|
|
414
|
+
* });
|
|
415
|
+
*
|
|
416
|
+
* <Puck config={config} plugins={[mediaPlugin]} />
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
declare function createMediaPlugin(options: MediaPluginOptions): PuckPlugin;
|
|
420
|
+
|
|
421
|
+
declare function ImageField({ value, onChange, field, languages, imageOptions, }: ImageFieldProps): react_jsx_runtime.JSX.Element;
|
|
422
|
+
|
|
423
|
+
declare function ImagePickerModal({ languages, imageOptions, title, selectedImage, onSelect, onClose, selectable, }: ImagePickerModalProps): react_jsx_runtime.JSX.Element;
|
|
424
|
+
|
|
425
|
+
declare function ImageGrid({ items, onSelect, selectedId, onEditAlt, manageMode, selectedIds, onToggleSelect, }: ImageGridProps): react_jsx_runtime.JSX.Element;
|
|
426
|
+
|
|
427
|
+
declare function GalleryField({ value, onChange, field, languages, galleryOptions, }: GalleryFieldProps): react_jsx_runtime.JSX.Element;
|
|
428
|
+
|
|
429
|
+
declare function GalleryPickerModal({ languages, galleryOptions, title, selectedGallery: _initialSelectedGallery, onSelect, onClose, selectable, }: GalleryPickerModalProps): react_jsx_runtime.JSX.Element;
|
|
430
|
+
|
|
431
|
+
declare function DocumentField({ value, onChange, field, languages, documentOptions, }: DocumentFieldProps): react_jsx_runtime.JSX.Element;
|
|
432
|
+
|
|
433
|
+
declare function DocumentPickerModal({ languages, documentOptions, title, selectedDocument, onSelect, onClose, selectable, }: DocumentPickerModalProps): react_jsx_runtime.JSX.Element;
|
|
434
|
+
|
|
435
|
+
interface MediaPanelProps {
|
|
436
|
+
languages: Language[];
|
|
437
|
+
imageOptions: ImageOptions;
|
|
438
|
+
galleryOptions?: GalleryOptions;
|
|
439
|
+
documentOptions?: DocumentOptions;
|
|
440
|
+
}
|
|
441
|
+
declare function MediaPanel({ languages, imageOptions, galleryOptions, documentOptions, }: MediaPanelProps): react_jsx_runtime.JSX.Element;
|
|
442
|
+
|
|
443
|
+
interface UploadDropzoneProps {
|
|
444
|
+
onFilesSelected: (files: FileList) => void;
|
|
445
|
+
config: Required<UploadConfig>;
|
|
446
|
+
disabled?: boolean;
|
|
447
|
+
}
|
|
448
|
+
declare function UploadDropzone({ onFilesSelected, config, disabled, }: UploadDropzoneProps): react_jsx_runtime.JSX.Element;
|
|
449
|
+
|
|
450
|
+
interface UploadQueueProps {
|
|
451
|
+
files: UploadingFile[];
|
|
452
|
+
onCancel: (id: string) => void;
|
|
453
|
+
onClearCompleted: () => void;
|
|
454
|
+
}
|
|
455
|
+
declare function UploadQueue({ files, onCancel, onClearCompleted }: UploadQueueProps): react_jsx_runtime.JSX.Element | null;
|
|
456
|
+
|
|
457
|
+
declare const formatFileSize: (bytes: number) => string;
|
|
458
|
+
interface UseUploadOptions<T extends ImageItem | DocumentItem> {
|
|
459
|
+
upload: UploadFn<T>;
|
|
460
|
+
config?: UploadConfig;
|
|
461
|
+
onUploadComplete?: (item: T) => void;
|
|
462
|
+
}
|
|
463
|
+
interface UseUploadReturn {
|
|
464
|
+
/** Files currently being uploaded */
|
|
465
|
+
uploading: UploadingFile[];
|
|
466
|
+
/** Whether any upload is in progress */
|
|
467
|
+
isUploading: boolean;
|
|
468
|
+
/** Add files to upload queue */
|
|
469
|
+
addFiles: (files: FileList | File[]) => void;
|
|
470
|
+
/** Cancel a specific upload */
|
|
471
|
+
cancelUpload: (id: string) => void;
|
|
472
|
+
/** Clear completed/errored uploads */
|
|
473
|
+
clearCompleted: () => void;
|
|
474
|
+
/** The merged config being used */
|
|
475
|
+
uploadConfig: Required<UploadConfig>;
|
|
476
|
+
}
|
|
477
|
+
declare function useUpload<T extends ImageItem | DocumentItem>({ upload, config, onUploadComplete, }: UseUploadOptions<T>): UseUploadReturn;
|
|
478
|
+
|
|
479
|
+
export { DEFAULT_LANGUAGES, DocumentField, type DocumentItem, type DocumentOptions, DocumentPickerModal, type FetchListFn, type FetchListParams, type FetchListResult, GalleryField, type GalleryItem, type GalleryOptions, GalleryPickerModal, ImageField, ImageGrid, type ImageItem, type ImageOptions, ImagePickerModal, type Language, type LocalizedString, MediaPanel, type MediaPluginOptions, type UploadCallbacks, type UploadConfig, UploadDropzone, type UploadFn, UploadQueue, type UploadStatus, type UploadingFile, createMediaPlugin, formatFileSize, useUpload };
|