完成评查点分组的增删改
This commit is contained in:
@@ -12,6 +12,7 @@ interface UploadAreaProps {
|
||||
mainText?: string;
|
||||
tipText?: ReactNode;
|
||||
disabled?: boolean;
|
||||
shouldPreventFileSelect?: boolean;
|
||||
}
|
||||
|
||||
export interface UploadAreaRef {
|
||||
@@ -31,7 +32,8 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
|
||||
buttonText = "选择文件",
|
||||
mainText = "点击或拖拽文件到此区域上传",
|
||||
tipText = "",
|
||||
disabled = false
|
||||
disabled = false,
|
||||
shouldPreventFileSelect = false
|
||||
}, ref) => {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [isDragOver, setIsDragOver] = useState(false);
|
||||
@@ -48,10 +50,10 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
|
||||
}));
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
if (!disabled && fileInputRef.current) {
|
||||
if (!disabled && !shouldPreventFileSelect && fileInputRef.current) {
|
||||
fileInputRef.current.click();
|
||||
}
|
||||
}, [disabled]);
|
||||
}, [disabled, shouldPreventFileSelect]);
|
||||
|
||||
const handleFileChange = useCallback(() => {
|
||||
if (fileInputRef.current?.files?.length) {
|
||||
@@ -61,10 +63,10 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
|
||||
|
||||
const handleDragOver = useCallback((e: React.DragEvent<HTMLDivElement>) => {
|
||||
e.preventDefault();
|
||||
if (!disabled) {
|
||||
if (!disabled && !shouldPreventFileSelect) {
|
||||
setIsDragOver(true);
|
||||
}
|
||||
}, [disabled]);
|
||||
}, [disabled, shouldPreventFileSelect]);
|
||||
|
||||
const handleDragLeave = useCallback(() => {
|
||||
setIsDragOver(false);
|
||||
@@ -74,17 +76,17 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
|
||||
e.preventDefault();
|
||||
setIsDragOver(false);
|
||||
|
||||
if (!disabled && e.dataTransfer.files.length > 0) {
|
||||
if (!disabled && !shouldPreventFileSelect && e.dataTransfer.files.length > 0) {
|
||||
onFilesSelected(e.dataTransfer.files);
|
||||
}
|
||||
}, [disabled, onFilesSelected]);
|
||||
}, [disabled, shouldPreventFileSelect, onFilesSelected]);
|
||||
|
||||
const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if ((e.key === 'Enter' || e.key === ' ') && !disabled) {
|
||||
if ((e.key === 'Enter' || e.key === ' ') && !disabled && !shouldPreventFileSelect) {
|
||||
e.preventDefault();
|
||||
handleClick();
|
||||
}
|
||||
}, [handleClick, disabled]);
|
||||
}, [handleClick, disabled, shouldPreventFileSelect]);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user