react-upload-pro 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.
@@ -0,0 +1,145 @@
1
+ import { HTMLAttributes, InputHTMLAttributes, Ref, RefObject } from 'react';
2
+ import { k as UploaderConfig, D as DropzoneCallbacks, f as UploadFile, l as ValidationError, d as DropzoneState, c as DropzoneOptions } from './types-BDyFUrlv.cjs';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type Listener = (files: UploadFile[]) => void;
6
+ /**
7
+ * Central upload coordinator. Owns the list of files, drives the upload
8
+ * lifecycle (start/pause/resume/retry/cancel/remove), and emits updates
9
+ * to subscribed React hooks.
10
+ *
11
+ * The queue is intentionally framework-agnostic — the hooks layer adapts it.
12
+ */
13
+ declare class UploadQueue {
14
+ private files;
15
+ private listeners;
16
+ private inFlight;
17
+ private callbacks;
18
+ private config;
19
+ private completionFired;
20
+ constructor(config?: UploaderConfig, callbacks?: DropzoneCallbacks);
21
+ getFiles(): UploadFile[];
22
+ subscribe(listener: Listener): () => void;
23
+ updateConfig(config: UploaderConfig): void;
24
+ updateCallbacks(callbacks: DropzoneCallbacks): void;
25
+ add(files: UploadFile[]): void;
26
+ remove(id: string): void;
27
+ removeAll(): void;
28
+ reorder(fromIndex: number, toIndex: number): void;
29
+ rename(id: string, newName: string): void;
30
+ setMetadata(id: string, metadata: UploadFile['metadata']): void;
31
+ start(): Promise<void>;
32
+ pause(id: string): void;
33
+ resume(id: string): void;
34
+ retry(id: string): void;
35
+ cancel(id: string): void;
36
+ private runFile;
37
+ private lookup;
38
+ private patch;
39
+ private emit;
40
+ private maybeFireCompletion;
41
+ }
42
+
43
+ interface UseUploadQueueOptions extends UploaderConfig, DropzoneCallbacks {
44
+ }
45
+ interface UseUploadQueueReturn {
46
+ queue: UploadQueue;
47
+ files: UploadFile[];
48
+ add: (files: UploadFile[]) => void;
49
+ remove: (id: string) => void;
50
+ removeAll: () => void;
51
+ reorder: (from: number, to: number) => void;
52
+ rename: (id: string, name: string) => void;
53
+ setMetadata: (id: string, metadata: UploadFile['metadata']) => void;
54
+ start: () => Promise<void>;
55
+ pause: (id: string) => void;
56
+ resume: (id: string) => void;
57
+ retry: (id: string) => void;
58
+ cancel: (id: string) => void;
59
+ }
60
+ /**
61
+ * Low-level hook that returns a stable UploadQueue instance bound to React state.
62
+ * Higher-level hooks (useDropzone, useUploader) compose this.
63
+ */
64
+ declare function useUploadQueue(options?: UseUploadQueueOptions): UseUploadQueueReturn;
65
+
66
+ /** The bag of props returned by getRootProps. Tagged with data-* attributes for styling. */
67
+ type RootProps<T extends HTMLElement = HTMLDivElement> = HTMLAttributes<T> & {
68
+ [dataAttr: `data-${string}`]: string | undefined;
69
+ };
70
+ /** Input props returned by getInputProps. Includes a callback ref. */
71
+ type InputProps = InputHTMLAttributes<HTMLInputElement> & {
72
+ ref?: Ref<HTMLInputElement>;
73
+ [dataAttr: `data-${string}`]: string | undefined;
74
+ };
75
+ interface UseDropzoneReturn {
76
+ /** Spread on the dropzone root element. */
77
+ getRootProps: <T extends HTMLElement = HTMLDivElement>(props?: HTMLAttributes<T>) => RootProps<T>;
78
+ /** Spread on a hidden <input type="file">. */
79
+ getInputProps: (props?: InputHTMLAttributes<HTMLInputElement>) => InputProps;
80
+ /** Open the native file dialog programmatically. */
81
+ open: () => void;
82
+ /** Files currently in the queue. */
83
+ files: UploadFile[];
84
+ /** Validation errors from the most recent drop. */
85
+ rejected: ValidationError[];
86
+ /** Whether anything is being dragged over the dropzone. */
87
+ isDragging: boolean;
88
+ /** Whether the current drag would be accepted. */
89
+ isDragAccept: boolean;
90
+ isDragReject: boolean;
91
+ /** Coarse state for styling. */
92
+ state: DropzoneState;
93
+ /** Queue helpers. */
94
+ add: (files: File[]) => Promise<{
95
+ accepted: UploadFile[];
96
+ rejected: ValidationError[];
97
+ }>;
98
+ remove: (id: string) => void;
99
+ removeAll: () => void;
100
+ reorder: (from: number, to: number) => void;
101
+ start: () => Promise<void>;
102
+ pause: (id: string) => void;
103
+ resume: (id: string) => void;
104
+ retry: (id: string) => void;
105
+ cancel: (id: string) => void;
106
+ rename: (id: string, name: string) => void;
107
+ setMetadata: (id: string, metadata: UploadFile['metadata']) => void;
108
+ /** Direct queue handle for advanced use. */
109
+ queue: ReturnType<typeof useUploadQueue>['queue'];
110
+ /** Ref to the hidden input. */
111
+ inputRef: RefObject<HTMLInputElement | null>;
112
+ }
113
+ /**
114
+ * The flagship hook. Wires drag-and-drop, paste, click, and folder upload
115
+ * to the validation + upload queue. SSR-safe: only attaches DOM listeners
116
+ * inside effects. Compatible with React 17/18/19.
117
+ */
118
+ declare function useDropzone(options?: DropzoneOptions): UseDropzoneReturn;
119
+
120
+ type ProgressVariant = 'bar' | 'striped' | 'circle' | 'minimal' | 'gradient' | 'segmented' | 'dots';
121
+ interface UploadProgressProps extends HTMLAttributes<HTMLDivElement> {
122
+ /** Progress 0..1 */
123
+ value: number;
124
+ /** Visual variant. */
125
+ variant?: ProgressVariant;
126
+ /** Show the percentage label. */
127
+ showLabel?: boolean;
128
+ /** Size in px for circle/dots variants, height in px for bar variants. */
129
+ size?: number;
130
+ /** Color overrides via Tailwind classes (e.g., 'bg-emerald-500'). */
131
+ fillClassName?: string;
132
+ /** Track color override. */
133
+ trackClassName?: string;
134
+ /** Marks the upload as indeterminate (no known progress). */
135
+ indeterminate?: boolean;
136
+ /** Number of segments for segmented/dots variants (default 10). */
137
+ segments?: number;
138
+ }
139
+ /**
140
+ * Single-file progress visualization. Pure presentational — does not subscribe
141
+ * to the queue. Multiple visual variants supported; choose via `variant`.
142
+ */
143
+ declare function UploadProgress({ value, variant, showLabel, size, fillClassName, trackClassName, indeterminate, segments, className, ...rest }: UploadProgressProps): react_jsx_runtime.JSX.Element;
144
+
145
+ export { type InputProps as I, type ProgressVariant as P, type RootProps as R, UploadProgress as U, type UploadProgressProps as a, UploadQueue as b, type UseDropzoneReturn as c, type UseUploadQueueOptions as d, type UseUploadQueueReturn as e, useUploadQueue as f, useDropzone as u };
@@ -0,0 +1,145 @@
1
+ import { HTMLAttributes, InputHTMLAttributes, Ref, RefObject } from 'react';
2
+ import { k as UploaderConfig, D as DropzoneCallbacks, f as UploadFile, l as ValidationError, d as DropzoneState, c as DropzoneOptions } from './types-BDyFUrlv.js';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type Listener = (files: UploadFile[]) => void;
6
+ /**
7
+ * Central upload coordinator. Owns the list of files, drives the upload
8
+ * lifecycle (start/pause/resume/retry/cancel/remove), and emits updates
9
+ * to subscribed React hooks.
10
+ *
11
+ * The queue is intentionally framework-agnostic — the hooks layer adapts it.
12
+ */
13
+ declare class UploadQueue {
14
+ private files;
15
+ private listeners;
16
+ private inFlight;
17
+ private callbacks;
18
+ private config;
19
+ private completionFired;
20
+ constructor(config?: UploaderConfig, callbacks?: DropzoneCallbacks);
21
+ getFiles(): UploadFile[];
22
+ subscribe(listener: Listener): () => void;
23
+ updateConfig(config: UploaderConfig): void;
24
+ updateCallbacks(callbacks: DropzoneCallbacks): void;
25
+ add(files: UploadFile[]): void;
26
+ remove(id: string): void;
27
+ removeAll(): void;
28
+ reorder(fromIndex: number, toIndex: number): void;
29
+ rename(id: string, newName: string): void;
30
+ setMetadata(id: string, metadata: UploadFile['metadata']): void;
31
+ start(): Promise<void>;
32
+ pause(id: string): void;
33
+ resume(id: string): void;
34
+ retry(id: string): void;
35
+ cancel(id: string): void;
36
+ private runFile;
37
+ private lookup;
38
+ private patch;
39
+ private emit;
40
+ private maybeFireCompletion;
41
+ }
42
+
43
+ interface UseUploadQueueOptions extends UploaderConfig, DropzoneCallbacks {
44
+ }
45
+ interface UseUploadQueueReturn {
46
+ queue: UploadQueue;
47
+ files: UploadFile[];
48
+ add: (files: UploadFile[]) => void;
49
+ remove: (id: string) => void;
50
+ removeAll: () => void;
51
+ reorder: (from: number, to: number) => void;
52
+ rename: (id: string, name: string) => void;
53
+ setMetadata: (id: string, metadata: UploadFile['metadata']) => void;
54
+ start: () => Promise<void>;
55
+ pause: (id: string) => void;
56
+ resume: (id: string) => void;
57
+ retry: (id: string) => void;
58
+ cancel: (id: string) => void;
59
+ }
60
+ /**
61
+ * Low-level hook that returns a stable UploadQueue instance bound to React state.
62
+ * Higher-level hooks (useDropzone, useUploader) compose this.
63
+ */
64
+ declare function useUploadQueue(options?: UseUploadQueueOptions): UseUploadQueueReturn;
65
+
66
+ /** The bag of props returned by getRootProps. Tagged with data-* attributes for styling. */
67
+ type RootProps<T extends HTMLElement = HTMLDivElement> = HTMLAttributes<T> & {
68
+ [dataAttr: `data-${string}`]: string | undefined;
69
+ };
70
+ /** Input props returned by getInputProps. Includes a callback ref. */
71
+ type InputProps = InputHTMLAttributes<HTMLInputElement> & {
72
+ ref?: Ref<HTMLInputElement>;
73
+ [dataAttr: `data-${string}`]: string | undefined;
74
+ };
75
+ interface UseDropzoneReturn {
76
+ /** Spread on the dropzone root element. */
77
+ getRootProps: <T extends HTMLElement = HTMLDivElement>(props?: HTMLAttributes<T>) => RootProps<T>;
78
+ /** Spread on a hidden <input type="file">. */
79
+ getInputProps: (props?: InputHTMLAttributes<HTMLInputElement>) => InputProps;
80
+ /** Open the native file dialog programmatically. */
81
+ open: () => void;
82
+ /** Files currently in the queue. */
83
+ files: UploadFile[];
84
+ /** Validation errors from the most recent drop. */
85
+ rejected: ValidationError[];
86
+ /** Whether anything is being dragged over the dropzone. */
87
+ isDragging: boolean;
88
+ /** Whether the current drag would be accepted. */
89
+ isDragAccept: boolean;
90
+ isDragReject: boolean;
91
+ /** Coarse state for styling. */
92
+ state: DropzoneState;
93
+ /** Queue helpers. */
94
+ add: (files: File[]) => Promise<{
95
+ accepted: UploadFile[];
96
+ rejected: ValidationError[];
97
+ }>;
98
+ remove: (id: string) => void;
99
+ removeAll: () => void;
100
+ reorder: (from: number, to: number) => void;
101
+ start: () => Promise<void>;
102
+ pause: (id: string) => void;
103
+ resume: (id: string) => void;
104
+ retry: (id: string) => void;
105
+ cancel: (id: string) => void;
106
+ rename: (id: string, name: string) => void;
107
+ setMetadata: (id: string, metadata: UploadFile['metadata']) => void;
108
+ /** Direct queue handle for advanced use. */
109
+ queue: ReturnType<typeof useUploadQueue>['queue'];
110
+ /** Ref to the hidden input. */
111
+ inputRef: RefObject<HTMLInputElement | null>;
112
+ }
113
+ /**
114
+ * The flagship hook. Wires drag-and-drop, paste, click, and folder upload
115
+ * to the validation + upload queue. SSR-safe: only attaches DOM listeners
116
+ * inside effects. Compatible with React 17/18/19.
117
+ */
118
+ declare function useDropzone(options?: DropzoneOptions): UseDropzoneReturn;
119
+
120
+ type ProgressVariant = 'bar' | 'striped' | 'circle' | 'minimal' | 'gradient' | 'segmented' | 'dots';
121
+ interface UploadProgressProps extends HTMLAttributes<HTMLDivElement> {
122
+ /** Progress 0..1 */
123
+ value: number;
124
+ /** Visual variant. */
125
+ variant?: ProgressVariant;
126
+ /** Show the percentage label. */
127
+ showLabel?: boolean;
128
+ /** Size in px for circle/dots variants, height in px for bar variants. */
129
+ size?: number;
130
+ /** Color overrides via Tailwind classes (e.g., 'bg-emerald-500'). */
131
+ fillClassName?: string;
132
+ /** Track color override. */
133
+ trackClassName?: string;
134
+ /** Marks the upload as indeterminate (no known progress). */
135
+ indeterminate?: boolean;
136
+ /** Number of segments for segmented/dots variants (default 10). */
137
+ segments?: number;
138
+ }
139
+ /**
140
+ * Single-file progress visualization. Pure presentational — does not subscribe
141
+ * to the queue. Multiple visual variants supported; choose via `variant`.
142
+ */
143
+ declare function UploadProgress({ value, variant, showLabel, size, fillClassName, trackClassName, indeterminate, segments, className, ...rest }: UploadProgressProps): react_jsx_runtime.JSX.Element;
144
+
145
+ export { type InputProps as I, type ProgressVariant as P, type RootProps as R, UploadProgress as U, type UploadProgressProps as a, UploadQueue as b, type UseDropzoneReturn as c, type UseUploadQueueOptions as d, type UseUploadQueueReturn as e, useUploadQueue as f, useDropzone as u };