feat: enhance import/export functionality with detailed results dialog and improved data handling
This commit is contained in:
@@ -7,6 +7,7 @@ import { cn } from "@/shared/lib/utils"
|
||||
|
||||
export type ImageInputFieldProps = BaseFieldControlProps<File | null> & {
|
||||
accept?: string
|
||||
initialPreviewUrl?: string | null
|
||||
}
|
||||
|
||||
export function ImageInputField({
|
||||
@@ -17,21 +18,24 @@ export function ImageInputField({
|
||||
disabled,
|
||||
invalid,
|
||||
accept = "image/*",
|
||||
initialPreviewUrl,
|
||||
}: ImageInputFieldProps) {
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
const [preview, setPreview] = useState<string | null>(null)
|
||||
const [filePreview, setFilePreview] = useState<string | null>(null)
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (!value) {
|
||||
setPreview(null)
|
||||
setFilePreview(null)
|
||||
return
|
||||
}
|
||||
const url = URL.createObjectURL(value)
|
||||
setPreview(url)
|
||||
setFilePreview(url)
|
||||
return () => URL.revokeObjectURL(url)
|
||||
}, [value])
|
||||
|
||||
const preview = filePreview ?? initialPreviewUrl ?? null
|
||||
|
||||
const handleFile = useCallback(
|
||||
(file: File | null) => {
|
||||
if (file && !file.type.startsWith("image/")) return
|
||||
@@ -110,7 +114,7 @@ export function ImageInputField({
|
||||
alt="Preview"
|
||||
className="max-h-30 max-w-full rounded-md object-contain"
|
||||
/>
|
||||
{!disabled && (
|
||||
{!disabled && filePreview && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleClear}
|
||||
|
||||
Reference in New Issue
Block a user