@anoki/fse-marche-ui
Version:
FSE UI components library
3 lines (2 loc) • 2.63 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./components/ui/DocumentUploadComponent/DocumentUploadComponent.css');const e=require("./index.cjs137.js"),q=require("react"),d=require("./index.cjs25.js"),l=require("./index.cjs139.js");;/* empty css */const I=require("./index.cjs10.js"),B=require("./index.cjs79.js"),S=require("./index.cjs112.js"),k=({onFileUpload:r,isLoading:u,title:m,description:p="",titleTag:j="h3",actionText:f="Aggiungi",className:g="",classNameTitle:b="",classNameDescription:h="",id:o="fileInput",name:R="fileInput",fileSizeLabel:y="Dimensioni",removeLabel:E="RIMUOVI"})=>{const[n,x]=q.useState(null),C=t=>{if(t.target.files&&t.target.files.length>0){const s=t.target.files[0];x(s),r&&s&&N(s).then(a=>{r(a,s.name,s.type)})}},N=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)}),w=()=>{x(null);const t=document.getElementById(o);t&&(t.value=""),r("","","")};return e.jsxRuntimeExports.jsxs(I.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:C,accept:".pdf,.doc,.docx,.jpg,.jpeg,.png",className:"fs-7",required:!0}),n?e.jsxRuntimeExports.jsxs(d.Button,{size:"2",textColor:"primary",bg:"lightblue-a03",className:"w-full ",onClick:w,disabled:u,children:[e.jsxRuntimeExports.jsx(B.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(S.Attachment,{className:"mr-x8"}),e.jsxRuntimeExports.jsx("p",{className:"fs-6 fw-bold",children:f})]})]})]})]})};exports.DocumentUploadComponent=k;
//# sourceMappingURL=index.cjs45.js.map