@pixpilot/shadcn 0.3.0 → 0.3.2
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/dist/_virtual/rolldown_runtime.cjs +25 -1
- package/dist/components/index.cjs +30 -1
- package/dist/components/index.js +30 -1
- package/dist/components/ui/OrContinueWithSeparator.cjs +30 -1
- package/dist/components/ui/OrContinueWithSeparator.js +27 -1
- package/dist/components/ui/alert-dialog.cjs +101 -1
- package/dist/components/ui/alert-dialog.js +87 -1
- package/dist/components/ui/alert.cjs +45 -1
- package/dist/components/ui/alert.d.cts +4 -4
- package/dist/components/ui/alert.js +39 -1
- package/dist/components/ui/avatar.cjs +37 -1
- package/dist/components/ui/avatar.js +31 -1
- package/dist/components/ui/badge.cjs +33 -1
- package/dist/components/ui/badge.js +27 -1
- package/dist/components/ui/button.cjs +52 -1
- package/dist/components/ui/button.js +46 -1
- package/dist/components/ui/calendar.cjs +113 -1
- package/dist/components/ui/calendar.js +107 -1
- package/dist/components/ui/card.cjs +67 -1
- package/dist/components/ui/card.js +58 -1
- package/dist/components/ui/checkbox.cjs +31 -1
- package/dist/components/ui/checkbox.js +26 -1
- package/dist/components/ui/command.cjs +104 -1
- package/dist/components/ui/command.js +91 -1
- package/dist/components/ui/dialog.cjs +102 -1
- package/dist/components/ui/dialog.js +88 -1
- package/dist/components/ui/dropdown-menu.cjs +144 -1
- package/dist/components/ui/dropdown-menu.js +125 -1
- package/dist/components/ui/file-upload.cjs +926 -1
- package/dist/components/ui/file-upload.js +910 -1
- package/dist/components/ui/form.cjs +101 -1
- package/dist/components/ui/form.js +89 -1
- package/dist/components/ui/index.cjs +29 -1
- package/dist/components/ui/index.js +29 -1
- package/dist/components/ui/input.cjs +20 -1
- package/dist/components/ui/input.js +17 -1
- package/dist/components/ui/label.cjs +21 -1
- package/dist/components/ui/label.js +17 -1
- package/dist/components/ui/pagination.cjs +92 -1
- package/dist/components/ui/pagination.js +82 -1
- package/dist/components/ui/popover.cjs +44 -1
- package/dist/components/ui/popover.js +37 -1
- package/dist/components/ui/radio-group.cjs +36 -1
- package/dist/components/ui/radio-group.js +30 -1
- package/dist/components/ui/select.cjs +116 -1
- package/dist/components/ui/select.js +102 -1
- package/dist/components/ui/separator.cjs +23 -1
- package/dist/components/ui/separator.js +19 -1
- package/dist/components/ui/shadcn-io/tags/index.cjs +146 -1
- package/dist/components/ui/shadcn-io/tags/index.js +134 -1
- package/dist/components/ui/shadcn-io/tags-input-inline/index.cjs +66 -1
- package/dist/components/ui/shadcn-io/tags-input-inline/index.js +57 -1
- package/dist/components/ui/sheet.cjs +96 -1
- package/dist/components/ui/sheet.js +84 -1
- package/dist/components/ui/slider.cjs +42 -1
- package/dist/components/ui/slider.js +38 -1
- package/dist/components/ui/switch.cjs +28 -1
- package/dist/components/ui/switch.js +24 -1
- package/dist/components/ui/tabs.cjs +45 -1
- package/dist/components/ui/tabs.js +38 -1
- package/dist/components/ui/textarea.cjs +19 -1
- package/dist/components/ui/textarea.js +16 -1
- package/dist/components/ui/tooltip.cjs +45 -1
- package/dist/components/ui/tooltip.d.cts +5 -5
- package/dist/components/ui/tooltip.js +38 -1
- package/dist/index.cjs +189 -1
- package/dist/index.js +34 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/utils.cjs +13 -1
- package/dist/lib/utils.js +10 -1
- package/package.json +1 -1
|
@@ -1 +1,910 @@
|
|
|
1
|
-
"use client";import{cn as e}from"../../lib/utils.js";import"../../lib/index.js";import*as t from"react";import{Fragment as n,jsx as r,jsxs as i}from"react/jsx-runtime";import{Slot as a}from"@radix-ui/react-slot";import{FileArchiveIcon as o,FileAudioIcon as s,FileCodeIcon as c,FileCogIcon as l,FileIcon as u,FileTextIcon as d,FileVideoIcon as f}from"lucide-react";import{useDirection as p}from"@radix-ui/react-direction";const m=`FileUpload`,h=`FileUploadDropzone`,g=`FileUploadItem`,_=`FileUploadItemPreview`,v=`FileUploadItemMetadata`,y=`FileUploadItemDelete`,b=`FileUploadClear`;function x(e){let n=t.useRef(null);return n.current===null&&(n.current=e()),n}function S(e,t,n,r,i){let a={files:t,dragOver:!1,invalid:r};function o(e,r){switch(r.type){case`ADD_FILES`:for(let e of r.files)t.set(e,{file:e,progress:0,status:`idle`});return i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_FILES`:{let n=new Set(r.files);for(let e of t.keys())n.has(e)||t.delete(e);for(let e of r.files)t.get(e)||t.set(e,{file:e,progress:0,status:`idle`});return{...e,files:t}}case`SET_PROGRESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:r.progress,status:`uploading`}),{...e,files:t}}case`SET_SUCCESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:100,status:`success`}),{...e,files:t}}case`SET_ERROR`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,error:r.error,status:`error`}),{...e,files:t}}case`REMOVE_FILE`:if(n){let e=n.get(r.file);e&&(URL.revokeObjectURL(e),n.delete(r.file))}return t.delete(r.file),i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_DRAG_OVER`:return{...e,dragOver:r.dragOver};case`SET_INVALID`:return{...e,invalid:r.invalid};case`CLEAR`:if(n)for(let e of t.keys()){let t=n.get(e);t&&(URL.revokeObjectURL(t),n.delete(e))}return t.clear(),i&&i([]),{...e,files:t,invalid:!1};default:return e}}function s(){return a}function c(t){a=o(a,t);for(let t of e)t()}function l(t){return e.add(t),()=>e.delete(t)}return{getState:s,dispatch:c,subscribe:l}}const C=t.createContext(null);function w(e){let n=t.use(C);if(!n)throw Error(`\`${e}\` must be used within \`${m}\``);return n}function T(e){let n=w(`useStore`),r=x(()=>null),i=t.useCallback(()=>{let t=n.getState(),i=r.current;if(i&&i.state===t)return i.value;let a=e(t);return r.current={value:a,state:t},a},[n,e,r]);return t.useSyncExternalStore(n.subscribe,i,i)}const E=t.createContext(null);function D(e){let n=t.use(E);if(!n)throw Error(`\`${e}\` must be used within \`${m}\``);return n}function O(n){let{value:o,defaultValue:s,onValueChange:c,onAccept:l,onFileAccept:u,onFileReject:d,onFilesReject:f,onFileValidate:m,onUpload:h,accept:g,maxFiles:_,maxSize:v,dir:y,label:b,name:w,asChild:T,disabled:D=!1,invalid:O=!1,multiple:k=!1,required:A=!1,children:j,className:M,...N}=n,P=t.useId(),F=t.useId(),I=t.useId(),L=t.useId(),R=p(y),z=x(()=>new Set).current,B=x(()=>new Map).current,V=x(()=>new WeakMap).current,H=t.useRef(null),U=o!==void 0,W=t.useMemo(()=>S(z,B,V,O,c),[z,B,O,c,V]),G=t.useMemo(()=>g?.split(`,`).map(e=>e.trim())??null,[g]),K=x(()=>{let e=0;return(t,n)=>{e||=requestAnimationFrame(()=>{e=0,W.dispatch({type:`SET_PROGRESS`,file:t,progress:Math.min(Math.max(0,n),100)})})}}).current;t.useEffect(()=>{U?W.dispatch({type:`SET_FILES`,files:o}):s&&s.length>0&&!W.getState().files.size&&W.dispatch({type:`SET_FILES`,files:s})},[o,s,U,W]),t.useEffect(()=>()=>{for(let e of B.keys()){let t=V.get(e);t&&URL.revokeObjectURL(t)}},[B,V]);let q=t.useCallback(async e=>{try{for(let t of e)W.dispatch({type:`SET_PROGRESS`,file:t,progress:0});if(h)await h(e,{onProgress:K,onSuccess:e=>{W.dispatch({type:`SET_SUCCESS`,file:e})},onError:(e,t)=>{W.dispatch({type:`SET_ERROR`,file:e,error:t.message??`Upload failed`})}});else for(let t of e)W.dispatch({type:`SET_SUCCESS`,file:t})}catch(t){let n=t instanceof Error?t.message:`Upload failed`;for(let t of e)W.dispatch({type:`SET_ERROR`,file:t,error:n})}},[W,h,K]),J=t.useCallback(e=>{if(D)return;let t=[...e],n=!1,r=[];if(_){let e=W.getState().files.size,i=Math.max(0,_-e);if(i<t.length){let e=t.slice(i);n=!0,t=t.slice(0,i);for(let t of e){let e=`Maximum ${_} files allowed`;if(m){let n=m(t);n&&(e=n)}d?.(t,e),r.push({file:t,message:e})}}}let i=[],a=[];for(let e of t){let t=!1,r=``;if(m){let i=m(e);if(i){r=i,d?.(e,r),t=!0,n=!0;continue}}if(G){let i=e.type,a=`.${e.name.split(`.`).pop()}`;G.some(e=>e===i||e===a||e.includes(`/*`)&&i.startsWith(e.replace(`/*`,`/`)))||(r=`File type not accepted`,d?.(e,r),t=!0,n=!0)}v&&e.size>v&&(r=`File too large`,d?.(e,r),t=!0,n=!0),t?a.push({file:e,message:r}):i.push(e)}if(r.push(...a),n&&(W.dispatch({type:`SET_INVALID`,invalid:n}),setTimeout(()=>{W.dispatch({type:`SET_INVALID`,invalid:!1})},2e3)),r.length>0&&f?.(r),i.length>0){W.dispatch({type:`ADD_FILES`,files:i}),U&&c&&c([...Array.from(W.getState().files.values()).map(e=>e.file)]),l&&l(i);for(let e of i)u?.(e);h&&requestAnimationFrame(()=>{q(i)})}},[W,U,c,l,u,h,q,_,m,d,f,G,v,D]),Y=t.useCallback(e=>{J(Array.from(e.target.files??[])),e.target.value=``},[J]),X=t.useMemo(()=>({dropzoneId:F,inputId:P,listId:I,labelId:L,dir:R,disabled:D,inputRef:H,urlCache:V}),[F,P,I,L,R,D,V]),Z=T?a:`div`;return r(C.Provider,{value:W,children:r(E.Provider,{value:X,children:i(Z,{"data-disabled":D?``:void 0,"data-slot":`file-upload`,dir:R,...N,className:e(`relative flex flex-col gap-2`,M),children:[j,r(`input`,{type:`file`,id:P,"aria-labelledby":L,"aria-describedby":F,ref:H,tabIndex:-1,accept:g,name:w,className:`sr-only`,disabled:D,multiple:k,required:A,onChange:Y}),r(`span`,{id:L,className:`sr-only`,children:b??`File upload`})]})})})}function k(n){let{asChild:i,className:o,onClick:s,onDragOver:c,onDragEnter:l,onDragLeave:u,onDrop:d,onPaste:f,onKeyDown:p,...m}=n,g=D(h),_=w(h),v=T(e=>e.dragOver),y=T(e=>e.invalid),b=t.useCallback(e=>{if(s?.(e),e.defaultPrevented)return;let{target:t}=e;t instanceof HTMLElement&&t.closest(`[data-slot="file-upload-trigger"]`)||g.inputRef.current?.click()},[g.inputRef,s]),x=t.useCallback(e=>{c?.(e),!e.defaultPrevented&&(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[_,c]),S=t.useCallback(e=>{l?.(e),!e.defaultPrevented&&(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[_,l]),C=t.useCallback(e=>{if(u?.(e),e.defaultPrevented)return;let{relatedTarget:t}=e;t&&t instanceof Node&&e.currentTarget.contains(t)||(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1}))},[_,u]),E=t.useCallback(e=>{if(d?.(e),e.defaultPrevented)return;e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=Array.from(e.dataTransfer.files),n=g.inputRef.current;if(!n)return;let r=new DataTransfer;for(let e of t)r.items.add(e);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))},[_,g.inputRef,d]),O=t.useCallback(e=>{if(f?.(e),e.defaultPrevented)return;e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r?.kind===`file`){let e=r.getAsFile();e&&n.push(e)}}if(n.length===0)return;let r=g.inputRef.current;if(!r)return;let i=new DataTransfer;for(let e of n)i.items.add(e);r.files=i.files,r.dispatchEvent(new Event(`change`,{bubbles:!0}))},[_,g.inputRef,f]),k=t.useCallback(e=>{p?.(e),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g.inputRef.current?.click())},[g.inputRef,p]);return r(i?a:`div`,{role:`region`,id:g.dropzoneId,"aria-controls":`${g.inputId} ${g.listId}`,"aria-disabled":g.disabled,"aria-invalid":y,"data-disabled":g.disabled?``:void 0,"data-dragging":v?``:void 0,"data-invalid":y?``:void 0,"data-slot":`file-upload-dropzone`,dir:g.dir,tabIndex:g.disabled?void 0:0,...m,className:e(`relative flex select-none flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 outline-none transition-colors hover:bg-accent/30 focus-visible:border-ring/50 data-disabled:pointer-events-none data-dragging:border-primary/30 data-invalid:border-destructive data-dragging:bg-accent/30 data-invalid:ring-destructive/20`,o),onClick:b,onDragEnter:S,onDragLeave:C,onDragOver:x,onDrop:E,onKeyDown:k,onPaste:O})}function A(e){let{asChild:n,onClick:i,...o}=e,s=D(`FileUploadTrigger`),c=t.useCallback(e=>{i?.(e),!e.defaultPrevented&&s.inputRef.current?.click()},[s.inputRef,i]);return r(n?a:`button`,{type:`button`,"aria-controls":s.inputId,"data-disabled":s.disabled?``:void 0,"data-slot":`file-upload-trigger`,...o,disabled:s.disabled,onClick:c})}function j(t){let{className:n,orientation:i=`vertical`,asChild:o,forceMount:s,...c}=t,l=D(`FileUploadList`),u=T(e=>e.files.size),d=s||u>0;return d?r(o?a:`div`,{role:`list`,id:l.listId,"aria-orientation":i,"data-orientation":i,"data-slot":`file-upload-list`,"data-state":d?`active`:`inactive`,dir:l.dir,...c,className:e(`data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 flex flex-col gap-2 data-[state=active]:animate-in data-[state=inactive]:animate-out`,i===`horizontal`&&`flex-row overflow-x-auto p-1.5`,n)}):null}const M=t.createContext(null);function N(e){let n=t.use(M);if(!n)throw Error(`\`${e}\` must be used within \`${g}\``);return n}function P(n){let{value:o,asChild:s,className:c,...l}=n,u=t.useId(),d=`${u}-status`,f=`${u}-name`,p=`${u}-size`,m=`${u}-message`,h=D(g),_=T(e=>e.files.get(o)),v=T(e=>e.files.size),y=T(e=>Array.from(e.files.keys()).indexOf(o)+1),b=t.useMemo(()=>({id:u,fileState:_,nameId:f,sizeId:p,statusId:d,messageId:m}),[u,_,d,f,p,m]);if(!_)return null;let x=_.error?`Error: ${_.error}`:_.status===`uploading`?`Uploading: ${_.progress}% complete`:_.status===`success`?`Upload complete`:`Ready to upload`,S=s?a:`div`;return r(M.Provider,{value:b,children:i(S,{role:`listitem`,id:u,"aria-setsize":v,"aria-posinset":y,"aria-describedby":`${f} ${p} ${d} ${_.error?m:``}`,"aria-labelledby":f,"data-slot":`file-upload-item`,dir:h.dir,...l,className:e(`relative flex items-center rounded-md border p-3`,c),children:[n.children,r(`span`,{id:d,className:`sr-only`,children:x})]})})}function F(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(n?1:0)} ${t[n]}`}function I(e){let{type:t}=e,n=e.name.split(`.`).pop()?.toLowerCase()??``;return t.startsWith(`video/`)?r(f,{}):t.startsWith(`audio/`)?r(s,{}):t.startsWith(`text/`)||[`txt`,`md`,`rtf`,`pdf`].includes(n)?r(d,{}):[`html`,`css`,`js`,`jsx`,`ts`,`tsx`,`json`,`xml`,`php`,`py`,`rb`,`java`,`c`,`cpp`,`cs`].includes(n)?r(c,{}):[`zip`,`rar`,`7z`,`tar`,`gz`,`bz2`].includes(n)?r(o,{}):[`exe`,`msi`,`app`,`apk`,`deb`,`rpm`].includes(n)||t.startsWith(`application/`)?r(l,{}):r(u,{})}function L(n){let{render:o,asChild:s,children:c,className:l,...u}=n,d=N(_),f=D(_),p=t.useCallback(e=>{if(d.fileState?.file.type.startsWith(`image/`)){let t=f.urlCache.get(e);return t||(t=URL.createObjectURL(e),f.urlCache.set(e,t)),r(`img`,{src:t,alt:e.name,className:`size-full object-cover`})}return I(e)},[d.fileState?.file.type,f.urlCache]),m=t.useCallback(e=>o?o(e,()=>p(e)):p(e),[o,p]);return d.fileState?i(s?a:`div`,{"aria-labelledby":d.nameId,"data-slot":`file-upload-preview`,...u,className:e(`relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10`,l),children:[m(d.fileState.file),c]}):null}function R(t){let{asChild:o,size:s=`default`,children:c,className:l,...u}=t,d=D(v),f=N(v);return f.fileState?r(o?a:`div`,{"data-slot":`file-upload-metadata`,dir:d.dir,...u,className:e(`flex min-w-0 flex-1 flex-col`,l),children:c??i(n,{children:[r(`span`,{id:f.nameId,className:e(`truncate font-medium text-sm`,s===`sm`&&`font-normal text-[13px] leading-snug`),children:f.fileState.file.name}),r(`span`,{id:f.sizeId,className:e(`truncate text-muted-foreground text-xs`,s===`sm`&&`text-[11px] leading-snug`),children:F(f.fileState.file.size)}),f.fileState.error&&r(`span`,{id:f.messageId,className:`text-destructive text-xs`,children:f.fileState.error})]})}):null}function z(t){let{variant:n=`linear`,size:o=40,strokeWidth:s=2,asChild:c,forceMount:l,className:u,...d}=t,f=N(`FileUploadItemProgress`);if(!f.fileState||!(l||f.fileState.progress!==100))return null;let p=c?a:`div`;switch(n){case`circular`:{let t=2*Math.PI*((o-4)/2),n=t-f.fileState.progress/100*t;return r(p,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":f.fileState.progress,"aria-valuetext":`${f.fileState.progress}%`,"aria-labelledby":f.nameId,"data-slot":`file-upload-progress`,...d,className:e(`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2`,u),children:i(`svg`,{className:`-rotate-90 transform`,width:o,height:o,viewBox:`0 0 ${o} ${o}`,fill:`none`,stroke:`currentColor`,children:[r(`circle`,{className:`text-primary/20`,strokeWidth:s,cx:o/2,cy:o/2,r:(o-4)/2}),r(`circle`,{className:`text-primary transition-[stroke-dashoffset] duration-300 ease-linear`,strokeWidth:s,strokeLinecap:`round`,strokeDasharray:t,strokeDashoffset:n,cx:o/2,cy:o/2,r:(o-4)/2})]})})}case`fill`:{let t=f.fileState.progress,n=100-t;return r(p,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t,"aria-valuetext":`${t}%`,"aria-labelledby":f.nameId,"data-slot":`file-upload-progress`,...d,className:e(`absolute inset-0 bg-primary/50 transition-[clip-path] duration-300 ease-linear`,u),style:{clipPath:`inset(${n}% 0% 0% 0%)`}})}default:return r(p,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":f.fileState.progress,"aria-valuetext":`${f.fileState.progress}%`,"aria-labelledby":f.nameId,"data-slot":`file-upload-progress`,...d,className:e(`relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20`,u),children:r(`div`,{className:`h-full w-full flex-1 bg-primary transition-transform duration-300 ease-linear`,style:{transform:`translateX(-${100-f.fileState.progress}%)`}})})}}function B(e){let{asChild:n,onClick:i,...o}=e,s=w(y),c=N(y),l=t.useCallback(e=>{i?.(e),!(!c.fileState||e.defaultPrevented)&&s.dispatch({type:`REMOVE_FILE`,file:c.fileState.file})},[s,c.fileState,i]);return c.fileState?r(n?a:`button`,{type:`button`,"aria-controls":c.id,"aria-describedby":c.nameId,"data-slot":`file-upload-item-delete`,...o,onClick:l}):null}function V(e){let{asChild:n,forceMount:i,disabled:o,onClick:s,...c}=e,l=D(b),u=w(b),d=T(e=>e.files.size),f=o||l.disabled,p=t.useCallback(e=>{s?.(e),!e.defaultPrevented&&u.dispatch({type:`CLEAR`})},[u,s]);return i||d>0?r(n?a:`button`,{type:`button`,"aria-controls":l.listId,"data-slot":`file-upload-clear`,"data-disabled":f?``:void 0,...c,disabled:f,onClick:p}):null}export{V as FileUploadClear,k as FileUploadDropzone,P as FileUploadItem,B as FileUploadItemDelete,R as FileUploadItemMetadata,L as FileUploadItemPreview,z as FileUploadItemProgress,j as FileUploadList,O as FileUploadRoot,A as FileUploadTrigger,T as useStore};
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
import "../../lib/index.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
9
|
+
import { FileArchiveIcon, FileAudioIcon, FileCodeIcon, FileCogIcon, FileIcon, FileTextIcon, FileVideoIcon } from "lucide-react";
|
|
10
|
+
import { useDirection } from "@radix-ui/react-direction";
|
|
11
|
+
|
|
12
|
+
//#region src/components/ui/file-upload.tsx
|
|
13
|
+
const ROOT_NAME = "FileUpload";
|
|
14
|
+
const DROPZONE_NAME = "FileUploadDropzone";
|
|
15
|
+
const TRIGGER_NAME = "FileUploadTrigger";
|
|
16
|
+
const LIST_NAME = "FileUploadList";
|
|
17
|
+
const ITEM_NAME = "FileUploadItem";
|
|
18
|
+
const ITEM_PREVIEW_NAME = "FileUploadItemPreview";
|
|
19
|
+
const ITEM_METADATA_NAME = "FileUploadItemMetadata";
|
|
20
|
+
const ITEM_PROGRESS_NAME = "FileUploadItemProgress";
|
|
21
|
+
const ITEM_DELETE_NAME = "FileUploadItemDelete";
|
|
22
|
+
const CLEAR_NAME = "FileUploadClear";
|
|
23
|
+
function useLazyRef(fn) {
|
|
24
|
+
const ref = React.useRef(null);
|
|
25
|
+
if (ref.current === null) ref.current = fn();
|
|
26
|
+
return ref;
|
|
27
|
+
}
|
|
28
|
+
function createStore(listeners, files, urlCache, invalid, onValueChange) {
|
|
29
|
+
let state = {
|
|
30
|
+
files,
|
|
31
|
+
dragOver: false,
|
|
32
|
+
invalid
|
|
33
|
+
};
|
|
34
|
+
function reducer(state$1, action) {
|
|
35
|
+
switch (action.type) {
|
|
36
|
+
case "ADD_FILES":
|
|
37
|
+
for (const file of action.files) files.set(file, {
|
|
38
|
+
file,
|
|
39
|
+
progress: 0,
|
|
40
|
+
status: "idle"
|
|
41
|
+
});
|
|
42
|
+
if (onValueChange) onValueChange(Array.from(files.values()).map((fileState) => fileState.file));
|
|
43
|
+
return {
|
|
44
|
+
...state$1,
|
|
45
|
+
files
|
|
46
|
+
};
|
|
47
|
+
case "SET_FILES": {
|
|
48
|
+
const newFileSet = new Set(action.files);
|
|
49
|
+
for (const existingFile of files.keys()) if (!newFileSet.has(existingFile)) files.delete(existingFile);
|
|
50
|
+
for (const file of action.files) if (!files.get(file)) files.set(file, {
|
|
51
|
+
file,
|
|
52
|
+
progress: 0,
|
|
53
|
+
status: "idle"
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
...state$1,
|
|
57
|
+
files
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
case "SET_PROGRESS": {
|
|
61
|
+
const fileState = files.get(action.file);
|
|
62
|
+
if (fileState) files.set(action.file, {
|
|
63
|
+
...fileState,
|
|
64
|
+
progress: action.progress,
|
|
65
|
+
status: "uploading"
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
...state$1,
|
|
69
|
+
files
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
case "SET_SUCCESS": {
|
|
73
|
+
const fileState = files.get(action.file);
|
|
74
|
+
if (fileState) files.set(action.file, {
|
|
75
|
+
...fileState,
|
|
76
|
+
progress: 100,
|
|
77
|
+
status: "success"
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
...state$1,
|
|
81
|
+
files
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
case "SET_ERROR": {
|
|
85
|
+
const fileState = files.get(action.file);
|
|
86
|
+
if (fileState) files.set(action.file, {
|
|
87
|
+
...fileState,
|
|
88
|
+
error: action.error,
|
|
89
|
+
status: "error"
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
...state$1,
|
|
93
|
+
files
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
case "REMOVE_FILE":
|
|
97
|
+
if (urlCache) {
|
|
98
|
+
const cachedUrl = urlCache.get(action.file);
|
|
99
|
+
if (cachedUrl) {
|
|
100
|
+
URL.revokeObjectURL(cachedUrl);
|
|
101
|
+
urlCache.delete(action.file);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
files.delete(action.file);
|
|
105
|
+
if (onValueChange) onValueChange(Array.from(files.values()).map((fileState) => fileState.file));
|
|
106
|
+
return {
|
|
107
|
+
...state$1,
|
|
108
|
+
files
|
|
109
|
+
};
|
|
110
|
+
case "SET_DRAG_OVER": return {
|
|
111
|
+
...state$1,
|
|
112
|
+
dragOver: action.dragOver
|
|
113
|
+
};
|
|
114
|
+
case "SET_INVALID": return {
|
|
115
|
+
...state$1,
|
|
116
|
+
invalid: action.invalid
|
|
117
|
+
};
|
|
118
|
+
case "CLEAR":
|
|
119
|
+
if (urlCache) for (const file of files.keys()) {
|
|
120
|
+
const cachedUrl = urlCache.get(file);
|
|
121
|
+
if (cachedUrl) {
|
|
122
|
+
URL.revokeObjectURL(cachedUrl);
|
|
123
|
+
urlCache.delete(file);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
files.clear();
|
|
127
|
+
if (onValueChange) onValueChange([]);
|
|
128
|
+
return {
|
|
129
|
+
...state$1,
|
|
130
|
+
files,
|
|
131
|
+
invalid: false
|
|
132
|
+
};
|
|
133
|
+
default: return state$1;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function getState() {
|
|
137
|
+
return state;
|
|
138
|
+
}
|
|
139
|
+
function dispatch(action) {
|
|
140
|
+
state = reducer(state, action);
|
|
141
|
+
for (const listener of listeners) listener();
|
|
142
|
+
}
|
|
143
|
+
function subscribe(listener) {
|
|
144
|
+
listeners.add(listener);
|
|
145
|
+
return () => listeners.delete(listener);
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
getState,
|
|
149
|
+
dispatch,
|
|
150
|
+
subscribe
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const StoreContext = React.createContext(null);
|
|
154
|
+
function useStoreContext(consumerName) {
|
|
155
|
+
const context = React.use(StoreContext);
|
|
156
|
+
if (!context) throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
|
|
157
|
+
return context;
|
|
158
|
+
}
|
|
159
|
+
function useStore(selector) {
|
|
160
|
+
const store = useStoreContext("useStore");
|
|
161
|
+
const lastValueRef = useLazyRef(() => null);
|
|
162
|
+
const getSnapshot = React.useCallback(() => {
|
|
163
|
+
const state = store.getState();
|
|
164
|
+
const prevValue = lastValueRef.current;
|
|
165
|
+
if (prevValue && prevValue.state === state) return prevValue.value;
|
|
166
|
+
const nextValue = selector(state);
|
|
167
|
+
lastValueRef.current = {
|
|
168
|
+
value: nextValue,
|
|
169
|
+
state
|
|
170
|
+
};
|
|
171
|
+
return nextValue;
|
|
172
|
+
}, [
|
|
173
|
+
store,
|
|
174
|
+
selector,
|
|
175
|
+
lastValueRef
|
|
176
|
+
]);
|
|
177
|
+
return React.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
178
|
+
}
|
|
179
|
+
const FileUploadContext = React.createContext(null);
|
|
180
|
+
function useFileUploadContext(consumerName) {
|
|
181
|
+
const context = React.use(FileUploadContext);
|
|
182
|
+
if (!context) throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
|
|
183
|
+
return context;
|
|
184
|
+
}
|
|
185
|
+
function FileUploadRoot(props) {
|
|
186
|
+
const { value, defaultValue, onValueChange, onAccept, onFileAccept, onFileReject, onFilesReject, onFileValidate, onUpload, accept, maxFiles, maxSize, dir: dirProp, label, name, asChild, disabled = false, invalid = false, multiple = false, required = false, children, className,...rootProps } = props;
|
|
187
|
+
const inputId = React.useId();
|
|
188
|
+
const dropzoneId = React.useId();
|
|
189
|
+
const listId = React.useId();
|
|
190
|
+
const labelId = React.useId();
|
|
191
|
+
const dir = useDirection(dirProp);
|
|
192
|
+
const listeners = useLazyRef(() => /* @__PURE__ */ new Set()).current;
|
|
193
|
+
const files = useLazyRef(() => /* @__PURE__ */ new Map()).current;
|
|
194
|
+
const urlCache = useLazyRef(() => /* @__PURE__ */ new WeakMap()).current;
|
|
195
|
+
const inputRef = React.useRef(null);
|
|
196
|
+
const isControlled = value !== void 0;
|
|
197
|
+
const store = React.useMemo(() => createStore(listeners, files, urlCache, invalid, onValueChange), [
|
|
198
|
+
listeners,
|
|
199
|
+
files,
|
|
200
|
+
invalid,
|
|
201
|
+
onValueChange,
|
|
202
|
+
urlCache
|
|
203
|
+
]);
|
|
204
|
+
const acceptTypes = React.useMemo(() => accept?.split(",").map((t) => t.trim()) ?? null, [accept]);
|
|
205
|
+
const onProgress = useLazyRef(() => {
|
|
206
|
+
let frame = 0;
|
|
207
|
+
return (file, progress) => {
|
|
208
|
+
if (frame) return;
|
|
209
|
+
frame = requestAnimationFrame(() => {
|
|
210
|
+
frame = 0;
|
|
211
|
+
store.dispatch({
|
|
212
|
+
type: "SET_PROGRESS",
|
|
213
|
+
file,
|
|
214
|
+
progress: Math.min(Math.max(0, progress), 100)
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
}).current;
|
|
219
|
+
React.useEffect(() => {
|
|
220
|
+
if (isControlled) store.dispatch({
|
|
221
|
+
type: "SET_FILES",
|
|
222
|
+
files: value
|
|
223
|
+
});
|
|
224
|
+
else if (defaultValue && defaultValue.length > 0 && !store.getState().files.size) store.dispatch({
|
|
225
|
+
type: "SET_FILES",
|
|
226
|
+
files: defaultValue
|
|
227
|
+
});
|
|
228
|
+
}, [
|
|
229
|
+
value,
|
|
230
|
+
defaultValue,
|
|
231
|
+
isControlled,
|
|
232
|
+
store
|
|
233
|
+
]);
|
|
234
|
+
React.useEffect(() => {
|
|
235
|
+
return () => {
|
|
236
|
+
for (const file of files.keys()) {
|
|
237
|
+
const cachedUrl = urlCache.get(file);
|
|
238
|
+
if (cachedUrl) URL.revokeObjectURL(cachedUrl);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}, [files, urlCache]);
|
|
242
|
+
const onFilesUpload = React.useCallback(async (files$1) => {
|
|
243
|
+
try {
|
|
244
|
+
for (const file of files$1) store.dispatch({
|
|
245
|
+
type: "SET_PROGRESS",
|
|
246
|
+
file,
|
|
247
|
+
progress: 0
|
|
248
|
+
});
|
|
249
|
+
if (onUpload) await onUpload(files$1, {
|
|
250
|
+
onProgress,
|
|
251
|
+
onSuccess: (file) => {
|
|
252
|
+
store.dispatch({
|
|
253
|
+
type: "SET_SUCCESS",
|
|
254
|
+
file
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
onError: (file, error) => {
|
|
258
|
+
store.dispatch({
|
|
259
|
+
type: "SET_ERROR",
|
|
260
|
+
file,
|
|
261
|
+
error: error.message ?? "Upload failed"
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
else for (const file of files$1) store.dispatch({
|
|
266
|
+
type: "SET_SUCCESS",
|
|
267
|
+
file
|
|
268
|
+
});
|
|
269
|
+
} catch (error) {
|
|
270
|
+
const errorMessage = error instanceof Error ? error.message : "Upload failed";
|
|
271
|
+
for (const file of files$1) store.dispatch({
|
|
272
|
+
type: "SET_ERROR",
|
|
273
|
+
file,
|
|
274
|
+
error: errorMessage
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}, [
|
|
278
|
+
store,
|
|
279
|
+
onUpload,
|
|
280
|
+
onProgress
|
|
281
|
+
]);
|
|
282
|
+
const onFilesChange = React.useCallback((originalFiles) => {
|
|
283
|
+
if (disabled) return;
|
|
284
|
+
let filesToProcess = [...originalFiles];
|
|
285
|
+
let invalid$1 = false;
|
|
286
|
+
const allRejectedFiles = [];
|
|
287
|
+
if (maxFiles) {
|
|
288
|
+
const currentCount = store.getState().files.size;
|
|
289
|
+
const remainingSlotCount = Math.max(0, maxFiles - currentCount);
|
|
290
|
+
if (remainingSlotCount < filesToProcess.length) {
|
|
291
|
+
const rejectedFromMaxFiles = filesToProcess.slice(remainingSlotCount);
|
|
292
|
+
invalid$1 = true;
|
|
293
|
+
filesToProcess = filesToProcess.slice(0, remainingSlotCount);
|
|
294
|
+
for (const file of rejectedFromMaxFiles) {
|
|
295
|
+
let rejectionMessage = `Maximum ${maxFiles} files allowed`;
|
|
296
|
+
if (onFileValidate) {
|
|
297
|
+
const validationMessage = onFileValidate(file);
|
|
298
|
+
if (validationMessage) rejectionMessage = validationMessage;
|
|
299
|
+
}
|
|
300
|
+
onFileReject?.(file, rejectionMessage);
|
|
301
|
+
allRejectedFiles.push({
|
|
302
|
+
file,
|
|
303
|
+
message: rejectionMessage
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const acceptedFiles = [];
|
|
309
|
+
const rejectedFiles = [];
|
|
310
|
+
for (const file of filesToProcess) {
|
|
311
|
+
let rejected = false;
|
|
312
|
+
let rejectionMessage = "";
|
|
313
|
+
if (onFileValidate) {
|
|
314
|
+
const validationMessage = onFileValidate(file);
|
|
315
|
+
if (validationMessage) {
|
|
316
|
+
rejectionMessage = validationMessage;
|
|
317
|
+
onFileReject?.(file, rejectionMessage);
|
|
318
|
+
rejected = true;
|
|
319
|
+
invalid$1 = true;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (acceptTypes) {
|
|
324
|
+
const fileType = file.type;
|
|
325
|
+
const fileExtension = `.${file.name.split(".").pop()}`;
|
|
326
|
+
if (!acceptTypes.some((type) => type === fileType || type === fileExtension || type.includes("/*") && fileType.startsWith(type.replace("/*", "/")))) {
|
|
327
|
+
rejectionMessage = "File type not accepted";
|
|
328
|
+
onFileReject?.(file, rejectionMessage);
|
|
329
|
+
rejected = true;
|
|
330
|
+
invalid$1 = true;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (maxSize && file.size > maxSize) {
|
|
334
|
+
rejectionMessage = "File too large";
|
|
335
|
+
onFileReject?.(file, rejectionMessage);
|
|
336
|
+
rejected = true;
|
|
337
|
+
invalid$1 = true;
|
|
338
|
+
}
|
|
339
|
+
if (!rejected) acceptedFiles.push(file);
|
|
340
|
+
else rejectedFiles.push({
|
|
341
|
+
file,
|
|
342
|
+
message: rejectionMessage
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
allRejectedFiles.push(...rejectedFiles);
|
|
346
|
+
if (invalid$1) {
|
|
347
|
+
store.dispatch({
|
|
348
|
+
type: "SET_INVALID",
|
|
349
|
+
invalid: invalid$1
|
|
350
|
+
});
|
|
351
|
+
setTimeout(() => {
|
|
352
|
+
store.dispatch({
|
|
353
|
+
type: "SET_INVALID",
|
|
354
|
+
invalid: false
|
|
355
|
+
});
|
|
356
|
+
}, 2e3);
|
|
357
|
+
}
|
|
358
|
+
if (allRejectedFiles.length > 0) onFilesReject?.(allRejectedFiles);
|
|
359
|
+
if (acceptedFiles.length > 0) {
|
|
360
|
+
store.dispatch({
|
|
361
|
+
type: "ADD_FILES",
|
|
362
|
+
files: acceptedFiles
|
|
363
|
+
});
|
|
364
|
+
if (isControlled && onValueChange) onValueChange([...Array.from(store.getState().files.values()).map((f) => f.file)]);
|
|
365
|
+
if (onAccept) onAccept(acceptedFiles);
|
|
366
|
+
for (const file of acceptedFiles) onFileAccept?.(file);
|
|
367
|
+
if (onUpload) requestAnimationFrame(() => {
|
|
368
|
+
onFilesUpload(acceptedFiles);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}, [
|
|
372
|
+
store,
|
|
373
|
+
isControlled,
|
|
374
|
+
onValueChange,
|
|
375
|
+
onAccept,
|
|
376
|
+
onFileAccept,
|
|
377
|
+
onUpload,
|
|
378
|
+
onFilesUpload,
|
|
379
|
+
maxFiles,
|
|
380
|
+
onFileValidate,
|
|
381
|
+
onFileReject,
|
|
382
|
+
onFilesReject,
|
|
383
|
+
acceptTypes,
|
|
384
|
+
maxSize,
|
|
385
|
+
disabled
|
|
386
|
+
]);
|
|
387
|
+
const onInputChange = React.useCallback((event) => {
|
|
388
|
+
onFilesChange(Array.from(event.target.files ?? []));
|
|
389
|
+
event.target.value = "";
|
|
390
|
+
}, [onFilesChange]);
|
|
391
|
+
const contextValue = React.useMemo(() => ({
|
|
392
|
+
dropzoneId,
|
|
393
|
+
inputId,
|
|
394
|
+
listId,
|
|
395
|
+
labelId,
|
|
396
|
+
dir,
|
|
397
|
+
disabled,
|
|
398
|
+
inputRef,
|
|
399
|
+
urlCache
|
|
400
|
+
}), [
|
|
401
|
+
dropzoneId,
|
|
402
|
+
inputId,
|
|
403
|
+
listId,
|
|
404
|
+
labelId,
|
|
405
|
+
dir,
|
|
406
|
+
disabled,
|
|
407
|
+
urlCache
|
|
408
|
+
]);
|
|
409
|
+
const RootPrimitive = asChild ? Slot : "div";
|
|
410
|
+
return /* @__PURE__ */ jsx(StoreContext.Provider, {
|
|
411
|
+
value: store,
|
|
412
|
+
children: /* @__PURE__ */ jsx(FileUploadContext.Provider, {
|
|
413
|
+
value: contextValue,
|
|
414
|
+
children: /* @__PURE__ */ jsxs(RootPrimitive, {
|
|
415
|
+
"data-disabled": disabled ? "" : void 0,
|
|
416
|
+
"data-slot": "file-upload",
|
|
417
|
+
dir,
|
|
418
|
+
...rootProps,
|
|
419
|
+
className: cn("relative flex flex-col gap-2", className),
|
|
420
|
+
children: [
|
|
421
|
+
children,
|
|
422
|
+
/* @__PURE__ */ jsx("input", {
|
|
423
|
+
type: "file",
|
|
424
|
+
id: inputId,
|
|
425
|
+
"aria-labelledby": labelId,
|
|
426
|
+
"aria-describedby": dropzoneId,
|
|
427
|
+
ref: inputRef,
|
|
428
|
+
tabIndex: -1,
|
|
429
|
+
accept,
|
|
430
|
+
name,
|
|
431
|
+
className: "sr-only",
|
|
432
|
+
disabled,
|
|
433
|
+
multiple,
|
|
434
|
+
required,
|
|
435
|
+
onChange: onInputChange
|
|
436
|
+
}),
|
|
437
|
+
/* @__PURE__ */ jsx("span", {
|
|
438
|
+
id: labelId,
|
|
439
|
+
className: "sr-only",
|
|
440
|
+
children: label ?? "File upload"
|
|
441
|
+
})
|
|
442
|
+
]
|
|
443
|
+
})
|
|
444
|
+
})
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function FileUploadDropzone(props) {
|
|
448
|
+
const { asChild, className, onClick: onClickProp, onDragOver: onDragOverProp, onDragEnter: onDragEnterProp, onDragLeave: onDragLeaveProp, onDrop: onDropProp, onPaste: onPasteProp, onKeyDown: onKeyDownProp,...dropzoneProps } = props;
|
|
449
|
+
const context = useFileUploadContext(DROPZONE_NAME);
|
|
450
|
+
const store = useStoreContext(DROPZONE_NAME);
|
|
451
|
+
const dragOver = useStore((state) => state.dragOver);
|
|
452
|
+
const invalid = useStore((state) => state.invalid);
|
|
453
|
+
const onClick = React.useCallback((event) => {
|
|
454
|
+
onClickProp?.(event);
|
|
455
|
+
if (event.defaultPrevented) return;
|
|
456
|
+
const { target } = event;
|
|
457
|
+
if (!(target instanceof HTMLElement && target.closest("[data-slot=\"file-upload-trigger\"]"))) context.inputRef.current?.click();
|
|
458
|
+
}, [context.inputRef, onClickProp]);
|
|
459
|
+
const onDragOver = React.useCallback((event) => {
|
|
460
|
+
onDragOverProp?.(event);
|
|
461
|
+
if (event.defaultPrevented) return;
|
|
462
|
+
event.preventDefault();
|
|
463
|
+
store.dispatch({
|
|
464
|
+
type: "SET_DRAG_OVER",
|
|
465
|
+
dragOver: true
|
|
466
|
+
});
|
|
467
|
+
}, [store, onDragOverProp]);
|
|
468
|
+
const onDragEnter = React.useCallback((event) => {
|
|
469
|
+
onDragEnterProp?.(event);
|
|
470
|
+
if (event.defaultPrevented) return;
|
|
471
|
+
event.preventDefault();
|
|
472
|
+
store.dispatch({
|
|
473
|
+
type: "SET_DRAG_OVER",
|
|
474
|
+
dragOver: true
|
|
475
|
+
});
|
|
476
|
+
}, [store, onDragEnterProp]);
|
|
477
|
+
const onDragLeave = React.useCallback((event) => {
|
|
478
|
+
onDragLeaveProp?.(event);
|
|
479
|
+
if (event.defaultPrevented) return;
|
|
480
|
+
const { relatedTarget } = event;
|
|
481
|
+
if (relatedTarget && relatedTarget instanceof Node && event.currentTarget.contains(relatedTarget)) return;
|
|
482
|
+
event.preventDefault();
|
|
483
|
+
store.dispatch({
|
|
484
|
+
type: "SET_DRAG_OVER",
|
|
485
|
+
dragOver: false
|
|
486
|
+
});
|
|
487
|
+
}, [store, onDragLeaveProp]);
|
|
488
|
+
const onDrop = React.useCallback((event) => {
|
|
489
|
+
onDropProp?.(event);
|
|
490
|
+
if (event.defaultPrevented) return;
|
|
491
|
+
event.preventDefault();
|
|
492
|
+
store.dispatch({
|
|
493
|
+
type: "SET_DRAG_OVER",
|
|
494
|
+
dragOver: false
|
|
495
|
+
});
|
|
496
|
+
const files = Array.from(event.dataTransfer.files);
|
|
497
|
+
const inputElement = context.inputRef.current;
|
|
498
|
+
if (!inputElement) return;
|
|
499
|
+
const dataTransfer = new DataTransfer();
|
|
500
|
+
for (const file of files) dataTransfer.items.add(file);
|
|
501
|
+
inputElement.files = dataTransfer.files;
|
|
502
|
+
inputElement.dispatchEvent(new Event("change", { bubbles: true }));
|
|
503
|
+
}, [
|
|
504
|
+
store,
|
|
505
|
+
context.inputRef,
|
|
506
|
+
onDropProp
|
|
507
|
+
]);
|
|
508
|
+
const onPaste = React.useCallback((event) => {
|
|
509
|
+
onPasteProp?.(event);
|
|
510
|
+
if (event.defaultPrevented) return;
|
|
511
|
+
event.preventDefault();
|
|
512
|
+
store.dispatch({
|
|
513
|
+
type: "SET_DRAG_OVER",
|
|
514
|
+
dragOver: false
|
|
515
|
+
});
|
|
516
|
+
const items = event.clipboardData?.items;
|
|
517
|
+
if (!items) return;
|
|
518
|
+
const files = [];
|
|
519
|
+
for (let i = 0; i < items.length; i++) {
|
|
520
|
+
const item = items[i];
|
|
521
|
+
if (item?.kind === "file") {
|
|
522
|
+
const file = item.getAsFile();
|
|
523
|
+
if (file) files.push(file);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
if (files.length === 0) return;
|
|
527
|
+
const inputElement = context.inputRef.current;
|
|
528
|
+
if (!inputElement) return;
|
|
529
|
+
const dataTransfer = new DataTransfer();
|
|
530
|
+
for (const file of files) dataTransfer.items.add(file);
|
|
531
|
+
inputElement.files = dataTransfer.files;
|
|
532
|
+
inputElement.dispatchEvent(new Event("change", { bubbles: true }));
|
|
533
|
+
}, [
|
|
534
|
+
store,
|
|
535
|
+
context.inputRef,
|
|
536
|
+
onPasteProp
|
|
537
|
+
]);
|
|
538
|
+
const onKeyDown = React.useCallback((event) => {
|
|
539
|
+
onKeyDownProp?.(event);
|
|
540
|
+
if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
|
|
541
|
+
event.preventDefault();
|
|
542
|
+
context.inputRef.current?.click();
|
|
543
|
+
}
|
|
544
|
+
}, [context.inputRef, onKeyDownProp]);
|
|
545
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
546
|
+
role: "region",
|
|
547
|
+
id: context.dropzoneId,
|
|
548
|
+
"aria-controls": `${context.inputId} ${context.listId}`,
|
|
549
|
+
"aria-disabled": context.disabled,
|
|
550
|
+
"aria-invalid": invalid,
|
|
551
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
552
|
+
"data-dragging": dragOver ? "" : void 0,
|
|
553
|
+
"data-invalid": invalid ? "" : void 0,
|
|
554
|
+
"data-slot": "file-upload-dropzone",
|
|
555
|
+
dir: context.dir,
|
|
556
|
+
tabIndex: context.disabled ? void 0 : 0,
|
|
557
|
+
...dropzoneProps,
|
|
558
|
+
className: cn("relative flex select-none flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 outline-none transition-colors hover:bg-accent/30 focus-visible:border-ring/50 data-disabled:pointer-events-none data-dragging:border-primary/30 data-invalid:border-destructive data-dragging:bg-accent/30 data-invalid:ring-destructive/20", className),
|
|
559
|
+
onClick,
|
|
560
|
+
onDragEnter,
|
|
561
|
+
onDragLeave,
|
|
562
|
+
onDragOver,
|
|
563
|
+
onDrop,
|
|
564
|
+
onKeyDown,
|
|
565
|
+
onPaste
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
function FileUploadTrigger(props) {
|
|
569
|
+
const { asChild, onClick: onClickProp,...triggerProps } = props;
|
|
570
|
+
const context = useFileUploadContext(TRIGGER_NAME);
|
|
571
|
+
const onClick = React.useCallback((event) => {
|
|
572
|
+
onClickProp?.(event);
|
|
573
|
+
if (event.defaultPrevented) return;
|
|
574
|
+
context.inputRef.current?.click();
|
|
575
|
+
}, [context.inputRef, onClickProp]);
|
|
576
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
577
|
+
type: "button",
|
|
578
|
+
"aria-controls": context.inputId,
|
|
579
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
580
|
+
"data-slot": "file-upload-trigger",
|
|
581
|
+
...triggerProps,
|
|
582
|
+
disabled: context.disabled,
|
|
583
|
+
onClick
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
function FileUploadList(props) {
|
|
587
|
+
const { className, orientation = "vertical", asChild, forceMount,...listProps } = props;
|
|
588
|
+
const context = useFileUploadContext(LIST_NAME);
|
|
589
|
+
const fileCount = useStore((state) => state.files.size);
|
|
590
|
+
const shouldRender = forceMount || fileCount > 0;
|
|
591
|
+
if (!shouldRender) return null;
|
|
592
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
593
|
+
role: "list",
|
|
594
|
+
id: context.listId,
|
|
595
|
+
"aria-orientation": orientation,
|
|
596
|
+
"data-orientation": orientation,
|
|
597
|
+
"data-slot": "file-upload-list",
|
|
598
|
+
"data-state": shouldRender ? "active" : "inactive",
|
|
599
|
+
dir: context.dir,
|
|
600
|
+
...listProps,
|
|
601
|
+
className: cn("data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 flex flex-col gap-2 data-[state=active]:animate-in data-[state=inactive]:animate-out", orientation === "horizontal" && "flex-row overflow-x-auto p-1.5", className)
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
const FileUploadItemContext = React.createContext(null);
|
|
605
|
+
function useFileUploadItemContext(consumerName) {
|
|
606
|
+
const context = React.use(FileUploadItemContext);
|
|
607
|
+
if (!context) throw new Error(`\`${consumerName}\` must be used within \`${ITEM_NAME}\``);
|
|
608
|
+
return context;
|
|
609
|
+
}
|
|
610
|
+
function FileUploadItem(props) {
|
|
611
|
+
const { value, asChild, className,...itemProps } = props;
|
|
612
|
+
const id = React.useId();
|
|
613
|
+
const statusId = `${id}-status`;
|
|
614
|
+
const nameId = `${id}-name`;
|
|
615
|
+
const sizeId = `${id}-size`;
|
|
616
|
+
const messageId = `${id}-message`;
|
|
617
|
+
const context = useFileUploadContext(ITEM_NAME);
|
|
618
|
+
const fileState = useStore((state) => state.files.get(value));
|
|
619
|
+
const fileCount = useStore((state) => state.files.size);
|
|
620
|
+
const fileIndex = useStore((state) => {
|
|
621
|
+
return Array.from(state.files.keys()).indexOf(value) + 1;
|
|
622
|
+
});
|
|
623
|
+
const itemContext = React.useMemo(() => ({
|
|
624
|
+
id,
|
|
625
|
+
fileState,
|
|
626
|
+
nameId,
|
|
627
|
+
sizeId,
|
|
628
|
+
statusId,
|
|
629
|
+
messageId
|
|
630
|
+
}), [
|
|
631
|
+
id,
|
|
632
|
+
fileState,
|
|
633
|
+
statusId,
|
|
634
|
+
nameId,
|
|
635
|
+
sizeId,
|
|
636
|
+
messageId
|
|
637
|
+
]);
|
|
638
|
+
if (!fileState) return null;
|
|
639
|
+
const statusText = fileState.error ? `Error: ${fileState.error}` : fileState.status === "uploading" ? `Uploading: ${fileState.progress}% complete` : fileState.status === "success" ? "Upload complete" : "Ready to upload";
|
|
640
|
+
const ItemPrimitive = asChild ? Slot : "div";
|
|
641
|
+
return /* @__PURE__ */ jsx(FileUploadItemContext.Provider, {
|
|
642
|
+
value: itemContext,
|
|
643
|
+
children: /* @__PURE__ */ jsxs(ItemPrimitive, {
|
|
644
|
+
role: "listitem",
|
|
645
|
+
id,
|
|
646
|
+
"aria-setsize": fileCount,
|
|
647
|
+
"aria-posinset": fileIndex,
|
|
648
|
+
"aria-describedby": `${nameId} ${sizeId} ${statusId} ${fileState.error ? messageId : ""}`,
|
|
649
|
+
"aria-labelledby": nameId,
|
|
650
|
+
"data-slot": "file-upload-item",
|
|
651
|
+
dir: context.dir,
|
|
652
|
+
...itemProps,
|
|
653
|
+
className: cn("relative flex items-center rounded-md border p-3", className),
|
|
654
|
+
children: [props.children, /* @__PURE__ */ jsx("span", {
|
|
655
|
+
id: statusId,
|
|
656
|
+
className: "sr-only",
|
|
657
|
+
children: statusText
|
|
658
|
+
})]
|
|
659
|
+
})
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
function formatBytes(bytes) {
|
|
663
|
+
if (bytes === 0) return "0 B";
|
|
664
|
+
const sizes = [
|
|
665
|
+
"B",
|
|
666
|
+
"KB",
|
|
667
|
+
"MB",
|
|
668
|
+
"GB",
|
|
669
|
+
"TB"
|
|
670
|
+
];
|
|
671
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
672
|
+
return `${(bytes / 1024 ** i).toFixed(i ? 1 : 0)} ${sizes[i]}`;
|
|
673
|
+
}
|
|
674
|
+
function getFileIcon(file) {
|
|
675
|
+
const { type } = file;
|
|
676
|
+
const extension = file.name.split(".").pop()?.toLowerCase() ?? "";
|
|
677
|
+
if (type.startsWith("video/")) return /* @__PURE__ */ jsx(FileVideoIcon, {});
|
|
678
|
+
if (type.startsWith("audio/")) return /* @__PURE__ */ jsx(FileAudioIcon, {});
|
|
679
|
+
if (type.startsWith("text/") || [
|
|
680
|
+
"txt",
|
|
681
|
+
"md",
|
|
682
|
+
"rtf",
|
|
683
|
+
"pdf"
|
|
684
|
+
].includes(extension)) return /* @__PURE__ */ jsx(FileTextIcon, {});
|
|
685
|
+
if ([
|
|
686
|
+
"html",
|
|
687
|
+
"css",
|
|
688
|
+
"js",
|
|
689
|
+
"jsx",
|
|
690
|
+
"ts",
|
|
691
|
+
"tsx",
|
|
692
|
+
"json",
|
|
693
|
+
"xml",
|
|
694
|
+
"php",
|
|
695
|
+
"py",
|
|
696
|
+
"rb",
|
|
697
|
+
"java",
|
|
698
|
+
"c",
|
|
699
|
+
"cpp",
|
|
700
|
+
"cs"
|
|
701
|
+
].includes(extension)) return /* @__PURE__ */ jsx(FileCodeIcon, {});
|
|
702
|
+
if ([
|
|
703
|
+
"zip",
|
|
704
|
+
"rar",
|
|
705
|
+
"7z",
|
|
706
|
+
"tar",
|
|
707
|
+
"gz",
|
|
708
|
+
"bz2"
|
|
709
|
+
].includes(extension)) return /* @__PURE__ */ jsx(FileArchiveIcon, {});
|
|
710
|
+
if ([
|
|
711
|
+
"exe",
|
|
712
|
+
"msi",
|
|
713
|
+
"app",
|
|
714
|
+
"apk",
|
|
715
|
+
"deb",
|
|
716
|
+
"rpm"
|
|
717
|
+
].includes(extension) || type.startsWith("application/")) return /* @__PURE__ */ jsx(FileCogIcon, {});
|
|
718
|
+
return /* @__PURE__ */ jsx(FileIcon, {});
|
|
719
|
+
}
|
|
720
|
+
function FileUploadItemPreview(props) {
|
|
721
|
+
const { render, asChild, children, className,...previewProps } = props;
|
|
722
|
+
const itemContext = useFileUploadItemContext(ITEM_PREVIEW_NAME);
|
|
723
|
+
const context = useFileUploadContext(ITEM_PREVIEW_NAME);
|
|
724
|
+
const getDefaultRender = React.useCallback((file) => {
|
|
725
|
+
if (itemContext.fileState?.file.type.startsWith("image/")) {
|
|
726
|
+
let url = context.urlCache.get(file);
|
|
727
|
+
if (!url) {
|
|
728
|
+
url = URL.createObjectURL(file);
|
|
729
|
+
context.urlCache.set(file, url);
|
|
730
|
+
}
|
|
731
|
+
return /* @__PURE__ */ jsx("img", {
|
|
732
|
+
src: url,
|
|
733
|
+
alt: file.name,
|
|
734
|
+
className: "size-full object-cover"
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
return getFileIcon(file);
|
|
738
|
+
}, [itemContext.fileState?.file.type, context.urlCache]);
|
|
739
|
+
const onPreviewRender = React.useCallback((file) => {
|
|
740
|
+
if (render) return render(file, () => getDefaultRender(file));
|
|
741
|
+
return getDefaultRender(file);
|
|
742
|
+
}, [render, getDefaultRender]);
|
|
743
|
+
if (!itemContext.fileState) return null;
|
|
744
|
+
return /* @__PURE__ */ jsxs(asChild ? Slot : "div", {
|
|
745
|
+
"aria-labelledby": itemContext.nameId,
|
|
746
|
+
"data-slot": "file-upload-preview",
|
|
747
|
+
...previewProps,
|
|
748
|
+
className: cn("relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10", className),
|
|
749
|
+
children: [onPreviewRender(itemContext.fileState.file), children]
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
function FileUploadItemMetadata(props) {
|
|
753
|
+
const { asChild, size = "default", children, className,...metadataProps } = props;
|
|
754
|
+
const context = useFileUploadContext(ITEM_METADATA_NAME);
|
|
755
|
+
const itemContext = useFileUploadItemContext(ITEM_METADATA_NAME);
|
|
756
|
+
if (!itemContext.fileState) return null;
|
|
757
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
758
|
+
"data-slot": "file-upload-metadata",
|
|
759
|
+
dir: context.dir,
|
|
760
|
+
...metadataProps,
|
|
761
|
+
className: cn("flex min-w-0 flex-1 flex-col", className),
|
|
762
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
763
|
+
/* @__PURE__ */ jsx("span", {
|
|
764
|
+
id: itemContext.nameId,
|
|
765
|
+
className: cn("truncate font-medium text-sm", size === "sm" && "font-normal text-[13px] leading-snug"),
|
|
766
|
+
children: itemContext.fileState.file.name
|
|
767
|
+
}),
|
|
768
|
+
/* @__PURE__ */ jsx("span", {
|
|
769
|
+
id: itemContext.sizeId,
|
|
770
|
+
className: cn("truncate text-muted-foreground text-xs", size === "sm" && "text-[11px] leading-snug"),
|
|
771
|
+
children: formatBytes(itemContext.fileState.file.size)
|
|
772
|
+
}),
|
|
773
|
+
itemContext.fileState.error && /* @__PURE__ */ jsx("span", {
|
|
774
|
+
id: itemContext.messageId,
|
|
775
|
+
className: "text-destructive text-xs",
|
|
776
|
+
children: itemContext.fileState.error
|
|
777
|
+
})
|
|
778
|
+
] })
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
function FileUploadItemProgress(props) {
|
|
782
|
+
const { variant = "linear", size = 40, strokeWidth = 2, asChild, forceMount, className,...progressProps } = props;
|
|
783
|
+
const itemContext = useFileUploadItemContext(ITEM_PROGRESS_NAME);
|
|
784
|
+
if (!itemContext.fileState) return null;
|
|
785
|
+
if (!(forceMount || itemContext.fileState.progress !== 100)) return null;
|
|
786
|
+
const ItemProgressPrimitive = asChild ? Slot : "div";
|
|
787
|
+
switch (variant) {
|
|
788
|
+
case "circular": {
|
|
789
|
+
const circumference = 2 * Math.PI * ((size - 4) / 2);
|
|
790
|
+
const strokeDashoffset = circumference - itemContext.fileState.progress / 100 * circumference;
|
|
791
|
+
return /* @__PURE__ */ jsx(ItemProgressPrimitive, {
|
|
792
|
+
role: "progressbar",
|
|
793
|
+
"aria-valuemin": 0,
|
|
794
|
+
"aria-valuemax": 100,
|
|
795
|
+
"aria-valuenow": itemContext.fileState.progress,
|
|
796
|
+
"aria-valuetext": `${itemContext.fileState.progress}%`,
|
|
797
|
+
"aria-labelledby": itemContext.nameId,
|
|
798
|
+
"data-slot": "file-upload-progress",
|
|
799
|
+
...progressProps,
|
|
800
|
+
className: cn("-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2", className),
|
|
801
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
802
|
+
className: "-rotate-90 transform",
|
|
803
|
+
width: size,
|
|
804
|
+
height: size,
|
|
805
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
806
|
+
fill: "none",
|
|
807
|
+
stroke: "currentColor",
|
|
808
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
809
|
+
className: "text-primary/20",
|
|
810
|
+
strokeWidth,
|
|
811
|
+
cx: size / 2,
|
|
812
|
+
cy: size / 2,
|
|
813
|
+
r: (size - 4) / 2
|
|
814
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
815
|
+
className: "text-primary transition-[stroke-dashoffset] duration-300 ease-linear",
|
|
816
|
+
strokeWidth,
|
|
817
|
+
strokeLinecap: "round",
|
|
818
|
+
strokeDasharray: circumference,
|
|
819
|
+
strokeDashoffset,
|
|
820
|
+
cx: size / 2,
|
|
821
|
+
cy: size / 2,
|
|
822
|
+
r: (size - 4) / 2
|
|
823
|
+
})]
|
|
824
|
+
})
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
case "fill": {
|
|
828
|
+
const progressPercentage = itemContext.fileState.progress;
|
|
829
|
+
const topInset = 100 - progressPercentage;
|
|
830
|
+
return /* @__PURE__ */ jsx(ItemProgressPrimitive, {
|
|
831
|
+
role: "progressbar",
|
|
832
|
+
"aria-valuemin": 0,
|
|
833
|
+
"aria-valuemax": 100,
|
|
834
|
+
"aria-valuenow": progressPercentage,
|
|
835
|
+
"aria-valuetext": `${progressPercentage}%`,
|
|
836
|
+
"aria-labelledby": itemContext.nameId,
|
|
837
|
+
"data-slot": "file-upload-progress",
|
|
838
|
+
...progressProps,
|
|
839
|
+
className: cn("absolute inset-0 bg-primary/50 transition-[clip-path] duration-300 ease-linear", className),
|
|
840
|
+
style: { clipPath: `inset(${topInset}% 0% 0% 0%)` }
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
default: return /* @__PURE__ */ jsx(ItemProgressPrimitive, {
|
|
844
|
+
role: "progressbar",
|
|
845
|
+
"aria-valuemin": 0,
|
|
846
|
+
"aria-valuemax": 100,
|
|
847
|
+
"aria-valuenow": itemContext.fileState.progress,
|
|
848
|
+
"aria-valuetext": `${itemContext.fileState.progress}%`,
|
|
849
|
+
"aria-labelledby": itemContext.nameId,
|
|
850
|
+
"data-slot": "file-upload-progress",
|
|
851
|
+
...progressProps,
|
|
852
|
+
className: cn("relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20", className),
|
|
853
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
854
|
+
className: "h-full w-full flex-1 bg-primary transition-transform duration-300 ease-linear",
|
|
855
|
+
style: { transform: `translateX(-${100 - itemContext.fileState.progress}%)` }
|
|
856
|
+
})
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
function FileUploadItemDelete(props) {
|
|
861
|
+
const { asChild, onClick: onClickProp,...deleteProps } = props;
|
|
862
|
+
const store = useStoreContext(ITEM_DELETE_NAME);
|
|
863
|
+
const itemContext = useFileUploadItemContext(ITEM_DELETE_NAME);
|
|
864
|
+
const onClick = React.useCallback((event) => {
|
|
865
|
+
onClickProp?.(event);
|
|
866
|
+
if (!itemContext.fileState || event.defaultPrevented) return;
|
|
867
|
+
store.dispatch({
|
|
868
|
+
type: "REMOVE_FILE",
|
|
869
|
+
file: itemContext.fileState.file
|
|
870
|
+
});
|
|
871
|
+
}, [
|
|
872
|
+
store,
|
|
873
|
+
itemContext.fileState,
|
|
874
|
+
onClickProp
|
|
875
|
+
]);
|
|
876
|
+
if (!itemContext.fileState) return null;
|
|
877
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
878
|
+
type: "button",
|
|
879
|
+
"aria-controls": itemContext.id,
|
|
880
|
+
"aria-describedby": itemContext.nameId,
|
|
881
|
+
"data-slot": "file-upload-item-delete",
|
|
882
|
+
...deleteProps,
|
|
883
|
+
onClick
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
function FileUploadClear(props) {
|
|
887
|
+
const { asChild, forceMount, disabled, onClick: onClickProp,...clearProps } = props;
|
|
888
|
+
const context = useFileUploadContext(CLEAR_NAME);
|
|
889
|
+
const store = useStoreContext(CLEAR_NAME);
|
|
890
|
+
const fileCount = useStore((state) => state.files.size);
|
|
891
|
+
const isDisabled = disabled || context.disabled;
|
|
892
|
+
const onClick = React.useCallback((event) => {
|
|
893
|
+
onClickProp?.(event);
|
|
894
|
+
if (event.defaultPrevented) return;
|
|
895
|
+
store.dispatch({ type: "CLEAR" });
|
|
896
|
+
}, [store, onClickProp]);
|
|
897
|
+
if (!(forceMount || fileCount > 0)) return null;
|
|
898
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
899
|
+
type: "button",
|
|
900
|
+
"aria-controls": context.listId,
|
|
901
|
+
"data-slot": "file-upload-clear",
|
|
902
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
903
|
+
...clearProps,
|
|
904
|
+
disabled: isDisabled,
|
|
905
|
+
onClick
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
//#endregion
|
|
910
|
+
export { FileUploadClear, FileUploadDropzone, FileUploadItem, FileUploadItemDelete, FileUploadItemMetadata, FileUploadItemPreview, FileUploadItemProgress, FileUploadList, FileUploadRoot, FileUploadTrigger, useStore };
|