react-profile-crop
Version:
A flexible, customizable React component for cropping profile pictures with real-time preview.
68 lines (64 loc) • 1.98 kB
TypeScript
import React from 'react';
interface CropArea {
x: number;
y: number;
width: number;
height: number;
}
type CropShape = "circle" | "square" | "rectangle";
type OutputImageType = "png" | "jpeg" | "webp";
type CropCompleteCallback = (area: CropArea, croppedImageData?: string) => void;
interface ThemeOptions {
backgroundColor?: string;
overlayColor?: string;
borderColor?: string;
accentColor?: string;
textColor?: string;
buttonBackgroundColor?: string;
buttonTextColor?: string;
}
interface ProfileCropperProps {
initialImage?: string;
onSave?: (imageData: string) => void;
onCancel?: () => void;
cropShape?: CropShape;
aspectRatio?: number;
outputFormat?: OutputImageType;
outputQuality?: number;
theme?: ThemeOptions;
size?: number;
className?: string;
style?: React.CSSProperties;
containerHeight?: number;
maxZoom?: number;
minZoom?: number;
zoomStep?: number;
allowZoom?: boolean;
allowDrag?: boolean;
headerText?: string;
previewText?: string;
saveButtonText?: string;
cancelButtonText?: string;
loadingText?: string;
uploadText?: string;
uploadSubtext?: string;
zoomLabel?: string;
changeButtonText?: string;
acceptedFileTypes?: string;
maxFileSizeMB?: number;
showPreview?: boolean;
previewSize?: number;
showZoomControls?: boolean;
showChangeButton?: boolean;
containerClassName?: string;
headerClassName?: string;
previewContainerClassName?: string;
buttonContainerClassName?: string;
saveButtonClassName?: string;
cancelButtonClassName?: string;
errorContainerClassname?: string;
errorTextClassname?: string;
onError?: (error: string) => void;
}
declare const ProfileCropper: React.FC<ProfileCropperProps>;
export { type CropArea, type CropCompleteCallback, type CropShape, type OutputImageType, ProfileCropper, type ProfileCropperProps, type ThemeOptions };