"use client" import type { ReactNode } from "react" import Link from "next/link" import { ArrowLeft, Globe, Lock, Users } from "lucide-react" import { EditorAccountButton } from "@/components/drive/editor-account-button" import { OfficeEditorInlineTitle } from "@/components/drive/office-editor-inline-title" import { ShareDialog } from "@/components/drive/share-dialog" import { CollabPresenceAvatars } from "@/components/drive/richtext/collab-presence-avatars" import { Button } from "@/components/ui/button" import type { DriveShare } from "@/lib/api/types" import type { CollabPresenceUser } from "@/lib/drive/use-collab-presence" import { resolveShareButtonIcon, type ShareButtonIcon, } from "@/lib/drive/drive-share-button-state" import type { UltidrawSaveStatus } from "@/lib/drive/ultidraw-types" import { cn } from "@/lib/utils" function ShareButtonIcon({ kind }: { kind: ShareButtonIcon }) { if (kind === "globe") return if (kind === "users") return return } function saveStatusLabel(status: UltidrawSaveStatus): string { switch (status) { case "saving": return "Enregistrement…" case "saved": return "Enregistré dans UltiDrive" case "error": return "Erreur d'enregistrement" default: return "" } } export function UltidrawChrome({ backHref, backLabel, title, showBack = true, onRename, renameDisabled = false, shares = [], onShareClick, showShare = false, showAccount = false, saveStatus = "idle", presenceUsers = [], trailing, }: { backHref?: string backLabel?: string title: string showBack?: boolean onRename?: (next: string) => Promise renameDisabled?: boolean shares?: DriveShare[] onShareClick?: () => void showShare?: boolean showAccount?: boolean saveStatus?: UltidrawSaveStatus presenceUsers?: CollabPresenceUser[] trailing?: ReactNode }) { const shareIcon = resolveShareButtonIcon(shares) const statusLabel = saveStatusLabel(saveStatus) return ( <>
{showBack && backHref ? ( ) : null}
{onRename ? ( ) : ( {title} )}
{presenceUsers.length > 0 ? : null} {statusLabel ? ( {statusLabel} ) : null} {trailing} {showShare ? ( ) : null} {showAccount ? : null}
{showShare ? : null} ) }