2 lines
2.6 KiB
JavaScript
2 lines
2.6 KiB
JavaScript
import{j as e,b as n,B as y,s as c,bt as j,T as C,ar as b,I as z}from"./mui-vendor-CkIVaoQP.js";import{r}from"./react-vendor-CmFgShSM.js";import{d as S}from"./CloudUpload-ceMRBIFJ.js";import{d as w}from"./Close-8pFLGZ5w.js";import{d as F}from"./CheckCircle-eA7tEzBu.js";import{A as I,m as x}from"./index-Vwb3Bce5.js";import{A}from"./index-19hIvwJJ.js";const B=c("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),R=c(x.div)(({theme:s})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:s.spacing(.5),margin:s.spacing(.25,0),borderRadius:s.shape.borderRadius,"&:hover":{backgroundColor:s.palette.action.hover}})),$=({onChange:s})=>{const[o,l]=r.useState([]),[f,u]=r.useState(!1),[h,d]=r.useState(0),[m]=r.useContext(I),g=t=>{const i=t.target.files[0];if(!i)return;if(i.size>5e6){m({vertical:"top",horizontal:"center",msg:"حجم فایل بیش از حد مجاز است!",severity:"error"});return}u(!0),d(0);const p=setInterval(()=>{d(a=>a>=100?(clearInterval(p),u(!1),100):a+10)},100);l(a=>[...a,i])},v=t=>{l(i=>i.filter((p,a)=>a!==t))};return r.useEffect(()=>{s&&s(o)},[o,s]),e.jsxs(n,{sx:{width:"100%"},children:[e.jsxs(y,{disabled:o.length>=4,component:"label",variant:"contained",color:"primary",size:"small",startIcon:e.jsx(S,{fontSize:"small"}),sx:{borderRadius:"12px",padding:"4px 12px",fontSize:"0.8125rem",minWidth:"auto","&:hover":{transform:"none"}},children:[o.length>=4?"حداکثر 4 فایل":"آپلود فایل",e.jsx(B,{type:"file",onChange:g})]}),e.jsx(A,{children:!!o.length&&e.jsx(x.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},style:{marginTop:8},children:e.jsxs(n,{sx:{maxHeight:150,overflowY:"auto",pr:1},children:[f&&e.jsx(j,{variant:"determinate",value:h,color:"secondary",sx:{height:4,borderRadius:2,mb:.5}}),o.map((t,i)=>e.jsxs(R,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[e.jsxs(n,{sx:{display:"flex",alignItems:"center",gap:1,overflow:"hidden"},children:[e.jsx(F,{color:"success",fontSize:"small",sx:{fontSize:"16px"}}),e.jsx(C,{variant:"body2",sx:{fontSize:"0.8125rem",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:120},children:t.name}),e.jsx(b,{label:`${(t.size/1e6).toFixed(2)}MB`,size:"small",sx:{height:20,fontSize:"0.6875rem"}})]}),e.jsx(z,{color:"error",onClick:()=>v(i),size:"small",sx:{p:.5},children:e.jsx(w,{fontSize:"small",sx:{fontSize:"16px"}})})]},t==null?void 0:t.name))]})})})]})};export{$ as F};
|