@better-s3/ui 2.3.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/upload/upload-button.d.ts +12 -0
- package/dist/upload/upload-dropzone.d.ts +11 -0
- package/dist/upload/use-upload-toast.d.ts +6 -0
- package/package.json +2 -2
- package/dist/upload/multi-upload.d.ts +0 -13
- package/dist/upload/upload.d.ts +0 -13
package/README.md
CHANGED
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
# @better-s3/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Styled React components for better-s3 flows. The package ships Mira-flavored, shadcn-style components for upload, multi-upload, download, and delete.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use it when you want production-ready UI fast. Keep the package if you want speed, restyle it with your own shadcn theme tokens, or build fully custom components with [`@better-s3/react`](../better-s3-react) when you want full source ownership.
|
|
6
|
+
|
|
7
|
+
> These components are designed around the [shadcn](https://ui.shadcn.com) styling model. Your app should already expose shadcn-style CSS variables such as `--background`, `--foreground`, `--primary`, `--border`, and friends.
|
|
6
8
|
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
|
-
pnpm add @better-s3/ui @better-s3/server
|
|
12
|
+
pnpm add @better-s3/ui @better-s3/server @aws-sdk/client-s3
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Peer dependencies:
|
|
16
|
+
|
|
17
|
+
- `react`
|
|
18
|
+
- `@base-ui/react`
|
|
19
|
+
- `class-variance-authority`
|
|
20
|
+
- `clsx`
|
|
21
|
+
- `lucide-react`
|
|
22
|
+
- `sonner`
|
|
23
|
+
- `tailwind-merge`
|
|
14
24
|
|
|
15
25
|
## Setup
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
Add the package stylesheet to your global CSS file and make sure your app already includes shadcn theme variables.
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
@import "shadcn/tailwind.css";
|
|
31
|
+
@import "@better-s3/ui/styles.css";
|
|
19
32
|
```
|
|
20
33
|
|
|
34
|
+
If your project already uses shadcn with CSS variables, that is usually enough.
|
|
35
|
+
|
|
36
|
+
If you prefer source-owned UI instead of consuming the package, keep the better-s3 server and hook layers and compose your own components with `@better-s3/react` plus the [shadcn CLI](https://ui.shadcn.com/docs/cli).
|
|
37
|
+
|
|
21
38
|
## Components
|
|
22
39
|
|
|
23
40
|
```tsx
|
|
@@ -49,6 +66,12 @@ const api = createS3Api("/api/s3");
|
|
|
49
66
|
<DeleteButton api={api} objectKey="report.pdf" />
|
|
50
67
|
```
|
|
51
68
|
|
|
69
|
+
## When to use this package
|
|
70
|
+
|
|
71
|
+
- Use `@better-s3/ui` when you want fast setup with polished defaults.
|
|
72
|
+
- Use `@better-s3/react` when you want to build your own UI with your own components.
|
|
73
|
+
- Mix both when you want ready-made upload flows now and custom components later.
|
|
74
|
+
|
|
52
75
|
## License
|
|
53
76
|
|
|
54
77
|
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { UploadButton, type UploadButtonProps } from "./upload/upload-button";
|
|
2
|
+
export { UploadDropzone, type UploadDropzoneProps, } from "./upload/upload-dropzone";
|
|
3
3
|
export { UploadStatus } from "./upload/upload-status";
|
|
4
4
|
export { MultiUploadStatus } from "./upload/multi-upload-status";
|
|
5
5
|
export { DownloadButton } from "./download/download-button";
|
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 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
|
|
1
|
+
import {XIcon,CheckCircleIcon,AlertCircleIcon,UploadIcon,LoaderIcon,DownloadIcon,Trash2Icon}from'lucide-react';import {formatFileSize,useUploadControls,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 {useRef,useEffect}from'react';import {toast}from'sonner';import {AlertDialog}from'@base-ui/react/alert-dialog';function a(...e){return twMerge(clsx(e))}var Ue=cva("group/button cursor-pointer inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs/relaxed font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",xs:"h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-2.5",sm:"h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",lg:"h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2 [&_svg:not([class*='size-'])]:size-4",icon:"size-7 [&_svg:not([class*='size-'])]:size-3.5","icon-xs":"size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5","icon-sm":"size-6 [&_svg:not([class*='size-'])]:size-3","icon-lg":"size-8 [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default",size:"default"}});function c({className:e,variant:t="default",size:o="default",...r}){return jsx(Button,{"data-slot":"button",className:a(Ue({variant:t,size:o,className:e})),...r})}function A({delay:e=0,...t}){return jsx(Tooltip.Provider,{"data-slot":"tooltip-provider",delay:e,...t})}function B({...e}){return jsx(Tooltip.Root,{"data-slot":"tooltip",...e})}function S({...e}){return jsx(Tooltip.Trigger,{"data-slot":"tooltip-trigger",...e})}function I({className:e,side:t="top",sideOffset:o=4,align:r="center",alignOffset:l=0,children:n,...s}){return jsx(Tooltip.Portal,{children:jsx(Tooltip.Positioner,{align:r,alignOffset:l,side:t,sideOffset:o,className:"isolate z-50",children:jsxs(Tooltip.Popup,{"data-slot":"tooltip-content",className:a("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",e),...s,children:[n,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 W({percent:e,size:t=20,strokeWidth:o=2.5}){let r=(t-o)/2,l=2*Math.PI*r,n=l-e/100*l;return jsxs("svg",{width:t,height:t,className:"shrink-0 -rotate-90",children:[jsx("circle",{cx:t/2,cy:t/2,r,fill:"none",stroke:"currentColor",strokeWidth:o,className:"text-muted-foreground/20"}),jsx("circle",{cx:t/2,cy:t/2,r,fill:"none",stroke:"currentColor",strokeWidth:o,strokeDasharray:l,strokeDashoffset:n,strokeLinecap:"round",className:"text-primary transition-[stroke-dashoffset] duration-200"})]})}function L({phase:e,progress:t,error:o,fileInfo:r,onCancel:l}){return e==="idle"?null:e==="uploading"&&r?jsxs("div",{className:"flex w-full items-center gap-1.5 text-xs",children:[jsx(W,{percent:t.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(t.loaded)," / ",formatFileSize(r.size)," (",t.percent,"%)"]}),jsx(c,{variant:"ghost",size:"icon",className:"ml-auto size-6 shrink-0",onClick:n=>{n.stopPropagation(),l?.();},children:jsx(XIcon,{className:"size-3.5"})})]}):e==="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)})]}):e==="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:o??"Upload failed"})]}):e==="validating"||e==="presigning"?jsx("span",{className:"text-xs text-muted-foreground",children:"Preparing\u2026"}):null}function se({className:e,children:t,value:o,...r}){return jsxs(Progress.Root,{value:o,"data-slot":"progress",className:a("flex flex-wrap gap-3",e),...r,children:[t,jsx(_e,{children:jsx(Me,{})})]})}function _e({className:e,...t}){return jsx(Progress.Track,{className:a("relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted",e),"data-slot":"progress-track",...t})}function Me({className:e,...t}){return jsx(Progress.Indicator,{"data-slot":"progress-indicator",className:a("h-full bg-primary transition-all",e),...t})}function ne({className:e,...t}){return jsx(Progress.Label,{className:a("text-xs/relaxed font-medium",e),"data-slot":"progress-label",...t})}function le({className:e,...t}){return jsx(Progress.Value,{className:a("ms-auto text-xs/relaxed text-muted-foreground tabular-nums",e),"data-slot":"progress-value",...t})}function E({phase:e,files:t,totalProgress:o,error:r,onCancel:l}){return e==="idle"?null:e==="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(se,{value:o.percent,className:"flex-1",children:[jsxs(ne,{children:[t.filter(n=>n.status==="success").length,"/",t.length," files"]}),jsx(le,{})]}),jsx(c,{variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:n=>{n.stopPropagation(),l?.();},children:jsx(XIcon,{className:"size-4"})})]}),jsx(ae,{files:t})]}):e==="success"?jsxs("div",{className:"flex w-full flex-col gap-1",children:[jsxs("span",{className:"text-xs text-green-600",children:["All ",t.length," file(s) uploaded"]}),jsx(ae,{files:t})]}):e==="error"?jsxs("div",{className:"flex w-full flex-col gap-1",children:[jsx("span",{className:"text-xs text-destructive",children:r??"Upload failed"}),t.length>0&&jsx(ae,{files:t})]}):e==="validating"?jsx("span",{className:"text-xs text-muted-foreground",children:"Validating\u2026"}):null}function ae({files:e}){return jsx("ul",{className:"flex flex-col gap-1",children:e.map(t=>jsxs("li",{className:"flex flex-col gap-0.5 text-xs",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[t.status==="success"&&jsx(CheckCircleIcon,{className:"size-3.5 shrink-0 text-green-600"}),t.status==="error"&&jsx(AlertCircleIcon,{className:"size-3.5 shrink-0 text-destructive"}),(t.status==="pending"||t.status==="uploading")&&jsx(W,{percent:t.status==="uploading"?t.progress.percent:0,size:14,strokeWidth:2}),jsx("span",{className:"max-w-32 min-w-16 truncate sm:max-w-48",children:t.fileName}),t.status==="uploading"?jsxs("span",{className:"shrink-0 text-muted-foreground",children:[formatFileSize(t.progress.loaded)," /"," ",formatFileSize(t.fileSize)," (",t.progress.percent,"%)"]}):jsx("span",{className:"shrink-0 text-muted-foreground",children:formatFileSize(t.fileSize)})]}),t.status==="error"&&t.error&&jsx("span",{className:"pl-5 text-destructive",children:t.error})]},t.id))})}function q(e,t){let o=useRef(null),r=e.mode==="multi",l=useRef(e.phase);if(l.current!==e.phase&&(l.current=e.phase,t&&(e.phase==="idle"&&o.current&&(toast.dismiss(o.current),o.current=null),e.phase==="success"&&(o.current&&toast.dismiss(o.current),r?toast.success(`${e.files.length} file(s) uploaded`,{description:formatFileSize(e.totalProgress.total)}):e.fileInfo&&toast.success("Upload complete",{description:formatFileSize(e.fileInfo.size)}),o.current=null),e.phase==="error"))){if(o.current&&toast.dismiss(o.current),r&&e.files.length>0){let n=e.files.filter(i=>i.status==="success").length,s=e.files.filter(i=>i.status==="error").length;toast.error("Upload finished with errors",{description:`${n} succeeded, ${s} failed`});}else toast.error("Upload failed",{description:e.error??"Unknown error"});o.current=null;}useEffect(()=>{if(!t||e.phase!=="uploading")return;let n=o.current??`upload-${Date.now()}`;if(o.current=n,r){let s=e.files.filter(i=>i.status==="success").length;toast.loading(`Uploading\u2026 ${s}/${e.files.length}`,{id:n,description:`${formatFileSize(e.totalProgress.loaded)} / ${formatFileSize(e.totalProgress.total)} (${e.totalProgress.percent}%)`,cancel:{label:"Cancel",onClick:()=>e.cancel()}});}else e.fileInfo&&toast.loading("Uploading\u2026",{id:n,description:`${formatFileSize(e.progress.loaded)} / ${formatFileSize(e.fileInfo.size)} (${e.progress.percent}%)`,cancel:{label:"Cancel",onClick:()=>e.cancel()}});},[t,e.phase,r,e.progress.loaded,e.progress.percent,e.totalProgress.loaded,e.totalProgress.total,e.totalProgress.percent,e.fileInfo,e.files,e.cancel]);}function qe({className:e,label:t,disabled:o,tooltipText:r,toast:l=true,showStatus:n=true,...s}){let i=useUploadControls(s),d=i.mode==="multi",v=o||i.isUploading;q(i,l);let P=n?d?jsx(E,{phase:i.phase,files:i.files,totalProgress:i.totalProgress,error:i.error,onCancel:i.cancel}):jsx(L,{phase:i.phase,progress:i.progress,error:i.error,fileInfo:i.fileInfo,onCancel:i.cancel}):null;return jsxs("div",{className:a("inline-flex flex-col gap-2",e),children:[jsxs("div",{className:"inline-flex items-center gap-2",children:[jsx("input",{...i.inputProps}),jsx(A,{children:jsxs(B,{children:[jsxs(S,{render:jsx(c,{size:"default",disabled:v,onClick:i.openFilePicker}),children:[jsx(UploadIcon,{"data-icon":"inline-start"}),t??(d?"Upload files":"Upload file")]}),jsx(I,{children:r??(d?"Upload files":"Upload file")})]})})]}),P]})}function Qe({className:e,label:t,disabled:o,toast:r=true,showStatus:l=true,...n}){let s=useUploadControls(n),i=s.mode==="multi",d=o||s.isUploading;q(s,r);let v=l?i?jsx(E,{phase:s.phase,files:s.files,totalProgress:s.totalProgress,error:s.error,onCancel:s.cancel}):jsx(L,{phase:s.phase,progress:s.progress,error:s.error,fileInfo:s.fileInfo,onCancel:s.cancel}):null;return jsxs("div",{className:a("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",e),onClick:d?void 0:s.openFilePicker,...d?{}:s.dropHandlers,children:[jsx("input",{...s.inputProps}),jsx(UploadIcon,{className:a("size-6 text-muted-foreground",d&&"opacity-50")}),jsx("p",{className:a("text-sm text-muted-foreground",d&&"opacity-50"),children:t??(i?"Click or drag & drop files to upload":"Click or drag & drop to upload")}),v&&jsx("div",{className:"w-full text-left",children:v})]})}function et({api:e,objectKey:t,fileName:o,label:r,className:l,disabled:n,toast:s=true}){let i=useDownload({api:e,onInitiated:()=>{s&&toast.success("Download started");},onError:(v,P)=>{s&&toast.error("Download failed",{description:P instanceof Error?P.message:"Unknown error"});}}),d=i.phase==="presigning";return jsxs("div",{className:a("inline-flex flex-col gap-1.5",l),children:[jsx(c,{size:"default",variant:"outline",disabled:n||d,onClick:()=>i.download(t,o),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[d?jsx(LoaderIcon,{className:"animate-spin","data-icon":"inline-start"}):jsx(DownloadIcon,{"data-icon":"inline-start"}),r??"Download"]})}),i.phase==="error"&&jsx("span",{className:"text-xs text-destructive",children:i.error??"Download failed"})]})}function at({api:e,objectKey:t,fileName:o,fileSize:r,bucket:l,label:n,className:s,fillClassName:i,disabled:d,tooltipText:v="Download file",toast:P=true,showStatus:Q=true,beforeDownload:Y,onDownloadStart:Z,onProgress:K,onSuccess:j,onError:ee,onCancel:O}){let h=o??t.split("/").pop()??t,g=useFetchDownload({api:e,bucket:l,beforeDownload:Y,onDownloadStart:Z,onProgress:K,onSuccess:(x,b)=>{P&&(toast.dismiss(`dl-${t}`),toast.success("Download complete",{description:`${b}${r!=null?` \xB7 ${formatFileSize(r)}`:""}`})),j?.(x,b);},onError:(x,b,oe)=>{P&&(toast.dismiss(`dl-${t}`),toast.error("Download failed",{description:b instanceof Error?b.message:"Unknown error"})),ee?.(x,b,oe);},onCancel:x=>{P&&(toast.dismiss(`dl-${t}`),toast.info("Download cancelled",{description:h})),O?.(x);}}),C=g.phase==="downloading"||g.phase==="presigning",te=()=>{if(C){g.cancel();return}g.download(t,o);};return jsxs("div",{className:a("inline-flex flex-col gap-1.5",s),children:[jsx(A,{children:jsxs(B,{children:[jsxs(S,{render:jsx(c,{size:"default",variant:"outline",disabled:d,className:a("relative min-w-24 overflow-hidden"),onClick:te}),children:[C&&jsx("span",{className:a("absolute inset-0 bg-primary/15 transition-[width] duration-200",i),style:{width:`${g.progress.percent}%`}}),jsxs("span",{className:"relative z-10 inline-flex items-center gap-1",children:[jsx(DownloadIcon,{"data-icon":"inline-start"}),C?formatFileSize(g.progress.loaded):n??"Download"]})]}),jsx(I,{children:C?"Cancel download":v})]})}),Q&&g.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:g.fileName??h})]}),jsx("span",{className:"text-destructive",children:g.error??"Download failed"})]})]})}function me({...e}){return jsx(AlertDialog.Root,{"data-slot":"alert-dialog",...e})}function ge({...e}){return jsx(AlertDialog.Trigger,{"data-slot":"alert-dialog-trigger",...e})}function it({...e}){return jsx(AlertDialog.Portal,{"data-slot":"alert-dialog-portal",...e})}function st({className:e,...t}){return jsx(AlertDialog.Backdrop,{"data-slot":"alert-dialog-overlay",className:a("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",e),...t})}function fe({className:e,size:t="default",...o}){return jsxs(it,{children:[jsx(st,{}),jsx(AlertDialog.Popup,{"data-slot":"alert-dialog-content","data-size":t,className:a("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",e),...o})]})}function xe({className:e,...t}){return jsx("div",{"data-slot":"alert-dialog-header",className:a("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]",e),...t})}function ve({className:e,...t}){return jsx("div",{"data-slot":"alert-dialog-footer",className:a("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",e),...t})}function Pe({className:e,...t}){return jsx("div",{"data-slot":"alert-dialog-media",className:a("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",e),...t})}function he({className:e,...t}){return jsx(AlertDialog.Title,{"data-slot":"alert-dialog-title",className:a("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",e),...t})}function be({className:e,...t}){return jsx(AlertDialog.Description,{"data-slot":"alert-dialog-description",className:a("text-xs/relaxed text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function De({className:e,...t}){return jsx(c,{"data-slot":"alert-dialog-action",className:a(e),...t})}function Ne({className:e,variant:t="outline",size:o="default",...r}){return jsx(AlertDialog.Close,{"data-slot":"alert-dialog-cancel",className:a(e),render:jsx(c,{variant:t,size:o}),...r})}function ut({api:e,objectKey:t,fileName:o,fileSize:r,bucket:l,label:n,className:s,disabled:i,tooltipText:d="Delete file",toast:v=true,showStatus:P=true,confirmTitle:Q="Delete file?",confirmDescription:Y,beforeDelete:Z,onDeleteStart:K,onSuccess:j,onError:ee}){let O=o??t.split("/").pop()??t,h=useDelete({api:e,bucket:l,beforeDelete:Z,onDeleteStart:K,onSuccess:x=>{v&&toast.success("File deleted",{description:O}),j?.(x);},onError:(x,b,oe)=>{v&&toast.error("Delete failed",{description:b instanceof Error?b.message:"Unknown error"}),ee?.(x,b,oe);}}),g=h.phase==="deleting",C=i||g,te=Y??`Are you sure you want to delete "${O}"${r!=null?` (${formatFileSize(r)})`:""}? This action cannot be undone.`;return jsxs("div",{className:a("inline-flex flex-col gap-1.5",s),children:[jsx("div",{className:"inline-flex items-center gap-2",children:jsxs(me,{open:h.phase==="confirming",onOpenChange:x=>{x||h.cancelDelete();},children:[jsx(A,{children:jsxs(B,{children:[jsxs(S,{render:jsx(ge,{disabled:C,onClick:()=>h.requestDelete(t),render:jsx(c,{size:"default",variant:"destructive",disabled:C})}),children:[g?jsx(LoaderIcon,{className:"animate-spin","data-icon":"inline-start"}):jsx(Trash2Icon,{"data-icon":"inline-start"}),n??"Delete"]}),jsx(I,{children:d})]})}),jsxs(fe,{children:[jsxs(xe,{children:[jsx(Pe,{children:jsx(Trash2Icon,{})}),jsx(he,{children:Q}),jsx(be,{children:te})]}),jsxs(ve,{children:[jsx(Ne,{children:"Cancel"}),jsx(De,{variant:"destructive",onClick:()=>h.confirmDelete(),children:"Delete"})]})]})]})}),P&&h.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:O})]}),jsx("span",{className:"text-destructive",children:h.error??"Delete failed"})]})]})}export{ut as DeleteButton,et as DownloadButton,E as MultiUploadStatus,at as ProgressDownloadButton,qe as UploadButton,Qe as UploadDropzone,L 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","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":"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AAA,CACF,EAEAvB,IAAAA,CAACmF,EAAAA,CAAA,CACC,QAAA,CAAA,CAAAnF,KAACoF,EAAAA,CAAA,CACC,UAAAjG,GAAAA,CAACmG,EAAAA,CAAA,CACC,QAAA,CAAAnG,GAAAA,CAACkH,WAAA,EAAW,CAAA,CACd,EACAlH,GAAAA,CAACoG,EAAAA,CAAA,CAAkB,QAAA,CAAAK,CAAAA,CAAa,EAChCzG,GAAAA,CAACqG,EAAAA,CAAA,CAAwB,QAAA,CAAAW,EAAY,CAAA,CAAA,CACvC,CAAA,CACAnG,KAACqF,EAAAA,CAAA,CACC,UAAAlG,GAAAA,CAACuG,EAAAA,CAAA,CAAkB,QAAA,CAAA,QAAA,CAAM,CAAA,CACzBvG,IAACsG,EAAAA,CAAA,CACC,QAAQ,aAAA,CACR,OAAA,CAAS,IAAMO,CAAAA,CAAI,aAAA,EAAc,CAAG,QAAA,CAAA,QAAA,CAEtC,GACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,EACF,CAAA,CAECvE,CAAAA,EAAcuE,EAAI,KAAA,GAAU,OAAA,EAC3BhG,KAAC,KAAA,CAAA,CAAI,SAAA,CAAU,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"]}
|
|
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/components/ui/progress.tsx","../src/upload/multi-upload-status.tsx","../src/upload/use-upload-toast.ts","../src/upload/upload-button.tsx","../src/upload/upload-dropzone.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","Progress","value","ProgressPrimitive","ProgressTrack","ProgressIndicator","ProgressLabel","ProgressValue","MultiUploadStatus","files","totalProgress","f","FileList","useUploadToast","ctrl","enabled","toastIdRef","useRef","isMulti","prevPhaseRef","toast","succeeded","failed","useEffect","id","done","UploadButton","label","disabled","tooltipText","enableToast","showStatus","options","useUploadControls","isDisabled","status","UploadIcon","UploadDropzone","DownloadButton","api","objectKey","fileName","dl","useDownload","_key","isPending","LoaderIcon","DownloadIcon","ProgressDownloadButton","fileSize","bucket","fillClassName","beforeDownload","onDownloadStart","onProgress","onSuccess","onError","displayName","useFetchDownload","key","actualFileName","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":"6m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AAA,CAAY,CAAA,CAAA,CAC/B,CAAA,CACF,EAEA9C,IAAAA,CAACqF,EAAAA,CAAA,CACC,QAAA,CAAA,CAAArF,IAAAA,CAACsF,GAAA,CACC,QAAA,CAAA,CAAAnG,GAAAA,CAACqG,EAAAA,CAAA,CACC,QAAA,CAAArG,GAAAA,CAACoH,UAAAA,CAAA,EAAW,EACd,CAAA,CACApH,GAAAA,CAACsG,EAAAA,CAAA,CAAkB,SAAAK,CAAAA,CAAa,CAAA,CAChC3G,IAACuG,EAAAA,CAAA,CAAwB,SAAAW,EAAAA,CAAY,CAAA,CAAA,CACvC,CAAA,CACArG,IAAAA,CAACuF,GAAA,CACC,QAAA,CAAA,CAAApG,IAACyG,EAAAA,CAAA,CAAkB,kBAAM,CAAA,CACzBzG,GAAAA,CAACwG,EAAAA,CAAA,CACC,QAAQ,aAAA,CACR,OAAA,CAAS,IAAMO,CAAAA,CAAI,aAAA,GAAiB,QAAA,CAAA,QAAA,CAEtC,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,EACF,CAAA,CAEClD,CAAAA,EAAckD,EAAI,KAAA,GAAU,OAAA,EAC3BlG,KAAC,KAAA,CAAA,CAAI,SAAA,CAAU,6BAAA,CACb,QAAA,CAAA,CAAAA,KAAC,KAAA,CAAA,CAAI,SAAA,CAAU,4BACb,QAAA,CAAA,CAAAb,GAAAA,CAAC6B,gBAAA,CAAgB,SAAA,CAAU,oCAAA,CAAqC,CAAA,CAChE7B,IAAC,MAAA,CAAA,CAAK,SAAA,CAAU,gCAAiC,QAAA,CAAAuF,CAAAA,CAAY,GAC/D,CAAA,CACAvF,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,mBACb,QAAA,CAAA+G,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 { 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 { formatFileSize } from \"@better-s3/react\";\nimport type { UseUploadControlsReturn } from \"@better-s3/react\";\n\n/**\n * Drives sonner toasts for upload progress/success/error.\n * Shared between UploadButton and UploadDropzone.\n */\nexport function useUploadToast(\n ctrl: Pick<\n UseUploadControlsReturn,\n | \"mode\"\n | \"phase\"\n | \"fileInfo\"\n | \"progress\"\n | \"files\"\n | \"totalProgress\"\n | \"error\"\n | \"cancel\"\n >,\n enabled: boolean,\n) {\n const toastIdRef = useRef<string | null>(null);\n const isMulti = ctrl.mode === \"multi\";\n\n // Phase-transition toasts (runs synchronously during render to fire exactly once)\n const prevPhaseRef = useRef(ctrl.phase);\n if (prevPhaseRef.current !== ctrl.phase) {\n prevPhaseRef.current = ctrl.phase;\n if (enabled) {\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 if (isMulti) {\n toast.success(`${ctrl.files.length} file(s) uploaded`, {\n description: formatFileSize(ctrl.totalProgress.total),\n });\n } else if (ctrl.fileInfo) {\n toast.success(\"Upload complete\", {\n description: formatFileSize(ctrl.fileInfo.size),\n });\n }\n toastIdRef.current = null;\n }\n if (ctrl.phase === \"error\") {\n if (toastIdRef.current) toast.dismiss(toastIdRef.current);\n if (isMulti && 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 toast.error(\"Upload finished with errors\", {\n description: `${succeeded} succeeded, ${failed} failed`,\n });\n } else {\n toast.error(\"Upload failed\", {\n description: ctrl.error ?? \"Unknown error\",\n });\n }\n toastIdRef.current = null;\n }\n }\n }\n\n // Progress toast (updated on each progress tick)\n useEffect(() => {\n if (!enabled || ctrl.phase !== \"uploading\") return;\n const id = toastIdRef.current ?? `upload-${Date.now()}`;\n toastIdRef.current = id;\n if (isMulti) {\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 } else if (ctrl.fileInfo) {\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 enabled,\n ctrl.phase,\n isMulti,\n ctrl.progress.loaded,\n ctrl.progress.percent,\n ctrl.totalProgress.loaded,\n ctrl.totalProgress.total,\n ctrl.totalProgress.percent,\n ctrl.fileInfo,\n ctrl.files,\n ctrl.cancel,\n ]);\n}\n","\"use client\";\n\nimport { UploadIcon } from \"lucide-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\";\nimport { MultiUploadStatus } from \"./multi-upload-status\";\nimport { useUploadToast } from \"./use-upload-toast\";\n\nexport type UploadButtonProps = UseUploadControlsOptions & {\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 button (default: `true`) */\n showStatus?: boolean;\n};\n\nexport function UploadButton({\n className,\n label,\n disabled,\n tooltipText,\n toast: enableToast = true,\n showStatus = true,\n ...options\n}: UploadButtonProps) {\n const ctrl = useUploadControls(options);\n const isMulti = ctrl.mode === \"multi\";\n const isDisabled = disabled || ctrl.isUploading;\n\n useUploadToast(ctrl, enableToast);\n\n const status = showStatus ? (\n isMulti ? (\n <MultiUploadStatus\n phase={ctrl.phase}\n files={ctrl.files}\n totalProgress={ctrl.totalProgress}\n error={ctrl.error}\n onCancel={ctrl.cancel}\n />\n ) : (\n <UploadStatus\n phase={ctrl.phase}\n progress={ctrl.progress}\n error={ctrl.error}\n fileInfo={ctrl.fileInfo}\n onCancel={ctrl.cancel}\n />\n )\n ) : null;\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 ?? (isMulti ? \"Upload files\" : \"Upload file\")}\n </TooltipTrigger>\n <TooltipContent>\n {tooltipText ?? (isMulti ? \"Upload files\" : \"Upload file\")}\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n </div>\n {status}\n </div>\n );\n}\n","\"use client\";\n\nimport { UploadIcon } from \"lucide-react\";\nimport type { UseUploadControlsOptions } from \"@better-s3/react\";\nimport { useUploadControls } from \"@better-s3/react\";\nimport { cn } from \"@/lib/utils\";\nimport { UploadStatus } from \"./upload-status\";\nimport { MultiUploadStatus } from \"./multi-upload-status\";\nimport { useUploadToast } from \"./use-upload-toast\";\n\nexport type UploadDropzoneProps = UseUploadControlsOptions & {\n className?: string;\n label?: string;\n disabled?: boolean;\n /** Enable sonner toasts (default: `true`) */\n toast?: boolean;\n /** Show inline status inside the dropzone (default: `true`) */\n showStatus?: boolean;\n};\n\nexport function UploadDropzone({\n className,\n label,\n disabled,\n toast: enableToast = true,\n showStatus = true,\n ...options\n}: UploadDropzoneProps) {\n const ctrl = useUploadControls(options);\n const isMulti = ctrl.mode === \"multi\";\n const isDisabled = disabled || ctrl.isUploading;\n\n useUploadToast(ctrl, enableToast);\n\n const status = showStatus ? (\n isMulti ? (\n <MultiUploadStatus\n phase={ctrl.phase}\n files={ctrl.files}\n totalProgress={ctrl.totalProgress}\n error={ctrl.error}\n onCancel={ctrl.cancel}\n />\n ) : (\n <UploadStatus\n phase={ctrl.phase}\n progress={ctrl.progress}\n error={ctrl.error}\n fileInfo={ctrl.fileInfo}\n onCancel={ctrl.cancel}\n />\n )\n ) : null;\n\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 ??\n (isMulti\n ? \"Click or drag & drop files to upload\"\n : \"Click or drag & drop to upload\")}\n </p>\n {status && <div className=\"w-full text-left\">{status}</div>}\n </div>\n );\n}\n","\"use client\";\n\nimport { DownloadIcon, 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 dl = useDownload({\n api,\n onInitiated: () => {\n if (enableToast) toast.success(\"Download started\");\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 isPending = dl.phase === \"presigning\";\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 || isPending}\n onClick={() => dl.download(objectKey, fileName)}>\n <span className=\"inline-flex items-center gap-1\">\n {isPending ? (\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, actualFileName) => {\n if (enableToast) {\n toast.dismiss(`dl-${objectKey}`);\n toast.success(\"Download complete\", {\n description: `${actualFileName}${fileSize != null ? ` · ${formatFileSize(fileSize)}` : \"\"}`,\n });\n }\n onSuccess?.(key, actualFileName);\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, fileName);\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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UseUploadControlsOptions } from "@better-s3/react";
|
|
2
|
+
export type UploadButtonProps = UseUploadControlsOptions & {
|
|
3
|
+
className?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
tooltipText?: string;
|
|
7
|
+
/** Enable sonner toasts (default: `true`) */
|
|
8
|
+
toast?: boolean;
|
|
9
|
+
/** Show inline status below the button (default: `true`) */
|
|
10
|
+
showStatus?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function UploadButton({ className, label, disabled, tooltipText, toast: enableToast, showStatus, ...options }: UploadButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UseUploadControlsOptions } from "@better-s3/react";
|
|
2
|
+
export type UploadDropzoneProps = UseUploadControlsOptions & {
|
|
3
|
+
className?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
/** Enable sonner toasts (default: `true`) */
|
|
7
|
+
toast?: boolean;
|
|
8
|
+
/** Show inline status inside the dropzone (default: `true`) */
|
|
9
|
+
showStatus?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function UploadDropzone({ className, label, disabled, toast: enableToast, showStatus, ...options }: UploadDropzoneProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UseUploadControlsReturn } from "@better-s3/react";
|
|
2
|
+
/**
|
|
3
|
+
* Drives sonner toasts for upload progress/success/error.
|
|
4
|
+
* Shared between UploadButton and UploadDropzone.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useUploadToast(ctrl: Pick<UseUploadControlsReturn, "mode" | "phase" | "fileInfo" | "progress" | "files" | "totalProgress" | "error" | "cancel">, enabled: boolean): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-s3/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
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": "
|
|
39
|
+
"@better-s3/react": "3.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@base-ui/react": ">=1.0.0",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { UseMultiUploadControlsOptions } from "@better-s3/react";
|
|
2
|
-
export type MultiUploadProps = UseMultiUploadControlsOptions & {
|
|
3
|
-
variant?: "button" | "dropzone";
|
|
4
|
-
className?: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
tooltipText?: string;
|
|
8
|
-
/** Enable sonner toasts (default: `true`) */
|
|
9
|
-
toast?: boolean;
|
|
10
|
-
/** Show inline status below the trigger (default: `true`) */
|
|
11
|
-
showStatus?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare function MultiUpload({ variant, objectKey, className, label, disabled, tooltipText, toast: enableToast, showStatus, ...options }: MultiUploadProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/upload/upload.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { UseUploadControlsOptions } from "@better-s3/react";
|
|
2
|
-
export type UploadProps = UseUploadControlsOptions & {
|
|
3
|
-
variant?: "button" | "dropzone";
|
|
4
|
-
className?: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
tooltipText?: string;
|
|
8
|
-
/** Enable sonner toasts (default: `true`) */
|
|
9
|
-
toast?: boolean;
|
|
10
|
-
/** Show inline status below the trigger (default: `true`) */
|
|
11
|
-
showStatus?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare function Upload({ variant, objectKey, className, label, disabled, tooltipText, toast: enableToast, showStatus, ...options }: UploadProps): import("react/jsx-runtime").JSX.Element;
|