"use client" import { EditorContent } from "@tiptap/react" import { Maximize2, X } from "lucide-react" import { readCoarsePointerMatches } from "@/hooks/use-touch-nav" import type { ComposeState } from "@/lib/compose-context" import type { Email } from "@/lib/email-data" import { cn } from "@/lib/utils" import { MAIL_COMPOSE_TITLEBAR_CLASS, MAIL_ICON_BTN, } from "@/lib/mail-chrome-classes" import { ComposeRecipientFields } from "@/components/gmail/compose/compose-recipients" import { ComposeBottomToolbar, FormattingToolbar, } from "@/components/gmail/compose/compose-toolbar" import { ComposeAttachmentsList, ComposeDockTitleBar, ComposeDropOverlay, ComposeInlineRecipientHeader, ComposeXsSheetHeader, } from "@/components/gmail/compose/compose-editor-chrome" import { useComposeWindow } from "@/components/gmail/compose/use-compose-window" export function ComposeWindow({ compose, threadSourceEmail = null, isXsSheet = false, bindXsSheetClose, }: { compose: ComposeState /** Fil courant : nécessaire pour le menu Répondre / Transférer en inline */ threadSourceEmail?: Email | null /** Plein écran dans une bottom sheet (xs) — pas de file ni réduction */ isXsSheet?: boolean bindXsSheetClose?: (fn: (() => void) | null) => void }) { const { isInline, isEditingScheduled, editor, titleText, showFormatting, setShowFormatting, recipientsFocused, setRecipientsFocused, sendMenuOpen, setSendMenuOpen, isDragOver, fieldsRef, inlineRecipientShellRef, fileInputRef, imageInputRef, handleClose, handleSend, saveScheduledEdit, sendScheduledFromEditNow, applyScheduledPlanAt, submitScheduledSendAt, addFiles, removeAttachment, handleDrop, handleDragOver, handleDragLeave, recipientSummary, showReplyAllInMenu, ThreadKindIcon, openInlinePreset, openDockFromInline, recipientFieldsProps, toggleMinimize, toggleMaximize, updateCompose, } = useComposeWindow(compose, threadSourceEmail, isXsSheet, bindXsSheetClose) const modalContent = (
{/* Hidden file inputs */} { if (e.target.files && e.target.files.length > 0) { addFiles(e.target.files) e.target.value = "" } }} /> { if (e.target.files && e.target.files.length > 0) { addFiles(e.target.files) e.target.value = "" } }} /> {/* Drop overlay */} {isDragOver ? : null} {isInline ? ( setRecipientsFocused(true)} updateCompose={updateCompose} recipientFieldsProps={recipientFieldsProps} fieldsRef={fieldsRef} inlineRecipientShellRef={inlineRecipientShellRef} /> ) : isXsSheet ? ( ) : ( <> {/* Title bar */} toggleMinimize(compose.id)} onMaximize={() => toggleMaximize(compose.id)} onClose={handleClose} /> )} {!isInline && (
)} {/* Editor */}
{showFormatting ? : null}
) if (compose.minimized && !isInline && !isXsSheet) { return (
toggleMinimize(compose.id)} > {titleText}
) } if (compose.maximized && !isInline && !isXsSheet) { return ( <>
toggleMaximize(compose.id)} /> {modalContent} ) } return modalContent }