fina-react-ds 1.0.49 → 1.0.50
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var z=Object.defineProperty;var o=(i,l)=>z(i,"name",{value:l,configurable:!0});import{jsxs as r,jsx as e,Fragment as f}from"react/jsx-runtime";import{useState as j,useCallback as p,useImperativeHandle as k}from"react";import{FileIcon as F,UploadIcon as C}from"lucide-react";import{useDropzone as D}from"react-dropzone";import{cn as c}from"../lib/utils.js";import{Button as I}from"./button.js";function H({onChange:i,"aria-invalid":l,fileTypes:x,ref:b}){const[a,d]=j([]),v=p(n=>{d(n),i?.(n.length>0?n[0]:null)},[i]),{getRootProps:g,getInputProps:h,acceptedFiles:u,open:y,rootRef:t}=D({maxFiles:1,noClick:!0,onDrop:v,onFileDialogCancel:o(()=>{t?.current&&t.current.focus()},"onFileDialogCancel")});k(b,()=>({focus:o(()=>{t?.current&&t.current.focus()},"focus")}));const N=p(n=>{let s=0,m="ko";return s=n.size/1e3,s>1e3&&(s/=1e3,m="mo"),s.toFixed(2)+" "+m},[]);return r("div",{...g(),className:c("bg-input border border-input-border flex flex-col h-50 flex-2 rounded-md px-3 py-1 text-base shadow-xs items-center justify-center md:text-sm outline-none","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive"),"aria-invalid":l,children:[a.length>0&&r(f,{children:[e("div",{className:c("bg-primary text-primary-foreground flex items-center justify-center rounded-full size-10 mb-4"),children:e(F,{className:"size-4"})}),r("div",{className:"mb-4 text-center",children:[u[0].name,e("br",{}),N(u[0])]}),e(I,{type:"button",color:"destructive",variant:"ghost",onClick:o(()=>{d([]),i?.(null),t?.current?.focus()},"onClick"),children:"Supprimer"})]}),a.length===0&&r(f,{children:[e("div",{className:c("bg-primary text-primary-foreground flex items-center justify-center rounded-full size-10 mb-4"),children:e(C,{className:"size-4"})}),r("div",{className:"mb-4",children:["Glisser-déposer ou"," ",e("span",{className:"font-bold underline cursor-pointer",onClick:y,children:"Choisir un fichier"})," ","à uploader"]}),r("div",{className:"text-center text-sm md:text-xs",children:["Formats acceptés : ",Object.keys(x).join(", "),e("br",{}),"Taille max : 5Mo"]})]}),e("input",{...h()})]})}o(H,"FileUploader");export{H as FileUploader};
|