"use client" import { useRouter } from "next/navigation" import { FolderOpen, Loader2 } from "lucide-react" import type { DriveFileInfo } from "@/lib/api/types" import { DriveFileTypeIcon } from "@/lib/drive/drive-file-icon" import { Button } from "@/components/ui/button" import { type DriveSearchScope, DRIVE_SEARCH_SCOPES, driveSearchScopeShortLabel, itemLocationLabel, itemParentFolderPath, } from "@/lib/drive/drive-search" import { driveFolderHref } from "@/lib/drive/drive-sidebar-tree" import { displayFileName } from "@/lib/drive/display-file-name" import { MAIL_SEARCH_SUGGESTIONS_DROPDOWN_CLASS } from "@/lib/mail-chrome-classes" import { cn } from "@/lib/utils" function ScopePicker({ scope, onScopeChange, showFolderScope, }: { scope: DriveSearchScope onScopeChange: (scope: DriveSearchScope) => void showFolderScope: boolean }) { const options = DRIVE_SEARCH_SCOPES.filter((s) => s !== "folder" || showFolderScope) return (
{options.map((option) => ( ))}
) } function SuggestionRow({ item, scope, onPick, }: { item: DriveFileInfo scope: DriveSearchScope onPick: (item: DriveFileInfo) => void }) { const router = useRouter() const view = scope === "shared" ? "shared" : "files" const parentPath = itemParentFolderPath(item.path, item.type) const parentHref = driveFolderHref(view, parentPath) const location = itemLocationLabel(item.path, item.type) return (
) } export function DriveSearchSuggestionsPanel({ query, scope, onScopeChange, showFolderScope, suggestions, loading, onPickItem, onSubmitSearch, className, }: { query: string scope: DriveSearchScope onScopeChange: (scope: DriveSearchScope) => void showFolderScope: boolean suggestions: DriveFileInfo[] loading: boolean onPickItem: (item: DriveFileInfo) => void onSubmitSearch: () => void className?: string }) { const trimmed = query.trim() if (trimmed.length < 2) return null return (
{loading ? (
Recherche…
) : suggestions.length === 0 ? (

Aucune suggestion pour « {trimmed} »

) : ( <> {suggestions.map((item) => ( ))} )}
) }