"use client"; import React, { useState, useRef } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { FileInfo, FileUploadConfig } from "./types"; import { Upload, Download, Trash2, Eye, File, FileText, Image as ImageIcon, Video, Music, Archive, Presentation, X, Star, ZoomIn, ZoomOut, RotateCcw, } from "lucide-react"; import { formatFileSize } from "@/lib/utils"; import { FileViewerModal } from "./FileViewerModal"; interface FileManagerModalProps { isOpen: boolean; onClose: () => void; uploadedFiles: FileInfo[]; onFileUpload: (files: File[]) => Promise; onFileDownload: (file: FileInfo) => void; onFileDelete: (file: FileInfo) => void; onFileView: (file: FileInfo) => void; onSetRepresentative?: (file: FileInfo) => void; // 대표 이미지 설정 콜백 config: FileUploadConfig; isDesignMode?: boolean; } export const FileManagerModal: React.FC = ({ isOpen, onClose, uploadedFiles, onFileUpload, onFileDownload, onFileDelete, onFileView, onSetRepresentative, config, isDesignMode = false, }) => { const [dragOver, setDragOver] = useState(false); const [uploading, setUploading] = useState(false); const [viewerFile, setViewerFile] = useState(null); const [isViewerOpen, setIsViewerOpen] = useState(false); const [selectedFile, setSelectedFile] = useState(null); // 선택된 파일 (좌측 미리보기용) const [previewImageUrl, setPreviewImageUrl] = useState(null); // 이미지 미리보기 URL const [zoomLevel, setZoomLevel] = useState(1); // 🔍 확대/축소 레벨 const [imagePosition, setImagePosition] = useState({ x: 0, y: 0 }); // 🖱️ 이미지 위치 const [isDragging, setIsDragging] = useState(false); // 🖱️ 드래그 중 여부 const [dragStart, setDragStart] = useState({ x: 0, y: 0 }); // 🖱️ 드래그 시작 위치 const fileInputRef = useRef(null); const imageContainerRef = useRef(null); // 파일 아이콘 가져오기 const getFileIcon = (fileExt: string) => { const ext = fileExt.toLowerCase(); if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'].includes(ext)) { return ; } else if (['pdf', 'doc', 'docx', 'txt', 'rtf'].includes(ext)) { return ; } else if (['xls', 'xlsx', 'csv'].includes(ext)) { return ; } else if (['ppt', 'pptx'].includes(ext)) { return ; } else if (['mp4', 'avi', 'mov', 'webm'].includes(ext)) { return