Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

refactor(web): Cleanup `Dropzone` component (#15498)

Ben Bachem092d13779c34
diff --git a/.agents/skills/react-component-cleaner/SKILL.md b/.agents/skills/react-component-cleaner/SKILL.md
index cec70f9b90..8d463a32bd 100644
--- a/.agents/skills/react-component-cleaner/SKILL.md
+++ b/.agents/skills/react-component-cleaner/SKILL.md
@@ -9,7 +9,7 @@ Avoid making any additional edits besides the ones instructed in this skill. If
Before starting to do any changes, audit the component you were instructed to fix by reading the [react-component-guidelines](../react-component-guidelines/SKILL.md) skill. Do not audit the callsites of the component, these will be looked at later in the skill.
-This skill references a `sweepy` cli tool. This can be found under https://github.com/bezbac/sweepy. Install version `v0.1.0`, pinned to commit `e58b55c0fb94364c12798ed16e632a5931b4eaa1`: https://github.com/bezbac/sweepy/tree/e58b55c0fb94364c12798ed16e632a5931b4eaa1. Follow only that pinned commit's instructions to install it. Do this in a safe manner and comply with other security guidelines of the repository. If you are unsure about any of the instructions, ask the user for confirmation.
+This skill references a `sweepy` cli tool. This can be found under https://github.com/bezbac/sweepy. Unless already available, install version `v0.1.0`, pinned to commit `e58b55c0fb94364c12798ed16e632a5931b4eaa1`: https://github.com/bezbac/sweepy/tree/e58b55c0fb94364c12798ed16e632a5931b4eaa1. Follow only that pinned commit's instructions to install it. Do this in a safe manner and comply with other security guidelines of the repository. If you are unsure about any of the instructions, ask the user for confirmation.
Now, you are ready to start cleaning up the component. Copy the contents of the [component cleanup todolist](./references/component-cleanup-todolist.md) verbatim into a TODO file (Use `cp` no manual edit) and follow the instructions in order, adding ✅ to the items you have completed. Do not commit the todo file, it is only for your reference.
diff --git a/web/.storybook/main.ts b/web/.storybook/main.ts
index 2ccb47d079..f12a2ada21 100644
--- a/web/.storybook/main.ts
+++ b/web/.storybook/main.ts
@@ -12,6 +12,7 @@ const STORY_EXTENSIONS = "@(js|jsx|mjs|ts|tsx)";
const DESIGN_COMPONENT_STORIES = [
"Checkbox/Checkbox",
"Codeblock/Codeblock",
+ "Dropzone/Dropzone",
"LangfuseIcon/LangfuseIcon",
"LangfuseLogo/LangfuseLogo",
"Progress/Progress",
diff --git a/web/src/components/design-system/Dropzone/Dropzone.stories.tsx b/web/src/components/design-system/Dropzone/Dropzone.stories.tsx
new file mode 100644
index 0000000000..16c0a86921
--- /dev/null
+++ b/web/src/components/design-system/Dropzone/Dropzone.stories.tsx
@@ -0,0 +1,168 @@
+import { expect, fn, userEvent } from "storybook/test";
+import preview from "../../../../.storybook/preview";
+import { Dropzone } from "./Dropzone";
+
+const meta = preview.meta({
+ component: Dropzone,
+});
+
+export const Empty = meta.story({
+ args: {
+ accept: { "text/csv": [".csv"] },
+ isDisabled: false,
+ maxFiles: 1,
+ maxSize: 10 * 1024 * 1024,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: undefined,
+ src: undefined,
+ variant: "panel",
+ },
+});
+
+export const WithFile = meta.story({
+ args: {
+ accept: undefined,
+ isDisabled: false,
+ maxFiles: 1,
+ maxSize: 10 * 1024 * 1024,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: undefined,
+ src: [new File(["name,value\nexample,1"], "example.csv")],
+ variant: "panel",
+ },
+});
+
+export const Compact = meta.story({
+ args: {
+ accept: undefined,
+ isDisabled: false,
+ maxFiles: 3,
+ maxSize: 5 * 1024 * 1024,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: undefined,
+ src: undefined,
+ variant: "compact",
+ },
+});
+
+export const CompactWithFiles = meta.story({
+ args: {
+ accept: undefined,
+ isDisabled: false,
+ maxFiles: 3,
+ maxSize: 5 * 1024 * 1024,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: undefined,
+ src: [
+ new File([new Uint8Array(1024 * 1024)], "first.txt"),
+ new File([new Uint8Array(512 * 1024)], "second.txt"),
+ ],
+ variant: "compact",
+ },
+});
+
+export const Disabled = meta.story({
+ args: {
+ accept: undefined,
+ isDisabled: true,
+ maxFiles: 1,
+ maxSize: 10 * 1024 * 1024,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: undefined,
+ src: undefined,
+ variant: "panel",
+ },
+});
+
+export const WithConstraints = meta.story({
+ args: {
+ accept: { "image/png": [".png"] },
+ isDisabled: false,
+ maxFiles: 1,
+ maxSize: 5 * 1024 * 1024,
+ minSize: 1024,
+ onDrop: fn(),
+ onError: undefined,
+ src: undefined,
+ variant: "panel",
+ },
+});
+
+export const WithManyFiles = meta.story({
+ args: {
+ accept: undefined,
+ isDisabled: false,
+ maxFiles: 5,
+ maxSize: 5 * 1024 * 1024,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: undefined,
+ src: [
+ new File([""], "first.txt"),
+ new File([""], "second.txt"),
+ new File([""], "third.txt"),
+ new File([""], "fourth.txt"),
+ ],
+ variant: "panel",
+ },
+});
+
+export const AcceptsFile = meta.story({
+ name: "(Test) Accepts File",
+ args: {
+ accept: { "text/plain": [".txt"] },
+ isDisabled: false,
+ maxFiles: 1,
+ maxSize: 1024,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: fn(),
+ src: undefined,
+ variant: "panel",
+ },
+ play: async ({ args, canvasElement }) => {
+ const input = canvasElement.querySelector('input[type="file"]');
+ if (!(input instanceof HTMLInputElement)) {
+ throw new Error("Dropzone file input not found");
+ }
+
+ const file = new File(["content"], "example.txt", {
+ type: "text/plain",
+ });
+ await userEvent.upload(input, file);
+
+ await expect(args.onDrop).toHaveBeenCalledWith([file]);
+ await expect(args.onError).not.toHaveBeenCalled();
+ },
+});
+
+export const RejectsOversizedFile = meta.story({
+ name: "(Test) Rejects Oversized File",
+ args: {
+ accept: undefined,
+ isDisabled: false,
+ maxFiles: 1,
+ maxSize: 1,
+ minSize: undefined,
+ onDrop: fn(),
+ onError: fn(),
+ src: undefined,
+ variant: "panel",
+ },
+ play: async ({ args, canvasElement }) => {
+ const input = canvasElement.querySelector('input[type="file"]');
+ if (!(input instanceof HTMLInputElement)) {
+ throw new Error("Dropzone file input not found");
+ }
+
+ await userEvent.upload(input, new File(["too large"], "example.txt"));
+
+ await expect(args.onError).toHaveBeenCalledOnce();
+ await expect(args.onDrop).not.toHaveBeenCalled();
+ },
+});
diff --git a/web/src/components/design-system/Dropzone/Dropzone.tsx b/web/src/components/design-system/Dropzone/Dropzone.tsx
new file mode 100644
index 0000000000..98bd17696f
--- /dev/null
+++ b/web/src/components/design-system/Dropzone/Dropzone.tsx
@@ -0,0 +1,184 @@
+"use client";
+
+import { cva } from "class-variance-authority";
+import { PaperclipIcon, UploadIcon } from "lucide-react";
+import { useMemo } from "react";
+import { useDropzone } from "react-dropzone";
+import { cn } from "@/src/utils/tailwind";
+
+const renderBytes = (bytes: number) => {
+ const units = ["B", "KB", "MB", "GB", "TB", "PB"];
+ let size = bytes;
+ let unitIndex = 0;
+
+ while (size >= 1024 && unitIndex < units.length - 1) {
+ size /= 1024;
+ unitIndex++;
+ }
+
+ return `${size.toFixed(2)}${units[unitIndex]}`;
+};
+
+export type DropzoneProps = {
+ accept: Record<string, string[]> | undefined;
+ isDisabled: boolean;
+ minSize: number | undefined;
+ onError: ((error: Error) => void) | undefined;
+ src: File[] | undefined;
+ maxFiles: number;
+ maxSize: number;
+ onDrop: (acceptedFiles: File[]) => void;
+ variant: "compact" | "panel";
+};
+
+const dropzoneVariants = cva(
+ "ring-offset-background focus-visible:ring-ring relative inline-flex h-auto w-full flex-col items-center justify-center overflow-hidden rounded-md text-sm whitespace-nowrap transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
+ {
+ variants: {
+ variant: {
+ compact:
+ "border-none bg-background p-0 text-left hover:bg-accent hover:text-accent-foreground",
+ panel:
+ "border-border-contrast bg-secondary/50 border border-dashed p-8 hover:bg-accent hover:text-accent-foreground",
+ },
+ isDragActive: {
+ true: "ring-ring ring-1 outline-hidden",
+ false: null,
+ },
+ },
+ },
+);
+
+const MAX_LABEL_ITEMS = 3;
+
+export const Dropzone = ({
+ accept,
+ maxFiles,
+ maxSize,
+ minSize,
+ onDrop,
+ onError,
+ isDisabled,
+ src,
+ variant,
+}: DropzoneProps) => {
+ const { getRootProps, getInputProps, isDragActive } = useDropzone({
+ accept,
+ maxFiles,
+ maxSize,
+ minSize,
+ onError,
+ disabled: isDisabled,
+ onDrop: (acceptedFiles, fileRejections) => {
+ if (fileRejections.length > 0) {
+ const message = fileRejections.at(0)?.errors.at(0)?.message;
+ onError?.(new Error(message));
+ return;
+ }
+
+ onDrop(acceptedFiles);
+ },
+ });
+
+ const contentText = useMemo(() => {
+ if (variant === "compact") {
+ if (!src?.length) {
+ return "Attach files";
+ }
+
+ return `${src.length} file${src.length > 1 ? "s" : ""} • ${(
+ src.reduce((total, file) => total + file.size, 0) /
+ (1024 * 1024)
+ ).toFixed(2)} MB`;
+ }
+
+ if (!src) {
+ return "";
+ }
+
+ if (src.length > MAX_LABEL_ITEMS) {
+ return `${new Intl.ListFormat("en").format(
+ src.slice(0, MAX_LABEL_ITEMS).map((file) => file.name),
+ )} and ${src.length - MAX_LABEL_ITEMS} more`;
+ }
+
+ return new Intl.ListFormat("en").format(src.map((file) => file.name));
+ }, [src, variant]);
+
+ const caption = useMemo(() => {
+ const acceptedTypes = accept
+ ? `Accepts ${new Intl.ListFormat("en").format(Object.keys(accept))}`
+ : "";
+
+ if (minSize && maxSize) {
+ return `${acceptedTypes} between ${renderBytes(minSize)} and ${renderBytes(maxSize)}`;
+ }
+
+ if (minSize) {
+ return `${acceptedTypes} at least ${renderBytes(minSize)}`;
+ }
+
+ if (maxSize) {
+ return `${acceptedTypes} less than ${renderBytes(maxSize)}`;
+ }
+
+ return acceptedTypes;
+ }, [accept, maxSize, minSize]);
+
+ const emptyStateTitle = `Upload ${maxFiles === 1 ? "a file" : "files"}`;
+ const emptyStateDescription = "Drag and drop or click to upload";
+ const panelTitle = src?.length ? contentText : emptyStateTitle;
+ const panelDescription = src?.length
+ ? "Drag and drop or click to replace"
+ : emptyStateDescription;
+
+ return (
+ <button
+ key={JSON.stringify(src)}
+ className={dropzoneVariants({ isDragActive, variant })}
+ disabled={isDisabled}
+ type="button"
+ {...getRootProps()}
+ >
+ <input {...getInputProps()} disabled={isDisabled} />
+ {variant === "compact" && (
+ <div className="flex w-full cursor-pointer items-center justify-start gap-2 p-2 text-xs">
+ <PaperclipIcon className="h-4 w-4" />
+ <span className="truncate" title={contentText}>
+ {contentText}
+ </span>
+ </div>
+ )}
+ {variant === "panel" && (
+ <div className="flex flex-col items-center justify-center">
+ <div className="bg-muted text-muted-foreground flex size-8 items-center justify-center rounded-md">
+ <UploadIcon size={16} />
+ </div>
+ <p
+ className={cn(
+ "my-2 w-full truncate text-sm font-bold",
+ !src?.length && "text-wrap",
+ )}
+ title={panelTitle}
+ >
+ {panelTitle}
+ </p>
+ <p
+ className={cn(
+ "text-muted-foreground w-full text-xs text-wrap",
+ !src?.length && "truncate",
+ )}
+ title={src?.length ? undefined : panelDescription}
+ >
+ {panelDescription}
+ </p>
+ {!src?.length && caption && (
+ <p className="text-muted-foreground text-xs text-wrap">
+ {caption}.
+ </p>
+ )}
+ </div>
+ )}
+ </button>
+ );
+};
diff --git a/web/src/components/ui/shadcn-io/dropzone/index.tsx b/web/src/components/ui/shadcn-io/dropzone/index.tsx
deleted file mode 100644
index fa6cba7d6b..0000000000
--- a/web/src/components/ui/shadcn-io/dropzone/index.tsx
+++ /dev/null
@@ -1,214 +0,0 @@
-"use client";
-
-import { UploadIcon } from "lucide-react";
-import type { ReactNode } from "react";
-import { createContext, useContext } from "react";
-import type { DropEvent, DropzoneOptions, FileRejection } from "react-dropzone";
-import { useDropzone } from "react-dropzone";
-import { Button } from "@/src/components/ui/button";
-import { cn } from "@/src/utils/tailwind";
-
-type DropzoneContextType = {
- src?: File[];
- accept?: DropzoneOptions["accept"];
- maxSize?: DropzoneOptions["maxSize"];
- minSize?: DropzoneOptions["minSize"];
- maxFiles?: DropzoneOptions["maxFiles"];
-};
-
-const renderBytes = (bytes: number) => {
- const units = ["B", "KB", "MB", "GB", "TB", "PB"];
- let size = bytes;
- let unitIndex = 0;
-
- while (size >= 1024 && unitIndex < units.length - 1) {
- size /= 1024;
- unitIndex++;
- }
-
- return `${size.toFixed(2)}${units[unitIndex]}`;
-};
-
-const DropzoneContext = createContext<DropzoneContextType | undefined>(
- undefined,
-);
-
-export type DropzoneProps = Omit<DropzoneOptions, "onDrop"> & {
- src?: File[];
- className?: string;
- onDrop?: (
- acceptedFiles: File[],
- fileRejections: FileRejection[],
- event: DropEvent,
- ) => void;
- children?: ReactNode;
-};
-
-export const Dropzone = ({
- accept,
- maxFiles = 1,
- maxSize,
- minSize,
- onDrop,
- onError,
- disabled,
- src,
- className,
- children,
- ...props
-}: DropzoneProps) => {
- const { getRootProps, getInputProps, isDragActive } = useDropzone({
- accept,
- maxFiles,
- maxSize,
- minSize,
- onError,
- disabled,
- onDrop: (acceptedFiles, fileRejections, event) => {
- if (fileRejections.length > 0) {
- const message = fileRejections.at(0)?.errors.at(0)?.message;
- onError?.(new Error(message));
- return;
- }
-
- onDrop?.(acceptedFiles, fileRejections, event);
- },
- ...props,
- });
-
- return (
- <DropzoneContext.Provider
- key={JSON.stringify(src)}
- value={{ src, accept, maxSize, minSize, maxFiles }}
- >
- <Button
- className={cn(
- "relative h-auto w-full flex-col overflow-hidden p-8",
- isDragActive && "ring-ring ring-1 outline-hidden",
- className,
- )}
- disabled={disabled}
- type="button"
- variant="outline"
- {...getRootProps()}
- >
- <input {...getInputProps()} disabled={disabled} />
- {children}
- </Button>
- </DropzoneContext.Provider>
- );
-};
-
-const useDropzoneContext = () => {
- const context = useContext(DropzoneContext);
-
- if (!context) {
- throw new Error("useDropzoneContext must be used within a Dropzone");
- }
-
- return context;
-};
-
-export type DropzoneContentProps = {
- children?: ReactNode;
- className?: string;
-};
-
-const maxLabelItems = 3;
-
-export const DropzoneContent = ({
- children,
- className,
-}: DropzoneContentProps) => {
- const { src } = useDropzoneContext();
-
- if (!src) {
- return null;
- }
-
- if (children) {
- return children;
- }
-
- const text =
- src.length > maxLabelItems
- ? `${new Intl.ListFormat("en").format(
- src.slice(0, maxLabelItems).map((file) => file.name),
- )} and ${src.length - maxLabelItems} more`
- : new Intl.ListFormat("en").format(src.map((file) => file.name));
-
- return (
- <div className={cn("flex flex-col items-center justify-center", className)}>
- <div className="bg-muted text-muted-foreground flex size-8 items-center justify-center rounded-md">
- <UploadIcon size={16} />
- </div>
- <p className="my-2 w-full truncate text-sm font-bold" title={text}>
- {text}
- </p>
- <p className="text-muted-foreground w-full text-xs text-wrap">
- Drag and drop or click to replace
- </p>
- </div>
- );
-};
-
-export type DropzoneEmptyStateProps = {
- children?: ReactNode;
- className?: string;
-};
-
-export const DropzoneEmptyState = ({
- children,
- className,
-}: DropzoneEmptyStateProps) => {
- const { src, accept, maxSize, minSize, maxFiles } = useDropzoneContext();
-
- if (src) {
- return null;
- }
-
- if (children) {
- return children;
- }
-
- let caption = "";
-
- if (accept) {
- caption += "Accepts ";
- caption += new Intl.ListFormat("en").format(Object.keys(accept));
- }
-
- if (minSize && maxSize) {
- caption += ` between ${renderBytes(minSize)} and ${renderBytes(maxSize)}`;
- } else if (minSize) {
- caption += ` at least ${renderBytes(minSize)}`;
- } else if (maxSize) {
- caption += ` less than ${renderBytes(maxSize)}`;
- }
-
- const text1 = `Upload ${maxFiles === 1 ? "a file" : "files"}`;
- const text2 = "Drag and drop or click to upload";
-
- return (
- <div className={cn("flex flex-col items-center justify-center", className)}>
- <div className="bg-muted text-muted-foreground flex size-8 items-center justify-center rounded-md">
- <UploadIcon size={16} />
- </div>
- <p
- className="my-2 w-full truncate text-sm font-bold text-wrap"
- title={text1}
- >
- {text1}
- </p>
- <p
- className="text-muted-foreground w-full truncate text-xs text-wrap"
- title={text2}
- >
- {text2}
- </p>
- {caption && (
- <p className="text-muted-foreground text-xs text-wrap">{caption}.</p>
- )}
- </div>
- );
-};
diff --git a/web/src/features/datasets/components/UploadDatasetCsv.tsx b/web/src/features/datasets/components/UploadDatasetCsv.tsx
index 9ce7a2fcac..e9fda7f26d 100644
--- a/web/src/features/datasets/components/UploadDatasetCsv.tsx
+++ b/web/src/features/datasets/components/UploadDatasetCsv.tsx
@@ -9,10 +9,7 @@ import { showErrorToast } from "@/src/features/notifications/showErrorToast";
import { z } from "zod";
import { parseCsvClient } from "@/src/features/datasets/lib/csv/helpers";
import { DialogBody } from "@/src/components/ui/dialog";
-import {
- Dropzone,
- DropzoneEmptyState,
-} from "@/src/components/ui/shadcn-io/dropzone";
+import { Dropzone } from "@/src/components/design-system/Dropzone/Dropzone";
import type { CsvPreviewResult } from "@/src/features/datasets/lib/csv/types";
export const MAX_FILE_SIZE_BYTES = 1024 * 1024 * 1 * 10; // 10MB
@@ -80,12 +77,14 @@ export const UploadDatasetCsv = ({
<Dropzone
onDrop={handleFiles}
accept={{ "text/csv": [".csv"] }}
+ isDisabled={false}
maxFiles={1}
maxSize={MAX_FILE_SIZE_BYTES}
- className="bg-secondary/50 border-dashed"
- >
- <DropzoneEmptyState />
- </Dropzone>
+ minSize={undefined}
+ onError={undefined}
+ src={undefined}
+ variant="panel"
+ />
</CardContent>
</Card>
</DialogBody>
diff --git a/web/src/features/support-chat/SupportFormSection.tsx b/web/src/features/support-chat/SupportFormSection.tsx
index 76624922ae..b7ce5334b3 100644
--- a/web/src/features/support-chat/SupportFormSection.tsx
+++ b/web/src/features/support-chat/SupportFormSection.tsx
@@ -52,14 +52,10 @@ import {
} from "@/src/components/ui/select";
import { Textarea } from "@/src/components/ui/textarea";
import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useState } from "react";
-import {
- Dropzone,
- DropzoneContent,
- DropzoneEmptyState,
-} from "@/src/components/ui/shadcn-io/dropzone";
-import { Paperclip, Trash2 } from "lucide-react";
+import { Dropzone } from "@/src/components/design-system/Dropzone/Dropzone";
+import { Trash2 } from "lucide-react";
import { showErrorToast } from "@/src/features/notifications/showErrorToast";
import { PYLON_MAX_FILE_SIZE_BYTES } from "./pylon/pylonConstants";
import Spinner from "@/src/components/design-system/Spinner/Spinner";
@@ -193,10 +189,6 @@ export function SupportFormSection({
// Local file state from Dropzone
const [files, setFiles] = useState<File[] | undefined>(undefined);
- const totalUploadBytes = useMemo(
- () => (files ?? []).reduce((sum, f) => sum + f.size, 0),
- [files],
- );
// Local submit guard to avoid flicker across multiple mutations
const [isSubmittingLocal, setIsSubmittingLocal] = useState(false);
@@ -380,10 +372,6 @@ export function SupportFormSection({
const messageIsShortAfterWarning =
warnedShortOnce && (form.getValues("message") ?? "").trim().length < 50;
- // --- Compact attachment row helpers
- const totalMB = (totalUploadBytes / (1024 * 1024)).toFixed(2);
- const hasFiles = (files?.length ?? 0) > 0;
-
return (
<div className="mt-1 flex flex-col gap-3">
<div className="flex items-center gap-2 text-base font-bold">
@@ -595,52 +583,33 @@ export function SupportFormSection({
<FormMessage />
- <Dropzone
- className="mt-1 border-none p-0 text-left"
- maxFiles={FILE_UPLOAD_CONSTRAINTS.maxFiles}
- maxSize={FILE_UPLOAD_CONSTRAINTS.maxFileSizeBytes}
- onDrop={(accepted) =>
- setFiles((prev) => {
- const existing = prev ?? [];
- const merged = [...existing, ...accepted];
- const maxFiles = FILE_UPLOAD_CONSTRAINTS.maxFiles;
- return merged.slice(0, maxFiles);
- })
- }
- onError={(error) => {
- const userMessage = formatFileError(error);
- showErrorToast("File Upload Error", userMessage, "WARNING");
- }}
- src={files}
- >
- {/* Small, single-line trigger */}
- <DropzoneEmptyState>
- <div className="flex w-full cursor-pointer items-center justify-start gap-2 p-2 text-xs">
- <Paperclip className="h-4 w-4" />
- <span
- className="truncate"
- title={
- hasFiles
- ? `${files!.length} file${files!.length > 1 ? "s" : ""} • ${totalMB} MB`
- : "Attach files"
- }
- >
- {hasFiles
- ? `${files!.length} file${files!.length > 1 ? "s" : ""} • ${totalMB} MB`
- : "Attach files"}
- </span>
- </div>
- </DropzoneEmptyState>
- {/* Keep content area minimal; we still allow preview slot if needed */}
- <DropzoneContent>
- <div className="flex w-full cursor-pointer items-center justify-start gap-2 p-2 text-xs">
- <Paperclip className="h-4 w-4" />
- <span className="truncate" title="Attach files">
- Attach files
- </span>
- </div>
- </DropzoneContent>
- </Dropzone>
+ <div className="mt-1">
+ <Dropzone
+ accept={undefined}
+ isDisabled={false}
+ maxFiles={FILE_UPLOAD_CONSTRAINTS.maxFiles}
+ maxSize={FILE_UPLOAD_CONSTRAINTS.maxFileSizeBytes}
+ minSize={undefined}
+ onDrop={(accepted) =>
+ setFiles((prev) => {
+ const existing = prev ?? [];
+ const merged = [...existing, ...accepted];
+ const maxFiles = FILE_UPLOAD_CONSTRAINTS.maxFiles;
+ return merged.slice(0, maxFiles);
+ })
+ }
+ onError={(error) => {
+ const userMessage = formatFileError(error);
+ showErrorToast(
+ "File Upload Error",
+ userMessage,
+ "WARNING",
+ );
+ }}
+ src={files}
+ variant="compact"
+ />
+ </div>
{files && files.length > 0 && (
<div className="p-0 text-left text-sm font-bold">