@uploadista/react 0.0.3 → 0.0.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/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/upload-zone-Cqvu-rTY.js +2 -0
- package/dist/upload-zone-Cqvu-rTY.js.map +1 -0
- package/dist/uploadista-provider-D8GQ2GhF.d.ts +1240 -0
- package/dist/uploadista-provider-D8GQ2GhF.d.ts.map +1 -0
- package/dist/use-upload-DpDLlhUA.js +2 -0
- package/dist/use-upload-DpDLlhUA.js.map +1 -0
- package/dist/use-upload-metrics-9Q-8Hij9.d.ts +382 -0
- package/dist/use-upload-metrics-9Q-8Hij9.d.ts.map +1 -0
- package/dist/use-upload-metrics-Dhx_po4K.js +2 -0
- package/dist/use-upload-metrics-Dhx_po4K.js.map +1 -0
- package/dist/use-uploadista-client-CeFo4wuV.d.ts +772 -0
- package/dist/use-uploadista-client-CeFo4wuV.d.ts.map +1 -0
- package/package.json +19 -9
- package/src/components/index.tsx +43 -0
- package/src/hooks/index.ts +49 -0
- package/tsdown.config.ts +14 -0
- package/.turbo/turbo-check.log +0 -89
|
@@ -0,0 +1,1240 @@
|
|
|
1
|
+
import { b as UseDragDropReturn, d as UseUploadOptions, f as UseUploadReturn, g as UseFlowUploadReturn, i as MultiUploadOptions, n as UseUploadistaClientReturn, o as UploadItem, s as UseMultiUploadReturn, t as UseUploadistaClientOptions, v as DragDropOptions } from "./use-uploadista-client-CeFo4wuV.js";
|
|
2
|
+
import React$1, { ReactNode } from "react";
|
|
3
|
+
import { BrowserUploadInput, FlowUploadConfig, FlowUploadItem, FlowUploadOptions, MultiFlowUploadOptions, UploadistaEvent } from "@uploadista/client-browser";
|
|
4
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/flow-upload-list.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Render props passed to the FlowUploadList children function.
|
|
10
|
+
* Provides access to upload items, aggregate statistics, and control methods.
|
|
11
|
+
*
|
|
12
|
+
* @property items - All flow upload items in the queue
|
|
13
|
+
* @property totalProgress - Average progress across all uploads (0-100)
|
|
14
|
+
* @property activeUploads - Count of currently uploading items
|
|
15
|
+
* @property completedUploads - Count of successfully completed uploads
|
|
16
|
+
* @property failedUploads - Count of failed uploads
|
|
17
|
+
* @property isUploading - True when any uploads are in progress
|
|
18
|
+
* @property addFiles - Add new files to the upload queue
|
|
19
|
+
* @property removeFile - Remove a specific file from the queue
|
|
20
|
+
* @property startUpload - Begin uploading all pending files
|
|
21
|
+
* @property abortUpload - Cancel a specific active upload
|
|
22
|
+
* @property abortAll - Cancel all active uploads
|
|
23
|
+
* @property clear - Remove all items from the queue
|
|
24
|
+
* @property retryUpload - Retry a specific failed upload
|
|
25
|
+
*/
|
|
26
|
+
interface FlowUploadListRenderProps {
|
|
27
|
+
/**
|
|
28
|
+
* List of upload items
|
|
29
|
+
*/
|
|
30
|
+
items: FlowUploadItem<BrowserUploadInput>[];
|
|
31
|
+
/**
|
|
32
|
+
* Total progress across all uploads
|
|
33
|
+
*/
|
|
34
|
+
totalProgress: number;
|
|
35
|
+
/**
|
|
36
|
+
* Number of active uploads
|
|
37
|
+
*/
|
|
38
|
+
activeUploads: number;
|
|
39
|
+
/**
|
|
40
|
+
* Number of completed uploads
|
|
41
|
+
*/
|
|
42
|
+
completedUploads: number;
|
|
43
|
+
/**
|
|
44
|
+
* Number of failed uploads
|
|
45
|
+
*/
|
|
46
|
+
failedUploads: number;
|
|
47
|
+
/**
|
|
48
|
+
* Whether any uploads are in progress
|
|
49
|
+
*/
|
|
50
|
+
isUploading: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Add files to the upload queue
|
|
53
|
+
*/
|
|
54
|
+
addFiles: (files: File[] | FileList) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Remove a file from the queue
|
|
57
|
+
*/
|
|
58
|
+
removeFile: (id: string) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Start uploading all pending files
|
|
61
|
+
*/
|
|
62
|
+
startUpload: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Abort a specific upload
|
|
65
|
+
*/
|
|
66
|
+
abortUpload: (id: string) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Abort all uploads
|
|
69
|
+
*/
|
|
70
|
+
abortAll: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Clear all items
|
|
73
|
+
*/
|
|
74
|
+
clear: () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Retry a failed upload
|
|
77
|
+
*/
|
|
78
|
+
retryUpload: (id: string) => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Props for the FlowUploadList component.
|
|
82
|
+
*
|
|
83
|
+
* @property flowConfig - Flow execution configuration (flowId, storageId, etc.)
|
|
84
|
+
* @property options - Multi-flow upload options (callbacks, concurrency, etc.)
|
|
85
|
+
* @property children - Render function receiving flow upload list state
|
|
86
|
+
*/
|
|
87
|
+
interface FlowUploadListProps {
|
|
88
|
+
/**
|
|
89
|
+
* Flow configuration
|
|
90
|
+
*/
|
|
91
|
+
flowConfig: FlowUploadConfig;
|
|
92
|
+
/**
|
|
93
|
+
* Multi-upload options
|
|
94
|
+
*/
|
|
95
|
+
options?: Omit<MultiFlowUploadOptions<BrowserUploadInput>, "flowConfig">;
|
|
96
|
+
/**
|
|
97
|
+
* Render function for the upload list
|
|
98
|
+
*/
|
|
99
|
+
children: (props: FlowUploadListRenderProps) => ReactNode;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Headless flow upload list component for managing batch file uploads through a flow.
|
|
103
|
+
* Uses render props pattern to provide complete control over the UI while handling
|
|
104
|
+
* concurrent uploads and flow processing.
|
|
105
|
+
*
|
|
106
|
+
* Each file is uploaded and processed independently through the specified flow,
|
|
107
|
+
* with automatic queue management and concurrency control.
|
|
108
|
+
*
|
|
109
|
+
* Must be used within an UploadistaProvider.
|
|
110
|
+
*
|
|
111
|
+
* @param props - Flow upload list configuration and render prop
|
|
112
|
+
* @returns Rendered flow upload list using the provided render prop
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```tsx
|
|
116
|
+
* // Batch image processing with custom UI
|
|
117
|
+
* <FlowUploadList
|
|
118
|
+
* flowConfig={{
|
|
119
|
+
* flowId: "image-batch-processing",
|
|
120
|
+
* storageId: "s3-images",
|
|
121
|
+
* outputNodeId: "optimized",
|
|
122
|
+
* }}
|
|
123
|
+
* options={{
|
|
124
|
+
* maxConcurrent: 3,
|
|
125
|
+
* onItemSuccess: (item) => {
|
|
126
|
+
* console.log(`${item.file.name} processed successfully`);
|
|
127
|
+
* },
|
|
128
|
+
* onComplete: (items) => {
|
|
129
|
+
* const successful = items.filter(i => i.status === 'success');
|
|
130
|
+
* console.log(`Batch complete: ${successful.length}/${items.length} successful`);
|
|
131
|
+
* },
|
|
132
|
+
* }}
|
|
133
|
+
* >
|
|
134
|
+
* {({
|
|
135
|
+
* items,
|
|
136
|
+
* totalProgress,
|
|
137
|
+
* activeUploads,
|
|
138
|
+
* completedUploads,
|
|
139
|
+
* failedUploads,
|
|
140
|
+
* addFiles,
|
|
141
|
+
* startUpload,
|
|
142
|
+
* abortUpload,
|
|
143
|
+
* retryUpload,
|
|
144
|
+
* clear,
|
|
145
|
+
* }) => (
|
|
146
|
+
* <div>
|
|
147
|
+
* <input
|
|
148
|
+
* type="file"
|
|
149
|
+
* multiple
|
|
150
|
+
* accept="image/*"
|
|
151
|
+
* onChange={(e) => {
|
|
152
|
+
* if (e.target.files) {
|
|
153
|
+
* addFiles(e.target.files);
|
|
154
|
+
* startUpload();
|
|
155
|
+
* }
|
|
156
|
+
* }}
|
|
157
|
+
* />
|
|
158
|
+
*
|
|
159
|
+
* <div style={{ marginTop: '1rem' }}>
|
|
160
|
+
* <h3>Upload Progress</h3>
|
|
161
|
+
* <div>Overall: {totalProgress}%</div>
|
|
162
|
+
* <div>
|
|
163
|
+
* Active: {activeUploads}, Completed: {completedUploads}, Failed: {failedUploads}
|
|
164
|
+
* </div>
|
|
165
|
+
* <button onClick={clear}>Clear All</button>
|
|
166
|
+
* </div>
|
|
167
|
+
*
|
|
168
|
+
* <ul style={{ listStyle: 'none', padding: 0 }}>
|
|
169
|
+
* {items.map((item) => (
|
|
170
|
+
* <li key={item.id} style={{
|
|
171
|
+
* padding: '1rem',
|
|
172
|
+
* border: '1px solid #ccc',
|
|
173
|
+
* marginBottom: '0.5rem'
|
|
174
|
+
* }}>
|
|
175
|
+
* <div>{item.file instanceof File ? item.file.name : 'File'}</div>
|
|
176
|
+
* <div>Status: {item.status}</div>
|
|
177
|
+
*
|
|
178
|
+
* {item.status === "uploading" && (
|
|
179
|
+
* <div>
|
|
180
|
+
* <progress value={item.progress} max={100} style={{ width: '100%' }} />
|
|
181
|
+
* <div>{item.progress}%</div>
|
|
182
|
+
* <button onClick={() => abortUpload(item.id)}>Cancel</button>
|
|
183
|
+
* </div>
|
|
184
|
+
* )}
|
|
185
|
+
*
|
|
186
|
+
* {item.status === "error" && (
|
|
187
|
+
* <div>
|
|
188
|
+
* <div style={{ color: 'red' }}>{item.error?.message}</div>
|
|
189
|
+
* <button onClick={() => retryUpload(item.id)}>Retry</button>
|
|
190
|
+
* </div>
|
|
191
|
+
* )}
|
|
192
|
+
*
|
|
193
|
+
* {item.status === "success" && (
|
|
194
|
+
* <div style={{ color: 'green' }}>✓ Complete</div>
|
|
195
|
+
* )}
|
|
196
|
+
* </li>
|
|
197
|
+
* ))}
|
|
198
|
+
* </ul>
|
|
199
|
+
* </div>
|
|
200
|
+
* )}
|
|
201
|
+
* </FlowUploadList>
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @see {@link SimpleFlowUploadList} for a pre-styled version
|
|
205
|
+
* @see {@link useMultiFlowUpload} for the underlying hook
|
|
206
|
+
*/
|
|
207
|
+
declare function FlowUploadList({
|
|
208
|
+
flowConfig,
|
|
209
|
+
options,
|
|
210
|
+
children
|
|
211
|
+
}: FlowUploadListProps): react_jsx_runtime0.JSX.Element;
|
|
212
|
+
/**
|
|
213
|
+
* Props for the SimpleFlowUploadListItem component.
|
|
214
|
+
*
|
|
215
|
+
* @property item - The flow upload item to display
|
|
216
|
+
* @property onAbort - Called when the abort button is clicked
|
|
217
|
+
* @property onRetry - Called when the retry button is clicked
|
|
218
|
+
* @property onRemove - Called when the remove button is clicked
|
|
219
|
+
*/
|
|
220
|
+
interface SimpleFlowUploadListItemProps {
|
|
221
|
+
/**
|
|
222
|
+
* Upload item
|
|
223
|
+
*/
|
|
224
|
+
item: FlowUploadItem<BrowserUploadInput>;
|
|
225
|
+
/**
|
|
226
|
+
* Abort the upload
|
|
227
|
+
*/
|
|
228
|
+
onAbort: () => void;
|
|
229
|
+
/**
|
|
230
|
+
* Retry the upload
|
|
231
|
+
*/
|
|
232
|
+
onRetry: () => void;
|
|
233
|
+
/**
|
|
234
|
+
* Remove the item
|
|
235
|
+
*/
|
|
236
|
+
onRemove: () => void;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Pre-styled flow upload list item component with status indicators.
|
|
240
|
+
* Displays file name, upload progress, status, and contextual action buttons.
|
|
241
|
+
*
|
|
242
|
+
* Features:
|
|
243
|
+
* - Status-specific icons and colors
|
|
244
|
+
* - Progress bar with percentage and byte count
|
|
245
|
+
* - Error message display
|
|
246
|
+
* - Contextual action buttons (cancel, retry, remove)
|
|
247
|
+
*
|
|
248
|
+
* @param props - Upload item and callback functions
|
|
249
|
+
* @returns Styled flow upload list item component
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```tsx
|
|
253
|
+
* <SimpleFlowUploadListItem
|
|
254
|
+
* item={uploadItem}
|
|
255
|
+
* onAbort={() => console.log('Abort')}
|
|
256
|
+
* onRetry={() => console.log('Retry')}
|
|
257
|
+
* onRemove={() => console.log('Remove')}
|
|
258
|
+
* />
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
declare function SimpleFlowUploadListItem({
|
|
262
|
+
item,
|
|
263
|
+
onAbort,
|
|
264
|
+
onRetry,
|
|
265
|
+
onRemove
|
|
266
|
+
}: SimpleFlowUploadListItemProps): react_jsx_runtime0.JSX.Element;
|
|
267
|
+
/**
|
|
268
|
+
* Props for the SimpleFlowUploadList component.
|
|
269
|
+
*
|
|
270
|
+
* @property flowConfig - Flow execution configuration
|
|
271
|
+
* @property options - Multi-flow upload options (callbacks, concurrency)
|
|
272
|
+
* @property className - CSS class name for the container
|
|
273
|
+
* @property showFileInput - Whether to display the file input (default: true)
|
|
274
|
+
* @property accept - Accepted file types for the file input
|
|
275
|
+
*/
|
|
276
|
+
interface SimpleFlowUploadListProps {
|
|
277
|
+
/**
|
|
278
|
+
* Flow configuration
|
|
279
|
+
*/
|
|
280
|
+
flowConfig: FlowUploadConfig;
|
|
281
|
+
/**
|
|
282
|
+
* Multi-upload options
|
|
283
|
+
*/
|
|
284
|
+
options?: Omit<MultiFlowUploadOptions<BrowserUploadInput>, "flowConfig">;
|
|
285
|
+
/**
|
|
286
|
+
* CSS class for the container
|
|
287
|
+
*/
|
|
288
|
+
className?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Show file input
|
|
291
|
+
*/
|
|
292
|
+
showFileInput?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* File input accept attribute
|
|
295
|
+
*/
|
|
296
|
+
accept?: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Simple pre-styled flow upload list component with built-in UI.
|
|
300
|
+
* Provides a ready-to-use interface for batch file uploads with flow processing.
|
|
301
|
+
*
|
|
302
|
+
* Features:
|
|
303
|
+
* - Built-in file input
|
|
304
|
+
* - Overall progress display
|
|
305
|
+
* - Individual item progress tracking
|
|
306
|
+
* - Status indicators and action buttons
|
|
307
|
+
* - Automatic upload start on file selection
|
|
308
|
+
*
|
|
309
|
+
* @param props - Flow upload list configuration with styling options
|
|
310
|
+
* @returns Styled flow upload list component
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```tsx
|
|
314
|
+
* // Basic batch image upload
|
|
315
|
+
* <SimpleFlowUploadList
|
|
316
|
+
* flowConfig={{
|
|
317
|
+
* flowId: "image-batch-processing",
|
|
318
|
+
* storageId: "s3-images",
|
|
319
|
+
* }}
|
|
320
|
+
* options={{
|
|
321
|
+
* maxConcurrent: 3,
|
|
322
|
+
* onItemSuccess: (item) => {
|
|
323
|
+
* console.log(`${item.file.name} processed`);
|
|
324
|
+
* },
|
|
325
|
+
* onComplete: (items) => {
|
|
326
|
+
* console.log("Batch complete:", items.length);
|
|
327
|
+
* },
|
|
328
|
+
* }}
|
|
329
|
+
* accept="image/*"
|
|
330
|
+
* className="my-upload-list"
|
|
331
|
+
* />
|
|
332
|
+
*
|
|
333
|
+
* // Without file input (add files programmatically)
|
|
334
|
+
* <SimpleFlowUploadList
|
|
335
|
+
* flowConfig={{
|
|
336
|
+
* flowId: "document-processing",
|
|
337
|
+
* storageId: "docs",
|
|
338
|
+
* }}
|
|
339
|
+
* showFileInput={false}
|
|
340
|
+
* options={{
|
|
341
|
+
* maxConcurrent: 2,
|
|
342
|
+
* }}
|
|
343
|
+
* />
|
|
344
|
+
* ```
|
|
345
|
+
*
|
|
346
|
+
* @see {@link FlowUploadList} for the headless version with full control
|
|
347
|
+
*/
|
|
348
|
+
declare function SimpleFlowUploadList({
|
|
349
|
+
flowConfig,
|
|
350
|
+
options,
|
|
351
|
+
className,
|
|
352
|
+
showFileInput,
|
|
353
|
+
accept
|
|
354
|
+
}: SimpleFlowUploadListProps): react_jsx_runtime0.JSX.Element;
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/components/flow-upload-zone.d.ts
|
|
357
|
+
/**
|
|
358
|
+
* Render props passed to the FlowUploadZone children function.
|
|
359
|
+
* Provides access to flow upload state, drag-drop handlers, and helper functions.
|
|
360
|
+
*
|
|
361
|
+
* @property dragDrop - Complete drag-and-drop state and handlers
|
|
362
|
+
* @property flowUpload - Flow upload hook with upload state and controls
|
|
363
|
+
* @property isActive - True when dragging over zone
|
|
364
|
+
* @property openFilePicker - Programmatically open file selection dialog
|
|
365
|
+
* @property getRootProps - Returns props to spread on the drop zone container
|
|
366
|
+
* @property getInputProps - Returns props to spread on the hidden file input
|
|
367
|
+
*/
|
|
368
|
+
interface FlowUploadZoneRenderProps {
|
|
369
|
+
/**
|
|
370
|
+
* Drag and drop state and handlers
|
|
371
|
+
*/
|
|
372
|
+
dragDrop: UseDragDropReturn;
|
|
373
|
+
/**
|
|
374
|
+
* Flow upload functionality
|
|
375
|
+
*/
|
|
376
|
+
flowUpload: UseFlowUploadReturn;
|
|
377
|
+
/**
|
|
378
|
+
* Whether the zone is currently active (dragging or uploading)
|
|
379
|
+
*/
|
|
380
|
+
isActive: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* Open file picker
|
|
383
|
+
*/
|
|
384
|
+
openFilePicker: () => void;
|
|
385
|
+
/**
|
|
386
|
+
* Props to spread on the drop zone element
|
|
387
|
+
*/
|
|
388
|
+
getRootProps: () => {
|
|
389
|
+
onDragEnter: (e: React.DragEvent) => void;
|
|
390
|
+
onDragOver: (e: React.DragEvent) => void;
|
|
391
|
+
onDragLeave: (e: React.DragEvent) => void;
|
|
392
|
+
onDrop: (e: React.DragEvent) => void;
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Props to spread on the file input element
|
|
396
|
+
*/
|
|
397
|
+
getInputProps: () => React.InputHTMLAttributes<HTMLInputElement>;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Props for the FlowUploadZone component.
|
|
401
|
+
*
|
|
402
|
+
* @property flowConfig - Flow execution configuration (flowId, storageId, etc.)
|
|
403
|
+
* @property options - Flow upload options (callbacks, metadata, etc.)
|
|
404
|
+
* @property accept - Accepted file types (e.g., "image/*", ".pdf")
|
|
405
|
+
* @property multiple - Allow multiple file selection (default: false)
|
|
406
|
+
* @property children - Render function receiving flow upload zone state
|
|
407
|
+
*/
|
|
408
|
+
interface FlowUploadZoneProps {
|
|
409
|
+
/**
|
|
410
|
+
* Flow configuration
|
|
411
|
+
*/
|
|
412
|
+
flowConfig: FlowUploadConfig;
|
|
413
|
+
/**
|
|
414
|
+
* Upload options
|
|
415
|
+
*/
|
|
416
|
+
options?: Omit<FlowUploadOptions, "flowConfig">;
|
|
417
|
+
/**
|
|
418
|
+
* Accepted file types (e.g., "image/*", ".pdf", etc.)
|
|
419
|
+
*/
|
|
420
|
+
accept?: string;
|
|
421
|
+
/**
|
|
422
|
+
* Whether to allow multiple files (uses multi-upload internally)
|
|
423
|
+
*/
|
|
424
|
+
multiple?: boolean;
|
|
425
|
+
/**
|
|
426
|
+
* Render function for the drop zone
|
|
427
|
+
*/
|
|
428
|
+
children: (props: FlowUploadZoneRenderProps) => ReactNode;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Headless flow upload zone component with drag-and-drop support.
|
|
432
|
+
* Combines drag-drop functionality with flow processing, using render props
|
|
433
|
+
* for complete UI control.
|
|
434
|
+
*
|
|
435
|
+
* Files uploaded through this zone are automatically processed through the
|
|
436
|
+
* specified flow, which can perform operations like image optimization,
|
|
437
|
+
* storage saving, webhooks, etc.
|
|
438
|
+
*
|
|
439
|
+
* Must be used within an UploadistaProvider.
|
|
440
|
+
*
|
|
441
|
+
* @param props - Flow upload zone configuration and render prop
|
|
442
|
+
* @returns Rendered flow upload zone using the provided render prop
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```tsx
|
|
446
|
+
* // Image upload with flow processing
|
|
447
|
+
* <FlowUploadZone
|
|
448
|
+
* flowConfig={{
|
|
449
|
+
* flowId: "image-processing-flow",
|
|
450
|
+
* storageId: "s3-images",
|
|
451
|
+
* outputNodeId: "optimized-image",
|
|
452
|
+
* }}
|
|
453
|
+
* options={{
|
|
454
|
+
* onSuccess: (result) => console.log('Processed:', result),
|
|
455
|
+
* onFlowComplete: (outputs) => {
|
|
456
|
+
* console.log('All outputs:', outputs);
|
|
457
|
+
* },
|
|
458
|
+
* }}
|
|
459
|
+
* accept="image/*"
|
|
460
|
+
* >
|
|
461
|
+
* {({ dragDrop, flowUpload, getRootProps, getInputProps, openFilePicker }) => (
|
|
462
|
+
* <div {...getRootProps()} style={{
|
|
463
|
+
* border: dragDrop.state.isDragging ? '2px solid blue' : '2px dashed gray',
|
|
464
|
+
* padding: '2rem',
|
|
465
|
+
* textAlign: 'center'
|
|
466
|
+
* }}>
|
|
467
|
+
* <input {...getInputProps()} />
|
|
468
|
+
*
|
|
469
|
+
* {dragDrop.state.isDragging && (
|
|
470
|
+
* <p>Drop image here...</p>
|
|
471
|
+
* )}
|
|
472
|
+
*
|
|
473
|
+
* {!dragDrop.state.isDragging && !flowUpload.isUploading && (
|
|
474
|
+
* <div>
|
|
475
|
+
* <p>Drag an image or click to browse</p>
|
|
476
|
+
* <button onClick={openFilePicker}>Choose File</button>
|
|
477
|
+
* </div>
|
|
478
|
+
* )}
|
|
479
|
+
*
|
|
480
|
+
* {flowUpload.isUploadingFile && (
|
|
481
|
+
* <div>
|
|
482
|
+
* <p>Uploading...</p>
|
|
483
|
+
* <progress value={flowUpload.state.progress} max={100} />
|
|
484
|
+
* <span>{flowUpload.state.progress}%</span>
|
|
485
|
+
* </div>
|
|
486
|
+
* )}
|
|
487
|
+
*
|
|
488
|
+
* {flowUpload.isProcessing && (
|
|
489
|
+
* <div>
|
|
490
|
+
* <p>Processing image...</p>
|
|
491
|
+
* {flowUpload.state.currentNodeName && (
|
|
492
|
+
* <span>Step: {flowUpload.state.currentNodeName}</span>
|
|
493
|
+
* )}
|
|
494
|
+
* </div>
|
|
495
|
+
* )}
|
|
496
|
+
*
|
|
497
|
+
* {flowUpload.state.status === "success" && (
|
|
498
|
+
* <div>
|
|
499
|
+
* <p>✓ Upload complete!</p>
|
|
500
|
+
* {flowUpload.state.result && (
|
|
501
|
+
* <img src={flowUpload.state.result.url} alt="Uploaded" />
|
|
502
|
+
* )}
|
|
503
|
+
* </div>
|
|
504
|
+
* )}
|
|
505
|
+
*
|
|
506
|
+
* {flowUpload.state.status === "error" && (
|
|
507
|
+
* <div>
|
|
508
|
+
* <p>Error: {flowUpload.state.error?.message}</p>
|
|
509
|
+
* <button onClick={flowUpload.reset}>Try Again</button>
|
|
510
|
+
* </div>
|
|
511
|
+
* )}
|
|
512
|
+
*
|
|
513
|
+
* {flowUpload.isUploading && (
|
|
514
|
+
* <button onClick={flowUpload.abort}>Cancel</button>
|
|
515
|
+
* )}
|
|
516
|
+
* </div>
|
|
517
|
+
* )}
|
|
518
|
+
* </FlowUploadZone>
|
|
519
|
+
* ```
|
|
520
|
+
*
|
|
521
|
+
* @see {@link SimpleFlowUploadZone} for a pre-styled version
|
|
522
|
+
* @see {@link useFlowUpload} for the underlying hook
|
|
523
|
+
*/
|
|
524
|
+
declare function FlowUploadZone({
|
|
525
|
+
flowConfig,
|
|
526
|
+
options,
|
|
527
|
+
accept,
|
|
528
|
+
multiple,
|
|
529
|
+
children
|
|
530
|
+
}: FlowUploadZoneProps): react_jsx_runtime0.JSX.Element;
|
|
531
|
+
/**
|
|
532
|
+
* Props for the SimpleFlowUploadZone component.
|
|
533
|
+
*
|
|
534
|
+
* @property flowConfig - Flow execution configuration
|
|
535
|
+
* @property options - Flow upload options (callbacks, metadata)
|
|
536
|
+
* @property accept - Accepted file types
|
|
537
|
+
* @property className - CSS class name for custom styling
|
|
538
|
+
* @property dragText - Text displayed when dragging files over zone
|
|
539
|
+
* @property idleText - Text displayed when zone is idle
|
|
540
|
+
*/
|
|
541
|
+
interface SimpleFlowUploadZoneProps {
|
|
542
|
+
/**
|
|
543
|
+
* Flow configuration
|
|
544
|
+
*/
|
|
545
|
+
flowConfig: FlowUploadConfig;
|
|
546
|
+
/**
|
|
547
|
+
* Upload options
|
|
548
|
+
*/
|
|
549
|
+
options?: Omit<FlowUploadOptions, "flowConfig">;
|
|
550
|
+
/**
|
|
551
|
+
* Accepted file types
|
|
552
|
+
*/
|
|
553
|
+
accept?: string;
|
|
554
|
+
/**
|
|
555
|
+
* CSS class for the container
|
|
556
|
+
*/
|
|
557
|
+
className?: string;
|
|
558
|
+
/**
|
|
559
|
+
* Custom drag overlay text
|
|
560
|
+
*/
|
|
561
|
+
dragText?: string;
|
|
562
|
+
/**
|
|
563
|
+
* Custom idle text
|
|
564
|
+
*/
|
|
565
|
+
idleText?: string;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Simple pre-styled flow upload zone component with built-in UI.
|
|
569
|
+
* Provides a ready-to-use drag-and-drop interface for flow uploads.
|
|
570
|
+
*
|
|
571
|
+
* Features:
|
|
572
|
+
* - Built-in drag-and-drop visual feedback
|
|
573
|
+
* - Automatic progress display for upload and processing phases
|
|
574
|
+
* - Success and error state display
|
|
575
|
+
* - Cancel button during upload
|
|
576
|
+
* - Customizable text labels
|
|
577
|
+
*
|
|
578
|
+
* @param props - Flow upload zone configuration with styling options
|
|
579
|
+
* @returns Styled flow upload zone component
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```tsx
|
|
583
|
+
* // Basic image upload with flow processing
|
|
584
|
+
* <SimpleFlowUploadZone
|
|
585
|
+
* flowConfig={{
|
|
586
|
+
* flowId: "image-optimization-flow",
|
|
587
|
+
* storageId: "s3-images",
|
|
588
|
+
* }}
|
|
589
|
+
* accept="image/*"
|
|
590
|
+
* options={{
|
|
591
|
+
* onSuccess: (result) => console.log("Image processed:", result),
|
|
592
|
+
* onError: (error) => console.error("Processing failed:", error),
|
|
593
|
+
* }}
|
|
594
|
+
* idleText="Drop an image to optimize and upload"
|
|
595
|
+
* dragText="Release to start processing"
|
|
596
|
+
* className="my-upload-zone"
|
|
597
|
+
* />
|
|
598
|
+
*
|
|
599
|
+
* // Document upload with custom flow
|
|
600
|
+
* <SimpleFlowUploadZone
|
|
601
|
+
* flowConfig={{
|
|
602
|
+
* flowId: "document-processing-flow",
|
|
603
|
+
* storageId: "docs",
|
|
604
|
+
* outputNodeId: "processed-doc",
|
|
605
|
+
* }}
|
|
606
|
+
* accept=".pdf,.doc,.docx"
|
|
607
|
+
* options={{
|
|
608
|
+
* onFlowComplete: (outputs) => {
|
|
609
|
+
* console.log('Processing outputs:', outputs);
|
|
610
|
+
* },
|
|
611
|
+
* }}
|
|
612
|
+
* />
|
|
613
|
+
* ```
|
|
614
|
+
*
|
|
615
|
+
* @see {@link FlowUploadZone} for the headless version with full control
|
|
616
|
+
*/
|
|
617
|
+
declare function SimpleFlowUploadZone({
|
|
618
|
+
flowConfig,
|
|
619
|
+
options,
|
|
620
|
+
accept,
|
|
621
|
+
className,
|
|
622
|
+
dragText,
|
|
623
|
+
idleText
|
|
624
|
+
}: SimpleFlowUploadZoneProps): react_jsx_runtime0.JSX.Element;
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/components/upload-list.d.ts
|
|
627
|
+
/**
|
|
628
|
+
* Render props passed to the UploadList children function.
|
|
629
|
+
* Provides organized access to upload items, status groupings, and actions.
|
|
630
|
+
*
|
|
631
|
+
* @property items - All upload items (filtered and sorted if configured)
|
|
632
|
+
* @property itemsByStatus - Upload items grouped by their current status
|
|
633
|
+
* @property multiUpload - Complete multi-upload hook instance
|
|
634
|
+
* @property actions - Helper functions for common item operations
|
|
635
|
+
* @property actions.removeItem - Remove an item from the list
|
|
636
|
+
* @property actions.retryItem - Retry a failed upload
|
|
637
|
+
* @property actions.abortItem - Cancel an active upload
|
|
638
|
+
* @property actions.startItem - Begin uploading an idle item
|
|
639
|
+
*/
|
|
640
|
+
interface UploadListRenderProps {
|
|
641
|
+
/**
|
|
642
|
+
* All upload items
|
|
643
|
+
*/
|
|
644
|
+
items: UploadItem[];
|
|
645
|
+
/**
|
|
646
|
+
* Items filtered by status
|
|
647
|
+
*/
|
|
648
|
+
itemsByStatus: {
|
|
649
|
+
idle: UploadItem[];
|
|
650
|
+
uploading: UploadItem[];
|
|
651
|
+
success: UploadItem[];
|
|
652
|
+
error: UploadItem[];
|
|
653
|
+
aborted: UploadItem[];
|
|
654
|
+
};
|
|
655
|
+
/**
|
|
656
|
+
* Multi-upload state and controls
|
|
657
|
+
*/
|
|
658
|
+
multiUpload: UseMultiUploadReturn;
|
|
659
|
+
/**
|
|
660
|
+
* Helper functions for item management
|
|
661
|
+
*/
|
|
662
|
+
actions: {
|
|
663
|
+
removeItem: (id: string) => void;
|
|
664
|
+
retryItem: (item: UploadItem) => void;
|
|
665
|
+
abortItem: (item: UploadItem) => void;
|
|
666
|
+
startItem: (item: UploadItem) => void;
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Props for the UploadList component.
|
|
671
|
+
*
|
|
672
|
+
* @property multiUpload - Multi-upload hook instance to display
|
|
673
|
+
* @property filter - Optional function to filter which items to show
|
|
674
|
+
* @property sortBy - Optional comparator function to sort items
|
|
675
|
+
* @property children - Render function receiving list state and actions
|
|
676
|
+
*/
|
|
677
|
+
interface UploadListProps {
|
|
678
|
+
/**
|
|
679
|
+
* Multi-upload instance from useMultiUpload hook
|
|
680
|
+
*/
|
|
681
|
+
multiUpload: UseMultiUploadReturn;
|
|
682
|
+
/**
|
|
683
|
+
* Optional filter for which items to display
|
|
684
|
+
*/
|
|
685
|
+
filter?: (item: UploadItem) => boolean;
|
|
686
|
+
/**
|
|
687
|
+
* Optional sorting function for items
|
|
688
|
+
*/
|
|
689
|
+
sortBy?: (a: UploadItem, b: UploadItem) => number;
|
|
690
|
+
/**
|
|
691
|
+
* Render prop that receives upload list state and actions
|
|
692
|
+
*/
|
|
693
|
+
children: (props: UploadListRenderProps) => React$1.ReactNode;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Headless upload list component that provides flexible rendering for upload items.
|
|
697
|
+
* Uses render props pattern to give full control over how upload items are displayed.
|
|
698
|
+
*
|
|
699
|
+
* @param props - Upload list configuration and render prop
|
|
700
|
+
* @returns Rendered upload list using the provided render prop
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```tsx
|
|
704
|
+
* // Basic upload list with progress bars
|
|
705
|
+
* <UploadList multiUpload={multiUpload}>
|
|
706
|
+
* {({ items, actions }) => (
|
|
707
|
+
* <div>
|
|
708
|
+
* <h3>Upload Queue ({items.length} files)</h3>
|
|
709
|
+
* {items.map((item) => (
|
|
710
|
+
* <div key={item.id} style={{
|
|
711
|
+
* padding: '1rem',
|
|
712
|
+
* border: '1px solid #ccc',
|
|
713
|
+
* marginBottom: '0.5rem',
|
|
714
|
+
* borderRadius: '4px'
|
|
715
|
+
* }}>
|
|
716
|
+
* <div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
717
|
+
* <span>{item.file.name}</span>
|
|
718
|
+
* <span>{item.state.status}</span>
|
|
719
|
+
* </div>
|
|
720
|
+
*
|
|
721
|
+
* {item.state.status === 'uploading' && (
|
|
722
|
+
* <div>
|
|
723
|
+
* <progress value={item.state.progress} max={100} />
|
|
724
|
+
* <span>{item.state.progress}%</span>
|
|
725
|
+
* <button onClick={() => actions.abortItem(item)}>Cancel</button>
|
|
726
|
+
* </div>
|
|
727
|
+
* )}
|
|
728
|
+
*
|
|
729
|
+
* {item.state.status === 'error' && (
|
|
730
|
+
* <div>
|
|
731
|
+
* <p style={{ color: 'red' }}>Error: {item.state.error?.message}</p>
|
|
732
|
+
* <button onClick={() => actions.retryItem(item)}>Retry</button>
|
|
733
|
+
* <button onClick={() => actions.removeItem(item.id)}>Remove</button>
|
|
734
|
+
* </div>
|
|
735
|
+
* )}
|
|
736
|
+
*
|
|
737
|
+
* {item.state.status === 'success' && (
|
|
738
|
+
* <div>
|
|
739
|
+
* <p style={{ color: 'green' }}>✓ Uploaded successfully</p>
|
|
740
|
+
* <button onClick={() => actions.removeItem(item.id)}>Remove</button>
|
|
741
|
+
* </div>
|
|
742
|
+
* )}
|
|
743
|
+
*
|
|
744
|
+
* {item.state.status === 'idle' && (
|
|
745
|
+
* <div>
|
|
746
|
+
* <button onClick={() => actions.startItem(item)}>Start Upload</button>
|
|
747
|
+
* <button onClick={() => actions.removeItem(item.id)}>Remove</button>
|
|
748
|
+
* </div>
|
|
749
|
+
* )}
|
|
750
|
+
* </div>
|
|
751
|
+
* ))}
|
|
752
|
+
* </div>
|
|
753
|
+
* )}
|
|
754
|
+
* </UploadList>
|
|
755
|
+
*
|
|
756
|
+
* // Upload list with status filtering and sorting
|
|
757
|
+
* <UploadList
|
|
758
|
+
* multiUpload={multiUpload}
|
|
759
|
+
* filter={(item) => item.state.status !== 'success'} // Hide successful uploads
|
|
760
|
+
* sortBy={(a, b) => {
|
|
761
|
+
* // Sort by status priority, then by filename
|
|
762
|
+
* const statusPriority = { error: 0, uploading: 1, idle: 2, success: 3, aborted: 4 };
|
|
763
|
+
* const aPriority = statusPriority[a.state.status];
|
|
764
|
+
* const bPriority = statusPriority[b.state.status];
|
|
765
|
+
*
|
|
766
|
+
* if (aPriority !== bPriority) {
|
|
767
|
+
* return aPriority - bPriority;
|
|
768
|
+
* }
|
|
769
|
+
*
|
|
770
|
+
* return a.file.name.localeCompare(b.file.name);
|
|
771
|
+
* }}
|
|
772
|
+
* >
|
|
773
|
+
* {({ items, itemsByStatus, multiUpload, actions }) => (
|
|
774
|
+
* <div>
|
|
775
|
+
* {itemsByStatus.error.length > 0 && (
|
|
776
|
+
* <div>
|
|
777
|
+
* <h4 style={{ color: 'red' }}>Failed Uploads ({itemsByStatus.error.length})</h4>
|
|
778
|
+
* {itemsByStatus.error.map((item) => (
|
|
779
|
+
* <UploadListItem key={item.id} item={item} actions={actions} />
|
|
780
|
+
* ))}
|
|
781
|
+
* </div>
|
|
782
|
+
* )}
|
|
783
|
+
*
|
|
784
|
+
* {itemsByStatus.uploading.length > 0 && (
|
|
785
|
+
* <div>
|
|
786
|
+
* <h4>Uploading ({itemsByStatus.uploading.length})</h4>
|
|
787
|
+
* {itemsByStatus.uploading.map((item) => (
|
|
788
|
+
* <UploadListItem key={item.id} item={item} actions={actions} />
|
|
789
|
+
* ))}
|
|
790
|
+
* </div>
|
|
791
|
+
* )}
|
|
792
|
+
*
|
|
793
|
+
* {itemsByStatus.idle.length > 0 && (
|
|
794
|
+
* <div>
|
|
795
|
+
* <h4>Pending ({itemsByStatus.idle.length})</h4>
|
|
796
|
+
* {itemsByStatus.idle.map((item) => (
|
|
797
|
+
* <UploadListItem key={item.id} item={item} actions={actions} />
|
|
798
|
+
* ))}
|
|
799
|
+
* </div>
|
|
800
|
+
* )}
|
|
801
|
+
* </div>
|
|
802
|
+
* )}
|
|
803
|
+
* </UploadList>
|
|
804
|
+
* ```
|
|
805
|
+
*/
|
|
806
|
+
declare function UploadList({
|
|
807
|
+
multiUpload,
|
|
808
|
+
filter,
|
|
809
|
+
sortBy,
|
|
810
|
+
children
|
|
811
|
+
}: UploadListProps): react_jsx_runtime0.JSX.Element;
|
|
812
|
+
/**
|
|
813
|
+
* Props for the SimpleUploadListItem component.
|
|
814
|
+
*
|
|
815
|
+
* @property item - The upload item to display
|
|
816
|
+
* @property actions - Action functions from UploadList render props
|
|
817
|
+
* @property className - Additional CSS class name
|
|
818
|
+
* @property style - Inline styles for the item container
|
|
819
|
+
* @property showDetails - Whether to display file size and upload details
|
|
820
|
+
*/
|
|
821
|
+
interface SimpleUploadListItemProps {
|
|
822
|
+
/**
|
|
823
|
+
* The upload item to render
|
|
824
|
+
*/
|
|
825
|
+
item: UploadItem;
|
|
826
|
+
/**
|
|
827
|
+
* Actions from UploadList render props
|
|
828
|
+
*/
|
|
829
|
+
actions: UploadListRenderProps["actions"];
|
|
830
|
+
/**
|
|
831
|
+
* Additional CSS class name
|
|
832
|
+
*/
|
|
833
|
+
className?: string;
|
|
834
|
+
/**
|
|
835
|
+
* Inline styles
|
|
836
|
+
*/
|
|
837
|
+
style?: React$1.CSSProperties;
|
|
838
|
+
/**
|
|
839
|
+
* Whether to show detailed information (file size, speed, etc.)
|
|
840
|
+
*/
|
|
841
|
+
showDetails?: boolean;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Pre-styled upload list item component with status indicators and action buttons.
|
|
845
|
+
* Displays file info, progress, errors, and contextual actions based on upload status.
|
|
846
|
+
*
|
|
847
|
+
* Features:
|
|
848
|
+
* - Status-specific color coding and icons
|
|
849
|
+
* - Progress bar for active uploads
|
|
850
|
+
* - Error message display
|
|
851
|
+
* - File size formatting
|
|
852
|
+
* - Contextual action buttons (start, cancel, retry, remove)
|
|
853
|
+
*
|
|
854
|
+
* @param props - Upload item and configuration
|
|
855
|
+
* @returns Styled upload list item component
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* ```tsx
|
|
859
|
+
* // Use with UploadList
|
|
860
|
+
* <UploadList multiUpload={multiUpload}>
|
|
861
|
+
* {({ items, actions }) => (
|
|
862
|
+
* <div>
|
|
863
|
+
* {items.map((item) => (
|
|
864
|
+
* <SimpleUploadListItem
|
|
865
|
+
* key={item.id}
|
|
866
|
+
* item={item}
|
|
867
|
+
* actions={actions}
|
|
868
|
+
* showDetails={true}
|
|
869
|
+
* />
|
|
870
|
+
* ))}
|
|
871
|
+
* </div>
|
|
872
|
+
* )}
|
|
873
|
+
* </UploadList>
|
|
874
|
+
*
|
|
875
|
+
* // Custom styling
|
|
876
|
+
* <SimpleUploadListItem
|
|
877
|
+
* item={uploadItem}
|
|
878
|
+
* actions={actions}
|
|
879
|
+
* className="my-upload-item"
|
|
880
|
+
* style={{ borderRadius: '12px', margin: '1rem' }}
|
|
881
|
+
* showDetails={true}
|
|
882
|
+
* />
|
|
883
|
+
* ```
|
|
884
|
+
*/
|
|
885
|
+
declare function SimpleUploadListItem({
|
|
886
|
+
item,
|
|
887
|
+
actions,
|
|
888
|
+
className,
|
|
889
|
+
style,
|
|
890
|
+
showDetails
|
|
891
|
+
}: SimpleUploadListItemProps): react_jsx_runtime0.JSX.Element;
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region src/components/upload-zone.d.ts
|
|
894
|
+
/**
|
|
895
|
+
* Render props passed to the UploadZone children function.
|
|
896
|
+
* Provides access to drag-drop state, upload controls, and helper functions.
|
|
897
|
+
*
|
|
898
|
+
* @property dragDrop - Complete drag-and-drop state and event handlers
|
|
899
|
+
* @property upload - Single upload hook (null when multiple=true)
|
|
900
|
+
* @property multiUpload - Multi-upload hook (null when multiple=false)
|
|
901
|
+
* @property openFilePicker - Programmatically trigger file selection dialog
|
|
902
|
+
* @property isActive - True when dragging over zone or files selected
|
|
903
|
+
* @property isProcessing - True when uploads are in progress
|
|
904
|
+
*/
|
|
905
|
+
interface UploadZoneRenderProps {
|
|
906
|
+
/**
|
|
907
|
+
* Drag and drop state and handlers
|
|
908
|
+
*/
|
|
909
|
+
dragDrop: UseDragDropReturn;
|
|
910
|
+
/**
|
|
911
|
+
* Single upload functionality (if not using multi-upload)
|
|
912
|
+
*/
|
|
913
|
+
upload: UseUploadReturn | null;
|
|
914
|
+
/**
|
|
915
|
+
* Multi-upload functionality (if using multi-upload)
|
|
916
|
+
*/
|
|
917
|
+
multiUpload: UseMultiUploadReturn | null;
|
|
918
|
+
/**
|
|
919
|
+
* Helper function to open file picker
|
|
920
|
+
*/
|
|
921
|
+
openFilePicker: () => void;
|
|
922
|
+
/**
|
|
923
|
+
* Whether the zone is currently active (dragging or uploading)
|
|
924
|
+
*/
|
|
925
|
+
isActive: boolean;
|
|
926
|
+
/**
|
|
927
|
+
* Whether files are being processed
|
|
928
|
+
*/
|
|
929
|
+
isProcessing: boolean;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Props for the UploadZone component.
|
|
933
|
+
* Combines drag-drop options with upload configuration.
|
|
934
|
+
*
|
|
935
|
+
* @property multiple - Enable multi-file selection and upload (default: true)
|
|
936
|
+
* @property multiUploadOptions - Configuration for multi-upload mode
|
|
937
|
+
* @property uploadOptions - Configuration for single-upload mode
|
|
938
|
+
* @property children - Render function receiving upload zone state
|
|
939
|
+
* @property onUploadStart - Called when files pass validation and upload begins
|
|
940
|
+
* @property onValidationError - Called when file validation fails
|
|
941
|
+
* @property accept - Accepted file types (e.g., ['image/*', '.pdf'])
|
|
942
|
+
* @property maxFiles - Maximum number of files allowed
|
|
943
|
+
* @property maxFileSize - Maximum file size in bytes
|
|
944
|
+
* @property validator - Custom validation function
|
|
945
|
+
*/
|
|
946
|
+
interface UploadZoneProps extends Omit<DragDropOptions, "onFilesReceived"> {
|
|
947
|
+
/**
|
|
948
|
+
* Whether to enable multi-file upload mode
|
|
949
|
+
*/
|
|
950
|
+
multiple?: boolean;
|
|
951
|
+
/**
|
|
952
|
+
* Multi-upload specific options (only used when multiple=true)
|
|
953
|
+
*/
|
|
954
|
+
multiUploadOptions?: MultiUploadOptions;
|
|
955
|
+
/**
|
|
956
|
+
* Single upload specific options (only used when multiple=false)
|
|
957
|
+
*/
|
|
958
|
+
uploadOptions?: UseUploadOptions;
|
|
959
|
+
/**
|
|
960
|
+
* Render prop that receives upload zone state and handlers
|
|
961
|
+
*/
|
|
962
|
+
children: (props: UploadZoneRenderProps) => React$1.ReactNode;
|
|
963
|
+
/**
|
|
964
|
+
* Called when files are processed and uploads begin
|
|
965
|
+
*/
|
|
966
|
+
onUploadStart?: (files: File[]) => void;
|
|
967
|
+
/**
|
|
968
|
+
* Called when validation errors occur
|
|
969
|
+
*/
|
|
970
|
+
onValidationError?: (errors: string[]) => void;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Headless upload zone component that combines drag and drop functionality
|
|
974
|
+
* with upload management. Uses render props pattern for maximum flexibility.
|
|
975
|
+
* Includes enhanced error handling for MIME type validation and file count validation.
|
|
976
|
+
*
|
|
977
|
+
* @param props - Upload zone configuration and render prop
|
|
978
|
+
* @returns Rendered upload zone using the provided render prop
|
|
979
|
+
*
|
|
980
|
+
* @example
|
|
981
|
+
* ```tsx
|
|
982
|
+
* // Single file upload zone with error handling
|
|
983
|
+
* <UploadZone
|
|
984
|
+
* multiple={false}
|
|
985
|
+
* accept={['image/*']}
|
|
986
|
+
* maxFileSize={5 * 1024 * 1024}
|
|
987
|
+
* onValidationError={(errors) => {
|
|
988
|
+
* console.error('Validation errors:', errors);
|
|
989
|
+
* }}
|
|
990
|
+
* uploadOptions={{
|
|
991
|
+
* onSuccess: (result) => console.log('Upload complete:', result),
|
|
992
|
+
* onError: (error) => console.error('Upload failed:', error),
|
|
993
|
+
* }}
|
|
994
|
+
* >
|
|
995
|
+
* {({ dragDrop, upload, openFilePicker, isActive }) => (
|
|
996
|
+
* <div {...dragDrop.dragHandlers} onClick={openFilePicker}>
|
|
997
|
+
* {dragDrop.state.isDragging ? (
|
|
998
|
+
* <p>Drop file here...</p>
|
|
999
|
+
* ) : upload?.isUploading ? (
|
|
1000
|
+
* <p>Uploading... {upload.state.progress}%</p>
|
|
1001
|
+
* ) : (
|
|
1002
|
+
* <p>Drag a file here or click to select</p>
|
|
1003
|
+
* )}
|
|
1004
|
+
*
|
|
1005
|
+
* {dragDrop.state.errors.length > 0 && (
|
|
1006
|
+
* <div style={{ color: 'red' }}>
|
|
1007
|
+
* {dragDrop.state.errors.map((error, index) => (
|
|
1008
|
+
* <p key={index}>{error}</p>
|
|
1009
|
+
* ))}
|
|
1010
|
+
* </div>
|
|
1011
|
+
* )}
|
|
1012
|
+
*
|
|
1013
|
+
* <input {...dragDrop.inputProps} />
|
|
1014
|
+
* </div>
|
|
1015
|
+
* )}
|
|
1016
|
+
* </UploadZone>
|
|
1017
|
+
* ```
|
|
1018
|
+
*/
|
|
1019
|
+
declare function UploadZone({
|
|
1020
|
+
children,
|
|
1021
|
+
multiple,
|
|
1022
|
+
multiUploadOptions,
|
|
1023
|
+
uploadOptions,
|
|
1024
|
+
onUploadStart,
|
|
1025
|
+
onValidationError,
|
|
1026
|
+
...dragDropOptions
|
|
1027
|
+
}: UploadZoneProps): react_jsx_runtime0.JSX.Element;
|
|
1028
|
+
/**
|
|
1029
|
+
* Props for the SimpleUploadZone component with built-in styling.
|
|
1030
|
+
*
|
|
1031
|
+
* @property className - CSS class name for custom styling
|
|
1032
|
+
* @property style - Inline styles for the upload zone container
|
|
1033
|
+
* @property text - Custom text labels for different states
|
|
1034
|
+
* @property text.idle - Text shown when zone is idle
|
|
1035
|
+
* @property text.dragging - Text shown when dragging files over zone
|
|
1036
|
+
* @property text.uploading - Text shown during upload
|
|
1037
|
+
* @property errorStyle - Custom styles for validation error display
|
|
1038
|
+
*/
|
|
1039
|
+
interface SimpleUploadZoneProps extends UploadZoneProps {
|
|
1040
|
+
/**
|
|
1041
|
+
* Additional CSS class name for styling
|
|
1042
|
+
*/
|
|
1043
|
+
className?: string;
|
|
1044
|
+
/**
|
|
1045
|
+
* Inline styles for the upload zone
|
|
1046
|
+
*/
|
|
1047
|
+
style?: React$1.CSSProperties;
|
|
1048
|
+
/**
|
|
1049
|
+
* Custom text to display in different states
|
|
1050
|
+
*/
|
|
1051
|
+
text?: {
|
|
1052
|
+
idle?: string;
|
|
1053
|
+
dragging?: string;
|
|
1054
|
+
uploading?: string;
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* Custom error message styling
|
|
1058
|
+
*/
|
|
1059
|
+
errorStyle?: React$1.CSSProperties;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Simple pre-styled upload zone component with built-in UI and error handling.
|
|
1063
|
+
* Provides a ready-to-use drag-and-drop upload interface with minimal configuration.
|
|
1064
|
+
*
|
|
1065
|
+
* Features:
|
|
1066
|
+
* - Built-in drag-and-drop visual feedback
|
|
1067
|
+
* - Automatic progress display
|
|
1068
|
+
* - File validation error display
|
|
1069
|
+
* - Customizable text and styling
|
|
1070
|
+
* - Keyboard accessible
|
|
1071
|
+
*
|
|
1072
|
+
* @param props - Upload zone configuration with styling options
|
|
1073
|
+
* @returns Styled upload zone component
|
|
1074
|
+
*
|
|
1075
|
+
* @example
|
|
1076
|
+
* ```tsx
|
|
1077
|
+
* // Multi-file upload with validation
|
|
1078
|
+
* <SimpleUploadZone
|
|
1079
|
+
* multiple={true}
|
|
1080
|
+
* accept={['image/*', '.pdf']}
|
|
1081
|
+
* maxFiles={5}
|
|
1082
|
+
* maxFileSize={10 * 1024 * 1024} // 10MB
|
|
1083
|
+
* onUploadStart={(files) => console.log('Starting uploads:', files.length)}
|
|
1084
|
+
* onValidationError={(errors) => {
|
|
1085
|
+
* errors.forEach(err => console.error(err));
|
|
1086
|
+
* }}
|
|
1087
|
+
* multiUploadOptions={{
|
|
1088
|
+
* maxConcurrent: 3,
|
|
1089
|
+
* onComplete: (results) => {
|
|
1090
|
+
* console.log(`${results.successful.length}/${results.total} uploaded`);
|
|
1091
|
+
* },
|
|
1092
|
+
* }}
|
|
1093
|
+
* style={{
|
|
1094
|
+
* width: '400px',
|
|
1095
|
+
* height: '200px',
|
|
1096
|
+
* margin: '20px auto',
|
|
1097
|
+
* }}
|
|
1098
|
+
* text={{
|
|
1099
|
+
* idle: 'Drop your files here or click to browse',
|
|
1100
|
+
* dragging: 'Release to upload',
|
|
1101
|
+
* uploading: 'Uploading files...',
|
|
1102
|
+
* }}
|
|
1103
|
+
* errorStyle={{
|
|
1104
|
+
* backgroundColor: '#fff3cd',
|
|
1105
|
+
* borderColor: '#ffeaa7',
|
|
1106
|
+
* }}
|
|
1107
|
+
* />
|
|
1108
|
+
*
|
|
1109
|
+
* // Single file upload
|
|
1110
|
+
* <SimpleUploadZone
|
|
1111
|
+
* multiple={false}
|
|
1112
|
+
* accept={['image/*']}
|
|
1113
|
+
* uploadOptions={{
|
|
1114
|
+
* onSuccess: (result) => console.log('Uploaded:', result),
|
|
1115
|
+
* onError: (error) => console.error('Failed:', error),
|
|
1116
|
+
* }}
|
|
1117
|
+
* text={{
|
|
1118
|
+
* idle: 'Click or drag an image to upload',
|
|
1119
|
+
* }}
|
|
1120
|
+
* />
|
|
1121
|
+
* ```
|
|
1122
|
+
*/
|
|
1123
|
+
declare function SimpleUploadZone({
|
|
1124
|
+
className,
|
|
1125
|
+
style,
|
|
1126
|
+
text,
|
|
1127
|
+
errorStyle,
|
|
1128
|
+
children,
|
|
1129
|
+
...uploadZoneProps
|
|
1130
|
+
}: SimpleUploadZoneProps): react_jsx_runtime0.JSX.Element;
|
|
1131
|
+
//#endregion
|
|
1132
|
+
//#region src/components/uploadista-provider.d.ts
|
|
1133
|
+
/**
|
|
1134
|
+
* Props for the UploadistaProvider component.
|
|
1135
|
+
* Combines client configuration options with React children.
|
|
1136
|
+
*
|
|
1137
|
+
* @property children - React components that will have access to the upload client context
|
|
1138
|
+
* @property baseUrl - API base URL for uploads
|
|
1139
|
+
* @property storageId - Default storage identifier
|
|
1140
|
+
* @property chunkSize - Upload chunk size in bytes
|
|
1141
|
+
* @property onEvent - Global event handler for all upload events
|
|
1142
|
+
* @property ... - All other UploadistaClientOptions
|
|
1143
|
+
*/
|
|
1144
|
+
interface UploadistaProviderProps extends UseUploadistaClientOptions {
|
|
1145
|
+
/**
|
|
1146
|
+
* Children components that will have access to the upload client
|
|
1147
|
+
*/
|
|
1148
|
+
children: React$1.ReactNode;
|
|
1149
|
+
}
|
|
1150
|
+
type UploadistaContextValue = UseUploadistaClientReturn & {
|
|
1151
|
+
/**
|
|
1152
|
+
* Subscribe to events (used internally by hooks)
|
|
1153
|
+
* @internal
|
|
1154
|
+
*/
|
|
1155
|
+
subscribeToEvents: (handler: (event: UploadistaEvent) => void) => () => void;
|
|
1156
|
+
};
|
|
1157
|
+
/**
|
|
1158
|
+
* Context provider that provides uploadista client functionality to child components.
|
|
1159
|
+
* This eliminates the need to pass upload client configuration down through props
|
|
1160
|
+
* and ensures a single, shared upload client instance across your application.
|
|
1161
|
+
*
|
|
1162
|
+
* @param props - Upload client options and children
|
|
1163
|
+
* @returns Provider component with upload client context
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* ```tsx
|
|
1167
|
+
* // Wrap your app with the upload provider
|
|
1168
|
+
* function App() {
|
|
1169
|
+
* return (
|
|
1170
|
+
* <UploadistaProvider
|
|
1171
|
+
* baseUrl="https://api.example.com"
|
|
1172
|
+
* storageId="my-storage"
|
|
1173
|
+
* chunkSize={1024 * 1024} // 1MB chunks
|
|
1174
|
+
* onEvent={(event) => {
|
|
1175
|
+
* console.log('Global upload event:', event);
|
|
1176
|
+
* }}
|
|
1177
|
+
* >
|
|
1178
|
+
* <UploadInterface />
|
|
1179
|
+
* </UploadistaProvider>
|
|
1180
|
+
* );
|
|
1181
|
+
* }
|
|
1182
|
+
*
|
|
1183
|
+
* // Use the upload client in any child component
|
|
1184
|
+
* function UploadInterface() {
|
|
1185
|
+
* const uploadClient = useUploadistaContext();
|
|
1186
|
+
* const upload = useUpload(uploadClient);
|
|
1187
|
+
* const dragDrop = useDragDrop({
|
|
1188
|
+
* onFilesReceived: (files) => {
|
|
1189
|
+
* files.forEach(file => upload.upload(file));
|
|
1190
|
+
* }
|
|
1191
|
+
* });
|
|
1192
|
+
*
|
|
1193
|
+
* return (
|
|
1194
|
+
* <div {...dragDrop.dragHandlers}>
|
|
1195
|
+
* <p>Drop files here to upload</p>
|
|
1196
|
+
* {upload.isUploading && <p>Progress: {upload.state.progress}%</p>}
|
|
1197
|
+
* </div>
|
|
1198
|
+
* );
|
|
1199
|
+
* }
|
|
1200
|
+
* ```
|
|
1201
|
+
*/
|
|
1202
|
+
declare function UploadistaProvider({
|
|
1203
|
+
children,
|
|
1204
|
+
...options
|
|
1205
|
+
}: UploadistaProviderProps): react_jsx_runtime0.JSX.Element;
|
|
1206
|
+
/**
|
|
1207
|
+
* Hook to access the uploadista client from the UploadistaProvider context.
|
|
1208
|
+
* Must be used within an UploadistaProvider component.
|
|
1209
|
+
*
|
|
1210
|
+
* @returns Upload client instance from context
|
|
1211
|
+
* @throws Error if used outside of UploadistaProvider
|
|
1212
|
+
*
|
|
1213
|
+
* @example
|
|
1214
|
+
* ```tsx
|
|
1215
|
+
* function FileUploader() {
|
|
1216
|
+
* const uploadClient = useUploadistaContext();
|
|
1217
|
+
* const upload = useUpload(uploadClient);
|
|
1218
|
+
*
|
|
1219
|
+
* return (
|
|
1220
|
+
* <button
|
|
1221
|
+
* onClick={() => {
|
|
1222
|
+
* const input = document.createElement('input');
|
|
1223
|
+
* input.type = 'file';
|
|
1224
|
+
* input.onchange = (e) => {
|
|
1225
|
+
* const file = (e.target as HTMLInputElement).files?.[0];
|
|
1226
|
+
* if (file) upload.upload(file);
|
|
1227
|
+
* };
|
|
1228
|
+
* input.click();
|
|
1229
|
+
* }}
|
|
1230
|
+
* >
|
|
1231
|
+
* Upload File
|
|
1232
|
+
* </button>
|
|
1233
|
+
* );
|
|
1234
|
+
* }
|
|
1235
|
+
* ```
|
|
1236
|
+
*/
|
|
1237
|
+
declare function useUploadistaContext(): UploadistaContextValue;
|
|
1238
|
+
//#endregion
|
|
1239
|
+
export { SimpleFlowUploadListItemProps as C, SimpleFlowUploadListItem as S, SimpleFlowUploadZoneProps as _, UploadZone as a, FlowUploadListRenderProps as b, SimpleUploadListItem as c, UploadListProps as d, UploadListRenderProps as f, SimpleFlowUploadZone as g, FlowUploadZoneRenderProps as h, SimpleUploadZoneProps as i, SimpleUploadListItemProps as l, FlowUploadZoneProps as m, useUploadistaContext as n, UploadZoneProps as o, FlowUploadZone as p, SimpleUploadZone as r, UploadZoneRenderProps as s, UploadistaProvider as t, UploadList as u, FlowUploadList as v, SimpleFlowUploadListProps as w, SimpleFlowUploadList as x, FlowUploadListProps as y };
|
|
1240
|
+
//# sourceMappingURL=uploadista-provider-D8GQ2GhF.d.ts.map
|