@better-s3/ui 2.2.0 → 2.3.1
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/README.md
CHANGED
|
@@ -21,14 +21,14 @@ import "@better-s3/ui/styles.css";
|
|
|
21
21
|
## Components
|
|
22
22
|
|
|
23
23
|
```tsx
|
|
24
|
-
import {
|
|
24
|
+
import { createS3Api } from "@better-s3/server";
|
|
25
25
|
import { Upload, MultiUpload, DownloadButton, DeleteButton } from "@better-s3/ui";
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const api = createS3Api("/api/s3");
|
|
28
28
|
|
|
29
29
|
// Single upload (button or dropzone)
|
|
30
30
|
<Upload
|
|
31
|
-
|
|
31
|
+
api={api}
|
|
32
32
|
objectKey={(file) => `uploads/${file.name}`}
|
|
33
33
|
variant="dropzone"
|
|
34
34
|
accept={["image/*"]}
|
|
@@ -37,16 +37,16 @@ const presignApi = createPresignApi("/api/s3");
|
|
|
37
37
|
|
|
38
38
|
// Batch upload
|
|
39
39
|
<MultiUpload
|
|
40
|
-
|
|
40
|
+
api={api}
|
|
41
41
|
objectKey={(file) => `uploads/${file.name}`}
|
|
42
42
|
maxFiles={10}
|
|
43
43
|
/>
|
|
44
44
|
|
|
45
45
|
// Download
|
|
46
|
-
<DownloadButton
|
|
46
|
+
<DownloadButton api={api} objectKey="report.pdf" fileName="report.pdf" />
|
|
47
47
|
|
|
48
48
|
// Delete with confirmation dialog
|
|
49
|
-
<DeleteButton
|
|
49
|
+
<DeleteButton api={api} objectKey="report.pdf" />
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { S3Api, DeleteHooks } from "@better-s3/react";
|
|
2
2
|
type DeleteButtonProps = DeleteHooks & {
|
|
3
|
-
|
|
3
|
+
api: S3Api;
|
|
4
4
|
objectKey: string;
|
|
5
5
|
fileName?: string;
|
|
6
6
|
fileSize?: number;
|
|
@@ -17,5 +17,5 @@ type DeleteButtonProps = DeleteHooks & {
|
|
|
17
17
|
confirmTitle?: string;
|
|
18
18
|
confirmDescription?: string;
|
|
19
19
|
};
|
|
20
|
-
export declare function DeleteButton({
|
|
20
|
+
export declare function DeleteButton({ api, objectKey, fileName, fileSize, bucket, label, className, disabled, tooltipText, toast: enableToast, showStatus, confirmTitle, confirmDescription, beforeDelete, onDeleteStart, onSuccess, onError, }: DeleteButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
export {};
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type DownloadButtonProps =
|
|
3
|
-
|
|
1
|
+
import type { S3Api } from "@better-s3/react";
|
|
2
|
+
type DownloadButtonProps = {
|
|
3
|
+
api: S3Api;
|
|
4
4
|
objectKey: string;
|
|
5
5
|
fileName?: string;
|
|
6
|
-
fileSize?: number;
|
|
7
|
-
/** Target bucket (overrides server default) */
|
|
8
|
-
bucket?: string;
|
|
9
6
|
label?: string;
|
|
10
7
|
className?: string;
|
|
11
8
|
disabled?: boolean;
|
|
12
|
-
tooltipText?: string;
|
|
13
9
|
/** Enable sonner toasts (default: `true`) */
|
|
14
10
|
toast?: boolean;
|
|
15
|
-
/** Show inline error status below the button (default: `true`) */
|
|
16
|
-
showStatus?: boolean;
|
|
17
11
|
};
|
|
18
|
-
export declare function DownloadButton({
|
|
12
|
+
export declare function DownloadButton({ api, objectKey, fileName, label, className, disabled, toast: enableToast, }: DownloadButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
19
13
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { S3Api, FetchDownloadHooks } from "@better-s3/react";
|
|
2
2
|
type ProgressDownloadButtonProps = FetchDownloadHooks & {
|
|
3
|
-
|
|
3
|
+
api: S3Api;
|
|
4
4
|
objectKey: string;
|
|
5
5
|
fileName?: string;
|
|
6
6
|
fileSize?: number;
|
|
@@ -16,5 +16,5 @@ type ProgressDownloadButtonProps = FetchDownloadHooks & {
|
|
|
16
16
|
/** Show inline error status below the button (default: `true`) */
|
|
17
17
|
showStatus?: boolean;
|
|
18
18
|
};
|
|
19
|
-
export declare function ProgressDownloadButton({
|
|
19
|
+
export declare function ProgressDownloadButton({ api, objectKey, fileName, fileSize, bucket, label, className, fillClassName, disabled, tooltipText, toast: enableToast, showStatus, beforeDownload, onDownloadStart, onProgress, onSuccess, onError, onCancel, }: ProgressDownloadButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {useRef,useEffect}from'react';import {toast}from'sonner';import {XIcon,CheckCircleIcon,AlertCircleIcon,UploadIcon,LoaderIcon,DownloadIcon,Trash2Icon}from'lucide-react';import {formatFileSize,useUploadControls,useMultiUploadControls,useDownload,useFetchDownload,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 i(...o){return twMerge(clsx(o))}var Fe=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 p({className:o,variant:e="default",size:s="default",...r}){return jsx(Button,{"data-slot":"button",className:i(Fe({variant:e,size:s,className:o})),...r})}function z({delay:o=0,...e}){return jsx(Tooltip.Provider,{"data-slot":"tooltip-provider",delay:o,...e})}function k({...o}){return jsx(Tooltip.Root,{"data-slot":"tooltip",...o})}function T({...o}){return jsx(Tooltip.Trigger,{"data-slot":"tooltip-trigger",...o})}function C({className:o,side:e="top",sideOffset:s=4,align:r="center",alignOffset:n=0,children:l,...m}){return jsx(Tooltip.Portal,{children:jsx(Tooltip.Positioner,{align:r,alignOffset:n,side:e,sideOffset:s,className:"isolate z-50",children:jsxs(Tooltip.Popup,{"data-slot":"tooltip-content",className:i("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),...m,children:[l,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 K({percent:o,size:e=20,strokeWidth:s=2.5}){let r=(e-s)/2,n=2*Math.PI*r,l=n-o/100*n;return jsxs("svg",{width:e,height:e,className:"shrink-0 -rotate-90",children:[jsx("circle",{cx:e/2,cy:e/2,r,fill:"none",stroke:"currentColor",strokeWidth:s,className:"text-muted-foreground/20"}),jsx("circle",{cx:e/2,cy:e/2,r,fill:"none",stroke:"currentColor",strokeWidth:s,strokeDasharray:n,strokeDashoffset:l,strokeLinecap:"round",className:"text-primary transition-[stroke-dashoffset] duration-200"})]})}function oe({phase:o,progress:e,error:s,fileInfo:r,onCancel:n}){return o==="idle"?null:o==="uploading"&&r?jsxs("div",{className:"flex w-full items-center gap-1.5 text-xs",children:[jsx(K,{percent:e.percent,size:14,strokeWidth:2}),jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:r.name}),jsxs("span",{className:"shrink-0 text-muted-foreground",children:[formatFileSize(e.loaded)," / ",formatFileSize(r.size)," (",e.percent,"%)"]}),jsx(p,{variant:"ghost",size:"icon",className:"ml-auto size-6 shrink-0",onClick:l=>{l.stopPropagation(),n?.();},children:jsx(XIcon,{className:"size-3.5"})})]}):o==="success"&&r?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:r.name}),jsx("span",{className:"shrink-0 text-muted-foreground",children:formatFileSize(r.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"}),r&&jsxs(Fragment,{children:[jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:r.name}),jsx("span",{className:"shrink-0 text-muted-foreground",children:formatFileSize(r.size)})]})]}),jsx("span",{className:"text-destructive",children:s??"Upload failed"})]}):o==="validating"||o==="presigning"?jsx("span",{className:"text-xs text-muted-foreground",children:"Preparing\u2026"}):null}function We({variant:o="button",objectKey:e,className:s,label:r,disabled:n,tooltipText:l="Upload file",toast:m=true,showStatus:B=true,...S}){let t=useUploadControls({...S,objectKey:e}),a=useRef(null),d=n||t.isUploading,D=useRef(t.phase);D.current!==t.phase&&(D.current=t.phase,m&&(t.phase==="idle"&&a.current&&(toast.dismiss(a.current),a.current=null),t.phase==="success"&&t.fileInfo&&(a.current&&toast.dismiss(a.current),toast.success("Upload complete",{description:formatFileSize(t.fileInfo.size)}),a.current=null),t.phase==="error"&&(a.current&&toast.dismiss(a.current),toast.error("Upload failed",{description:t.error??"Unknown error"}),a.current=null))),useEffect(()=>{if(m&&t.phase==="uploading"&&t.fileInfo){let g=a.current??`upload-${Date.now()}`;a.current=g,toast.loading("Uploading\u2026",{id:g,description:`${formatFileSize(t.progress.loaded)} / ${formatFileSize(t.fileInfo.size)} (${t.progress.percent}%)`,cancel:{label:"Cancel",onClick:()=>t.cancel()}});}},[m,t.phase,t.progress.percent,t.progress.loaded,t.fileInfo,t.cancel]);let v=B?jsx(oe,{phase:t.phase,progress:t.progress,error:t.error,fileInfo:t.fileInfo,onCancel:t.cancel}):null;return o==="dropzone"?jsxs("div",{className:i("flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-6 text-center transition-colors",d?"cursor-not-allowed border-muted-foreground/25":"cursor-pointer border-muted-foreground/25 hover:border-primary/50",s),onClick:d?void 0:t.openFilePicker,...d?{}:t.dropHandlers,children:[jsx("input",{...t.inputProps}),jsx(UploadIcon,{className:i("size-6 text-muted-foreground",d&&"opacity-50")}),jsx("p",{className:i("text-sm text-muted-foreground",d&&"opacity-50"),children:r??"Click or drag & drop to upload"}),v&&jsx("div",{className:"w-full text-left",children:v})]}):jsxs("div",{className:i("inline-flex flex-col gap-2",s),children:[jsxs("div",{className:"inline-flex items-center gap-2",children:[jsx("input",{...t.inputProps}),jsx(z,{children:jsxs(k,{children:[jsxs(T,{render:jsx(p,{size:"default",disabled:d,onClick:t.openFilePicker}),children:[jsx(UploadIcon,{"data-icon":"inline-start"}),r??"Upload file"]}),jsx(C,{children:l})]})})]}),v]})}function ce({className:o,children:e,value:s,...r}){return jsxs(Progress.Root,{value:s,"data-slot":"progress",className:i("flex flex-wrap gap-3",o),...r,children:[e,jsx(Xe,{children:jsx(qe,{})})]})}function Xe({className:o,...e}){return jsx(Progress.Track,{className:i("relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted",o),"data-slot":"progress-track",...e})}function qe({className:o,...e}){return jsx(Progress.Indicator,{"data-slot":"progress-indicator",className:i("h-full bg-primary transition-all",o),...e})}function ue({className:o,...e}){return jsx(Progress.Label,{className:i("text-xs/relaxed font-medium",o),"data-slot":"progress-label",...e})}function me({className:o,...e}){return jsx(Progress.Value,{className:i("ms-auto text-xs/relaxed text-muted-foreground tabular-nums",o),"data-slot":"progress-value",...e})}function se({phase:o,files:e,totalProgress:s,error:r,onCancel:n}){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(ce,{value:s.percent,className:"flex-1",children:[jsxs(ue,{children:[e.filter(l=>l.status==="success").length,"/",e.length," files"]}),jsx(me,{})]}),jsx(p,{variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:l=>{l.stopPropagation(),n?.();},children:jsx(XIcon,{className:"size-4"})})]}),jsx(ae,{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(ae,{files:e})]}):o==="error"?jsxs("div",{className:"flex w-full flex-col gap-1",children:[jsx("span",{className:"text-xs text-destructive",children:r??"Upload failed"}),e.length>0&&jsx(ae,{files:e})]}):o==="validating"?jsx("span",{className:"text-xs text-muted-foreground",children:"Validating\u2026"}):null}function ae({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(K,{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 je({variant:o="button",objectKey:e,className:s,label:r,disabled:n,tooltipText:l="Upload files",toast:m=true,showStatus:B=true,...S}){let t=useMultiUploadControls({...S,objectKey:e}),a=useRef(null),d=n||t.isUploading,D=useRef(t.phase);if(D.current!==t.phase&&(D.current=t.phase,m&&(t.phase==="idle"&&a.current&&(toast.dismiss(a.current),a.current=null),t.phase==="success"&&(a.current&&toast.dismiss(a.current),toast.success(`${t.files.length} file(s) uploaded`,{description:formatFileSize(t.totalProgress.total)}),a.current=null),t.phase==="error"&&t.files.length>0))){let g=t.files.filter(h=>h.status==="success").length,P=t.files.filter(h=>h.status==="error").length;a.current&&toast.dismiss(a.current),toast.error("Upload finished with errors",{description:`${g} succeeded, ${P} failed`}),a.current=null;}useEffect(()=>{if(m&&t.phase==="uploading"){let g=a.current??`multi-upload-${Date.now()}`;a.current=g;let P=t.files.filter(h=>h.status==="success").length;toast.loading(`Uploading\u2026 ${P}/${t.files.length}`,{id:g,description:`${formatFileSize(t.totalProgress.loaded)} / ${formatFileSize(t.totalProgress.total)} (${t.totalProgress.percent}%)`,cancel:{label:"Cancel",onClick:()=>t.cancel()}});}},[m,t.phase,t.totalProgress.percent,t.totalProgress.loaded,t.files,t.cancel]);let v=B?jsx(se,{phase:t.phase,files:t.files,totalProgress:t.totalProgress,error:t.error,onCancel:t.cancel}):null;return o==="dropzone"?jsxs("div",{className:i("flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-6 text-center transition-colors",d?"cursor-not-allowed border-muted-foreground/25":"cursor-pointer border-muted-foreground/25 hover:border-primary/50",s),onClick:d?void 0:t.openFilePicker,...d?{}:t.dropHandlers,children:[jsx("input",{...t.inputProps}),jsx(UploadIcon,{className:i("size-6 text-muted-foreground",d&&"opacity-50")}),jsx("p",{className:i("text-sm text-muted-foreground",d&&"opacity-50"),children:r??"Click or drag & drop files to upload"}),v&&jsx("div",{className:"w-full text-left",children:v})]}):jsxs("div",{className:i("inline-flex flex-col gap-2",s),children:[jsxs("div",{className:"inline-flex items-center gap-2",children:[jsx("input",{...t.inputProps}),jsx(z,{children:jsxs(k,{children:[jsxs(T,{render:jsx(p,{size:"default",disabled:d,onClick:t.openFilePicker}),children:[jsx(UploadIcon,{"data-icon":"inline-start"}),r??"Upload files"]}),jsx(C,{children:l})]})})]}),v]})}function at({presignApi:o,objectKey:e,fileName:s,fileSize:r,bucket:n,label:l,className:m,disabled:B,tooltipText:S="Download file",toast:t=true,showStatus:a=true,beforeDownload:d,onSuccess:D,onError:v}){let g=s??e.split("/").pop()??e,P=useDownload({presignApi:o,bucket:n,beforeDownload:d,onSuccess:$=>{t&&toast.success("Download complete",{description:`${g}${r!=null?` \xB7 ${formatFileSize(r)}`:""}`}),D?.($);},onError:($,c)=>{t&&toast.error("Download failed",{description:c instanceof Error?c.message:"Unknown error"}),v?.($,c);}}),h=P.phase==="downloading";return jsxs("div",{className:i("inline-flex flex-col gap-1.5",m),children:[jsx(z,{children:jsxs(k,{children:[jsx(T,{render:jsx(p,{size:"default",variant:"outline",disabled:B||h,onClick:()=>P.download(e,g)}),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[h?jsx(LoaderIcon,{className:"animate-spin","data-icon":"inline-start"}):jsx(DownloadIcon,{"data-icon":"inline-start"}),l??"Download"]})}),jsx(C,{children:S})]})}),a&&P.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:P.fileName??g})]}),jsx("span",{className:"text-destructive",children:P.error??"Download failed"})]})]})}function dt({presignApi:o,objectKey:e,fileName:s,fileSize:r,bucket:n,label:l,className:m,fillClassName:B,disabled:S,tooltipText:t="Download file",toast:a=true,showStatus:d=true,beforeDownload:D,onDownloadStart:v,onProgress:g,onSuccess:P,onError:h,onCancel:$}){let c=s??e.split("/").pop()??e,b=useFetchDownload({presignApi:o,bucket:n,beforeDownload:D,onDownloadStart:v,onProgress:g,onSuccess:w=>{a&&(toast.dismiss(`dl-${e}`),toast.success("Download complete",{description:`${c}${r!=null?` \xB7 ${formatFileSize(r)}`:""}`})),P?.(w);},onError:(w,V,te)=>{a&&(toast.dismiss(`dl-${e}`),toast.error("Download failed",{description:V instanceof Error?V.message:"Unknown error"})),h?.(w,V,te);},onCancel:w=>{a&&(toast.dismiss(`dl-${e}`),toast.info("Download cancelled",{description:c})),$?.(w);}}),_=b.phase==="downloading"||b.phase==="presigning",ee=()=>{if(_){b.cancel();return}b.download(e,c);};return jsxs("div",{className:i("inline-flex flex-col gap-1.5",m),children:[jsx(z,{children:jsxs(k,{children:[jsxs(T,{render:jsx(p,{size:"default",variant:"outline",disabled:S,className:i("relative min-w-24 overflow-hidden"),onClick:ee}),children:[_&&jsx("span",{className:i("absolute inset-0 bg-primary/15 transition-[width] duration-200",B),style:{width:`${b.progress.percent}%`}}),jsxs("span",{className:"relative z-10 inline-flex items-center gap-1",children:[jsx(DownloadIcon,{"data-icon":"inline-start"}),_?formatFileSize(b.progress.loaded):l??"Download"]})]}),jsx(C,{children:_?"Cancel download":t})]})}),d&&b.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:b.fileName??c})]}),jsx("span",{className:"text-destructive",children:b.error??"Download failed"})]})]})}function Pe({...o}){return jsx(AlertDialog.Root,{"data-slot":"alert-dialog",...o})}function he({...o}){return jsx(AlertDialog.Trigger,{"data-slot":"alert-dialog-trigger",...o})}function pt({...o}){return jsx(AlertDialog.Portal,{"data-slot":"alert-dialog-portal",...o})}function ct({className:o,...e}){return jsx(AlertDialog.Backdrop,{"data-slot":"alert-dialog-overlay",className:i("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 be({className:o,size:e="default",...s}){return jsxs(pt,{children:[jsx(ct,{}),jsx(AlertDialog.Popup,{"data-slot":"alert-dialog-content","data-size":e,className:i("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),...s})]})}function Ne({className:o,...e}){return jsx("div",{"data-slot":"alert-dialog-header",className:i("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 De({className:o,...e}){return jsx("div",{"data-slot":"alert-dialog-footer",className:i("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 we({className:o,...e}){return jsx("div",{"data-slot":"alert-dialog-media",className:i("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 ze({className:o,...e}){return jsx(AlertDialog.Title,{"data-slot":"alert-dialog-title",className:i("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 ke({className:o,...e}){return jsx(AlertDialog.Description,{"data-slot":"alert-dialog-description",className:i("text-xs/relaxed text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",o),...e})}function Te({className:o,...e}){return jsx(p,{"data-slot":"alert-dialog-action",className:i(o),...e})}function Ce({className:o,variant:e="outline",size:s="default",...r}){return jsx(AlertDialog.Close,{"data-slot":"alert-dialog-cancel",className:i(o),render:jsx(p,{variant:e,size:s}),...r})}function vt({presignApi:o,objectKey:e,fileName:s,fileSize:r,bucket:n,label:l,className:m,disabled:B,tooltipText:S="Delete file",toast:t=true,showStatus:a=true,confirmTitle:d="Delete file?",confirmDescription:D,beforeDelete:v,onDeleteStart:g,onSuccess:P,onError:h}){let $=s??e.split("/").pop()??e,c=useDelete({presignApi:o,bucket:n,beforeDelete:v,onDeleteStart:g,onSuccess:w=>{t&&toast.success("File deleted",{description:$}),P?.(w);},onError:(w,V,te)=>{t&&toast.error("Delete failed",{description:V instanceof Error?V.message:"Unknown error"}),h?.(w,V,te);}}),b=c.phase==="deleting",_=B||b,ee=D??`Are you sure you want to delete "${$}"${r!=null?` (${formatFileSize(r)})`:""}? This action cannot be undone.`;return jsxs("div",{className:i("inline-flex flex-col gap-1.5",m),children:[jsx("div",{className:"inline-flex items-center gap-2",children:jsxs(Pe,{open:c.phase==="confirming",onOpenChange:w=>{w||c.cancelDelete();},children:[jsx(z,{children:jsxs(k,{children:[jsxs(T,{render:jsx(he,{disabled:_,onClick:()=>c.requestDelete(e),render:jsx(p,{size:"default",variant:"destructive",disabled:_})}),children:[b?jsx(LoaderIcon,{className:"animate-spin","data-icon":"inline-start"}):jsx(Trash2Icon,{"data-icon":"inline-start"}),l??"Delete"]}),jsx(C,{children:S})]})}),jsxs(be,{children:[jsxs(Ne,{children:[jsx(we,{children:jsx(Trash2Icon,{})}),jsx(ze,{children:d}),jsx(ke,{children:ee})]}),jsxs(De,{children:[jsx(Ce,{children:"Cancel"}),jsx(Te,{variant:"destructive",onClick:()=>c.confirmDelete(),children:"Delete"})]})]})]})}),a&&c.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:$})]}),jsx("span",{className:"text-destructive",children:c.error??"Delete failed"})]})]})}export{vt as DeleteButton,at as DownloadButton,je as MultiUpload,se as MultiUploadStatus,dt as ProgressDownloadButton,We as Upload,oe as UploadStatus};//# sourceMappingURL=index.js.map
|
|
1
|
+
import {useRef,useEffect}from'react';import {toast}from'sonner';import {XIcon,CheckCircleIcon,AlertCircleIcon,UploadIcon,LoaderIcon,DownloadIcon,Trash2Icon}from'lucide-react';import {formatFileSize,useUploadControls,useMultiUploadControls,useDownload,useFetchDownload,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 Ie=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 p({className:o,variant:e="default",size:s="default",...i}){return jsx(Button,{"data-slot":"button",className:r(Ie({variant:e,size:s,className:o})),...i})}function A({delay:o=0,...e}){return jsx(Tooltip.Provider,{"data-slot":"tooltip-provider",delay:o,...e})}function U({...o}){return jsx(Tooltip.Root,{"data-slot":"tooltip",...o})}function B({...o}){return jsx(Tooltip.Trigger,{"data-slot":"tooltip-trigger",...o})}function S({className:o,side:e="top",sideOffset:s=4,align:i="center",alignOffset:l=0,children:d,...c}){return jsx(Tooltip.Portal,{children:jsx(Tooltip.Positioner,{align:i,alignOffset:l,side:e,sideOffset:s,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),...c,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 Y({percent:o,size:e=20,strokeWidth:s=2.5}){let i=(e-s)/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:s,className:"text-muted-foreground/20"}),jsx("circle",{cx:e/2,cy:e/2,r:i,fill:"none",stroke:"currentColor",strokeWidth:s,strokeDasharray:l,strokeDashoffset:d,strokeLinecap:"round",className:"text-primary transition-[stroke-dashoffset] duration-200"})]})}function te({phase:o,progress:e,error:s,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(Y,{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(p,{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:s??"Upload failed"})]}):o==="validating"||o==="presigning"?jsx("span",{className:"text-xs text-muted-foreground",children:"Preparing\u2026"}):null}function We({variant:o="button",objectKey:e,className:s,label:i,disabled:l,tooltipText:d="Upload file",toast:c=true,showStatus:D=true,...f}){let t=useUploadControls({...f,objectKey:e}),a=useRef(null),n=l||t.isUploading,C=useRef(t.phase);C.current!==t.phase&&(C.current=t.phase,c&&(t.phase==="idle"&&a.current&&(toast.dismiss(a.current),a.current=null),t.phase==="success"&&t.fileInfo&&(a.current&&toast.dismiss(a.current),toast.success("Upload complete",{description:formatFileSize(t.fileInfo.size)}),a.current=null),t.phase==="error"&&(a.current&&toast.dismiss(a.current),toast.error("Upload failed",{description:t.error??"Unknown error"}),a.current=null))),useEffect(()=>{if(c&&t.phase==="uploading"&&t.fileInfo){let b=a.current??`upload-${Date.now()}`;a.current=b,toast.loading("Uploading\u2026",{id:b,description:`${formatFileSize(t.progress.loaded)} / ${formatFileSize(t.fileInfo.size)} (${t.progress.percent}%)`,cancel:{label:"Cancel",onClick:()=>t.cancel()}});}},[c,t.phase,t.progress.percent,t.progress.loaded,t.fileInfo,t.cancel]);let h=D?jsx(te,{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",s),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"}),h&&jsx("div",{className:"w-full text-left",children:h})]}):jsxs("div",{className:r("inline-flex flex-col gap-2",s),children:[jsxs("div",{className:"inline-flex items-center gap-2",children:[jsx("input",{...t.inputProps}),jsx(A,{children:jsxs(U,{children:[jsxs(B,{render:jsx(p,{size:"default",disabled:n,onClick:t.openFilePicker}),children:[jsx(UploadIcon,{"data-icon":"inline-start"}),i??"Upload file"]}),jsx(S,{children:d})]})})]}),h]})}function pe({className:o,children:e,value:s,...i}){return jsxs(Progress.Root,{value:s,"data-slot":"progress",className:r("flex flex-wrap gap-3",o),...i,children:[e,jsx(Xe,{children:jsx(qe,{})})]})}function Xe({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 qe({className:o,...e}){return jsx(Progress.Indicator,{"data-slot":"progress-indicator",className:r("h-full bg-primary transition-all",o),...e})}function ce({className:o,...e}){return jsx(Progress.Label,{className:r("text-xs/relaxed font-medium",o),"data-slot":"progress-label",...e})}function ue({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 ae({phase:o,files:e,totalProgress:s,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(pe,{value:s.percent,className:"flex-1",children:[jsxs(ce,{children:[e.filter(d=>d.status==="success").length,"/",e.length," files"]}),jsx(ue,{})]}),jsx(p,{variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:d=>{d.stopPropagation(),l?.();},children:jsx(XIcon,{className:"size-4"})})]}),jsx(ie,{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(ie,{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(ie,{files:e})]}):o==="validating"?jsx("span",{className:"text-xs text-muted-foreground",children:"Validating\u2026"}):null}function ie({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(Y,{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 je({variant:o="button",objectKey:e,className:s,label:i,disabled:l,tooltipText:d="Upload files",toast:c=true,showStatus:D=true,...f}){let t=useMultiUploadControls({...f,objectKey:e}),a=useRef(null),n=l||t.isUploading,C=useRef(t.phase);if(C.current!==t.phase&&(C.current=t.phase,c&&(t.phase==="idle"&&a.current&&(toast.dismiss(a.current),a.current=null),t.phase==="success"&&(a.current&&toast.dismiss(a.current),toast.success(`${t.files.length} file(s) uploaded`,{description:formatFileSize(t.totalProgress.total)}),a.current=null),t.phase==="error"&&t.files.length>0))){let b=t.files.filter(T=>T.status==="success").length,F=t.files.filter(T=>T.status==="error").length;a.current&&toast.dismiss(a.current),toast.error("Upload finished with errors",{description:`${b} succeeded, ${F} failed`}),a.current=null;}useEffect(()=>{if(c&&t.phase==="uploading"){let b=a.current??`multi-upload-${Date.now()}`;a.current=b;let F=t.files.filter(T=>T.status==="success").length;toast.loading(`Uploading\u2026 ${F}/${t.files.length}`,{id:b,description:`${formatFileSize(t.totalProgress.loaded)} / ${formatFileSize(t.totalProgress.total)} (${t.totalProgress.percent}%)`,cancel:{label:"Cancel",onClick:()=>t.cancel()}});}},[c,t.phase,t.totalProgress.percent,t.totalProgress.loaded,t.files,t.cancel]);let h=D?jsx(ae,{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",s),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"}),h&&jsx("div",{className:"w-full text-left",children:h})]}):jsxs("div",{className:r("inline-flex flex-col gap-2",s),children:[jsxs("div",{className:"inline-flex items-center gap-2",children:[jsx("input",{...t.inputProps}),jsx(A,{children:jsxs(U,{children:[jsxs(B,{render:jsx(p,{size:"default",disabled:n,onClick:t.openFilePicker}),children:[jsx(UploadIcon,{"data-icon":"inline-start"}),i??"Upload files"]}),jsx(S,{children:d})]})})]}),h]})}function rt({api:o,objectKey:e,fileName:s,label:i,className:l,disabled:d,toast:c=true}){let D=s??e.split("/").pop()??e,f=useDownload({api:o,onSuccess:()=>{c&&toast.success("Download complete",{description:D});},onError:(a,n)=>{c&&toast.error("Download failed",{description:n instanceof Error?n.message:"Unknown error"});}}),t=f.phase==="downloading";return jsxs("div",{className:r("inline-flex flex-col gap-1.5",l),children:[jsx(p,{size:"default",variant:"outline",disabled:d||t,onClick:()=>f.download(e,D),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[t?jsx(LoaderIcon,{className:"animate-spin","data-icon":"inline-start"}):jsx(DownloadIcon,{"data-icon":"inline-start"}),i??"Download"]})}),f.phase==="error"&&jsx("span",{className:"text-xs text-destructive",children:f.error??"Download failed"})]})}function nt({api:o,objectKey:e,fileName:s,fileSize:i,bucket:l,label:d,className:c,fillClassName:D,disabled:f,tooltipText:t="Download file",toast:a=true,showStatus:n=true,beforeDownload:C,onDownloadStart:h,onProgress:b,onSuccess:F,onError:T,onCancel:q}){let x=s??e.split("/").pop()??e,v=useFetchDownload({api:o,bucket:l,beforeDownload:C,onDownloadStart:h,onProgress:b,onSuccess:N=>{a&&(toast.dismiss(`dl-${e}`),toast.success("Download complete",{description:`${x}${i!=null?` \xB7 ${formatFileSize(i)}`:""}`})),F?.(N);},onError:(N,M,ee)=>{a&&(toast.dismiss(`dl-${e}`),toast.error("Download failed",{description:M instanceof Error?M.message:"Unknown error"})),T?.(N,M,ee);},onCancel:N=>{a&&(toast.dismiss(`dl-${e}`),toast.info("Download cancelled",{description:x})),q?.(N);}}),R=v.phase==="downloading"||v.phase==="presigning",j=()=>{if(R){v.cancel();return}v.download(e,x);};return jsxs("div",{className:r("inline-flex flex-col gap-1.5",c),children:[jsx(A,{children:jsxs(U,{children:[jsxs(B,{render:jsx(p,{size:"default",variant:"outline",disabled:f,className:r("relative min-w-24 overflow-hidden"),onClick:j}),children:[R&&jsx("span",{className:r("absolute inset-0 bg-primary/15 transition-[width] duration-200",D),style:{width:`${v.progress.percent}%`}}),jsxs("span",{className:"relative z-10 inline-flex items-center gap-1",children:[jsx(DownloadIcon,{"data-icon":"inline-start"}),R?formatFileSize(v.progress.loaded):d??"Download"]})]}),jsx(S,{children:R?"Cancel download":t})]})}),n&&v.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:v.fileName??x})]}),jsx("span",{className:"text-destructive",children:v.error??"Download failed"})]})]})}function Pe({...o}){return jsx(AlertDialog.Root,{"data-slot":"alert-dialog",...o})}function he({...o}){return jsx(AlertDialog.Trigger,{"data-slot":"alert-dialog-trigger",...o})}function lt({...o}){return jsx(AlertDialog.Portal,{"data-slot":"alert-dialog-portal",...o})}function dt({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 be({className:o,size:e="default",...s}){return jsxs(lt,{children:[jsx(dt,{}),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),...s})]})}function Ne({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 De({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 we({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 ze({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 ke({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 Ce({className:o,...e}){return jsx(p,{"data-slot":"alert-dialog-action",className:r(o),...e})}function Te({className:o,variant:e="outline",size:s="default",...i}){return jsx(AlertDialog.Close,{"data-slot":"alert-dialog-cancel",className:r(o),render:jsx(p,{variant:e,size:s}),...i})}function ft({api:o,objectKey:e,fileName:s,fileSize:i,bucket:l,label:d,className:c,disabled:D,tooltipText:f="Delete file",toast:t=true,showStatus:a=true,confirmTitle:n="Delete file?",confirmDescription:C,beforeDelete:h,onDeleteStart:b,onSuccess:F,onError:T}){let q=s??e.split("/").pop()??e,x=useDelete({api:o,bucket:l,beforeDelete:h,onDeleteStart:b,onSuccess:N=>{t&&toast.success("File deleted",{description:q}),F?.(N);},onError:(N,M,ee)=>{t&&toast.error("Delete failed",{description:M instanceof Error?M.message:"Unknown error"}),T?.(N,M,ee);}}),v=x.phase==="deleting",R=D||v,j=C??`Are you sure you want to delete "${q}"${i!=null?` (${formatFileSize(i)})`:""}? This action cannot be undone.`;return jsxs("div",{className:r("inline-flex flex-col gap-1.5",c),children:[jsx("div",{className:"inline-flex items-center gap-2",children:jsxs(Pe,{open:x.phase==="confirming",onOpenChange:N=>{N||x.cancelDelete();},children:[jsx(A,{children:jsxs(U,{children:[jsxs(B,{render:jsx(he,{disabled:R,onClick:()=>x.requestDelete(e),render:jsx(p,{size:"default",variant:"destructive",disabled:R})}),children:[v?jsx(LoaderIcon,{className:"animate-spin","data-icon":"inline-start"}):jsx(Trash2Icon,{"data-icon":"inline-start"}),d??"Delete"]}),jsx(S,{children:f})]})}),jsxs(be,{children:[jsxs(Ne,{children:[jsx(we,{children:jsx(Trash2Icon,{})}),jsx(ze,{children:n}),jsx(ke,{children:j})]}),jsxs(De,{children:[jsx(Te,{children:"Cancel"}),jsx(Ce,{variant:"destructive",onClick:()=>x.confirmDelete(),children:"Delete"})]})]})]})}),a&&x.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:q})]}),jsx("span",{className:"text-destructive",children:x.error??"Delete failed"})]})]})}export{ft as DeleteButton,rt as DownloadButton,je as MultiUpload,ae as MultiUploadStatus,nt as ProgressDownloadButton,We as Upload,te as UploadStatus};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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/download/progress-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","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","bucket","beforeDownload","onSuccess","onError","displayName","dl","useDownload","key","isLoading","LoaderIcon","DownloadIcon","ProgressDownloadButton","fillClassName","onDownloadStart","onProgress","useFetchDownload","isDownloading","handleClick","AlertDialog","AlertDialogPrimitive","AlertDialogTrigger","AlertDialogPortal","AlertDialogOverlay","AlertDialogContent","AlertDialogHeader","AlertDialogFooter","AlertDialogMedia","AlertDialogTitle","AlertDialogDescription","AlertDialogAction","AlertDialogCancel","DeleteButton","confirmTitle","confirmDescription","beforeDelete","onDeleteStart","del","useDelete","isDeleting","description","open","Trash2Icon"],"mappings":"ooBAGO,SAASA,KAAMC,CAAAA,CAAsB,CAC1C,OAAOC,OAAAA,CAAQC,IAAAA,CAAKF,CAAM,CAAC,CAC7B,CCEA,IAAMG,EAAAA,CAAiBC,IACrB,mnBAAA,CACA,CACE,SAAU,CACR,OAAA,CAAS,CACP,OAAA,CAAS,wDAAA,CACT,QACE,6HAAA,CACF,SAAA,CACE,kIACF,KAAA,CACE,kHAAA,CACF,YACE,6NAAA,CACF,IAAA,CAAM,iDACR,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CACE,6IAAA,CACF,GAAI,wJAAA,CACJ,EAAA,CAAI,4IACJ,EAAA,CAAI,yIAAA,CACJ,KAAM,+CAAA,CACN,SAAA,CAAW,2DACX,SAAA,CAAW,6CAAA,CACX,UAAW,6CACb,CACF,CAAA,CACA,eAAA,CAAiB,CACf,OAAA,CAAS,SAAA,CACT,KAAM,SACR,CACF,CACF,CAAA,CAEA,SAASC,EAAO,CACd,SAAA,CAAAC,EACA,OAAA,CAAAC,CAAAA,CAAU,UACV,IAAA,CAAAC,CAAAA,CAAO,UACP,GAAGC,CACL,EAAgE,CAC9D,OACEC,IAACC,MAAAA,CAAA,CACC,YAAU,QAAA,CACV,SAAA,CAAWZ,EAAGI,EAAAA,CAAe,CAAE,QAAAI,CAAAA,CAAS,IA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UAAAA,CAAA,EAAW,CAAA,CACd,CAAA,CACAhH,IAACkG,EAAAA,CAAA,CAAkB,SAAAK,CAAAA,CAAa,CAAA,CAChCvG,IAACmG,EAAAA,CAAA,CAAwB,SAAAW,EAAAA,CAAY,CAAA,CAAA,CACvC,EACAjG,IAAAA,CAACmF,EAAAA,CAAA,CACC,QAAA,CAAA,CAAAhG,GAAAA,CAACqG,GAAA,CAAkB,QAAA,CAAA,QAAA,CAAM,EACzBrG,GAAAA,CAACoG,EAAAA,CAAA,CACC,OAAA,CAAQ,aAAA,CACR,QAAS,IAAMO,CAAAA,CAAI,eAAc,CAAG,QAAA,CAAA,QAAA,CAEtC,GACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,EACF,CAAA,CAECtE,CAAAA,EAAcsE,EAAI,KAAA,GAAU,OAAA,EAC3B9F,KAAC,KAAA,CAAA,CAAI,SAAA,CAAU,8BACb,QAAA,CAAA,CAAAA,IAAAA,CAAC,OAAI,SAAA,CAAU,2BAAA,CACb,UAAAb,GAAAA,CAAC6B,eAAAA,CAAA,CAAgB,SAAA,CAAU,oCAAA,CAAqC,EAChE7B,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,+BAAA,CAAiC,QAAA,CAAA2E,EAAY,CAAA,CAAA,CAC/D,CAAA,CACA3E,IAAC,MAAA,CAAA,CAAK,SAAA,CAAU,mBACb,QAAA,CAAA2G,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/react\";\nimport type { UploadPhase, UploadProgress } from \"@better-s3/react\";\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/react\";\nimport type { UseUploadControlsOptions } 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 = UseUploadControlsOptions & {\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/react\";\nimport type { UploadProgress, MultiUploadFileState } from \"@better-s3/react\";\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/react\";\nimport type { UseMultiUploadControlsOptions } 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 = UseMultiUploadControlsOptions & {\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, LoaderIcon } from \"lucide-react\";\nimport { toast } from \"sonner\";\nimport { cn } from \"@/lib/utils\";\nimport { formatFileSize } from \"@better-s3/react\";\nimport type { PresignApi, DownloadHooks } from \"@better-s3/react\";\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 /** Target bucket (overrides server default) */\n bucket?: string;\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};\n\nexport function DownloadButton({\n presignApi,\n objectKey,\n fileName,\n fileSize,\n bucket,\n label,\n className,\n disabled,\n tooltipText = \"Download file\",\n toast: enableToast = true,\n showStatus = true,\n beforeDownload,\n onSuccess,\n onError,\n}: DownloadButtonProps) {\n const displayName = fileName ?? objectKey.split(\"/\").pop() ?? objectKey;\n\n const dl = useDownload({\n presignApi,\n bucket,\n beforeDownload,\n onSuccess: (key) => {\n if (enableToast) {\n toast.success(\"Download complete\", {\n description: `${displayName}${fileSize != null ? ` · ${formatFileSize(fileSize)}` : \"\"}`,\n });\n }\n onSuccess?.(key);\n },\n onError: (key, error) => {\n if (enableToast) {\n toast.error(\"Download failed\", {\n description: error instanceof Error ? error.message : \"Unknown error\",\n });\n }\n onError?.(key, error);\n },\n });\n\n const isLoading = dl.phase === \"downloading\";\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 || isLoading}\n onClick={() => dl.download(objectKey, displayName)}\n />\n }>\n <span className=\"inline-flex items-center gap-1\">\n {isLoading ? (\n <LoaderIcon className=\"animate-spin\" data-icon=\"inline-start\" />\n ) : (\n <DownloadIcon data-icon=\"inline-start\" />\n )}\n {label ?? \"Download\"}\n </span>\n </TooltipTrigger>\n <TooltipContent>{tooltipText}</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 { DownloadIcon, AlertCircleIcon } from \"lucide-react\";\nimport { toast } from \"sonner\";\nimport { cn } from \"@/lib/utils\";\nimport { formatFileSize } from \"@better-s3/react\";\nimport type { PresignApi, FetchDownloadHooks } from \"@better-s3/react\";\nimport { useFetchDownload } 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 ProgressDownloadButtonProps = FetchDownloadHooks & {\n presignApi: PresignApi;\n objectKey: string;\n fileName?: string;\n fileSize?: number;\n /** Target bucket (overrides server default) */\n bucket?: string;\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\nexport function ProgressDownloadButton({\n presignApi,\n objectKey,\n fileName,\n fileSize,\n bucket,\n label,\n className,\n fillClassName,\n disabled,\n tooltipText = \"Download file\",\n toast: enableToast = true,\n showStatus = true,\n beforeDownload,\n onDownloadStart,\n onProgress,\n onSuccess,\n onError,\n onCancel,\n}: ProgressDownloadButtonProps) {\n const displayName = fileName ?? objectKey.split(\"/\").pop() ?? objectKey;\n\n const dl = useFetchDownload({\n presignApi,\n bucket,\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 isDownloading = dl.phase === \"downloading\" || dl.phase === \"presigning\";\n\n const handleClick = () => {\n if (isDownloading) {\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}\n className={cn(\"relative min-w-24 overflow-hidden\")}\n onClick={handleClick}\n />\n }>\n {isDownloading && (\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 className=\"relative z-10 inline-flex items-center gap-1\">\n <DownloadIcon data-icon=\"inline-start\" />\n {isDownloading\n ? formatFileSize(dl.progress.loaded)\n : (label ?? \"Download\")}\n </span>\n </TooltipTrigger>\n <TooltipContent>\n {isDownloading ? \"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/react\";\nimport type { PresignApi, DeleteHooks } from \"@better-s3/react\";\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 /** Target bucket (overrides server default) */\n bucket?: string;\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 bucket,\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 bucket,\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"]}
|
|
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/download/progress-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","api","fileName","displayName","dl","useDownload","_key","isLoading","LoaderIcon","DownloadIcon","ProgressDownloadButton","fileSize","bucket","fillClassName","beforeDownload","onDownloadStart","onProgress","onSuccess","onError","useFetchDownload","key","isDownloading","handleClick","AlertDialog","AlertDialogPrimitive","AlertDialogTrigger","AlertDialogPortal","AlertDialogOverlay","AlertDialogContent","AlertDialogHeader","AlertDialogFooter","AlertDialogMedia","AlertDialogTitle","AlertDialogDescription","AlertDialogAction","AlertDialogCancel","DeleteButton","confirmTitle","confirmDescription","beforeDelete","onDeleteStart","del","useDelete","isDeleting","description","open","Trash2Icon"],"mappings":"ooBAGO,SAASA,CAAAA,CAAAA,GAAMC,CAAAA,CAAsB,CAC1C,OAAOC,OAAAA,CAAQC,KAAKF,CAAM,CAAC,CAC7B,CCEA,IAAMG,GAAiBC,GAAAA,CACrB,mnBAAA,CACA,CACE,QAAA,CAAU,CACR,QAAS,CACP,OAAA,CAAS,yDACT,OAAA,CACE,6HAAA,CACF,UACE,iIAAA,CACF,KAAA,CACE,kHAAA,CACF,WAAA,CACE,8NACF,IAAA,CAAM,iDACR,EACA,IAAA,CAAM,CACJ,QACE,6IAAA,CACF,EAAA,CAAI,yJACJ,EAAA,CAAI,2IAAA,CACJ,GAAI,yIAAA,CACJ,IAAA,CAAM,gDACN,SAAA,CAAW,0DAAA,CACX,UAAW,6CAAA,CACX,SAAA,CAAW,6CACb,CACF,EACA,eAAA,CAAiB,CACf,QAAS,SAAA,CACT,IAAA,CAAM,SACR,CACF,CACF,EAEA,SAASC,CAAAA,CAAO,CACd,SAAA,CAAAC,CAAAA,CACA,QAAAC,CAAAA,CAAU,SAAA,CACV,KAAAC,CAAAA,CAAO,SAAA,CACP,GAAGC,CACL,EAAgE,CAC9D,OACEC,IAACC,MAAAA,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,8BACb,QAAA,CAAA,CAAAA,IAAAA,CAAC,OAAI,SAAA,CAAU,2BAAA,CACb,UAAAb,GAAAA,CAAC8B,eAAAA,CAAA,CAAgB,SAAA,CAAU,oCAAA,CAAqC,EAChE9B,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,+BAAA,CAAiC,QAAA,CAAAuE,EAAY,CAAA,CAAA,CAC/D,CAAA,CACAvE,IAAC,MAAA,CAAA,CAAK,SAAA,CAAU,mBACb,QAAA,CAAA6G,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/react\";\nimport type { UploadPhase, UploadProgress } from \"@better-s3/react\";\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/react\";\nimport type { UseUploadControlsOptions } 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 = UseUploadControlsOptions & {\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/react\";\nimport type { UploadProgress, MultiUploadFileState } from \"@better-s3/react\";\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/react\";\nimport type { UseMultiUploadControlsOptions } 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 = UseMultiUploadControlsOptions & {\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, LoaderIcon } from \"lucide-react\";\nimport { toast } from \"sonner\";\nimport { cn } from \"@/lib/utils\";\nimport type { S3Api } from \"@better-s3/react\";\nimport { useDownload } from \"@better-s3/react\";\nimport { Button } from \"@/components/ui/button\";\n\ntype DownloadButtonProps = {\n api: S3Api;\n objectKey: string;\n fileName?: string;\n label?: string;\n className?: string;\n disabled?: boolean;\n /** Enable sonner toasts (default: `true`) */\n toast?: boolean;\n};\n\nexport function DownloadButton({\n api,\n objectKey,\n fileName,\n label,\n className,\n disabled,\n toast: enableToast = true,\n}: DownloadButtonProps) {\n const displayName = fileName ?? objectKey.split(\"/\").pop() ?? objectKey;\n\n const dl = useDownload({\n api,\n onSuccess: () => {\n if (enableToast)\n toast.success(\"Download complete\", { description: displayName });\n },\n onError: (_key, error) => {\n if (enableToast) {\n toast.error(\"Download failed\", {\n description: error instanceof Error ? error.message : \"Unknown error\",\n });\n }\n },\n });\n\n const isLoading = dl.phase === \"downloading\";\n\n return (\n <div className={cn(\"inline-flex flex-col gap-1.5\", className)}>\n <Button\n size=\"default\"\n variant=\"outline\"\n disabled={disabled || isLoading}\n onClick={() => dl.download(objectKey, displayName)}>\n <span className=\"inline-flex items-center gap-1\">\n {isLoading ? (\n <LoaderIcon className=\"animate-spin\" data-icon=\"inline-start\" />\n ) : (\n <DownloadIcon data-icon=\"inline-start\" />\n )}\n {label ?? \"Download\"}\n </span>\n </Button>\n\n {dl.phase === \"error\" && (\n <span className=\"text-xs text-destructive\">\n {dl.error ?? \"Download failed\"}\n </span>\n )}\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/react\";\nimport type { S3Api, FetchDownloadHooks } from \"@better-s3/react\";\nimport { useFetchDownload } 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 ProgressDownloadButtonProps = FetchDownloadHooks & {\n api: S3Api;\n objectKey: string;\n fileName?: string;\n fileSize?: number;\n /** Target bucket (overrides server default) */\n bucket?: string;\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\nexport function ProgressDownloadButton({\n api,\n objectKey,\n fileName,\n fileSize,\n bucket,\n label,\n className,\n fillClassName,\n disabled,\n tooltipText = \"Download file\",\n toast: enableToast = true,\n showStatus = true,\n beforeDownload,\n onDownloadStart,\n onProgress,\n onSuccess,\n onError,\n onCancel,\n}: ProgressDownloadButtonProps) {\n const displayName = fileName ?? objectKey.split(\"/\").pop() ?? objectKey;\n\n const dl = useFetchDownload({\n api,\n bucket,\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 isDownloading = dl.phase === \"downloading\" || dl.phase === \"presigning\";\n\n const handleClick = () => {\n if (isDownloading) {\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}\n className={cn(\"relative min-w-24 overflow-hidden\")}\n onClick={handleClick}\n />\n }>\n {isDownloading && (\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 className=\"relative z-10 inline-flex items-center gap-1\">\n <DownloadIcon data-icon=\"inline-start\" />\n {isDownloading\n ? formatFileSize(dl.progress.loaded)\n : (label ?? \"Download\")}\n </span>\n </TooltipTrigger>\n <TooltipContent>\n {isDownloading ? \"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/react\";\nimport type { S3Api, DeleteHooks } from \"@better-s3/react\";\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 api: S3Api;\n objectKey: string;\n fileName?: string;\n fileSize?: number;\n /** Target bucket (overrides server default) */\n bucket?: string;\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 api,\n objectKey,\n fileName,\n fileSize,\n bucket,\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 api,\n bucket,\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-s3/ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Pre-built React UI components for S3 file upload, download, and delete",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"styles.css"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@better-s3/react": "2.
|
|
39
|
+
"@better-s3/react": "2.3.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@base-ui/react": ">=1.0.0",
|