@better-s3/ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hamidreza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @better-s3/ui
2
+
3
+ Pre-built React UI components for S3 file upload, download, and delete — built with [shadcn/ui](https://ui.shadcn.com) patterns and Tailwind CSS.
4
+
5
+ > **Don't need pre-built UI?** Use [`@better-s3/react`](../better-s3-react) for headless hooks and bring your own components.
6
+
7
+ > **shadcn CLI**: You can also install individual components via `npx shadcn add` (coming soon).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @better-s3/ui @better-s3/core
13
+ ```
14
+
15
+ **Peer dependencies:** `react`, `@base-ui/react`, `sonner`, `lucide-react`, `class-variance-authority`, `clsx`, `tailwind-merge`
16
+
17
+ ## Setup
18
+
19
+ Import the stylesheet in your app:
20
+
21
+ ```tsx
22
+ import "@better-s3/ui/styles.css";
23
+ ```
24
+
25
+ ## Components
26
+
27
+ ### `<Upload />` — Single file upload
28
+
29
+ ```tsx
30
+ import { Upload } from "@better-s3/ui";
31
+ import { createPresignApi } from "@better-s3/core";
32
+
33
+ const presignApi = createPresignApi({ basePath: "/api/s3" });
34
+
35
+ <Upload
36
+ presignApi={presignApi}
37
+ objectKey={(file) => `uploads/${file.name}`}
38
+ variant="dropzone" // "button" | "dropzone"
39
+ accept={["image/*"]}
40
+ maxFileSize={10 * 1024 * 1024}
41
+ toast={true} // sonner toast notifications
42
+ showStatus={true} // inline progress display
43
+ />;
44
+ ```
45
+
46
+ ### `<MultiUpload />` — Batch file upload
47
+
48
+ ```tsx
49
+ import { MultiUpload } from "@better-s3/ui";
50
+
51
+ <MultiUpload
52
+ presignApi={presignApi}
53
+ objectKey={(file) => `uploads/${file.name}`}
54
+ maxFiles={10}
55
+ variant="dropzone"
56
+ />;
57
+ ```
58
+
59
+ ### `<DownloadButton />` — File download
60
+
61
+ ```tsx
62
+ import { DownloadButton } from "@better-s3/ui";
63
+
64
+ <DownloadButton
65
+ presignApi={presignApi}
66
+ objectKey="uploads/report.pdf"
67
+ fileName="report.pdf"
68
+ mode="native" // "native" | "fetch"
69
+ />;
70
+ ```
71
+
72
+ ### `<DeleteButton />` — File delete with confirmation
73
+
74
+ ```tsx
75
+ import { DeleteButton } from "@better-s3/ui";
76
+
77
+ <DeleteButton
78
+ presignApi={presignApi}
79
+ objectKey="uploads/report.pdf"
80
+ fileName="report.pdf"
81
+ confirmTitle="Delete file?"
82
+ confirmDescription="This action cannot be undone."
83
+ />;
84
+ ```
85
+
86
+ ## Features
87
+
88
+ - **Two upload variants** — compact button or drag-and-drop dropzone
89
+ - **Toast notifications** — loading, success, and error toasts via Sonner
90
+ - **Inline progress** — progress bar with file name and phase icons
91
+ - **Delete confirmation** — AlertDialog before destructive actions
92
+ - **Download modes** — native browser download or streaming with progress
93
+ - **Tailwind CSS** — fully styled, customizable via className props
94
+ - **Accessible** — built on Base UI primitives
95
+
96
+ ## License
97
+
98
+ MIT
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
3
+ import { Button } from "../../components/ui/button";
4
+ declare function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props): import("react/jsx-runtime").JSX.Element;
5
+ declare function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props): import("react/jsx-runtime").JSX.Element;
6
+ declare function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props): import("react/jsx-runtime").JSX.Element;
7
+ declare function AlertDialogOverlay({ className, ...props }: AlertDialogPrimitive.Backdrop.Props): import("react/jsx-runtime").JSX.Element;
8
+ declare function AlertDialogContent({ className, size, ...props }: AlertDialogPrimitive.Popup.Props & {
9
+ size?: "default" | "sm";
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
12
+ declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
13
+ declare function AlertDialogMedia({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
14
+ declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
15
+ declare function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
16
+ declare function AlertDialogAction({ className, ...props }: React.ComponentProps<typeof Button>): import("react/jsx-runtime").JSX.Element;
17
+ declare function AlertDialogCancel({ className, variant, size, ...props }: AlertDialogPrimitive.Close.Props & Pick<React.ComponentProps<typeof Button>, "variant" | "size">): import("react/jsx-runtime").JSX.Element;
18
+ export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, };
@@ -0,0 +1,8 @@
1
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare const buttonVariants: (props?: ({
4
+ variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link" | null | undefined;
5
+ size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ declare function Button({ className, variant, size, ...props }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>): import("react/jsx-runtime").JSX.Element;
8
+ export { Button, buttonVariants };
@@ -0,0 +1,5 @@
1
+ export declare function CircleProgress({ percent, size, strokeWidth, }: {
2
+ percent: number;
3
+ size?: number;
4
+ strokeWidth?: number;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { Progress as ProgressPrimitive } from "@base-ui/react/progress";
2
+ declare function Progress({ className, children, value, ...props }: ProgressPrimitive.Root.Props): import("react/jsx-runtime").JSX.Element;
3
+ declare function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props): import("react/jsx-runtime").JSX.Element;
4
+ declare function ProgressIndicator({ className, ...props }: ProgressPrimitive.Indicator.Props): import("react/jsx-runtime").JSX.Element;
5
+ declare function ProgressLabel({ className, ...props }: ProgressPrimitive.Label.Props): import("react/jsx-runtime").JSX.Element;
6
+ declare function ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props): import("react/jsx-runtime").JSX.Element;
7
+ export { Progress, ProgressTrack, ProgressIndicator, ProgressLabel, ProgressValue, };
@@ -0,0 +1,6 @@
1
+ import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
2
+ declare function TooltipProvider({ delay, ...props }: TooltipPrimitive.Provider.Props): import("react/jsx-runtime").JSX.Element;
3
+ declare function Tooltip({ ...props }: TooltipPrimitive.Root.Props): import("react/jsx-runtime").JSX.Element;
4
+ declare function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props): import("react/jsx-runtime").JSX.Element;
5
+ declare function TooltipContent({ className, side, sideOffset, align, alignOffset, children, ...props }: TooltipPrimitive.Popup.Props & Pick<TooltipPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">): import("react/jsx-runtime").JSX.Element;
6
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,19 @@
1
+ import type { PresignApi, DeleteHooks } from "@better-s3/core";
2
+ type DeleteButtonProps = DeleteHooks & {
3
+ presignApi: PresignApi;
4
+ objectKey: string;
5
+ fileName?: string;
6
+ fileSize?: number;
7
+ label?: string;
8
+ className?: string;
9
+ disabled?: boolean;
10
+ tooltipText?: string;
11
+ /** Enable sonner toasts (default: `true`) */
12
+ toast?: boolean;
13
+ /** Show inline error status below the button (default: `true`) */
14
+ showStatus?: boolean;
15
+ confirmTitle?: string;
16
+ confirmDescription?: string;
17
+ };
18
+ export declare function DeleteButton({ presignApi, objectKey, fileName, fileSize, label, className, disabled, tooltipText, toast: enableToast, showStatus, confirmTitle, confirmDescription, beforeDelete, onDeleteStart, onSuccess, onError, }: DeleteButtonProps): import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { PresignApi, DownloadHooks } from "@better-s3/core";
2
+ type DownloadButtonProps = DownloadHooks & {
3
+ presignApi: PresignApi;
4
+ objectKey: string;
5
+ fileName?: string;
6
+ fileSize?: number;
7
+ label?: string;
8
+ className?: string;
9
+ fillClassName?: string;
10
+ disabled?: boolean;
11
+ tooltipText?: string;
12
+ /** Enable sonner toasts (default: `true`) */
13
+ toast?: boolean;
14
+ /** Show inline error status below the button (default: `true`) */
15
+ showStatus?: boolean;
16
+ /**
17
+ * `"native"` — browser handles download natively via presigned URL (default)
18
+ * `"fetch"` — streams via fetch, shows in-button progress
19
+ */
20
+ mode?: "native" | "fetch";
21
+ };
22
+ export declare function DownloadButton({ presignApi, objectKey, fileName, fileSize, label, className, fillClassName, disabled, tooltipText, toast: enableToast, showStatus, mode, beforeDownload, onDownloadStart, onProgress, onSuccess, onError, onCancel, }: DownloadButtonProps): import("react/jsx-runtime").JSX.Element;
23
+ export {};
@@ -0,0 +1,6 @@
1
+ export { Upload, type UploadProps } from "./upload/upload";
2
+ export { MultiUpload, type MultiUploadProps } from "./upload/multi-upload";
3
+ export { UploadStatus } from "./upload/upload-status";
4
+ export { MultiUploadStatus } from "./upload/multi-upload-status";
5
+ export { DownloadButton } from "./download/download-button";
6
+ export { DeleteButton } from "./delete/delete-button";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import {useRef,useEffect}from'react';import {toast}from'sonner';import {XIcon,CheckCircleIcon,AlertCircleIcon,UploadIcon,DownloadIcon,LoaderIcon,Trash2Icon}from'lucide-react';import {formatFileSize}from'@better-s3/core';import {useUploadControls,useMultiUploadControls,useDownload,useDelete}from'@better-s3/react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {Button}from'@base-ui/react/button';import {cva}from'class-variance-authority';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {Tooltip}from'@base-ui/react/tooltip';import {Progress}from'@base-ui/react/progress';import {AlertDialog}from'@base-ui/react/alert-dialog';function r(...o){return twMerge(clsx(o))}var Se=cva("group/button cursor-pointer inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs/relaxed font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",xs:"h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-2.5",sm:"h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",lg:"h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2 [&_svg:not([class*='size-'])]:size-4",icon:"size-7 [&_svg:not([class*='size-'])]:size-3.5","icon-xs":"size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5","icon-sm":"size-6 [&_svg:not([class*='size-'])]:size-3","icon-lg":"size-8 [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default",size:"default"}});function c({className:o,variant:e="default",size:a="default",...i}){return jsx(Button,{"data-slot":"button",className:r(Se({variant:e,size:a,className:o})),...i})}function C({delay:o=0,...e}){return jsx(Tooltip.Provider,{"data-slot":"tooltip-provider",delay:o,...e})}function y({...o}){return jsx(Tooltip.Root,{"data-slot":"tooltip",...o})}function A({...o}){return jsx(Tooltip.Trigger,{"data-slot":"tooltip-trigger",...o})}function U({className:o,side:e="top",sideOffset:a=4,align:i="center",alignOffset:l=0,children:d,...g}){return jsx(Tooltip.Portal,{children:jsx(Tooltip.Positioner,{align:i,alignOffset:l,side:e,sideOffset:a,className:"isolate z-50",children:jsxs(Tooltip.Popup,{"data-slot":"tooltip-content",className:r("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",o),...g,children:[d,jsx(Tooltip.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-start-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-end-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}function Z({percent:o,size:e=20,strokeWidth:a=2.5}){let i=(e-a)/2,l=2*Math.PI*i,d=l-o/100*l;return jsxs("svg",{width:e,height:e,className:"shrink-0 -rotate-90",children:[jsx("circle",{cx:e/2,cy:e/2,r:i,fill:"none",stroke:"currentColor",strokeWidth:a,className:"text-muted-foreground/20"}),jsx("circle",{cx:e/2,cy:e/2,r:i,fill:"none",stroke:"currentColor",strokeWidth:a,strokeDasharray:l,strokeDashoffset:d,strokeLinecap:"round",className:"text-primary transition-[stroke-dashoffset] duration-200"})]})}function ee({phase:o,progress:e,error:a,fileInfo:i,onCancel:l}){return o==="idle"?null:o==="uploading"&&i?jsxs("div",{className:"flex w-full items-center gap-1.5 text-xs",children:[jsx(Z,{percent:e.percent,size:14,strokeWidth:2}),jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:i.name}),jsxs("span",{className:"shrink-0 text-muted-foreground",children:[formatFileSize(e.loaded)," / ",formatFileSize(i.size)," (",e.percent,"%)"]}),jsx(c,{variant:"ghost",size:"icon",className:"ml-auto size-6 shrink-0",onClick:d=>{d.stopPropagation(),l?.();},children:jsx(XIcon,{className:"size-3.5"})})]}):o==="success"&&i?jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[jsx(CheckCircleIcon,{className:"size-3.5 shrink-0 text-green-600"}),jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:i.name}),jsx("span",{className:"shrink-0 text-muted-foreground",children:formatFileSize(i.size)})]}):o==="error"?jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(AlertCircleIcon,{className:"size-3.5 shrink-0 text-destructive"}),i&&jsxs(Fragment,{children:[jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:i.name}),jsx("span",{className:"shrink-0 text-muted-foreground",children:formatFileSize(i.size)})]})]}),jsx("span",{className:"text-destructive",children:a??"Upload failed"})]}):o==="validating"||o==="presigning"?jsx("span",{className:"text-xs text-muted-foreground",children:"Preparing\u2026"}):null}function Le({variant:o="button",objectKey:e,className:a,label:i,disabled:l,tooltipText:d="Upload file",toast:g=true,showStatus:$=true,...T}){let t=useUploadControls({...T,objectKey:e}),s=useRef(null),n=l||t.isUploading,D=useRef(t.phase);D.current!==t.phase&&(D.current=t.phase,g&&(t.phase==="idle"&&s.current&&(toast.dismiss(s.current),s.current=null),t.phase==="success"&&t.fileInfo&&(s.current&&toast.dismiss(s.current),toast.success("Upload complete",{description:formatFileSize(t.fileInfo.size)}),s.current=null),t.phase==="error"&&(s.current&&toast.dismiss(s.current),toast.error("Upload failed",{description:t.error??"Unknown error"}),s.current=null))),useEffect(()=>{if(g&&t.phase==="uploading"&&t.fileInfo){let P=s.current??`upload-${Date.now()}`;s.current=P,toast.loading("Uploading\u2026",{id:P,description:`${formatFileSize(t.progress.loaded)} / ${formatFileSize(t.fileInfo.size)} (${t.progress.percent}%)`,cancel:{label:"Cancel",onClick:()=>t.cancel()}});}},[g,t.phase,t.progress.percent,t.progress.loaded,t.fileInfo,t.cancel]);let v=$?jsx(ee,{phase:t.phase,progress:t.progress,error:t.error,fileInfo:t.fileInfo,onCancel:t.cancel}):null;return o==="dropzone"?jsxs("div",{className:r("flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-6 text-center transition-colors",n?"cursor-not-allowed border-muted-foreground/25":"cursor-pointer border-muted-foreground/25 hover:border-primary/50",a),onClick:n?void 0:t.openFilePicker,...n?{}:t.dropHandlers,children:[jsx("input",{...t.inputProps}),jsx(UploadIcon,{className:r("size-6 text-muted-foreground",n&&"opacity-50")}),jsx("p",{className:r("text-sm text-muted-foreground",n&&"opacity-50"),children:i??"Click or drag & drop to upload"}),v&&jsx("div",{className:"w-full text-left",children:v})]}):jsxs("div",{className:r("inline-flex flex-col gap-2",a),children:[jsxs("div",{className:"inline-flex items-center gap-2",children:[jsx("input",{...t.inputProps}),jsx(C,{children:jsxs(y,{children:[jsxs(A,{render:jsx(c,{size:"default",disabled:n,onClick:t.openFilePicker}),children:[jsx(UploadIcon,{"data-icon":"inline-start"}),i??"Upload file"]}),jsx(U,{children:d})]})})]}),v]})}function de({className:o,children:e,value:a,...i}){return jsxs(Progress.Root,{value:a,"data-slot":"progress",className:r("flex flex-wrap gap-3",o),...i,children:[e,jsx(Ee,{children:jsx(We,{})})]})}function Ee({className:o,...e}){return jsx(Progress.Track,{className:r("relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted",o),"data-slot":"progress-track",...e})}function We({className:o,...e}){return jsx(Progress.Indicator,{"data-slot":"progress-indicator",className:r("h-full bg-primary transition-all",o),...e})}function pe({className:o,...e}){return jsx(Progress.Label,{className:r("text-xs/relaxed font-medium",o),"data-slot":"progress-label",...e})}function ce({className:o,...e}){return jsx(Progress.Value,{className:r("ms-auto text-xs/relaxed text-muted-foreground tabular-nums",o),"data-slot":"progress-value",...e})}function ie({phase:o,files:e,totalProgress:a,error:i,onCancel:l}){return o==="idle"?null:o==="uploading"?jsxs("div",{className:"flex w-full flex-col gap-2",children:[jsxs("div",{className:"flex w-full items-center gap-1.5",children:[jsxs(de,{value:a.percent,className:"flex-1",children:[jsxs(pe,{children:[e.filter(d=>d.status==="success").length,"/",e.length," files"]}),jsx(ce,{})]}),jsx(c,{variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:d=>{d.stopPropagation(),l?.();},children:jsx(XIcon,{className:"size-4"})})]}),jsx(re,{files:e})]}):o==="success"?jsxs("div",{className:"flex w-full flex-col gap-1",children:[jsxs("span",{className:"text-xs text-green-600",children:["All ",e.length," file(s) uploaded"]}),jsx(re,{files:e})]}):o==="error"?jsxs("div",{className:"flex w-full flex-col gap-1",children:[jsx("span",{className:"text-xs text-destructive",children:i??"Upload failed"}),e.length>0&&jsx(re,{files:e})]}):o==="validating"?jsx("span",{className:"text-xs text-muted-foreground",children:"Validating\u2026"}):null}function re({files:o}){return jsx("ul",{className:"flex flex-col gap-1",children:o.map(e=>jsxs("li",{className:"flex flex-col gap-0.5 text-xs",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[e.status==="success"&&jsx(CheckCircleIcon,{className:"size-3.5 shrink-0 text-green-600"}),e.status==="error"&&jsx(AlertCircleIcon,{className:"size-3.5 shrink-0 text-destructive"}),(e.status==="pending"||e.status==="uploading")&&jsx(Z,{percent:e.status==="uploading"?e.progress.percent:0,size:14,strokeWidth:2}),jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:e.fileName}),e.status==="uploading"?jsxs("span",{className:"shrink-0 text-muted-foreground",children:[formatFileSize(e.progress.loaded)," /"," ",formatFileSize(e.fileSize)," (",e.progress.percent,"%)"]}):jsx("span",{className:"shrink-0 text-muted-foreground",children:formatFileSize(e.fileSize)})]}),e.status==="error"&&e.error&&jsx("span",{className:"pl-5 text-destructive",children:e.error})]},e.id))})}function Ze({variant:o="button",objectKey:e,className:a,label:i,disabled:l,tooltipText:d="Upload files",toast:g=true,showStatus:$=true,...T}){let t=useMultiUploadControls({...T,objectKey:e}),s=useRef(null),n=l||t.isUploading,D=useRef(t.phase);if(D.current!==t.phase&&(D.current=t.phase,g&&(t.phase==="idle"&&s.current&&(toast.dismiss(s.current),s.current=null),t.phase==="success"&&(s.current&&toast.dismiss(s.current),toast.success(`${t.files.length} file(s) uploaded`,{description:formatFileSize(t.totalProgress.total)}),s.current=null),t.phase==="error"&&t.files.length>0))){let P=t.files.filter(h=>h.status==="success").length,F=t.files.filter(h=>h.status==="error").length;s.current&&toast.dismiss(s.current),toast.error("Upload finished with errors",{description:`${P} succeeded, ${F} failed`}),s.current=null;}useEffect(()=>{if(g&&t.phase==="uploading"){let P=s.current??`multi-upload-${Date.now()}`;s.current=P;let F=t.files.filter(h=>h.status==="success").length;toast.loading(`Uploading\u2026 ${F}/${t.files.length}`,{id:P,description:`${formatFileSize(t.totalProgress.loaded)} / ${formatFileSize(t.totalProgress.total)} (${t.totalProgress.percent}%)`,cancel:{label:"Cancel",onClick:()=>t.cancel()}});}},[g,t.phase,t.totalProgress.percent,t.totalProgress.loaded,t.files,t.cancel]);let v=$?jsx(ie,{phase:t.phase,files:t.files,totalProgress:t.totalProgress,error:t.error,onCancel:t.cancel}):null;return o==="dropzone"?jsxs("div",{className:r("flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-6 text-center transition-colors",n?"cursor-not-allowed border-muted-foreground/25":"cursor-pointer border-muted-foreground/25 hover:border-primary/50",a),onClick:n?void 0:t.openFilePicker,...n?{}:t.dropHandlers,children:[jsx("input",{...t.inputProps}),jsx(UploadIcon,{className:r("size-6 text-muted-foreground",n&&"opacity-50")}),jsx("p",{className:r("text-sm text-muted-foreground",n&&"opacity-50"),children:i??"Click or drag & drop files to upload"}),v&&jsx("div",{className:"w-full text-left",children:v})]}):jsxs("div",{className:r("inline-flex flex-col gap-2",a),children:[jsxs("div",{className:"inline-flex items-center gap-2",children:[jsx("input",{...t.inputProps}),jsx(C,{children:jsxs(y,{children:[jsxs(A,{render:jsx(c,{size:"default",disabled:n,onClick:t.openFilePicker}),children:[jsx(UploadIcon,{"data-icon":"inline-start"}),i??"Upload files"]}),jsx(U,{children:d})]})})]}),v]})}function tt({presignApi:o,objectKey:e,fileName:a,fileSize:i,label:l,className:d,fillClassName:g,disabled:$,tooltipText:T="Download file",toast:t=true,showStatus:s=true,mode:n="native",beforeDownload:D,onDownloadStart:v,onProgress:P,onSuccess:F,onError:h,onCancel:k}){let R=a??e.split("/").pop()??e,f=useDownload({presignApi:o,mode:n,beforeDownload:D,onDownloadStart:v,onProgress:P,onSuccess:_=>{t&&(toast.dismiss(`dl-${e}`),toast.success("Download complete",{description:`${R}${i!=null?` \xB7 ${formatFileSize(i)}`:""}`})),F?.(_);},onError:(_,j,Ce)=>{t&&(toast.dismiss(`dl-${e}`),toast.error("Download failed",{description:j instanceof Error?j.message:"Unknown error"})),h?.(_,j,Ce);},onCancel:_=>{t&&(toast.dismiss(`dl-${e}`),toast.info("Download cancelled",{description:R})),k?.(_);}}),I=n==="fetch"&&(f.phase==="downloading"||f.phase==="presigning"),M=n==="native"?f.phase==="presigning":I,G=()=>{if(n==="fetch"&&I){f.cancel();return}f.download(e,R);};return jsxs("div",{className:r("inline-flex flex-col gap-1.5",d),children:[jsx(C,{children:jsxs(y,{children:[jsxs(A,{render:jsx(c,{size:"default",variant:"outline",disabled:$||n==="native"&&M,className:r(n==="fetch"&&"relative min-w-24 overflow-hidden"),onClick:G}),children:[I&&jsx("span",{className:r("absolute inset-0 bg-primary/15 transition-[width] duration-200",g),style:{width:`${f.progress.percent}%`}}),jsxs("span",{className:r("inline-flex items-center gap-1",n==="fetch"&&"relative z-10"),children:[jsx(DownloadIcon,{"data-icon":"inline-start"}),I?formatFileSize(f.progress.loaded):l??"Download"]})]}),jsx(U,{children:I?"Cancel download":T})]})}),s&&f.phase==="error"&&jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(AlertCircleIcon,{className:"size-3.5 shrink-0 text-destructive"}),jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:f.fileName??R})]}),jsx("span",{className:"text-destructive",children:f.error??"Download failed"})]})]})}function fe({...o}){return jsx(AlertDialog.Root,{"data-slot":"alert-dialog",...o})}function xe({...o}){return jsx(AlertDialog.Trigger,{"data-slot":"alert-dialog-trigger",...o})}function ot({...o}){return jsx(AlertDialog.Portal,{"data-slot":"alert-dialog-portal",...o})}function rt({className:o,...e}){return jsx(AlertDialog.Backdrop,{"data-slot":"alert-dialog-overlay",className:r("fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",o),...e})}function ve({className:o,size:e="default",...a}){return jsxs(ot,{children:[jsx(rt,{}),jsx(AlertDialog.Popup,{"data-slot":"alert-dialog-content","data-size":e,className:r("group/alert-dialog-content fixed top-1/2 start-1/2 z-50 grid w-full -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 gap-3 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",o),...a})]})}function Pe({className:o,...e}){return jsx("div",{"data-slot":"alert-dialog-header",className:r("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-start sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",o),...e})}function he({className:o,...e}){return jsx("div",{"data-slot":"alert-dialog-footer",className:r("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",o),...e})}function be({className:o,...e}){return jsx("div",{"data-slot":"alert-dialog-media",className:r("mb-2 inline-flex size-8 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-4",o),...e})}function Ne({className:o,...e}){return jsx(AlertDialog.Title,{"data-slot":"alert-dialog-title",className:r("font-heading text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",o),...e})}function ze({className:o,...e}){return jsx(AlertDialog.Description,{"data-slot":"alert-dialog-description",className:r("text-xs/relaxed text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",o),...e})}function De({className:o,...e}){return jsx(c,{"data-slot":"alert-dialog-action",className:r(o),...e})}function ke({className:o,variant:e="outline",size:a="default",...i}){return jsx(AlertDialog.Close,{"data-slot":"alert-dialog-cancel",className:r(o),render:jsx(c,{variant:e,size:a}),...i})}function dt({presignApi:o,objectKey:e,fileName:a,fileSize:i,label:l,className:d,disabled:g,tooltipText:$="Delete file",toast:T=true,showStatus:t=true,confirmTitle:s="Delete file?",confirmDescription:n,beforeDelete:D,onDeleteStart:v,onSuccess:P,onError:F}){let h=a??e.split("/").pop()??e,k=useDelete({presignApi:o,beforeDelete:D,onDeleteStart:v,onSuccess:M=>{T&&toast.success("File deleted",{description:h}),P?.(M);},onError:(M,G,_)=>{T&&toast.error("Delete failed",{description:G instanceof Error?G.message:"Unknown error"}),F?.(M,G,_);}}),R=k.phase==="deleting",f=g||R,I=n??`Are you sure you want to delete "${h}"${i!=null?` (${formatFileSize(i)})`:""}? This action cannot be undone.`;return jsxs("div",{className:r("inline-flex flex-col gap-1.5",d),children:[jsx("div",{className:"inline-flex items-center gap-2",children:jsxs(fe,{open:k.phase==="confirming",onOpenChange:M=>{M||k.cancelDelete();},children:[jsx(C,{children:jsxs(y,{children:[jsxs(A,{render:jsx(xe,{disabled:f,onClick:()=>k.requestDelete(e),render:jsx(c,{size:"default",variant:"destructive",disabled:f})}),children:[R?jsx(LoaderIcon,{className:"animate-spin","data-icon":"inline-start"}):jsx(Trash2Icon,{"data-icon":"inline-start"}),l??"Delete"]}),jsx(U,{children:$})]})}),jsxs(ve,{children:[jsxs(Pe,{children:[jsx(be,{children:jsx(Trash2Icon,{})}),jsx(Ne,{children:s}),jsx(ze,{children:I})]}),jsxs(he,{children:[jsx(ke,{children:"Cancel"}),jsx(De,{variant:"destructive",onClick:()=>k.confirmDelete(),children:"Delete"})]})]})]})}),t&&k.phase==="error"&&jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(AlertCircleIcon,{className:"size-3.5 shrink-0 text-destructive"}),jsx("span",{className:"max-w-32 truncate sm:max-w-48",children:h})]}),jsx("span",{className:"text-destructive",children:k.error??"Delete failed"})]})]})}export{dt as DeleteButton,tt as DownloadButton,Ze as MultiUpload,ie as MultiUploadStatus,Le as Upload,ee as UploadStatus};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/utils.ts","../src/components/ui/button.tsx","../src/components/ui/tooltip.tsx","../src/components/ui/circle-progress.tsx","../src/upload/upload-status.tsx","../src/upload/upload.tsx","../src/components/ui/progress.tsx","../src/upload/multi-upload-status.tsx","../src/upload/multi-upload.tsx","../src/download/download-button.tsx","../src/components/ui/alert-dialog.tsx","../src/delete/delete-button.tsx"],"names":["cn","inputs","twMerge","clsx","buttonVariants","cva","Button","className","variant","size","props","jsx","ButtonPrimitive","TooltipProvider","delay","TooltipPrimitive","Tooltip","TooltipTrigger","TooltipContent","side","sideOffset","align","alignOffset","children","jsxs","CircleProgress","percent","strokeWidth","r","c","offset","UploadStatus","phase","progress","error","fileInfo","onCancel","formatFileSize","e","XIcon","CheckCircleIcon","AlertCircleIcon","Fragment","Upload","objectKey","label","disabled","tooltipText","enableToast","showStatus","options","ctrl","useUploadControls","toastIdRef","useRef","isDisabled","prevPhaseRef","toast","useEffect","id","status","UploadIcon","Progress","value","ProgressPrimitive","ProgressTrack","ProgressIndicator","ProgressLabel","ProgressValue","MultiUploadStatus","files","totalProgress","f","FileList","MultiUpload","useMultiUploadControls","succeeded","failed","done","DownloadButton","presignApi","fileName","fileSize","fillClassName","mode","beforeDownload","onDownloadStart","onProgress","onSuccess","onError","displayName","dl","useDownload","key","isFetchDownloading","isLoading","handleClick","DownloadIcon","AlertDialog","AlertDialogPrimitive","AlertDialogTrigger","AlertDialogPortal","AlertDialogOverlay","AlertDialogContent","AlertDialogHeader","AlertDialogFooter","AlertDialogMedia","AlertDialogTitle","AlertDialogDescription","AlertDialogAction","AlertDialogCancel","DeleteButton","confirmTitle","confirmDescription","beforeDelete","onDeleteStart","del","useDelete","isDeleting","description","open","LoaderIcon","Trash2Icon"],"mappings":"ipBAGO,SAASA,CAAAA,CAAAA,GAAMC,CAAAA,CAAsB,CAC1C,OAAOC,OAAAA,CAAQC,KAAKF,CAAM,CAAC,CAC7B,CCEA,IAAMG,EAAAA,CAAiBC,GAAAA,CACrB,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+E,CAAAA,CAAY,GAC/D,CAAA,CACA/E,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,mBACb,QAAA,CAAAyG,CAAAA,CAAI,OAAS,eAAA,CAChB,CAAA,CAAA,CACF,GAEJ,CAEJ","file":"index.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n","\"use client\"\n\nimport { Button as ButtonPrimitive } from \"@base-ui/react/button\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst buttonVariants = cva(\n \"group/button cursor-pointer inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs/relaxed font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/80\",\n outline:\n \"border-border hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30\",\n secondary:\n \"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground\",\n ghost:\n \"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50\",\n destructive:\n \"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default:\n \"h-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5\",\n xs: \"h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-2.5\",\n sm: \"h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3\",\n lg: \"h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2 [&_svg:not([class*='size-'])]:size-4\",\n icon: \"size-7 [&_svg:not([class*='size-'])]:size-3.5\",\n \"icon-xs\": \"size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5\",\n \"icon-sm\": \"size-6 [&_svg:not([class*='size-'])]:size-3\",\n \"icon-lg\": \"size-8 [&_svg:not([class*='size-'])]:size-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction Button({\n className,\n variant = \"default\",\n size = \"default\",\n ...props\n}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {\n return (\n <ButtonPrimitive\n data-slot=\"button\"\n className={cn(buttonVariants({ variant, size, className }))}\n {...props}\n />\n )\n}\n\nexport { Button, buttonVariants }\n","\"use client\"\n\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction TooltipProvider({\n delay = 0,\n ...props\n}: TooltipPrimitive.Provider.Props) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delay={delay}\n {...props}\n />\n )\n}\n\nfunction Tooltip({ ...props }: TooltipPrimitive.Root.Props) {\n return <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n}\n\nfunction TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />\n}\n\nfunction TooltipContent({\n className,\n side = \"top\",\n sideOffset = 4,\n align = \"center\",\n alignOffset = 0,\n children,\n ...props\n}: TooltipPrimitive.Popup.Props &\n Pick<\n TooltipPrimitive.Positioner.Props,\n \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\"\n >) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"isolate z-50\"\n >\n <TooltipPrimitive.Popup\n data-slot=\"tooltip-content\"\n className={cn(\n \"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n className\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-start-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-end-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5\" />\n </TooltipPrimitive.Popup>\n </TooltipPrimitive.Positioner>\n </TooltipPrimitive.Portal>\n )\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }\n","\"use client\"\n\nexport function CircleProgress({\n percent,\n size = 20,\n strokeWidth = 2.5,\n}: {\n percent: number\n size?: number\n strokeWidth?: number\n}) {\n const r = (size - strokeWidth) / 2\n const c = 2 * Math.PI * r\n const offset = c - (percent / 100) * c\n return (\n <svg width={size} height={size} className=\"shrink-0 -rotate-90\">\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={strokeWidth}\n className=\"text-muted-foreground/20\"\n />\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={strokeWidth}\n strokeDasharray={c}\n strokeDashoffset={offset}\n strokeLinecap=\"round\"\n className=\"text-primary transition-[stroke-dashoffset] duration-200\"\n />\n </svg>\n )\n}\n","\"use client\";\n\nimport { XIcon, CheckCircleIcon, AlertCircleIcon } from \"lucide-react\";\nimport { formatFileSize } from \"@better-s3/core\";\nimport type { UploadPhase, UploadProgress } from \"@better-s3/core\";\nimport { Button } from \"@/components/ui/button\";\nimport { CircleProgress } from \"@/components/ui/circle-progress\";\n\nexport function UploadStatus({\n phase,\n progress,\n error,\n fileInfo,\n onCancel,\n}: {\n phase: UploadPhase;\n progress: UploadProgress;\n error: string | null;\n fileInfo: { name: string; size: number } | null;\n onCancel?: () => void;\n}) {\n if (phase === \"idle\") return null;\n\n if (phase === \"uploading\" && fileInfo) {\n return (\n <div className=\"flex w-full items-center gap-1.5 text-xs\">\n <CircleProgress percent={progress.percent} size={14} strokeWidth={2} />\n <span className=\"max-w-32 min-w-16 truncate sm:max-w-48\">\n {fileInfo.name}\n </span>\n <span className=\"shrink-0 text-muted-foreground\">\n {formatFileSize(progress.loaded)} / {formatFileSize(fileInfo.size)} (\n {progress.percent}%)\n </span>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"ml-auto size-6 shrink-0\"\n onClick={(e) => {\n e.stopPropagation();\n onCancel?.();\n }}>\n <XIcon className=\"size-3.5\" />\n </Button>\n </div>\n );\n }\n\n if (phase === \"success\" && fileInfo) {\n return (\n <div className=\"flex items-center gap-1.5 text-xs\">\n <CheckCircleIcon className=\"size-3.5 shrink-0 text-green-600\" />\n <span className=\"max-w-32 min-w-16 truncate sm:max-w-48\">\n {fileInfo.name}\n </span>\n <span className=\"shrink-0 text-muted-foreground\">\n {formatFileSize(fileInfo.size)}\n </span>\n </div>\n );\n }\n\n if (phase === \"error\") {\n return (\n <div className=\"flex flex-col gap-1 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n <AlertCircleIcon className=\"size-3.5 shrink-0 text-destructive\" />\n {fileInfo && (\n <>\n <span className=\"max-w-32 min-w-16 truncate sm:max-w-48\">\n {fileInfo.name}\n </span>\n <span className=\"shrink-0 text-muted-foreground\">\n {formatFileSize(fileInfo.size)}\n </span>\n </>\n )}\n </div>\n <span className=\"text-destructive\">{error ?? \"Upload failed\"}</span>\n </div>\n );\n }\n\n if (phase === \"validating\" || phase === \"presigning\") {\n return <span className=\"text-xs text-muted-foreground\">Preparing…</span>;\n }\n\n return null;\n}\n","\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport { toast } from \"sonner\";\nimport { UploadIcon } from \"lucide-react\";\nimport { formatFileSize } from \"@better-s3/core\";\nimport type { UseUploadOptions } from \"@better-s3/react\";\nimport { useUploadControls } from \"@better-s3/react\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { UploadStatus } from \"./upload-status\";\n\nexport type UploadProps = UseUploadOptions & {\n objectKey: string | ((file: File) => string);\n variant?: \"button\" | \"dropzone\";\n className?: string;\n label?: string;\n disabled?: boolean;\n tooltipText?: string;\n /** Enable sonner toasts (default: `true`) */\n toast?: boolean;\n /** Show inline status below the trigger (default: `true`) */\n showStatus?: boolean;\n};\n\nexport function Upload({\n variant = \"button\",\n objectKey,\n className,\n label,\n disabled,\n tooltipText = \"Upload file\",\n toast: enableToast = true,\n showStatus = true,\n ...options\n}: UploadProps) {\n const ctrl = useUploadControls({ ...options, objectKey });\n const toastIdRef = useRef<string | null>(null);\n const isDisabled = disabled || ctrl.isUploading;\n\n // ── Toast ─────────────────────────────────────────────────────────\n\n const prevPhaseRef = useRef(ctrl.phase);\n if (prevPhaseRef.current !== ctrl.phase) {\n prevPhaseRef.current = ctrl.phase;\n if (enableToast) {\n if (ctrl.phase === \"idle\" && toastIdRef.current) {\n toast.dismiss(toastIdRef.current);\n toastIdRef.current = null;\n }\n if (ctrl.phase === \"success\" && ctrl.fileInfo) {\n if (toastIdRef.current) toast.dismiss(toastIdRef.current);\n toast.success(\"Upload complete\", {\n description: formatFileSize(ctrl.fileInfo.size),\n });\n toastIdRef.current = null;\n }\n if (ctrl.phase === \"error\") {\n if (toastIdRef.current) toast.dismiss(toastIdRef.current);\n toast.error(\"Upload failed\", {\n description: ctrl.error ?? \"Unknown error\",\n });\n toastIdRef.current = null;\n }\n }\n }\n\n useEffect(() => {\n if (enableToast && ctrl.phase === \"uploading\" && ctrl.fileInfo) {\n const id = toastIdRef.current ?? `upload-${Date.now()}`;\n toastIdRef.current = id;\n toast.loading(\"Uploading…\", {\n id,\n description: `${formatFileSize(ctrl.progress.loaded)} / ${formatFileSize(ctrl.fileInfo.size)} (${ctrl.progress.percent}%)`,\n cancel: { label: \"Cancel\", onClick: () => ctrl.cancel() },\n });\n }\n }, [\n enableToast,\n ctrl.phase,\n ctrl.progress.percent,\n ctrl.progress.loaded,\n ctrl.fileInfo,\n ctrl.cancel,\n ]);\n\n // ── Render ────────────────────────────────────────────────────────\n\n const status = showStatus ? (\n <UploadStatus\n phase={ctrl.phase}\n progress={ctrl.progress}\n error={ctrl.error}\n fileInfo={ctrl.fileInfo}\n onCancel={ctrl.cancel}\n />\n ) : null;\n\n if (variant === \"dropzone\") {\n return (\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-6 text-center transition-colors\",\n isDisabled\n ? \"cursor-not-allowed border-muted-foreground/25\"\n : \"cursor-pointer border-muted-foreground/25 hover:border-primary/50\",\n className,\n )}\n onClick={isDisabled ? undefined : ctrl.openFilePicker}\n {...(isDisabled ? {} : ctrl.dropHandlers)}>\n <input {...ctrl.inputProps} />\n <UploadIcon\n className={cn(\n \"size-6 text-muted-foreground\",\n isDisabled && \"opacity-50\",\n )}\n />\n <p\n className={cn(\n \"text-sm text-muted-foreground\",\n isDisabled && \"opacity-50\",\n )}>\n {label ?? \"Click or drag & drop to upload\"}\n </p>\n {status && <div className=\"w-full text-left\">{status}</div>}\n </div>\n );\n }\n\n return (\n <div className={cn(\"inline-flex flex-col gap-2\", className)}>\n <div className=\"inline-flex items-center gap-2\">\n <input {...ctrl.inputProps} />\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n size=\"default\"\n disabled={isDisabled}\n onClick={ctrl.openFilePicker}\n />\n }>\n <UploadIcon data-icon=\"inline-start\" />\n {label ?? \"Upload file\"}\n </TooltipTrigger>\n <TooltipContent>{tooltipText}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n </div>\n {status}\n </div>\n );\n}\n","\"use client\"\n\nimport { Progress as ProgressPrimitive } from \"@base-ui/react/progress\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Progress({\n className,\n children,\n value,\n ...props\n}: ProgressPrimitive.Root.Props) {\n return (\n <ProgressPrimitive.Root\n value={value}\n data-slot=\"progress\"\n className={cn(\"flex flex-wrap gap-3\", className)}\n {...props}\n >\n {children}\n <ProgressTrack>\n <ProgressIndicator />\n </ProgressTrack>\n </ProgressPrimitive.Root>\n )\n}\n\nfunction ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props) {\n return (\n <ProgressPrimitive.Track\n className={cn(\n \"relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted\",\n className\n )}\n data-slot=\"progress-track\"\n {...props}\n />\n )\n}\n\nfunction ProgressIndicator({\n className,\n ...props\n}: ProgressPrimitive.Indicator.Props) {\n return (\n <ProgressPrimitive.Indicator\n data-slot=\"progress-indicator\"\n className={cn(\"h-full bg-primary transition-all\", className)}\n {...props}\n />\n )\n}\n\nfunction ProgressLabel({ className, ...props }: ProgressPrimitive.Label.Props) {\n return (\n <ProgressPrimitive.Label\n className={cn(\"text-xs/relaxed font-medium\", className)}\n data-slot=\"progress-label\"\n {...props}\n />\n )\n}\n\nfunction ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props) {\n return (\n <ProgressPrimitive.Value\n className={cn(\n \"ms-auto text-xs/relaxed text-muted-foreground tabular-nums\",\n className\n )}\n data-slot=\"progress-value\"\n {...props}\n />\n )\n}\n\nexport {\n Progress,\n ProgressTrack,\n ProgressIndicator,\n ProgressLabel,\n ProgressValue,\n}\n","\"use client\";\n\nimport { XIcon, CheckCircleIcon, AlertCircleIcon } from \"lucide-react\";\nimport { formatFileSize } from \"@better-s3/core\";\nimport type { UploadProgress, MultiUploadFileState } from \"@better-s3/core\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Progress,\n ProgressLabel,\n ProgressValue,\n} from \"@/components/ui/progress\";\nimport { CircleProgress } from \"@/components/ui/circle-progress\";\n\nexport function MultiUploadStatus({\n phase,\n files,\n totalProgress,\n error,\n onCancel,\n}: {\n phase: string;\n files: MultiUploadFileState[];\n totalProgress: UploadProgress;\n error: string | null;\n onCancel?: () => void;\n}) {\n if (phase === \"idle\") return null;\n\n if (phase === \"uploading\") {\n return (\n <div className=\"flex w-full flex-col gap-2\">\n <div className=\"flex w-full items-center gap-1.5\">\n <Progress value={totalProgress.percent} className=\"flex-1\">\n <ProgressLabel>\n {files.filter((f) => f.status === \"success\").length}/\n {files.length} files\n </ProgressLabel>\n <ProgressValue />\n </Progress>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"size-7 shrink-0\"\n onClick={(e) => {\n e.stopPropagation();\n onCancel?.();\n }}>\n <XIcon className=\"size-4\" />\n </Button>\n </div>\n <FileList files={files} />\n </div>\n );\n }\n\n if (phase === \"success\") {\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <span className=\"text-xs text-green-600\">\n All {files.length} file(s) uploaded\n </span>\n <FileList files={files} />\n </div>\n );\n }\n\n if (phase === \"error\") {\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <span className=\"text-xs text-destructive\">\n {error ?? \"Upload failed\"}\n </span>\n {files.length > 0 && <FileList files={files} />}\n </div>\n );\n }\n\n if (phase === \"validating\") {\n return <span className=\"text-xs text-muted-foreground\">Validating…</span>;\n }\n\n return null;\n}\n\n// ─── File List ──────────────────────────────────────────────────────────\n\nfunction FileList({ files }: { files: MultiUploadFileState[] }) {\n return (\n <ul className=\"flex flex-col gap-1\">\n {files.map((f) => (\n <li key={f.id} className=\"flex flex-col gap-0.5 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n {f.status === \"success\" && (\n <CheckCircleIcon className=\"size-3.5 shrink-0 text-green-600\" />\n )}\n {f.status === \"error\" && (\n <AlertCircleIcon className=\"size-3.5 shrink-0 text-destructive\" />\n )}\n {(f.status === \"pending\" || f.status === \"uploading\") && (\n <CircleProgress\n percent={f.status === \"uploading\" ? f.progress.percent : 0}\n size={14}\n strokeWidth={2}\n />\n )}\n <span className=\"max-w-32 min-w-16 truncate sm:max-w-48\">\n {f.fileName}\n </span>\n {f.status === \"uploading\" ? (\n <span className=\"shrink-0 text-muted-foreground\">\n {formatFileSize(f.progress.loaded)} /{\" \"}\n {formatFileSize(f.fileSize)} ({f.progress.percent}%)\n </span>\n ) : (\n <span className=\"shrink-0 text-muted-foreground\">\n {formatFileSize(f.fileSize)}\n </span>\n )}\n </div>\n {f.status === \"error\" && f.error && (\n <span className=\"pl-5 text-destructive\">{f.error}</span>\n )}\n </li>\n ))}\n </ul>\n );\n}\n","\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport { toast } from \"sonner\";\nimport { UploadIcon } from \"lucide-react\";\nimport { formatFileSize } from \"@better-s3/core\";\nimport type { UseMultiUploadOptions } from \"@better-s3/react\";\nimport { useMultiUploadControls } from \"@better-s3/react\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { MultiUploadStatus } from \"./multi-upload-status\";\n\nexport type MultiUploadProps = UseMultiUploadOptions & {\n objectKey: (file: File) => string;\n variant?: \"button\" | \"dropzone\";\n className?: string;\n label?: string;\n disabled?: boolean;\n tooltipText?: string;\n /** Enable sonner toasts (default: `true`) */\n toast?: boolean;\n /** Show inline status below the trigger (default: `true`) */\n showStatus?: boolean;\n};\n\nexport function MultiUpload({\n variant = \"button\",\n objectKey,\n className,\n label,\n disabled,\n tooltipText = \"Upload files\",\n toast: enableToast = true,\n showStatus = true,\n ...options\n}: MultiUploadProps) {\n const ctrl = useMultiUploadControls({ ...options, objectKey });\n const toastIdRef = useRef<string | null>(null);\n const isDisabled = disabled || ctrl.isUploading;\n\n // ── Toast ─────────────────────────────────────────────────────────\n\n const prevPhaseRef = useRef(ctrl.phase);\n if (prevPhaseRef.current !== ctrl.phase) {\n prevPhaseRef.current = ctrl.phase;\n if (enableToast) {\n if (ctrl.phase === \"idle\" && toastIdRef.current) {\n toast.dismiss(toastIdRef.current);\n toastIdRef.current = null;\n }\n if (ctrl.phase === \"success\") {\n if (toastIdRef.current) toast.dismiss(toastIdRef.current);\n toast.success(`${ctrl.files.length} file(s) uploaded`, {\n description: formatFileSize(ctrl.totalProgress.total),\n });\n toastIdRef.current = null;\n }\n if (ctrl.phase === \"error\" && ctrl.files.length > 0) {\n const succeeded = ctrl.files.filter(\n (f) => f.status === \"success\",\n ).length;\n const failed = ctrl.files.filter((f) => f.status === \"error\").length;\n if (toastIdRef.current) toast.dismiss(toastIdRef.current);\n toast.error(\"Upload finished with errors\", {\n description: `${succeeded} succeeded, ${failed} failed`,\n });\n toastIdRef.current = null;\n }\n }\n }\n\n useEffect(() => {\n if (enableToast && ctrl.phase === \"uploading\") {\n const id = toastIdRef.current ?? `multi-upload-${Date.now()}`;\n toastIdRef.current = id;\n const done = ctrl.files.filter((f) => f.status === \"success\").length;\n toast.loading(`Uploading… ${done}/${ctrl.files.length}`, {\n id,\n description: `${formatFileSize(ctrl.totalProgress.loaded)} / ${formatFileSize(ctrl.totalProgress.total)} (${ctrl.totalProgress.percent}%)`,\n cancel: { label: \"Cancel\", onClick: () => ctrl.cancel() },\n });\n }\n }, [\n enableToast,\n ctrl.phase,\n ctrl.totalProgress.percent,\n ctrl.totalProgress.loaded,\n ctrl.files,\n ctrl.cancel,\n ]);\n\n // ── Render ────────────────────────────────────────────────────────\n\n const status = showStatus ? (\n <MultiUploadStatus\n phase={ctrl.phase}\n files={ctrl.files}\n totalProgress={ctrl.totalProgress}\n error={ctrl.error}\n onCancel={ctrl.cancel}\n />\n ) : null;\n\n if (variant === \"dropzone\") {\n return (\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-6 text-center transition-colors\",\n isDisabled\n ? \"cursor-not-allowed border-muted-foreground/25\"\n : \"cursor-pointer border-muted-foreground/25 hover:border-primary/50\",\n className,\n )}\n onClick={isDisabled ? undefined : ctrl.openFilePicker}\n {...(isDisabled ? {} : ctrl.dropHandlers)}>\n <input {...ctrl.inputProps} />\n <UploadIcon\n className={cn(\n \"size-6 text-muted-foreground\",\n isDisabled && \"opacity-50\",\n )}\n />\n <p\n className={cn(\n \"text-sm text-muted-foreground\",\n isDisabled && \"opacity-50\",\n )}>\n {label ?? \"Click or drag & drop files to upload\"}\n </p>\n {status && <div className=\"w-full text-left\">{status}</div>}\n </div>\n );\n }\n\n return (\n <div className={cn(\"inline-flex flex-col gap-2\", className)}>\n <div className=\"inline-flex items-center gap-2\">\n <input {...ctrl.inputProps} />\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n size=\"default\"\n disabled={isDisabled}\n onClick={ctrl.openFilePicker}\n />\n }>\n <UploadIcon data-icon=\"inline-start\" />\n {label ?? \"Upload files\"}\n </TooltipTrigger>\n <TooltipContent>{tooltipText}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n </div>\n {status}\n </div>\n );\n}\n","\"use client\";\n\nimport { DownloadIcon, AlertCircleIcon } from \"lucide-react\";\nimport { toast } from \"sonner\";\nimport { cn } from \"@/lib/utils\";\nimport { formatFileSize } from \"@better-s3/core\";\nimport type { PresignApi, DownloadHooks } from \"@better-s3/core\";\nimport { useDownload } from \"@better-s3/react\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\n\ntype DownloadButtonProps = DownloadHooks & {\n presignApi: PresignApi;\n objectKey: string;\n fileName?: string;\n fileSize?: number;\n label?: string;\n className?: string;\n fillClassName?: string;\n disabled?: boolean;\n tooltipText?: string;\n /** Enable sonner toasts (default: `true`) */\n toast?: boolean;\n /** Show inline error status below the button (default: `true`) */\n showStatus?: boolean;\n /**\n * `\"native\"` — browser handles download natively via presigned URL (default)\n * `\"fetch\"` — streams via fetch, shows in-button progress\n */\n mode?: \"native\" | \"fetch\";\n};\n\nexport function DownloadButton({\n presignApi,\n objectKey,\n fileName,\n fileSize,\n label,\n className,\n fillClassName,\n disabled,\n tooltipText = \"Download file\",\n toast: enableToast = true,\n showStatus = true,\n mode = \"native\",\n beforeDownload,\n onDownloadStart,\n onProgress,\n onSuccess,\n onError,\n onCancel,\n}: DownloadButtonProps) {\n const displayName = fileName ?? objectKey.split(\"/\").pop() ?? objectKey;\n\n const dl = useDownload({\n presignApi,\n mode,\n beforeDownload,\n onDownloadStart,\n onProgress,\n onSuccess: (key) => {\n if (enableToast) {\n toast.dismiss(`dl-${objectKey}`);\n toast.success(\"Download complete\", {\n description: `${displayName}${fileSize != null ? ` · ${formatFileSize(fileSize)}` : \"\"}`,\n });\n }\n onSuccess?.(key);\n },\n onError: (key, error, phase) => {\n if (enableToast) {\n toast.dismiss(`dl-${objectKey}`);\n toast.error(\"Download failed\", {\n description: error instanceof Error ? error.message : \"Unknown error\",\n });\n }\n onError?.(key, error, phase);\n },\n onCancel: (key) => {\n if (enableToast) {\n toast.dismiss(`dl-${objectKey}`);\n toast.info(\"Download cancelled\", { description: displayName });\n }\n onCancel?.(key);\n },\n });\n\n const isFetchDownloading =\n mode === \"fetch\" &&\n (dl.phase === \"downloading\" || dl.phase === \"presigning\");\n\n const isLoading =\n mode === \"native\" ? dl.phase === \"presigning\" : isFetchDownloading;\n\n const handleClick = () => {\n if (mode === \"fetch\" && isFetchDownloading) {\n dl.cancel();\n return;\n }\n dl.download(objectKey, displayName);\n };\n\n return (\n <div className={cn(\"inline-flex flex-col gap-1.5\", className)}>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n size=\"default\"\n variant=\"outline\"\n disabled={disabled || (mode === \"native\" && isLoading)}\n className={cn(\n mode === \"fetch\" && \"relative min-w-24 overflow-hidden\",\n )}\n onClick={handleClick}\n />\n }>\n {isFetchDownloading && (\n <span\n className={cn(\n \"absolute inset-0 bg-primary/15 transition-[width] duration-200\",\n fillClassName,\n )}\n style={{ width: `${dl.progress.percent}%` }}\n />\n )}\n <span\n className={cn(\n \"inline-flex items-center gap-1\",\n mode === \"fetch\" && \"relative z-10\",\n )}>\n <DownloadIcon data-icon=\"inline-start\" />\n {isFetchDownloading\n ? formatFileSize(dl.progress.loaded)\n : (label ?? \"Download\")}\n </span>\n </TooltipTrigger>\n <TooltipContent>\n {isFetchDownloading ? \"Cancel download\" : tooltipText}\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n\n {showStatus && dl.phase === \"error\" && (\n <div className=\"flex flex-col gap-1 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n <AlertCircleIcon className=\"size-3.5 shrink-0 text-destructive\" />\n <span className=\"max-w-32 min-w-16 truncate sm:max-w-48\">\n {dl.fileName ?? displayName}\n </span>\n </div>\n <span className=\"text-destructive\">\n {dl.error ?? \"Download failed\"}\n </span>\n </div>\n )}\n </div>\n );\n}\n","\"use client\"\n\nimport * as React from \"react\"\nimport { AlertDialog as AlertDialogPrimitive } from \"@base-ui/react/alert-dialog\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\n\nfunction AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {\n return <AlertDialogPrimitive.Root data-slot=\"alert-dialog\" {...props} />\n}\n\nfunction AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {\n return (\n <AlertDialogPrimitive.Trigger data-slot=\"alert-dialog-trigger\" {...props} />\n )\n}\n\nfunction AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {\n return (\n <AlertDialogPrimitive.Portal data-slot=\"alert-dialog-portal\" {...props} />\n )\n}\n\nfunction AlertDialogOverlay({\n className,\n ...props\n}: AlertDialogPrimitive.Backdrop.Props) {\n return (\n <AlertDialogPrimitive.Backdrop\n data-slot=\"alert-dialog-overlay\"\n className={cn(\n \"fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogContent({\n className,\n size = \"default\",\n ...props\n}: AlertDialogPrimitive.Popup.Props & {\n size?: \"default\" | \"sm\"\n}) {\n return (\n <AlertDialogPortal>\n <AlertDialogOverlay />\n <AlertDialogPrimitive.Popup\n data-slot=\"alert-dialog-content\"\n data-size={size}\n className={cn(\n \"group/alert-dialog-content fixed top-1/2 start-1/2 z-50 grid w-full -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 gap-3 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n className\n )}\n {...props}\n />\n </AlertDialogPortal>\n )\n}\n\nfunction AlertDialogHeader({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-dialog-header\"\n className={cn(\n \"grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-start sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogFooter({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-dialog-footer\"\n className={cn(\n \"flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogMedia({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-dialog-media\"\n className={cn(\n \"mb-2 inline-flex size-8 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogTitle({\n className,\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {\n return (\n <AlertDialogPrimitive.Title\n data-slot=\"alert-dialog-title\"\n className={cn(\n \"font-heading text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {\n return (\n <AlertDialogPrimitive.Description\n data-slot=\"alert-dialog-description\"\n className={cn(\n \"text-xs/relaxed text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogAction({\n className,\n ...props\n}: React.ComponentProps<typeof Button>) {\n return (\n <Button\n data-slot=\"alert-dialog-action\"\n className={cn(className)}\n {...props}\n />\n )\n}\n\nfunction AlertDialogCancel({\n className,\n variant = \"outline\",\n size = \"default\",\n ...props\n}: AlertDialogPrimitive.Close.Props &\n Pick<React.ComponentProps<typeof Button>, \"variant\" | \"size\">) {\n return (\n <AlertDialogPrimitive.Close\n data-slot=\"alert-dialog-cancel\"\n className={cn(className)}\n render={<Button variant={variant} size={size} />}\n {...props}\n />\n )\n}\n\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogMedia,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger,\n}\n","\"use client\";\n\nimport { Trash2Icon, LoaderIcon, AlertCircleIcon } from \"lucide-react\";\nimport { toast } from \"sonner\";\nimport { cn } from \"@/lib/utils\";\nimport { formatFileSize } from \"@better-s3/core\";\nimport type { PresignApi, DeleteHooks } from \"@better-s3/core\";\nimport { useDelete } from \"@better-s3/react\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogMedia,\n AlertDialogTitle,\n AlertDialogTrigger,\n} from \"@/components/ui/alert-dialog\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\n\ntype DeleteButtonProps = DeleteHooks & {\n presignApi: PresignApi;\n objectKey: string;\n fileName?: string;\n fileSize?: number;\n label?: string;\n className?: string;\n disabled?: boolean;\n tooltipText?: string;\n /** Enable sonner toasts (default: `true`) */\n toast?: boolean;\n /** Show inline error status below the button (default: `true`) */\n showStatus?: boolean;\n confirmTitle?: string;\n confirmDescription?: string;\n};\n\nexport function DeleteButton({\n presignApi,\n objectKey,\n fileName,\n fileSize,\n label,\n className,\n disabled,\n tooltipText = \"Delete file\",\n toast: enableToast = true,\n showStatus = true,\n confirmTitle = \"Delete file?\",\n confirmDescription,\n beforeDelete,\n onDeleteStart,\n onSuccess,\n onError,\n}: DeleteButtonProps) {\n const displayName = fileName ?? objectKey.split(\"/\").pop() ?? objectKey;\n\n const del = useDelete({\n presignApi,\n beforeDelete,\n onDeleteStart,\n onSuccess: (key) => {\n if (enableToast) {\n toast.success(\"File deleted\", { description: displayName });\n }\n onSuccess?.(key);\n },\n onError: (key, error, phase) => {\n if (enableToast) {\n toast.error(\"Delete failed\", {\n description: error instanceof Error ? error.message : \"Unknown error\",\n });\n }\n onError?.(key, error, phase);\n },\n });\n\n const isDeleting = del.phase === \"deleting\";\n const isDisabled = disabled || isDeleting;\n\n const description =\n confirmDescription ??\n `Are you sure you want to delete \"${displayName}\"${fileSize != null ? ` (${formatFileSize(fileSize)})` : \"\"}? This action cannot be undone.`;\n\n return (\n <div className={cn(\"inline-flex flex-col gap-1.5\", className)}>\n <div className=\"inline-flex items-center gap-2\">\n <AlertDialog\n open={del.phase === \"confirming\"}\n onOpenChange={(open) => {\n if (!open) del.cancelDelete();\n }}>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={\n <AlertDialogTrigger\n disabled={isDisabled}\n onClick={() => del.requestDelete(objectKey)}\n render={\n <Button\n size=\"default\"\n variant=\"destructive\"\n disabled={isDisabled}\n />\n }\n />\n }>\n {isDeleting ? (\n <LoaderIcon\n className=\"animate-spin\"\n data-icon=\"inline-start\"\n />\n ) : (\n <Trash2Icon data-icon=\"inline-start\" />\n )}\n {label ?? \"Delete\"}\n </TooltipTrigger>\n <TooltipContent>{tooltipText}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogMedia>\n <Trash2Icon />\n </AlertDialogMedia>\n <AlertDialogTitle>{confirmTitle}</AlertDialogTitle>\n <AlertDialogDescription>{description}</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n variant=\"destructive\"\n onClick={() => del.confirmDelete()}>\n Delete\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n\n {showStatus && del.phase === \"error\" && (\n <div className=\"flex flex-col gap-1 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n <AlertCircleIcon className=\"size-3.5 shrink-0 text-destructive\" />\n <span className=\"max-w-32 truncate sm:max-w-48\">{displayName}</span>\n </div>\n <span className=\"text-destructive\">\n {del.error ?? \"Delete failed\"}\n </span>\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,8 @@
1
+ import type { UploadProgress, MultiUploadFileState } from "@better-s3/core";
2
+ export declare function MultiUploadStatus({ phase, files, totalProgress, error, onCancel, }: {
3
+ phase: string;
4
+ files: MultiUploadFileState[];
5
+ totalProgress: UploadProgress;
6
+ error: string | null;
7
+ onCancel?: () => void;
8
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ import type { UseMultiUploadOptions } from "@better-s3/react";
2
+ export type MultiUploadProps = UseMultiUploadOptions & {
3
+ objectKey: (file: File) => string;
4
+ variant?: "button" | "dropzone";
5
+ className?: string;
6
+ label?: string;
7
+ disabled?: boolean;
8
+ tooltipText?: string;
9
+ /** Enable sonner toasts (default: `true`) */
10
+ toast?: boolean;
11
+ /** Show inline status below the trigger (default: `true`) */
12
+ showStatus?: boolean;
13
+ };
14
+ export declare function MultiUpload({ variant, objectKey, className, label, disabled, tooltipText, toast: enableToast, showStatus, ...options }: MultiUploadProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import type { UploadPhase, UploadProgress } from "@better-s3/core";
2
+ export declare function UploadStatus({ phase, progress, error, fileInfo, onCancel, }: {
3
+ phase: UploadPhase;
4
+ progress: UploadProgress;
5
+ error: string | null;
6
+ fileInfo: {
7
+ name: string;
8
+ size: number;
9
+ } | null;
10
+ onCancel?: () => void;
11
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ import type { UseUploadOptions } from "@better-s3/react";
2
+ export type UploadProps = UseUploadOptions & {
3
+ objectKey: string | ((file: File) => string);
4
+ variant?: "button" | "dropzone";
5
+ className?: string;
6
+ label?: string;
7
+ disabled?: boolean;
8
+ tooltipText?: string;
9
+ /** Enable sonner toasts (default: `true`) */
10
+ toast?: boolean;
11
+ /** Show inline status below the trigger (default: `true`) */
12
+ showStatus?: boolean;
13
+ };
14
+ export declare function Upload({ variant, objectKey, className, label, disabled, tooltipText, toast: enableToast, showStatus, ...options }: UploadProps): import("react/jsx-runtime").JSX.Element;
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@better-s3/ui",
3
+ "version": "1.0.0",
4
+ "description": "Pre-built React UI components for S3 file upload, download, and delete",
5
+ "keywords": [
6
+ "s3",
7
+ "react",
8
+ "ui",
9
+ "upload",
10
+ "download",
11
+ "file-upload",
12
+ "components"
13
+ ],
14
+ "author": "Hamidrezakz",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/hamidrezakz/better-s3.git",
19
+ "directory": "packages/better-s3-ui"
20
+ },
21
+ "homepage": "https://github.com/hamidrezakz/better-s3/tree/master/packages/better-s3-ui",
22
+ "bugs": {
23
+ "url": "https://github.com/hamidrezakz/better-s3/issues"
24
+ },
25
+ "sideEffects": false,
26
+ "type": "module",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./styles.css": "./styles.css"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "styles.css"
37
+ ],
38
+ "dependencies": {
39
+ "@better-s3/core": "1.0.0",
40
+ "@better-s3/react": "1.0.0"
41
+ },
42
+ "peerDependencies": {
43
+ "@base-ui/react": ">=1.0.0",
44
+ "class-variance-authority": ">=0.7.0",
45
+ "clsx": ">=2.0.0",
46
+ "lucide-react": ">=0.400.0",
47
+ "react": ">=18",
48
+ "sonner": ">=1.0.0",
49
+ "tailwind-merge": ">=2.0.0"
50
+ },
51
+ "devDependencies": {
52
+ "@base-ui/react": "^1.3.0",
53
+ "@types/react": "^19.0.0",
54
+ "class-variance-authority": "^0.7.1",
55
+ "clsx": "^2.1.1",
56
+ "lucide-react": "^0.500.0",
57
+ "react": "^19.0.0",
58
+ "sonner": "^2.0.0",
59
+ "tailwind-merge": "^3.0.0",
60
+ "tsc-alias": "^1.8.16",
61
+ "tsup": "^8.5.1",
62
+ "typescript": "^5.8.3"
63
+ },
64
+ "publishConfig": {
65
+ "access": "public"
66
+ },
67
+ "scripts": {
68
+ "build": "tsup --config tsup.config.ts && tsc --emitDeclarationOnly && tsc-alias",
69
+ "check-types": "tsc --noEmit"
70
+ }
71
+ }
package/styles.css ADDED
@@ -0,0 +1,7 @@
1
+ /* @better-s3/ui — Tailwind v4 source registration
2
+ Import this file in your CSS so Tailwind can detect the utility classes
3
+ used by this package:
4
+
5
+ @import "@better-s3/ui/styles.css";
6
+ */
7
+ @source "./dist";