@uploadista/react 0.0.20 → 0.1.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/dist/components/index.d.mts +3 -3
- package/dist/components/index.mjs +1 -1
- package/dist/index.d.mts +4 -548
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/upload-zone-CH8B2-hl.mjs +2 -0
- package/dist/upload-zone-CH8B2-hl.mjs.map +1 -0
- package/dist/{uploadista-provider-Cb13AK7Z.d.mts → uploadista-provider-DwKXudoT.d.mts} +558 -15
- package/dist/uploadista-provider-DwKXudoT.d.mts.map +1 -0
- package/dist/use-upload-BgaJmdwF.mjs.map +1 -1
- package/dist/use-uploadista-events-CtDXJYrR.d.mts.map +1 -1
- package/dist/use-uploadista-events-KhJ4knam.mjs.map +1 -1
- package/package.json +12 -9
- package/src/__tests__/event-utils.test.ts +179 -0
- package/src/__tests__/setup.ts +40 -0
- package/src/__tests__/uploadista-provider.test.tsx +316 -0
- package/src/__tests__/use-drag-drop.test.tsx +476 -0
- package/src/__tests__/use-upload.test.tsx +317 -0
- package/src/__tests__/use-uploadista-client.test.tsx +208 -0
- package/src/components/flow-primitives.tsx +3 -8
- package/src/components/index.tsx +37 -6
- package/src/components/upload-primitives.tsx +22 -19
- package/src/components/upload-zone.tsx +1 -2
- package/src/hooks/event-utils.ts +1 -1
- package/src/hooks/use-upload-events.ts +2 -5
- package/src/index.ts +89 -96
- package/vitest.config.ts +16 -0
- package/dist/flow-upload-list-BJSCZ4Ty.mjs +0 -2
- package/dist/flow-upload-list-BJSCZ4Ty.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/uploadista-provider-Cb13AK7Z.d.mts.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../use-uploadista-client-CkzVVmFT.mjs";
|
|
2
|
-
import { A as
|
|
3
|
-
export { Flow, type FlowCancelProps, type FlowContextValue, type FlowDropZoneProps, type FlowDropZoneRenderProps, type FlowErrorProps, type FlowErrorRenderProps, type FlowInputContextValue, type FlowInputDropZoneProps, type FlowInputDropZoneRenderProps, type FlowInputPreviewProps, type FlowInputPreviewRenderProps, type FlowInputProps, type FlowInputUrlFieldProps, type FlowInputsProps, type FlowInputsRenderProps, type FlowProgressProps, type FlowProgressRenderProps, type FlowProps, type FlowResetProps, type FlowStatusProps, type FlowStatusRenderProps, type FlowSubmitProps, FlowUploadList, type FlowUploadListProps, type FlowUploadListRenderProps, SimpleFlowUploadList, SimpleFlowUploadListItem, type SimpleFlowUploadListItemProps, type SimpleFlowUploadListProps, SimpleUploadListItem, type SimpleUploadListItemProps, SimpleUploadZone, type SimpleUploadZoneProps, UploadList, type UploadListProps, type UploadListRenderProps, UploadZone, type UploadZoneProps, type UploadZoneRenderProps, UploadistaProvider, useFlowContext, useFlowInputContext, useUploadistaContext };
|
|
1
|
+
import { a as MultiUploadState, l as UploadState, o as UploadItem, u as UploadStatus } from "../use-uploadista-client-CkzVVmFT.mjs";
|
|
2
|
+
import { $ as FlowInputPreviewRenderProps, A as SimpleUploadListItem, B as SimpleFlowUploadListItemProps, C as UploadResetProps, D as UploadStatusRenderProps, E as UploadStatusProps, F as FlowUploadList, G as FlowDropZoneProps, H as Flow, I as FlowUploadListProps, J as FlowErrorRenderProps, K as FlowDropZoneRenderProps, L as FlowUploadListRenderProps, M as UploadList, N as UploadListProps, O as useUploadContext, P as UploadListRenderProps, Q as FlowInputPreviewProps, R as SimpleFlowUploadList, S as UploadProps, T as UploadStartAllProps, U as FlowCancelProps, V as SimpleFlowUploadListProps, W as FlowContextValue, X as FlowInputDropZoneProps, Y as FlowInputContextValue, Z as FlowInputDropZoneRenderProps, _ as UploadItemProps, a as UploadZone, at as FlowProgressRenderProps, b as UploadProgressProps, c as Upload, ct as FlowStatusProps, d as UploadContextValue, dt as useFlowContext, et as FlowInputProps, f as UploadDropZoneProps, ft as useFlowInputContext, g as UploadItemContextValue, h as UploadErrorRenderProps, i as SimpleUploadZoneProps, it as FlowProgressProps, j as SimpleUploadListItemProps, k as useUploadItemContext, l as UploadCancelProps, lt as FlowStatusRenderProps, m as UploadErrorProps, n as useUploadistaContext, nt as FlowInputsProps, o as UploadZoneProps, ot as FlowProps, p as UploadDropZoneRenderProps, q as FlowErrorProps, r as SimpleUploadZone, rt as FlowInputsRenderProps, s as UploadZoneRenderProps, st as FlowResetProps, t as UploadistaProvider, tt as FlowInputUrlFieldProps, u as UploadClearCompletedProps, ut as FlowSubmitProps, v as UploadItemsProps, w as UploadRetryProps, x as UploadProgressRenderProps, y as UploadItemsRenderProps, z as SimpleFlowUploadListItem } from "../uploadista-provider-DwKXudoT.mjs";
|
|
3
|
+
export { Flow, type FlowCancelProps, type FlowContextValue, type FlowDropZoneProps, type FlowDropZoneRenderProps, type FlowErrorProps, type FlowErrorRenderProps, type FlowInputContextValue, type FlowInputDropZoneProps, type FlowInputDropZoneRenderProps, type FlowInputPreviewProps, type FlowInputPreviewRenderProps, type FlowInputProps, type FlowInputUrlFieldProps, type FlowInputsProps, type FlowInputsRenderProps, type FlowProgressProps, type FlowProgressRenderProps, type FlowProps, type FlowResetProps, type FlowStatusProps, type FlowStatusRenderProps, type FlowSubmitProps, FlowUploadList, type FlowUploadListProps, type FlowUploadListRenderProps, type MultiUploadState, SimpleFlowUploadList, SimpleFlowUploadListItem, type SimpleFlowUploadListItemProps, type SimpleFlowUploadListProps, SimpleUploadListItem, type SimpleUploadListItemProps, SimpleUploadZone, type SimpleUploadZoneProps, Upload, type UploadCancelProps, type UploadClearCompletedProps, type UploadContextValue, type UploadDropZoneProps, type UploadDropZoneRenderProps, type UploadErrorProps, type UploadErrorRenderProps, type UploadItem, type UploadItemContextValue, type UploadItemProps, type UploadItemsProps, type UploadItemsRenderProps, UploadList, type UploadListProps, type UploadListRenderProps, type UploadProgressProps, type UploadProgressRenderProps, type UploadProps, type UploadResetProps, type UploadRetryProps, type UploadStartAllProps, type UploadState, type UploadStatus, type UploadStatusProps, type UploadStatusRenderProps, UploadZone, type UploadZoneProps, type UploadZoneRenderProps, UploadistaProvider, useFlowContext, useFlowInputContext, useUploadContext, useUploadItemContext, useUploadistaContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,o as t}from"../use-upload-BgaJmdwF.mjs";import{a as n,c as r,i,
|
|
1
|
+
import{a as e,o as t}from"../use-upload-BgaJmdwF.mjs";import{a as n,c as r,d as i,f as a,i as o,l as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"../upload-zone-CH8B2-hl.mjs";export{i as Flow,r as FlowUploadList,s as SimpleFlowUploadList,m as SimpleFlowUploadListItem,l as SimpleUploadListItem,p as SimpleUploadZone,d as Upload,f as UploadList,c as UploadZone,e as UploadistaProvider,a as useFlowContext,u as useFlowInputContext,o as useUploadContext,n as useUploadItemContext,t as useUploadistaContext};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,555 +1,11 @@
|
|
|
1
1
|
import { C as useDragDrop, S as UseDragDropReturn, _ as InputExecutionState, a as MultiUploadState, b as DragDropOptions, c as useMultiUpload, d as UseUploadOptions, f as UseUploadReturn, g as FlowUploadStatus, h as FlowUploadState, i as MultiUploadOptions, l as UploadState, m as FlowInputMetadata, n as UseUploadistaClientReturn, o as UploadItem, p as useUpload, r as useUploadistaClient, s as UseMultiUploadReturn, t as UseUploadistaClientOptions, u as UploadStatus, v as UseFlowReturn, x as DragDropState, y as useFlow } from "./use-uploadista-client-CkzVVmFT.mjs";
|
|
2
|
-
import { A as
|
|
2
|
+
import { $ as FlowInputPreviewRenderProps, A as SimpleUploadListItem, B as SimpleFlowUploadListItemProps, C as UploadResetProps, D as UploadStatusRenderProps, E as UploadStatusProps, F as FlowUploadList, G as FlowDropZoneProps, H as Flow, I as FlowUploadListProps, J as FlowErrorRenderProps, K as FlowDropZoneRenderProps, L as FlowUploadListRenderProps, M as UploadList, N as UploadListProps, O as useUploadContext, P as UploadListRenderProps, Q as FlowInputPreviewProps, R as SimpleFlowUploadList, S as UploadProps, T as UploadStartAllProps, U as FlowCancelProps, V as SimpleFlowUploadListProps, W as FlowContextValue, X as FlowInputDropZoneProps, Y as FlowInputContextValue, Z as FlowInputDropZoneRenderProps, _ as UploadItemProps, a as UploadZone, at as FlowProgressRenderProps, b as UploadProgressProps, c as Upload, ct as FlowStatusProps, d as UploadContextValue, dt as useFlowContext, et as FlowInputProps, f as UploadDropZoneProps, ft as useFlowInputContext, g as UploadItemContextValue, h as UploadErrorRenderProps, i as SimpleUploadZoneProps, it as FlowProgressProps, j as SimpleUploadListItemProps, k as useUploadItemContext, l as UploadCancelProps, lt as FlowStatusRenderProps, m as UploadErrorProps, n as useUploadistaContext, nt as FlowInputsProps, o as UploadZoneProps, ot as FlowProps, p as UploadDropZoneRenderProps, q as FlowErrorProps, r as SimpleUploadZone, rt as FlowInputsRenderProps, s as UploadZoneRenderProps, st as FlowResetProps, t as UploadistaProvider, tt as FlowInputUrlFieldProps, u as UploadClearCompletedProps, ut as FlowSubmitProps, v as UploadItemsProps, w as UploadRetryProps, x as UploadProgressRenderProps, y as UploadItemsRenderProps, z as SimpleFlowUploadListItem } from "./uploadista-provider-DwKXudoT.mjs";
|
|
3
3
|
import { _ as UseFlowEventsOptions, a as UseUploadMetricsReturn, b as isUploadEvent, c as UploadFileEventData, d as UploadValidationSuccessEventData, f as UploadValidationWarningEventData, g as useMultiFlowUpload, h as UseMultiFlowUploadReturn, i as UseUploadMetricsOptions, l as UploadProgressEventData, m as useUploadEvents, n as FileUploadMetrics, o as useUploadMetrics, p as UseUploadEventsOptions, r as UploadMetrics, s as UploadFailedEventData, t as useUploadistaEvents, u as UploadValidationFailedEventData, v as useFlowEvents, y as isFlowEvent } from "./use-uploadista-events-CtDXJYrR.mjs";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
import { FlowManager, FlowManagerCallbacks } from "@uploadista/client-core";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { BrowserUploadInput, FlowUploadOptions } from "@uploadista/client-browser";
|
|
6
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
+
import { FlowUploadOptions } from "@uploadista/client-browser";
|
|
9
8
|
|
|
10
|
-
//#region src/components/upload-primitives.d.ts
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Context value provided by the Upload component root.
|
|
14
|
-
* Contains all upload state and actions.
|
|
15
|
-
*/
|
|
16
|
-
interface UploadContextValue {
|
|
17
|
-
/** Whether in multi-file mode */
|
|
18
|
-
mode: "single" | "multi";
|
|
19
|
-
/** Current multi-upload state (aggregate) */
|
|
20
|
-
state: MultiUploadState;
|
|
21
|
-
/** All upload items */
|
|
22
|
-
items: UploadItem$1[];
|
|
23
|
-
/** Whether auto-start is enabled */
|
|
24
|
-
autoStart: boolean;
|
|
25
|
-
/** Add files to the upload queue */
|
|
26
|
-
addFiles: (files: BrowserUploadInput[]) => void;
|
|
27
|
-
/** Remove an item from the queue */
|
|
28
|
-
removeItem: (id: string) => void;
|
|
29
|
-
/** Start all pending uploads */
|
|
30
|
-
startAll: () => void;
|
|
31
|
-
/** Abort a specific upload by ID */
|
|
32
|
-
abortUpload: (id: string) => void;
|
|
33
|
-
/** Abort all active uploads */
|
|
34
|
-
abortAll: () => void;
|
|
35
|
-
/** Retry a specific failed upload by ID */
|
|
36
|
-
retryUpload: (id: string) => void;
|
|
37
|
-
/** Retry all failed uploads */
|
|
38
|
-
retryFailed: () => void;
|
|
39
|
-
/** Clear all completed uploads */
|
|
40
|
-
clearCompleted: () => void;
|
|
41
|
-
/** Clear all items and reset state */
|
|
42
|
-
clearAll: () => void;
|
|
43
|
-
/** Internal handler for files received from drop zone */
|
|
44
|
-
handleFilesReceived: (files: File[]) => void;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Hook to access upload context from within an Upload component.
|
|
48
|
-
* @throws Error if used outside of an Upload component
|
|
49
|
-
*/
|
|
50
|
-
declare function useUploadContext(): UploadContextValue;
|
|
51
|
-
/**
|
|
52
|
-
* Context value for a specific upload item within an Upload.
|
|
53
|
-
*/
|
|
54
|
-
interface UploadItemContextValue {
|
|
55
|
-
/** Item ID */
|
|
56
|
-
id: string;
|
|
57
|
-
/** The file being uploaded */
|
|
58
|
-
file: BrowserUploadInput;
|
|
59
|
-
/** Current upload state */
|
|
60
|
-
state: UploadState;
|
|
61
|
-
/** Abort this upload */
|
|
62
|
-
abort: () => void;
|
|
63
|
-
/** Retry this upload */
|
|
64
|
-
retry: () => void;
|
|
65
|
-
/** Remove this item from the queue */
|
|
66
|
-
remove: () => void;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Hook to access upload item context from within an Upload.Item component.
|
|
70
|
-
* @throws Error if used outside of an Upload.Item component
|
|
71
|
-
*/
|
|
72
|
-
declare function useUploadItemContext(): UploadItemContextValue;
|
|
73
|
-
/**
|
|
74
|
-
* Props for the Upload root component.
|
|
75
|
-
*/
|
|
76
|
-
interface UploadProps {
|
|
77
|
-
/** Whether to allow multiple file uploads (default: false) */
|
|
78
|
-
multiple?: boolean;
|
|
79
|
-
/** Maximum concurrent uploads (default: 3, only used in multi mode) */
|
|
80
|
-
maxConcurrent?: number;
|
|
81
|
-
/** Whether to auto-start uploads when files are received (default: true) */
|
|
82
|
-
autoStart?: boolean;
|
|
83
|
-
/** Metadata to attach to uploads */
|
|
84
|
-
metadata?: Record<string, string>;
|
|
85
|
-
/** Called when a single file upload succeeds (single mode) */
|
|
86
|
-
onSuccess?: (result: UploadFile) => void;
|
|
87
|
-
/** Called when an upload fails */
|
|
88
|
-
onError?: (error: Error, item?: UploadItem$1) => void;
|
|
89
|
-
/** Called when all uploads complete (multi mode) */
|
|
90
|
-
onComplete?: (results: {
|
|
91
|
-
successful: UploadItem$1[];
|
|
92
|
-
failed: UploadItem$1[];
|
|
93
|
-
total: number;
|
|
94
|
-
}) => void;
|
|
95
|
-
/** Called when an individual upload starts */
|
|
96
|
-
onUploadStart?: (item: UploadItem$1) => void;
|
|
97
|
-
/** Called on upload progress */
|
|
98
|
-
onProgress?: (item: UploadItem$1, progress: number, bytesUploaded: number, totalBytes: number | null) => void;
|
|
99
|
-
/** Children to render */
|
|
100
|
-
children: ReactNode;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Root component for file uploads.
|
|
104
|
-
* Provides context for all Upload sub-components.
|
|
105
|
-
* Supports both single-file and multi-file modes via the `multiple` prop.
|
|
106
|
-
*
|
|
107
|
-
* @example Single file upload
|
|
108
|
-
* ```tsx
|
|
109
|
-
* <Upload onSuccess={handleSuccess}>
|
|
110
|
-
* <Upload.DropZone accept="image/*">
|
|
111
|
-
* {({ isDragging, getRootProps, getInputProps }) => (
|
|
112
|
-
* <div {...getRootProps()}>
|
|
113
|
-
* <input {...getInputProps()} />
|
|
114
|
-
* {isDragging ? "Drop here" : "Drag or click"}
|
|
115
|
-
* </div>
|
|
116
|
-
* )}
|
|
117
|
-
* </Upload.DropZone>
|
|
118
|
-
* <Upload.Progress>
|
|
119
|
-
* {({ progress }) => <progress value={progress} max={100} />}
|
|
120
|
-
* </Upload.Progress>
|
|
121
|
-
* </Upload>
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* @example Multi-file upload
|
|
125
|
-
* ```tsx
|
|
126
|
-
* <Upload multiple maxConcurrent={3} onComplete={handleComplete}>
|
|
127
|
-
* <Upload.DropZone>
|
|
128
|
-
* {(props) => ...}
|
|
129
|
-
* </Upload.DropZone>
|
|
130
|
-
* <Upload.Items>
|
|
131
|
-
* {({ items }) => items.map(item => (
|
|
132
|
-
* <Upload.Item key={item.id} id={item.id}>
|
|
133
|
-
* {({ file, state, abort, remove }) => (
|
|
134
|
-
* <div>{file.name}: {state.progress}%</div>
|
|
135
|
-
* )}
|
|
136
|
-
* </Upload.Item>
|
|
137
|
-
* ))}
|
|
138
|
-
* </Upload.Items>
|
|
139
|
-
* <Upload.StartAll>Upload All</Upload.StartAll>
|
|
140
|
-
* </Upload>
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
declare function UploadRoot({
|
|
144
|
-
multiple,
|
|
145
|
-
maxConcurrent,
|
|
146
|
-
autoStart,
|
|
147
|
-
metadata,
|
|
148
|
-
onSuccess,
|
|
149
|
-
onError,
|
|
150
|
-
onComplete,
|
|
151
|
-
onUploadStart,
|
|
152
|
-
onProgress,
|
|
153
|
-
children
|
|
154
|
-
}: UploadProps): react_jsx_runtime12.JSX.Element;
|
|
155
|
-
/**
|
|
156
|
-
* Render props for Upload.DropZone component.
|
|
157
|
-
*/
|
|
158
|
-
interface UploadDropZoneRenderProps {
|
|
159
|
-
/** Whether files are being dragged over */
|
|
160
|
-
isDragging: boolean;
|
|
161
|
-
/** Whether drag is over the zone */
|
|
162
|
-
isOver: boolean;
|
|
163
|
-
/** Validation errors */
|
|
164
|
-
errors: string[];
|
|
165
|
-
/** Props to spread on the drop zone container */
|
|
166
|
-
getRootProps: () => UseDragDropReturn["dragHandlers"];
|
|
167
|
-
/** Props to spread on the hidden file input */
|
|
168
|
-
getInputProps: () => UseDragDropReturn["inputProps"];
|
|
169
|
-
/** Open file picker programmatically */
|
|
170
|
-
openFilePicker: () => void;
|
|
171
|
-
/** Current drag-drop state */
|
|
172
|
-
dragDropState: DragDropState;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Props for Upload.DropZone component.
|
|
176
|
-
*/
|
|
177
|
-
interface UploadDropZoneProps {
|
|
178
|
-
/** Accepted file types (e.g., "image/*", ".pdf") */
|
|
179
|
-
accept?: string;
|
|
180
|
-
/** Maximum file size in bytes */
|
|
181
|
-
maxFileSize?: number;
|
|
182
|
-
/** Maximum number of files (only in multi mode) */
|
|
183
|
-
maxFiles?: number;
|
|
184
|
-
/** Render function receiving drop zone state */
|
|
185
|
-
children: (props: UploadDropZoneRenderProps) => ReactNode;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Drop zone for file uploads within an Upload component.
|
|
189
|
-
* Handles drag-and-drop and click-to-select file selection.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```tsx
|
|
193
|
-
* <Upload.DropZone accept="image/*">
|
|
194
|
-
* {({ isDragging, getRootProps, getInputProps }) => (
|
|
195
|
-
* <div {...getRootProps()}>
|
|
196
|
-
* <input {...getInputProps()} />
|
|
197
|
-
* {isDragging ? "Drop here" : "Click or drag"}
|
|
198
|
-
* </div>
|
|
199
|
-
* )}
|
|
200
|
-
* </Upload.DropZone>
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
declare function UploadDropZone({
|
|
204
|
-
accept,
|
|
205
|
-
maxFileSize,
|
|
206
|
-
maxFiles,
|
|
207
|
-
children
|
|
208
|
-
}: UploadDropZoneProps): react_jsx_runtime12.JSX.Element;
|
|
209
|
-
/**
|
|
210
|
-
* Render props for Upload.Items component.
|
|
211
|
-
*/
|
|
212
|
-
interface UploadItemsRenderProps {
|
|
213
|
-
/** All upload items */
|
|
214
|
-
items: UploadItem$1[];
|
|
215
|
-
/** Whether there are any items */
|
|
216
|
-
hasItems: boolean;
|
|
217
|
-
/** Whether items array is empty */
|
|
218
|
-
isEmpty: boolean;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Props for Upload.Items component.
|
|
222
|
-
*/
|
|
223
|
-
interface UploadItemsProps {
|
|
224
|
-
/** Render function receiving items */
|
|
225
|
-
children: (props: UploadItemsRenderProps) => ReactNode;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Renders the list of upload items via render props.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```tsx
|
|
232
|
-
* <Upload.Items>
|
|
233
|
-
* {({ items, isEmpty }) => (
|
|
234
|
-
* isEmpty ? <p>No files</p> : (
|
|
235
|
-
* items.map(item => (
|
|
236
|
-
* <Upload.Item key={item.id} id={item.id}>
|
|
237
|
-
* {(props) => ...}
|
|
238
|
-
* </Upload.Item>
|
|
239
|
-
* ))
|
|
240
|
-
* )
|
|
241
|
-
* )}
|
|
242
|
-
* </Upload.Items>
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
declare function UploadItems({
|
|
246
|
-
children
|
|
247
|
-
}: UploadItemsProps): react_jsx_runtime12.JSX.Element;
|
|
248
|
-
/**
|
|
249
|
-
* Props for Upload.Item component.
|
|
250
|
-
*/
|
|
251
|
-
interface UploadItemProps {
|
|
252
|
-
/** Item ID */
|
|
253
|
-
id: string;
|
|
254
|
-
/** Children (can be render function or regular children) */
|
|
255
|
-
children: ReactNode | ((props: UploadItemContextValue) => ReactNode);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Scoped context provider for a specific upload item.
|
|
259
|
-
* Children can access item-specific state via useUploadItemContext().
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* ```tsx
|
|
263
|
-
* <Upload.Item id={item.id}>
|
|
264
|
-
* {({ file, state, abort, remove }) => (
|
|
265
|
-
* <div>
|
|
266
|
-
* <span>{file.name}</span>
|
|
267
|
-
* <progress value={state.progress} max={100} />
|
|
268
|
-
* <button onClick={abort}>Cancel</button>
|
|
269
|
-
* <button onClick={remove}>Remove</button>
|
|
270
|
-
* </div>
|
|
271
|
-
* )}
|
|
272
|
-
* </Upload.Item>
|
|
273
|
-
* ```
|
|
274
|
-
*/
|
|
275
|
-
declare function UploadItem$1({
|
|
276
|
-
id,
|
|
277
|
-
children
|
|
278
|
-
}: UploadItemProps): react_jsx_runtime12.JSX.Element | null;
|
|
279
|
-
/**
|
|
280
|
-
* Render props for Upload.Progress component.
|
|
281
|
-
*/
|
|
282
|
-
interface UploadProgressRenderProps {
|
|
283
|
-
/** Progress percentage (0-100) */
|
|
284
|
-
progress: number;
|
|
285
|
-
/** Bytes uploaded so far */
|
|
286
|
-
bytesUploaded: number;
|
|
287
|
-
/** Total bytes to upload */
|
|
288
|
-
totalBytes: number;
|
|
289
|
-
/** Whether any uploads are active */
|
|
290
|
-
isUploading: boolean;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Props for Upload.Progress component.
|
|
294
|
-
*/
|
|
295
|
-
interface UploadProgressProps {
|
|
296
|
-
/** Render function receiving progress state */
|
|
297
|
-
children: (props: UploadProgressRenderProps) => ReactNode;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Progress display component within an Upload.
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* ```tsx
|
|
304
|
-
* <Upload.Progress>
|
|
305
|
-
* {({ progress, isUploading }) => (
|
|
306
|
-
* isUploading && <progress value={progress} max={100} />
|
|
307
|
-
* )}
|
|
308
|
-
* </Upload.Progress>
|
|
309
|
-
* ```
|
|
310
|
-
*/
|
|
311
|
-
declare function UploadProgress({
|
|
312
|
-
children
|
|
313
|
-
}: UploadProgressProps): react_jsx_runtime12.JSX.Element;
|
|
314
|
-
/**
|
|
315
|
-
* Render props for Upload.Status component.
|
|
316
|
-
*/
|
|
317
|
-
interface UploadStatusRenderProps {
|
|
318
|
-
/** Overall status */
|
|
319
|
-
status: "idle" | "uploading" | "success" | "error";
|
|
320
|
-
/** Whether idle (no uploads active or completed) */
|
|
321
|
-
isIdle: boolean;
|
|
322
|
-
/** Whether uploading */
|
|
323
|
-
isUploading: boolean;
|
|
324
|
-
/** Whether all uploads succeeded */
|
|
325
|
-
isSuccess: boolean;
|
|
326
|
-
/** Whether any upload failed */
|
|
327
|
-
isError: boolean;
|
|
328
|
-
/** Whether all uploads completed (success or failure) */
|
|
329
|
-
isComplete: boolean;
|
|
330
|
-
/** Number of total items */
|
|
331
|
-
total: number;
|
|
332
|
-
/** Number of successful uploads */
|
|
333
|
-
successful: number;
|
|
334
|
-
/** Number of failed uploads */
|
|
335
|
-
failed: number;
|
|
336
|
-
/** Number of currently uploading */
|
|
337
|
-
uploading: number;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Props for Upload.Status component.
|
|
341
|
-
*/
|
|
342
|
-
interface UploadStatusProps {
|
|
343
|
-
/** Render function receiving status state */
|
|
344
|
-
children: (props: UploadStatusRenderProps) => ReactNode;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Status display component within an Upload.
|
|
348
|
-
*
|
|
349
|
-
* @example
|
|
350
|
-
* ```tsx
|
|
351
|
-
* <Upload.Status>
|
|
352
|
-
* {({ status, total, successful, failed }) => (
|
|
353
|
-
* <div>
|
|
354
|
-
* Status: {status}
|
|
355
|
-
* ({successful}/{total} uploaded, {failed} failed)
|
|
356
|
-
* </div>
|
|
357
|
-
* )}
|
|
358
|
-
* </Upload.Status>
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
declare function UploadStatus$1({
|
|
362
|
-
children
|
|
363
|
-
}: UploadStatusProps): react_jsx_runtime12.JSX.Element;
|
|
364
|
-
/**
|
|
365
|
-
* Render props for Upload.Error component.
|
|
366
|
-
*/
|
|
367
|
-
interface UploadErrorRenderProps {
|
|
368
|
-
/** Whether there are any errors */
|
|
369
|
-
hasError: boolean;
|
|
370
|
-
/** Number of failed uploads */
|
|
371
|
-
failedCount: number;
|
|
372
|
-
/** Failed items */
|
|
373
|
-
failedItems: UploadItem$1[];
|
|
374
|
-
/** Reset/clear all errors */
|
|
375
|
-
reset: () => void;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Props for Upload.Error component.
|
|
379
|
-
*/
|
|
380
|
-
interface UploadErrorProps {
|
|
381
|
-
/** Render function receiving error state */
|
|
382
|
-
children: (props: UploadErrorRenderProps) => ReactNode;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Error display component within an Upload.
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```tsx
|
|
389
|
-
* <Upload.Error>
|
|
390
|
-
* {({ hasError, failedItems, reset }) => (
|
|
391
|
-
* hasError && (
|
|
392
|
-
* <div>
|
|
393
|
-
* {failedItems.map(item => (
|
|
394
|
-
* <p key={item.id}>{item.file.name}: {item.state.error?.message}</p>
|
|
395
|
-
* ))}
|
|
396
|
-
* <button onClick={reset}>Clear</button>
|
|
397
|
-
* </div>
|
|
398
|
-
* )
|
|
399
|
-
* )}
|
|
400
|
-
* </Upload.Error>
|
|
401
|
-
* ```
|
|
402
|
-
*/
|
|
403
|
-
declare function UploadError({
|
|
404
|
-
children
|
|
405
|
-
}: UploadErrorProps): react_jsx_runtime12.JSX.Element;
|
|
406
|
-
/**
|
|
407
|
-
* Props for Upload.Cancel component.
|
|
408
|
-
*/
|
|
409
|
-
interface UploadCancelProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
410
|
-
/** Button content */
|
|
411
|
-
children: ReactNode;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Cancel button that aborts all active uploads.
|
|
415
|
-
* Automatically disabled when no uploads are active.
|
|
416
|
-
*/
|
|
417
|
-
declare function UploadCancel({
|
|
418
|
-
children,
|
|
419
|
-
disabled,
|
|
420
|
-
...props
|
|
421
|
-
}: UploadCancelProps): react_jsx_runtime12.JSX.Element;
|
|
422
|
-
/**
|
|
423
|
-
* Props for Upload.Retry component.
|
|
424
|
-
*/
|
|
425
|
-
interface UploadRetryProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
426
|
-
/** Button content */
|
|
427
|
-
children: ReactNode;
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Retry button that retries all failed uploads.
|
|
431
|
-
* Automatically disabled when no failed uploads exist.
|
|
432
|
-
*/
|
|
433
|
-
declare function UploadRetry({
|
|
434
|
-
children,
|
|
435
|
-
disabled,
|
|
436
|
-
...props
|
|
437
|
-
}: UploadRetryProps): react_jsx_runtime12.JSX.Element;
|
|
438
|
-
/**
|
|
439
|
-
* Props for Upload.Reset component.
|
|
440
|
-
*/
|
|
441
|
-
interface UploadResetProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
442
|
-
/** Button content */
|
|
443
|
-
children: ReactNode;
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Reset button that clears all items and resets state.
|
|
447
|
-
*/
|
|
448
|
-
declare function UploadReset({
|
|
449
|
-
children,
|
|
450
|
-
...props
|
|
451
|
-
}: UploadResetProps): react_jsx_runtime12.JSX.Element;
|
|
452
|
-
/**
|
|
453
|
-
* Props for Upload.StartAll component.
|
|
454
|
-
*/
|
|
455
|
-
interface UploadStartAllProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
456
|
-
/** Button content */
|
|
457
|
-
children: ReactNode;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Start all button that begins all queued uploads.
|
|
461
|
-
* Primarily useful when autoStart is disabled.
|
|
462
|
-
* Automatically disabled when uploads are already active.
|
|
463
|
-
*/
|
|
464
|
-
declare function UploadStartAll({
|
|
465
|
-
children,
|
|
466
|
-
disabled,
|
|
467
|
-
...props
|
|
468
|
-
}: UploadStartAllProps): react_jsx_runtime12.JSX.Element;
|
|
469
|
-
/**
|
|
470
|
-
* Props for Upload.ClearCompleted component.
|
|
471
|
-
*/
|
|
472
|
-
interface UploadClearCompletedProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
473
|
-
/** Button content */
|
|
474
|
-
children: ReactNode;
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Clear completed button that removes all finished uploads from the list.
|
|
478
|
-
* Automatically disabled when no completed uploads exist.
|
|
479
|
-
*/
|
|
480
|
-
declare function UploadClearCompleted({
|
|
481
|
-
children,
|
|
482
|
-
disabled,
|
|
483
|
-
...props
|
|
484
|
-
}: UploadClearCompletedProps): react_jsx_runtime12.JSX.Element;
|
|
485
|
-
/**
|
|
486
|
-
* Upload compound component for file uploads.
|
|
487
|
-
*
|
|
488
|
-
* Provides a composable, headless API for building upload interfaces.
|
|
489
|
-
* Supports both single-file and multi-file modes via the `multiple` prop.
|
|
490
|
-
* All sub-components use render props for complete UI control.
|
|
491
|
-
*
|
|
492
|
-
* @example Single file upload
|
|
493
|
-
* ```tsx
|
|
494
|
-
* <Upload onSuccess={handleSuccess}>
|
|
495
|
-
* <Upload.DropZone accept="image/*">
|
|
496
|
-
* {({ isDragging, getRootProps, getInputProps }) => (
|
|
497
|
-
* <div {...getRootProps()}>
|
|
498
|
-
* <input {...getInputProps()} />
|
|
499
|
-
* {isDragging ? "Drop here" : "Drag or click"}
|
|
500
|
-
* </div>
|
|
501
|
-
* )}
|
|
502
|
-
* </Upload.DropZone>
|
|
503
|
-
* <Upload.Progress>
|
|
504
|
-
* {({ progress }) => <progress value={progress} max={100} />}
|
|
505
|
-
* </Upload.Progress>
|
|
506
|
-
* </Upload>
|
|
507
|
-
* ```
|
|
508
|
-
*
|
|
509
|
-
* @example Multi-file upload
|
|
510
|
-
* ```tsx
|
|
511
|
-
* <Upload multiple maxConcurrent={3} onComplete={handleComplete}>
|
|
512
|
-
* <Upload.DropZone>
|
|
513
|
-
* {({ getRootProps, getInputProps }) => (
|
|
514
|
-
* <div {...getRootProps()}>
|
|
515
|
-
* <input {...getInputProps()} />
|
|
516
|
-
* Drop files here
|
|
517
|
-
* </div>
|
|
518
|
-
* )}
|
|
519
|
-
* </Upload.DropZone>
|
|
520
|
-
* <Upload.Items>
|
|
521
|
-
* {({ items }) => items.map(item => (
|
|
522
|
-
* <Upload.Item key={item.id} id={item.id}>
|
|
523
|
-
* {({ file, state, abort, remove }) => (
|
|
524
|
-
* <div>
|
|
525
|
-
* {file.name}: {state.progress}%
|
|
526
|
-
* <button onClick={abort}>Cancel</button>
|
|
527
|
-
* <button onClick={remove}>Remove</button>
|
|
528
|
-
* </div>
|
|
529
|
-
* )}
|
|
530
|
-
* </Upload.Item>
|
|
531
|
-
* ))}
|
|
532
|
-
* </Upload.Items>
|
|
533
|
-
* <Upload.StartAll>Upload All</Upload.StartAll>
|
|
534
|
-
* <Upload.Cancel>Cancel All</Upload.Cancel>
|
|
535
|
-
* <Upload.ClearCompleted>Clear Completed</Upload.ClearCompleted>
|
|
536
|
-
* </Upload>
|
|
537
|
-
* ```
|
|
538
|
-
*/
|
|
539
|
-
declare const Upload: typeof UploadRoot & {
|
|
540
|
-
DropZone: typeof UploadDropZone;
|
|
541
|
-
Items: typeof UploadItems;
|
|
542
|
-
Item: typeof UploadItem$1;
|
|
543
|
-
Progress: typeof UploadProgress;
|
|
544
|
-
Status: typeof UploadStatus$1;
|
|
545
|
-
Error: typeof UploadError;
|
|
546
|
-
Cancel: typeof UploadCancel;
|
|
547
|
-
Retry: typeof UploadRetry;
|
|
548
|
-
Reset: typeof UploadReset;
|
|
549
|
-
StartAll: typeof UploadStartAll;
|
|
550
|
-
ClearCompleted: typeof UploadClearCompleted;
|
|
551
|
-
};
|
|
552
|
-
//#endregion
|
|
553
9
|
//#region src/contexts/flow-manager-context.d.ts
|
|
554
10
|
/**
|
|
555
11
|
* Context value providing access to flow managers
|
|
@@ -598,7 +54,7 @@ interface FlowManagerProviderProps {
|
|
|
598
54
|
*/
|
|
599
55
|
declare function FlowManagerProvider({
|
|
600
56
|
children
|
|
601
|
-
}: FlowManagerProviderProps):
|
|
57
|
+
}: FlowManagerProviderProps): react_jsx_runtime0.JSX.Element;
|
|
602
58
|
/**
|
|
603
59
|
* Hook to access the FlowManager context.
|
|
604
60
|
* Must be used within a FlowManagerProvider.
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/contexts/flow-manager-context.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;UAkDU,uBAAA;;;AAvC6B;;;;;AAqDrB;AAuClB;EAAsC,UAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,SAAA,EAzCvB,oBAyCuB,EAAA,OAAA,EAxCzB,iBAwCyB,EAAA,GAvC/B,WAuC+B,CAAA,OAAA,CAAA;EAAY;;;AAuGlD;;;;;;;;UA5HU,wBAAA;YACE;;;;;;;;;;;;;;;;;;;iBAoBI,mBAAA;;GAAkC,2BAAwB,kBAAA,CAAA,GAAA,CAAA;;;;;;;;;;;;;;;;iBAuG1D,qBAAA,CAAA,GAAyB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./use-upload-BgaJmdwF.mjs";import{a as u,c as d,
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./use-upload-BgaJmdwF.mjs";import{a as u,c as d,d as f,f as p,i as m,l as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S}from"./upload-zone-CH8B2-hl.mjs";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./use-uploadista-events-KhJ4knam.mjs";export{f as Flow,t as FlowManagerProvider,d as FlowUploadList,h as SimpleFlowUploadList,S as SimpleFlowUploadListItem,_ as SimpleUploadListItem,x as SimpleUploadZone,y as Upload,b as UploadList,g as UploadZone,e as UploadistaProvider,C as isFlowEvent,E as isUploadEvent,l as useDragDrop,n as useFlow,p as useFlowContext,w as useFlowEvents,v as useFlowInputContext,r as useFlowManagerContext,o as useMultiFlowUpload,i as useMultiUpload,c as useUpload,m as useUploadContext,D as useUploadEvents,u as useUploadItemContext,T as useUploadMetrics,s as useUploadistaClient,a as useUploadistaContext,O as useUploadistaEvents};
|