export type FileUploadEntry = {
status: 'pending';
id: string;
file: File;
} | {
status: 'uploading';
id: string;
file: File;
} | {
status: 'done';
id: string;
file: File;
meta: Meta;
} | {
status: 'error';
id: string;
file: File;
error: unknown;
};
export type UseFileUploadStoreOptions = {
/**
* Called for each file to perform the actual upload.
* Should return a promise resolving to file metadata.
* Not called when `withoutApply` is true.
*/
upload: (file: File) => Promise;
/** Maximum number of files allowed */
maxFiles?: number;
/**
* When true, files are queued without starting the upload.
* `onUpload` is called instead so the consumer can drive the upload externally.
*/
withoutApply?: boolean;
/** Called with newly added files when `withoutApply` is true */
onUpload?: (files: File[]) => void;
};
export type UseFileUploadStoreReturn = {
entries: FileUploadEntry[];
isLoading: boolean;
addFiles: (files: File[]) => void;
removeFile: (id: string) => void;
reset: () => void;
uploadedMetas: Meta[];
};
/**
* State machine for managing the file upload lifecycle.
* The consumer provides an `upload` function — this hook never calls any API directly.
*/
export declare function useFileUploadStore(options: UseFileUploadStoreOptions): UseFileUploadStoreReturn;