@anoki/fse-ui
Version:
FSE UI components library
3 lines (2 loc) • 2.64 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./components/ui/DocumentUploadComponent/DocumentUploadComponent.css');const e=require("./index.cjs244.js"),I=require("react"),d=require("./index.cjs28.js"),l=require("./index.cjs246.js");;/* empty css */const B=require("./index.cjs10.js"),S=require("./index.cjs161.js"),k=require("./index.cjs197.js"),v=({onFileUpload:r,isLoading:u,title:m,description:p="",titleTag:j="h1",actionText:f="Aggiungi",className:g="",classNameTitle:b="",classNameDescription:h="",id:o="fileInput",name:R="fileInput",fileSizeLabel:y="Dimensioni",removeLabel:E="RIMUOVI",accept:C=".pdf,.doc,.docx,.jpg,.jpeg,.png"})=>{const[n,x]=I.useState(null),N=t=>{if(t.target.files&&t.target.files.length>0){const s=t.target.files[0];x(s),r&&s&&w(s).then(a=>{r(a,s.name,s.type)})}},w=t=>new Promise((s,a)=>{const i=new FileReader;i.readAsDataURL(t),i.onload=()=>{if(typeof i.result=="string"){const c=i.result.split(",")[1];s(c)}},i.onerror=c=>a(c)}),q=()=>{x(null);const t=document.getElementById(o);t&&(t.value=""),r("","","")};return e.jsxRuntimeExports.jsxs(B.Col,{br:"x4",gap:"x16",bg:"lightblue-a03",className:l.clsx(g,"ui-banner-upload shadow"),children:[e.jsxRuntimeExports.jsx(j,{className:l.clsx(n?"text-primary":"text-slate-20","ui-banner-title-upload ",b||"fs-4 fw-bold"),children:n?n.name:m}),e.jsxRuntimeExports.jsxs("main",{className:l.clsx("ui-banner-content-upload fs-6 text-secondary w-100 ui-banner-content-layout1-upload text-secondary justify-content-between"),children:[e.jsxRuntimeExports.jsx("div",{className:l.clsx(h,"ui-banner-description-upload"),children:n?e.jsxRuntimeExports.jsxs("div",{children:[y,": ",(n.size/(1024*1024)).toFixed(2)," ","MB"]}):p}),e.jsxRuntimeExports.jsxs("div",{className:l.clsx("ui-banner-link-upload"),children:[e.jsxRuntimeExports.jsx("input",{type:"file",id:o,name:R,style:{display:"none"},onChange:N,accept:C,className:"fs-7",required:!0}),n?e.jsxRuntimeExports.jsxs(d.Button,{size:"2",textColor:"primary",bg:"lightblue-a03",className:"w-full ",onClick:q,disabled:u,children:[e.jsxRuntimeExports.jsx(S.Close,{}),e.jsxRuntimeExports.jsx("p",{className:"fs-6 fw-bold px-x8",children:E})]}):e.jsxRuntimeExports.jsxs(d.Button,{size:"2",textColor:"primary",bg:"lightblue-a03",border:"primary",className:"w-full",onClick:()=>{var t;return(t=document.getElementById(o))==null?void 0:t.click()},disabled:u,children:[e.jsxRuntimeExports.jsx(k.Attachment,{className:"mr-x8"}),e.jsxRuntimeExports.jsx("p",{className:"fs-6 fw-bold",children:f})]})]})]})]})};exports.DocumentUploadComponent=v;
//# sourceMappingURL=index.cjs53.js.map