'use client'; import * as React from 'react'; import { createPortal } from 'react-dom'; import { ChevronLeft, ChevronRight, X, ZoomIn } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { MediaImageSkeleton } from '@/components/ui/media-image-skeleton'; import { cn } from '@/lib/utils'; interface DocumentFullscreenViewerProps { images: { storageKey: string; url: string }[]; initialIndex?: number; open: boolean; onOpenChange: (open: boolean) => void; } export function DocumentFullscreenViewer({ images, initialIndex = 0, open, onOpenChange }: DocumentFullscreenViewerProps) { const [index, setIndex] = React.useState(initialIndex); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); React.useEffect(() => { if (open) setIndex(initialIndex); }, [initialIndex, open]); React.useEffect(() => { if (!open) return; function onKeyDown(event: KeyboardEvent) { if (event.key === 'Escape') onOpenChange(false); if (event.key === 'ArrowLeft') setIndex((current) => Math.max(0, current - 1)); if (event.key === 'ArrowRight') setIndex((current) => Math.min(images.length - 1, current + 1)); } window.addEventListener('keydown', onKeyDown); return () => window.removeEventListener('keydown', onKeyDown); }, [images.length, onOpenChange, open]); React.useEffect(() => { if (!open) return; const previous = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = previous; }; }, [open]); if (!open || images.length === 0 || !mounted) return null; const current = images[index]; return createPortal(

Фото документа

{index + 1} из {images.length}

{images.length > 1 ? ( ) : null} {/* eslint-disable-next-line @next/next/no-img-element */} Фото документа {images.length > 1 ? ( ) : null}
{images.length > 1 ? (
{images.map((image, imageIndex) => ( ))}
) : null}
, document.body ); } interface DocumentPhotoThumbnailProps { url?: string; loading?: boolean; className?: string; onClick?: () => void; } export function DocumentPhotoThumbnail({ url, loading, className, onClick }: DocumentPhotoThumbnailProps) { return ( ); }