Uploader Provider
edgestore/uploader-providerFreeComponent
A provider component and hook for managing file uploads with progress tracking and state management.
Live preview
live · rendered by the registry
Rendered by EdgeStore on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://edgestore.dev/r/uploader-provider.jsonSource
1'use client';23import * as React from 'react';45/**6 * Represents the possible statuses of a file in the uploader.7 */8export type FileStatus = 'PENDING' | 'UPLOADING' | 'COMPLETE' | 'ERROR';910/**11 * Represents the state of a file in the uploader.12 */13export type FileState = {14 /** The file object being uploaded */15 file: File;1617 /** Unique identifier for the file */18 key: string;1920 /** Upload progress (0-100) */21 progress: number;2223 /** Current status of the file */24 status: FileStatus;2526 /** URL of the uploaded file (available when status is COMPLETE) */27 url?: string;2829 /** Error message if the upload failed */30 error?: string;3132 /** AbortController to cancel the upload */33 abortController?: AbortController;3435 /** Whether the file should be automatically uploaded */36 autoUpload?: boolean;37};3839/**40 * Represents a file that has completed uploading.41 */42export type CompletedFileState = Omit<FileState, 'status' | 'url'> & {43 /** Status is guaranteed to be 'COMPLETE' */44 status: 'COMPLETE';4546 /** URL is guaranteed to be available */47 url: string;48};4950/**51 * Function type for handling file uploads.52 */53export type UploadFn<TOptions = unknown> = (props: {54 /** The file to be uploaded */55 file: File;5657 /** AbortSignal to cancel the upload */58 signal: AbortSignal;5960 /** Callback to update progress */61 onProgressChange: (progress: number) => void | Promise<void>;6263 /** Additional options */64 options?: TOptions;65}) => Promise<{ url: string }>;6667/**68 * Context type for the UploaderProvider.69 */70type UploaderContextType<TOptions = unknown> = {71 /** List of all files in the uploader */72 fileStates: FileState[];7374 /** Add files to the uploader */75 addFiles: (files: File[]) => void;7677 /** Update a file's state */78 updateFileState: (key: string, changes: Partial<FileState>) => void;7980 /** Remove a file from the uploader */81 removeFile: (key: string) => void;8283 /** Cancel an ongoing upload */84 cancelUpload: (key: string) => void;8586 /** Start uploading files */87 uploadFiles: (keysToUpload?: string[], options?: TOptions) => Promise<void>;8889 /** Reset all files */90 resetFiles: () => void;9192 /** Whether any file is currently uploading */93 isUploading: boolean;9495 /** Whether files should be automatically uploaded */96 autoUpload?: boolean;97};9899/**100 * Props for the UploaderProvider component.101 */102type ProviderProps<TOptions = unknown> = {103 /** React children or render function */104 children:105 | React.ReactNode106// … truncated
Files it writes
More from EdgeStore
All 12 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Progress Barprogress-bar | EdgeStore | Components | Free | no deps | |
| Progress Circleprogress-circle | EdgeStore | Components | Free | no deps | |
| Single Image Dropzonesingle-image-dropzone | EdgeStore | Components | Free | 2 deps |
