@ibanzajoe/uploader 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,208 @@
1
+ import { P as PickerResponse, F as FileResult, h as UploaderClientOptions } from './transform-ybCOCWBG.js';
2
+ export { C as CropParams, O as OutputParams, a as PolicySpec, Q as QualityParams, R as ResizeParams, b as RotateParams, T as TransformChain, c as TransformOp, d as TransformOpName, e as TransformUrlOptions, U as UploadAllOptions, f as UploadOptions, g as UploaderClient, i as crop, j as flip, k as flop, o as output, q as quality, r as resize, l as rotate, t as transformUrl } from './transform-ybCOCWBG.js';
3
+ import * as React from 'react';
4
+ import React__default, { CSSProperties } from 'react';
5
+
6
+ /**
7
+ * React picker prop and state types.
8
+ *
9
+ * Designed for filestack-parity naming so existing filestack integrations can
10
+ * migrate with minimal changes. All callback names match filestack's onUploadDone /
11
+ * onFileUploadFinished / onFileUploadFailed / onCancel surface.
12
+ */
13
+
14
+ /** State of a single file entry in the picker queue. */
15
+ type PickerFileState = 'pending' | 'uploading' | 'done' | 'error';
16
+ /** A file in the picker's queue with upload state. */
17
+ type PickerFile = {
18
+ /** Browser File object. */
19
+ file: File;
20
+ /** Stable key for React list rendering. */
21
+ id: string;
22
+ /** Current upload state. */
23
+ state: PickerFileState;
24
+ /** Upload progress 0–100, or null while pending. */
25
+ progress: number | null;
26
+ /** Result after successful upload. */
27
+ result?: FileResult;
28
+ /** Error message if upload failed. */
29
+ error?: string;
30
+ /** Object URL for image preview; revoked on removal. */
31
+ previewUrl?: string;
32
+ };
33
+ /** File type/size constraints and source settings for the picker. */
34
+ type PickerOptions = {
35
+ /**
36
+ * MIME types or extensions to accept (e.g. ['image/*', '.pdf']).
37
+ * Maps to the <input accept="..."> attribute.
38
+ */
39
+ accept?: string[];
40
+ /** Maximum number of files selectable in one session. Default: unlimited. */
41
+ maxFiles?: number;
42
+ /** Maximum file size in bytes. Files above this are rejected at selection. */
43
+ maxSize?: number;
44
+ /**
45
+ * Upload sources. Currently only 'local_file_system' is supported (MVP).
46
+ * Extension point for webcam/URL/cloud pickers.
47
+ */
48
+ fromSources?: Array<'local_file_system'>;
49
+ };
50
+ /** Props shared by PickerOverlay and DropPane. */
51
+ type SharedPickerProps = {
52
+ /** Public API key (pk_...). */
53
+ apikey: string;
54
+ /** Base URL of the upload API. */
55
+ apiUrl?: string;
56
+ /** Optional signed security policy. */
57
+ security?: {
58
+ policy: string;
59
+ signature: string;
60
+ };
61
+ /** File constraint and source options. */
62
+ pickerOptions?: PickerOptions;
63
+ /** Called when all uploads complete. */
64
+ onUploadDone?: (response: PickerResponse) => void;
65
+ /** Called when a single file finishes uploading. */
66
+ onFileUploadFinished?: (file: FileResult) => void;
67
+ /** Called when a single file upload fails. */
68
+ onFileUploadFailed?: (file: File, error: Error) => void;
69
+ /** Called when the user cancels / closes without uploading. */
70
+ onCancel?: () => void;
71
+ };
72
+ /** State and actions returned by usePicker. */
73
+ type UsePickerResult = {
74
+ /** Current file queue. */
75
+ files: PickerFile[];
76
+ /** Add files to the queue. Respects maxFiles and maxSize. */
77
+ addFiles: (incoming: FileList | File[]) => void;
78
+ /** Remove a file from the queue by id. */
79
+ removeFile: (id: string) => void;
80
+ /** Replace a queued file's bytes with an edited version (resets it to pending). */
81
+ editFile: (id: string, newFile: File) => void;
82
+ /** Retry a failed file upload. */
83
+ retryFile: (id: string) => void;
84
+ /** Start uploading all pending files. */
85
+ upload: () => Promise<void>;
86
+ /** Aggregate progress 0–100 across all uploading files. */
87
+ progress: number;
88
+ /** True while any file is uploading. */
89
+ isUploading: boolean;
90
+ /** True once all files have finished (done or error). */
91
+ isDone: boolean;
92
+ };
93
+
94
+ /**
95
+ * PickerOverlay — modal file picker with drag-and-drop.
96
+ *
97
+ * A full-featured modal picker matching filestack's core UX:
98
+ * - Drag-and-drop dropzone + "Browse files" button
99
+ * - Multi-file queue with thumbnails/preview, per-file progress bars
100
+ * - Remove and retry controls per file
101
+ * - Aggregate progress bar
102
+ * - Upload / Cancel action buttons
103
+ * - Keyboard: ESC closes; Tab cycles within the modal (focus trap)
104
+ * - ARIA: role="dialog", aria-modal, labelled header, live regions
105
+ * - Themeable via CSS variables (--uploader-accent, etc.)
106
+ *
107
+ * Opens when `open={true}`. Calls `onClose` when the user dismisses via ESC,
108
+ * the backdrop click, or the Cancel button. `onUploadDone` fires after all
109
+ * selected files have been uploaded.
110
+ */
111
+
112
+ type PickerOverlayProps = SharedPickerProps & {
113
+ /** Whether the modal is open. */
114
+ open: boolean;
115
+ /** Called when the modal should close (ESC, backdrop, cancel). */
116
+ onClose: () => void;
117
+ /** Additional CSS class(es) applied to the modal panel. */
118
+ className?: string;
119
+ /** Inline styles applied to the modal panel. */
120
+ style?: React__default.CSSProperties;
121
+ };
122
+ declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
123
+
124
+ /**
125
+ * DropPane — inline drag-and-drop upload zone.
126
+ *
127
+ * A non-modal file drop target that renders in-place. Suitable for embedding
128
+ * directly in a page (e.g. a form upload field) rather than as a modal overlay.
129
+ *
130
+ * Uses usePicker() internally; exposes the same filestack-parity callbacks as
131
+ * PickerOverlay. Renders a file list with progress and remove/retry controls
132
+ * below the drop zone.
133
+ */
134
+
135
+ type DropPaneProps = SharedPickerProps & {
136
+ /** Additional CSS class(es) applied to the root element. */
137
+ className?: string;
138
+ /** Inline styles applied to the root element. */
139
+ style?: React__default.CSSProperties;
140
+ };
141
+ declare function DropPane({ apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, className, style, }: DropPaneProps): React__default.JSX.Element;
142
+
143
+ type UsePickerOptions = UploaderClientOptions & {
144
+ pickerOptions?: PickerOptions;
145
+ onUploadDone?: (response: PickerResponse) => void;
146
+ onFileUploadFinished?: (file: FileResult) => void;
147
+ onFileUploadFailed?: (file: File, error: Error) => void;
148
+ };
149
+ declare function usePicker(opts: UsePickerOptions): UsePickerResult;
150
+
151
+ type ImageEditorProps = {
152
+ /** The image File to edit. */
153
+ file: File;
154
+ /** Called with the edited File when the user clicks Apply. */
155
+ onApply: (edited: File) => void;
156
+ /** Called when the user cancels editing. */
157
+ onCancel: () => void;
158
+ /** Output MIME type. Defaults to the source type (when re-encodable) else png. */
159
+ outputType?: string;
160
+ /** Quality 0–1 for lossy output. Default 0.92. */
161
+ quality?: number;
162
+ /** Default "max longest side" for the resize control. Default 1920. */
163
+ maxDimensionDefault?: number;
164
+ className?: string;
165
+ style?: CSSProperties;
166
+ };
167
+ declare function ImageEditor({ file, onApply, onCancel, outputType, quality, maxDimensionDefault, className, style, }: ImageEditorProps): React.JSX.Element;
168
+
169
+ /**
170
+ * editImage — bake pre-upload edits (rotate / flip / crop / resize) into an
171
+ * image File using a <canvas>, returning a NEW File. Browser-only.
172
+ *
173
+ * The crop rectangle is in the pixel space of the rotated+flipped image (the
174
+ * order is: rotate, then flip, then crop, then resize). ImageEditor bakes
175
+ * rotation/flip into a working image first and passes a crop with rotation=0, so
176
+ * the crop coordinates come straight from the on-screen selection.
177
+ */
178
+ type Flip = {
179
+ horizontal: boolean;
180
+ vertical: boolean;
181
+ };
182
+ type CropArea = {
183
+ x: number;
184
+ y: number;
185
+ width: number;
186
+ height: number;
187
+ };
188
+ type EditImageOptions = {
189
+ /** Clockwise rotation in degrees. */
190
+ rotation?: number;
191
+ /** Mirror horizontally / vertically. */
192
+ flip?: Flip;
193
+ /** Crop rectangle in the rotated+flipped image's natural pixels. */
194
+ crop?: CropArea;
195
+ /** If set, scale the result down so its longest side is at most this many pixels. */
196
+ maxDimension?: number;
197
+ /** Mask the result to a circle/ellipse (transparent corners). Forces PNG output. */
198
+ circle?: boolean;
199
+ /** Output MIME type. Defaults to the source type when re-encodable, else image/png. */
200
+ outputType?: string;
201
+ /** Quality 0–1 for lossy formats (jpeg/webp). Default 0.92. */
202
+ quality?: number;
203
+ /** Override the output filename. Defaults to the source name with a matching extension. */
204
+ fileName?: string;
205
+ };
206
+ declare function editImage(file: File, opts?: EditImageOptions): Promise<File>;
207
+
208
+ export { type CropArea, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UsePickerOptions, type UsePickerResult, editImage, usePicker };