analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
81 lines • 2.94 kB
TypeScript
export type FileType = 'image' | 'video' | 'audio' | 'pdf' | 'subtitle';
export interface FileDropzoneProps {
/** Label text displayed above the dropzone */
label?: string;
/** Helper text displayed below the dropzone */
helperText?: string;
/** Error message displayed below the dropzone */
errorMessage?: string;
/** Current file URL (for existing files) */
fileUrl?: string | null;
/** File currently selected */
selectedFile?: File | null;
/** Callback when a file is selected */
onFileSelect?: (file: File) => void;
/** Callback when file is removed */
onRemoveFile?: () => void;
/** Accept specific file types (required) */
accept: string;
/** Type of file for display purposes */
fileType: FileType;
/** Action text shown as link (default: "Clique aqui") */
actionText?: string;
/** Description text shown after action text */
placeholder?: string;
/** Text shown when hovering over an existing file */
changeText?: string;
/** Label of the replace button shown in the image preview state (default: "Trocar") */
changeButtonText?: string;
/** Disabled state */
disabled?: boolean;
/** Required field indicator */
required?: boolean;
/** Custom class name */
className?: string;
/** Max file size in bytes */
maxSize?: number;
/** Callback when file size exceeds maxSize */
onSizeError?: (file: File, maxSize: number) => void;
/** Callback when invalid file type is selected */
onTypeError?: (file: File) => void;
/** Show image preview (only for image type) */
showPreview?: boolean;
/** Max height for image preview */
previewMaxHeight?: string;
}
/**
* FileDropzone component for Analytica Ensino platforms
*
* A generic dropzone component for file upload with drag-and-drop support,
* file preview, and dashed border styling. Supports multiple file types.
*
* @example
* ```tsx
* // Video upload
* <FileDropzone
* label="Arquivo do vídeo"
* accept="video/mp4,.mp4"
* fileType="video"
* onFileSelect={(file) => setVideoFile(file)}
* />
*
* // Audio upload
* <FileDropzone
* label="Arquivo do podcast"
* accept="audio/*,.mp3,.wav"
* fileType="audio"
* onFileSelect={(file) => setAudioFile(file)}
* />
*
* // Image upload with preview
* <FileDropzone
* label="Quadro inicial"
* accept="image/*"
* fileType="image"
* showPreview={true}
* onFileSelect={(file) => setImageFile(file)}
* />
* ```
*/
export default function FileDropzone({ label, helperText, errorMessage, fileUrl, selectedFile, onFileSelect, onRemoveFile, accept, fileType, actionText, placeholder, changeText, changeButtonText, disabled, required, className, maxSize, onSizeError, onTypeError, showPreview, previewMaxHeight, }: Readonly<FileDropzoneProps>): import("react/jsx-runtime").JSX.Element;
//# sourceMappingURL=FileDropzone.d.ts.map