UNPKG

@kopexa/sight

Version:

Kopexa Sight Design System — React component library for GRC applications

48 lines (45 loc) 1.62 kB
import React__default, { DragEvent, ChangeEvent, InputHTMLAttributes } from 'react'; type FileMetadata = { name: string; size: number; type: string; url: string; id: string; }; type FileWithPreview = { file: File | FileMetadata; id: string; preview?: string; }; type FileUploadOptions = { maxFiles?: number; maxSize?: number; accept?: string; multiple?: boolean; initialFiles?: FileMetadata[]; onFilesChange?: (files: FileWithPreview[]) => void; onFilesAdded?: (addedFiles: FileWithPreview[]) => void; onError?: (errors: string[]) => void; }; type FileUploadState = { files: FileWithPreview[]; isDragging: boolean; errors: string[]; }; type FileUploadActions = { addFiles: (files: FileList | File[]) => void; removeFile: (id: string) => void; clearFiles: () => void; clearErrors: () => void; handleDragEnter: (e: DragEvent<HTMLElement>) => void; handleDragLeave: (e: DragEvent<HTMLElement>) => void; handleDragOver: (e: DragEvent<HTMLElement>) => void; handleDrop: (e: DragEvent<HTMLElement>) => void; handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void; openFileDialog: () => void; getInputProps: (props?: InputHTMLAttributes<HTMLInputElement>) => InputHTMLAttributes<HTMLInputElement> & { ref: React__default.Ref<HTMLInputElement>; }; }; declare const useFileUpload: (options?: FileUploadOptions) => [FileUploadState, FileUploadActions]; export { type FileMetadata, type FileUploadActions, type FileUploadOptions, type FileUploadState, type FileWithPreview, useFileUpload };