UNPKG

@wordpress/media-utils

Version:
41 lines 1.73 kB
/** * Hook for tracking media upload status with batch-scoped callbacks. * * This is a transitional layer that manually tracks upload progress using * local state. The @wordpress/upload-media package provides a Redux-based * store with richer capabilities (per-file progress, pause/resume, retry, * concurrency control, client-side processing). When the media upload modal * adopts @wordpress/upload-media, this hook can be replaced by selectors * from that store (getItems, isBatchUploaded, getItemProgress, etc.) while * keeping the same return interface. */ /** * Internal dependencies */ import type { Attachment } from '../../utils/types'; import type { UploadingFile } from './upload-status-popover'; interface UseUploadStatusOptions { onBatchComplete?: (attachments: Partial<Attachment>[]) => void; } interface RegisterBatchResult { onFileChange: (attachments: Partial<Attachment>[]) => void; onError: (error: Error) => void; } interface UseUploadStatusReturn { /** Current list of all tracked files. */ uploadingFiles: UploadingFile[]; /** * Register a new batch of files for tracking. * Returns batch-scoped onFileChange and onError callbacks. */ registerBatch: (files: File[]) => RegisterBatchResult; /** Remove a single error entry by file id. */ dismissError: (fileId: string) => void; /** Remove all uploaded (completed) entries from the list. */ clearCompleted: () => void; /** True when tracked entries exist but none are still uploading. */ allComplete: boolean; } export declare function useUploadStatus({ onBatchComplete, }?: UseUploadStatusOptions): UseUploadStatusReturn; export {}; //# sourceMappingURL=use-upload-status.d.ts.map