@s_mart/dropzone 11.0.0 → 11.0.1
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/index.mjs +3 -3
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Button as be,styled as F,Typography as He}from"@mui/material";import{colorPalette as
|
|
1
|
+
import{Button as be,styled as F,Typography as He}from"@mui/material";import{colorPalette as I}from"@s_mart/tokens";var j=F("div")`
|
|
2
2
|
min-width: 300px;
|
|
3
3
|
align-items: center;
|
|
4
4
|
display: flex;
|
|
@@ -14,7 +14,7 @@ import{Button as be,styled as F,Typography as He}from"@mui/material";import{colo
|
|
|
14
14
|
left: 0;
|
|
15
15
|
height: 0;
|
|
16
16
|
width: 0;
|
|
17
|
-
border: 0px dashed ${
|
|
17
|
+
border: 0px dashed ${I.neutral[500]};
|
|
18
18
|
border-radius: 8px;
|
|
19
19
|
display: flex;
|
|
20
20
|
justify-content: center;
|
|
@@ -27,7 +27,7 @@ import{Button as be,styled as F,Typography as He}from"@mui/material";import{colo
|
|
|
27
27
|
width: 99.3%;
|
|
28
28
|
border-width: 2px;
|
|
29
29
|
}
|
|
30
|
-
`,K=F(be)(({theme:e})=>({width:"100%",pointerEvents:"all",minHeight:"40px",backgroundColor:e.palette.primary.main,borderRadius:Number.parseFloat(e.shape.borderRadius.toString())*2,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"8px",padding:".5rem 1rem",cursor:"pointer",transition:"all 0.5s ease",'&[data-max-files="1"]':{minHeight:0},'&[data-has-files="true"]':{height:"40px"},'&[data-has-files="true"][data-max-files="1"]':{height:0},'&[data-has-files="true"] #dropzone-upload-info':{display:"none"},'&:not([data-has-files="true"]) #dropzone-upload-more-label, &[data-max-files="1"] #dropzone-upload-more-label':{display:"none"},"& #dropzone-upload-more-label":{pointerEvents:"all",color:"white"},'&[data-is-processing-zip="true"], &[data-is-processing-zip="true"] #dropzone-upload-more-label':{pointerEvents:"none"},"&:hover":{backgroundColor:({theme:t})=>t.palette.primary.dark}})),Q=F("div")(({theme:e})=>({width:"100%",maxHeight:"300px",backgroundColor:M.neutral[20],borderRadius:Number.parseFloat(e.shape.borderRadius.toString())*2,display:"flex",flexDirection:"column",border:`1px solid ${M.neutral[20]}`,padding:"8px",gap:"8px"})),Y=F("div")({backgroundColor:"white",borderRadius:"16px",padding:"8px",gap:"24px",display:"grid",gridTemplateColumns:"min-content min-content 1fr min-content",alignItems:"center",justifyContent:"space-between"}),J=F("div")({height:300,overflow:"auto"}),W=F("div")({position:"relative",width:"100%"}),ee=F("div")({top:0,left:0,width:"100%",position:"absolute",paddingBottom:"8px",boxSizing:"border-box"}),oe=F(He)({color:M.neutral[600],overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"start"});import{Tooltip as Ze,Typography as Ne}from"@mui/material";import{IconButton as _e,LIcon as se}from"@s_mart/core";import{lineTimes as je}from"@s_mart/regular-icons";import{colorPalette as Ge}from"@s_mart/tokens";import{useMemo as re}from"react";import{lineFile as we,linePicture as Pe,lineXMLFile as Ee}from"@s_mart/light-icons";import{lineFileCertificate as Se}from"@s_mart/regular-icons";var te=e=>{switch(console.log(e),e){case"application/xml":case"text/xml":return Ee;case"image/gif":case"image/jpeg":case"image/png":case"image/svg":case"image/webp":return Pe;case"application/pkcs12":return Se;default:return we}},H=e=>{let t="";return e<1024?t=`${e} Bytes`:e<1024*1024?t=`${(e/1024).toFixed(2)} KB`:e<1024*1024*1024&&(t=`${(e/1024/1024).toFixed(2)} MB`),t};var ne=({filesInfo:e})=>{let t=re(()=>(console.log(e),e.map(o=>({name:o.name,fileSize:H(o.size),icon:te(o.type)}))),[e]),r=re(()=>({totalSize:H(e.reduce((o,n)=>o+n.size,0)),totalFilesLabel:e.length===1?"1 arquivo":`${e.length} arquivos`}),[e]);return{files:t,headerInfo:r}};import{Tooltip as Me}from"@mui/material";import V from"@mui/utils/deepmerge";import{IconButton as Ie,LIcon as Re}from"@s_mart/core";import{lineTimes as Ae}from"@s_mart/regular-icons";import{jsx as O}from"react/jsx-runtime";var U={headerCleartooltip:{title:"Remover todos"},headerClearIconButton:{variant:"text",color:"neutral",sx:{borderRadius:50}},headerClearLicon:{icon:Ae,removeMargin:!0}},q={clone:!1},ie=({onClick:e,slotProps:t})=>{let r=V(U.headerCleartooltip,t?.headerCleartooltip,q),o=V(U.headerClearIconButton,t?.headerClearIconButton,q),n=V(U.headerClearLicon,t?.headerClearLicon,q);return O(Me,{...r,children:O(Ie,{...o,onClick:e,children:O(Re,{...n})})})};import{styled as ke}from"@mui/material";var ae=ke("div")({display:"flex",justifyContent:"space-between",alignItems:"center",paddingBlock:"0.5rem"});import{Typography as Be}from"@mui/material";import $e from"@mui/utils/deepmerge";import{useMemo as Ve}from"react";import{Fragment as Xe,jsx as I}from"react/jsx-runtime";var Ue={headerTitle:{variant:"titleXXS"}},qe={headerTitleContent:e=>I(Oe,{...e})},Oe=e=>{let t=`${e.filesLengthLabel}`;return e.showFilesSize&&(t+=` - ${e.filesTotalSize}`),I(Xe,{children:t})},le=e=>{let t=e.slots?.headerTitleContent??qe.headerTitleContent,r=Ve(()=>$e(Ue.headerTitle,{...e,...e.slotProps?.headerTitle}),[e.filesLengthLabel,e.filesTotalSize,e]);return I(Be,{...r,children:I(t,{...r})})};var R={Container:ae,Title:le,ClearButton:ie};import{useRef as Ke}from"react";import{useVirtualizer as Qe}from"@tanstack/react-virtual";import{jsx as h,jsxs as X}from"react/jsx-runtime";var pe=({filesInfo:e,onRemoveFile:t,onRemoveAllFiles:r,slotProps:o,slots:n,showFilesSize:p})=>{let{files:l,headerInfo:i}=ne({filesInfo:e}),u=Ke(null),d=Qe({count:l.length,getScrollElement:()=>u.current,estimateSize:()=>60,overscan:5});return l.length===0?null:X(Q,{...o?.filesContainer,children:[X(R.Container,{children:[h(R.Title,{slots:n,slotProps:o?.header,filesLengthLabel:i.totalFilesLabel,filesTotalSize:i.totalSize,showFilesSize:p}),h(R.ClearButton,{onClick:r})]}),h(J,{ref:u,...o?.filesListRoot,children:h(W,{...o?.filesListContainer,sx:{height:`${d.getTotalSize()}px`,...o?.filesListContainer},children:d.getVirtualItems().map(m=>{let g=l[m.index];return h(ee,{sx:{height:`${m.size}px`,transform:`translateY(${m.start}px)`},children:h(Ze,{title:g.name,arrow:!0,placement:"top",children:X(Y,{...o?.listItem,children:[h(se,{icon:g.icon,removeMargin:!0,size:"24px"}),h(Ne,{variant:"titleXXS",color:Ge.neutral[600],whiteSpace:"nowrap",children:p&&g.fileSize}),h(oe,{variant:"titleXXS",children:g.name}),h(_e,{variant:"text",color:"neutral",sx:{borderRadius:50},onClick:()=>t(m.index),children:h(se,{icon:je,removeMargin:!0})})]})})},m.key)})})})]})};import{CircularProgress as de,Stack as Z,Typography as A}from"@mui/material";import{LIcon as Ye}from"@s_mart/core";import{lineFileUpload as Je}from"@s_mart/regular-icons";import{jsx as T,jsxs as w}from"react/jsx-runtime";var ce=({placeholder:e,isProcessingZip:t})=>t?w("div",{children:[w(Z,{id:"dropzone-upload-info",sx:{gap:1,alignItems:"center",direction:"row"},children:[T(de,{sx:{color:"white"},size:24}),T(A,{variant:"titleSM",color:"white",children:"Descompactando zip..."})]}),w(Z,{id:"dropzone-upload-more-label",sx:{gap:1,alignItems:"center",direction:"row"},children:[T(de,{sx:{color:"white"},size:12}),T(A,{variant:"bodySM",sx:{fontWeight:700},children:"Descompactando zip..."})]})]}):w("div",{children:[w(Z,{id:"dropzone-upload-info",sx:{gap:1,alignItems:"center",direction:"row"},children:[T(Ye,{icon:Je,size:"48px",color:"white",removeMargin:!0}),T(A,{variant:"titleSM",color:"white",children:e})]}),T(A,{id:"dropzone-upload-more-label",variant:"bodySM",sx:{fontWeight:700},children:"Carregar mais arquivos"})]});import{useCallback as P,useMemo as ro,useRef as ue,useState as fe}from"react";var me=async(e,t)=>{let r=[];for(let o of e.items){if(o.kind!=="file")continue;if(typeof o.webkitGetAsEntry=="function"){let p=o.webkitGetAsEntry();if(p===null)continue;let l=await We(p);r.push(...l);continue}let n=o.getAsFile();n&&r.push(n)}return t!==void 0&&(r=to(r,t)),r},We=e=>new Promise((t,r)=>{let o=0,n=[];p(e);function p(i){oo(i)?(o++,i.file(u=>{o--,n.push(u),o===0&&t(n)})):eo(i)&&l(i.createReader())}function l(i){o++,i.readEntries(function(u){o--;for(let d of u)p(d);o===0&&t(n)})}}),eo=e=>e.isDirectory,oo=e=>e.isFile,to=(e,t)=>{let r=[],o=t.split(",");for(let n of e){let p=`.${n.name.split(".").pop()?.toLowerCase()}`;o.includes(p)&&r.push(n)}return r};var N=e=>{e.stopPropagation(),e.preventDefault()},_=e=>{e.dataTransfer.dropEffect="link",N(e)};var ge=({onChange:e,filterOnDrop:t,maxSize:r,maxFiles:o,accept:n,onError:p,onWarning:l,files:i})=>{let[u,d]=fe(!1),[m,g]=fe(!1),y=ue(null),B=ue(!1),s=P(async a=>{g(!0);let f=[],{BlobReader:D,BlobWriter:b,ZipReader:E}=await import("@zip.js/zip.js").catch(()=>{throw new Error("Fa\xE7a a instala\xE7\xE3o da biblioteca @zip.js/zip.js para utilizar o Dropzone com exporta\xE7\xE3o de .zip")}),x=new D(a),v=new E(x);try{let $=await v.getEntries();for(let S of $){if(S.directory||S.getData===void 0)continue;let Te=await S.getData(new b),Le=new File([Te],S.filename);f.push(Le)}}catch($){p?.("Ocorreu um erro ao processar o arquivo compactado.",$)}finally{g(!1),await v.close()}return f},[p]),z=P(async a=>{if(!n)return a;let f=[];for(let D of a){let b=`.${D.name.split(".").pop()?.toLocaleLowerCase()}`;if(!n.split(",").includes(b)){l?.(`O arquivo "${D.name}" n\xE3o \xE9 valido, extens\xF5es aceitas ${n}`);continue}if(b===".zip"){let x=await s(D);if(!x.length)continue;let v=await z(x);v.length&&f.push(...v);continue}f.push(D)}return f},[n,l,s]),c=P(async a=>{let f=await t?.(a)??a,D=await z(f);if(o!==void 0&&i.length+D.length>o)return l?.(`Quantidade m\xE1xima de arquivos ${o} alcan\xE7ada`),i;if(r!==void 0){let b=i.reduce((x,v)=>x+v.size,0),E=D.reduce((x,v)=>x+v.size,0);if(b+E>r)return l?.(`O arquivo \xE9 muito grande, O tamanho m\xE1ximo permitido \xE9 ${H(r)}`),i}return B.current=!0,[...i,...D]},[i,t,o,r,l,z]),L=async a=>{if(a.target.files){let f=[...a.target.files];e(await c(f))}},ve=P(a=>{y.current?.value&&(y.current.value=""),e(i.filter((f,D)=>D!==a))},[e,i]),Fe=P(()=>{y.current?.value&&(y.current.value=""),e([])},[e]),xe=ro(()=>i?.map(a=>({size:a.size,type:a.type,name:a.name}))??[],[i]),Ce=n?`${n.toUpperCase()},${n.toLowerCase()}`:void 0;return{inputRef:y,isDragging:u,filesInfo:xe,treatedAccept:Ce,isProcessingZip:m,handleRemoveFile:ve,handleRemoveAllFiles:Fe,handleChangeFiles:L,handleDragEnter:a=>{_(a),d(!0)},handleDragLeave:a=>{_(a),d(!1)},handleDrop:async a=>{N(a),d(!1);let f=await me(a.dataTransfer,n);c(f)}}};import{jsx as k,jsxs as ze}from"react/jsx-runtime";var no=e=>{let{inputRef:t,filesInfo:r,treatedAccept:o,handleChangeFiles:n,handleRemoveFile:p,handleRemoveAllFiles:l,handleDragEnter:i,handleDragLeave:u,handleDrop:d,isDragging:m,isProcessingZip:g}=ge(e),y=e.placeholder??"Pressione para carregar os arquivos";return ze(j,{onDragOver:i,...e.slotProps?.root,children:[k(G,{"data-is-dragging":m,onDrop:d,onDragLeave:u,...e.slotProps?.overlay}),k(pe,{filesInfo:r,onRemoveFile:p,onRemoveAllFiles:l,showFilesSize:e.showFilesSize,slotProps:e.slotProps,slots:e.slots}),ze(K,{onClick:()=>t.current?.click(),"data-max-files":e.maxFiles,"data-has-files":!!r.length,"data-is-processing-zip":g,...e.slotProps?.labelContainer,children:[k(ce,{placeholder:y,isProcessingZip:g}),k("input",{ref:t,type:"file",accept:o,hidden:!0,onChange:n,multiple:e.maxFiles===void 0||e.maxFiles>1})]})]})};import{useEffect as ao,useState as lo}from"react";import{Dropzone as so,FileItem as po}from"@dropzone-ui/react";import{LIcon as co}from"@s_mart/core";import{Tooltip as mo,Typography as uo}from"@mui/material";import{lineTimes as fo}from"@s_mart/regular-icons";import{styled as io}from"@mui/material";import{colorPalette as De}from"@s_mart/tokens";var he=io("button")`
|
|
30
|
+
`,K=F(be)(({theme:e})=>({width:"100%",pointerEvents:"all",minHeight:"40px",backgroundColor:e.palette.primary.main,borderRadius:Number.parseFloat(e.shape.borderRadius.toString())*2,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"8px",padding:".5rem 1rem",cursor:"pointer",transition:"all 0.5s ease",'&[data-max-files="1"]':{minHeight:0},'&[data-has-files="true"]':{height:"40px"},'&[data-has-files="true"][data-max-files="1"]':{height:0},'&[data-has-files="true"] #dropzone-upload-info':{display:"none"},'&:not([data-has-files="true"]) #dropzone-upload-more-label, &[data-max-files="1"] #dropzone-upload-more-label':{display:"none"},"& #dropzone-upload-more-label":{pointerEvents:"all",color:"white"},'&[data-is-processing-zip="true"], &[data-is-processing-zip="true"] #dropzone-upload-more-label':{pointerEvents:"none"},"&:hover":{backgroundColor:({theme:t})=>t.palette.primary.dark}})),Q=F("div")(({theme:e})=>({width:"100%",maxHeight:"300px",backgroundColor:I.neutral[20],borderRadius:Number.parseFloat(e.shape.borderRadius.toString())*2,display:"flex",flexDirection:"column",border:`1px solid ${I.neutral[20]}`,padding:"8px",gap:"8px"})),Y=F("div")({backgroundColor:"white",borderRadius:"16px",padding:"8px",gap:"24px",display:"grid",gridTemplateColumns:"min-content min-content 1fr min-content",alignItems:"center",justifyContent:"space-between"}),J=F("div")({height:300,overflow:"auto"}),W=F("div")({position:"relative",width:"100%"}),ee=F("div")({top:0,left:0,width:"100%",position:"absolute",paddingBottom:"8px",boxSizing:"border-box"}),oe=F(He)({color:I.neutral[600],overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"start"});import{Tooltip as Ze,Typography as Ne}from"@mui/material";import{IconButton as _e,LIcon as se}from"@s_mart/core";import{lineTimes as je}from"@s_mart/regular-icons";import{colorPalette as Ge}from"@s_mart/tokens";import{useMemo as re}from"react";import{lineFile as we,linePicture as Pe,lineXMLFile as Ee}from"@s_mart/light-icons";import{lineFileCertificate as Se}from"@s_mart/regular-icons";var te=e=>{switch(e){case"application/xml":case"text/xml":return Ee;case"image/gif":case"image/jpeg":case"image/png":case"image/svg":case"image/webp":return Pe;case"application/pkcs12":return Se;default:return we}},H=e=>{let t="";return e<1024?t=`${e} Bytes`:e<1024*1024?t=`${(e/1024).toFixed(2)} KB`:e<1024*1024*1024&&(t=`${(e/1024/1024).toFixed(2)} MB`),t};var ne=({filesInfo:e})=>{let t=re(()=>e.map(o=>({name:o.name,fileSize:H(o.size),icon:te(o.type)})),[e]),r=re(()=>({totalSize:H(e.reduce((o,n)=>o+n.size,0)),totalFilesLabel:e.length===1?"1 arquivo":`${e.length} arquivos`}),[e]);return{files:t,headerInfo:r}};import{Tooltip as Ie}from"@mui/material";import V from"@mui/utils/deepmerge";import{IconButton as Me,LIcon as Re}from"@s_mart/core";import{lineTimes as Ae}from"@s_mart/regular-icons";import{jsx as O}from"react/jsx-runtime";var U={headerCleartooltip:{title:"Remover todos"},headerClearIconButton:{variant:"text",color:"neutral",sx:{borderRadius:50}},headerClearLicon:{icon:Ae,removeMargin:!0}},q={clone:!1},ie=({onClick:e,slotProps:t})=>{let r=V(U.headerCleartooltip,t?.headerCleartooltip,q),o=V(U.headerClearIconButton,t?.headerClearIconButton,q),n=V(U.headerClearLicon,t?.headerClearLicon,q);return O(Ie,{...r,children:O(Me,{...o,onClick:e,children:O(Re,{...n})})})};import{styled as ke}from"@mui/material";var ae=ke("div")({display:"flex",justifyContent:"space-between",alignItems:"center",paddingBlock:"0.5rem"});import{Typography as Be}from"@mui/material";import $e from"@mui/utils/deepmerge";import{useMemo as Ve}from"react";import{Fragment as Xe,jsx as M}from"react/jsx-runtime";var Ue={headerTitle:{variant:"titleXXS"}},qe={headerTitleContent:e=>M(Oe,{...e})},Oe=e=>{let t=`${e.filesLengthLabel}`;return e.showFilesSize&&(t+=` - ${e.filesTotalSize}`),M(Xe,{children:t})},le=e=>{let t=e.slots?.headerTitleContent??qe.headerTitleContent,r=Ve(()=>$e(Ue.headerTitle,{...e,...e.slotProps?.headerTitle}),[e.filesLengthLabel,e.filesTotalSize,e]);return M(Be,{...r,children:M(t,{...r})})};var R={Container:ae,Title:le,ClearButton:ie};import{useRef as Ke}from"react";import{useVirtualizer as Qe}from"@tanstack/react-virtual";import{jsx as h,jsxs as X}from"react/jsx-runtime";var pe=({filesInfo:e,onRemoveFile:t,onRemoveAllFiles:r,slotProps:o,slots:n,showFilesSize:p})=>{let{files:l,headerInfo:i}=ne({filesInfo:e}),u=Ke(null),d=Qe({count:l.length,getScrollElement:()=>u.current,estimateSize:()=>60,overscan:5});return l.length===0?null:X(Q,{...o?.filesContainer,children:[X(R.Container,{children:[h(R.Title,{slots:n,slotProps:o?.header,filesLengthLabel:i.totalFilesLabel,filesTotalSize:i.totalSize,showFilesSize:p}),h(R.ClearButton,{onClick:r})]}),h(J,{ref:u,...o?.filesListRoot,children:h(W,{...o?.filesListContainer,sx:{height:`${d.getTotalSize()}px`,...o?.filesListContainer},children:d.getVirtualItems().map(m=>{let g=l[m.index];return h(ee,{sx:{height:`${m.size}px`,transform:`translateY(${m.start}px)`},children:h(Ze,{title:g.name,arrow:!0,placement:"top",children:X(Y,{...o?.listItem,children:[h(se,{icon:g.icon,removeMargin:!0,size:"24px"}),h(Ne,{variant:"titleXXS",color:Ge.neutral[600],whiteSpace:"nowrap",children:p&&g.fileSize}),h(oe,{variant:"titleXXS",children:g.name}),h(_e,{variant:"text",color:"neutral",sx:{borderRadius:50},onClick:()=>t(m.index),children:h(se,{icon:je,removeMargin:!0})})]})})},m.key)})})})]})};import{CircularProgress as de,Stack as Z,Typography as A}from"@mui/material";import{LIcon as Ye}from"@s_mart/core";import{lineFileUpload as Je}from"@s_mart/regular-icons";import{jsx as T,jsxs as w}from"react/jsx-runtime";var ce=({placeholder:e,isProcessingZip:t})=>t?w("div",{children:[w(Z,{id:"dropzone-upload-info",sx:{gap:1,alignItems:"center",direction:"row"},children:[T(de,{sx:{color:"white"},size:24}),T(A,{variant:"titleSM",color:"white",children:"Descompactando zip..."})]}),w(Z,{id:"dropzone-upload-more-label",sx:{gap:1,alignItems:"center",direction:"row"},children:[T(de,{sx:{color:"white"},size:12}),T(A,{variant:"bodySM",sx:{fontWeight:700},children:"Descompactando zip..."})]})]}):w("div",{children:[w(Z,{id:"dropzone-upload-info",sx:{gap:1,alignItems:"center",direction:"row"},children:[T(Ye,{icon:Je,size:"48px",color:"white",removeMargin:!0}),T(A,{variant:"titleSM",color:"white",children:e})]}),T(A,{id:"dropzone-upload-more-label",variant:"bodySM",sx:{fontWeight:700},children:"Carregar mais arquivos"})]});import{useCallback as P,useMemo as ro,useRef as ue,useState as fe}from"react";var me=async(e,t)=>{let r=[];for(let o of e.items){if(o.kind!=="file")continue;if(typeof o.webkitGetAsEntry=="function"){let p=o.webkitGetAsEntry();if(p===null)continue;let l=await We(p);r.push(...l);continue}let n=o.getAsFile();n&&r.push(n)}return t!==void 0&&(r=to(r,t)),r},We=e=>new Promise((t,r)=>{let o=0,n=[];p(e);function p(i){oo(i)?(o++,i.file(u=>{o--,n.push(u),o===0&&t(n)})):eo(i)&&l(i.createReader())}function l(i){o++,i.readEntries(function(u){o--;for(let d of u)p(d);o===0&&t(n)})}}),eo=e=>e.isDirectory,oo=e=>e.isFile,to=(e,t)=>{let r=[],o=t.split(",");for(let n of e){let p=`.${n.name.split(".").pop()?.toLowerCase()}`;o.includes(p)&&r.push(n)}return r};var N=e=>{e.stopPropagation(),e.preventDefault()},_=e=>{e.dataTransfer.dropEffect="link",N(e)};var ge=({onChange:e,filterOnDrop:t,maxSize:r,maxFiles:o,accept:n,onError:p,onWarning:l,files:i})=>{let[u,d]=fe(!1),[m,g]=fe(!1),y=ue(null),B=ue(!1),s=P(async a=>{g(!0);let f=[],{BlobReader:D,BlobWriter:b,ZipReader:E}=await import("@zip.js/zip.js").catch(()=>{throw new Error("Fa\xE7a a instala\xE7\xE3o da biblioteca @zip.js/zip.js para utilizar o Dropzone com exporta\xE7\xE3o de .zip")}),x=new D(a),v=new E(x);try{let $=await v.getEntries();for(let S of $){if(S.directory||S.getData===void 0)continue;let Te=await S.getData(new b),Le=new File([Te],S.filename);f.push(Le)}}catch($){p?.("Ocorreu um erro ao processar o arquivo compactado.",$)}finally{g(!1),await v.close()}return f},[p]),z=P(async a=>{if(!n)return a;let f=[];for(let D of a){let b=`.${D.name.split(".").pop()?.toLocaleLowerCase()}`;if(!n.split(",").includes(b)){l?.(`O arquivo "${D.name}" n\xE3o \xE9 valido, extens\xF5es aceitas ${n}`);continue}if(b===".zip"){let x=await s(D);if(!x.length)continue;let v=await z(x);v.length&&f.push(...v);continue}f.push(D)}return f},[n,l,s]),c=P(async a=>{let f=await t?.(a)??a,D=await z(f);if(o!==void 0&&i.length+D.length>o)return l?.(`Quantidade m\xE1xima de arquivos ${o} alcan\xE7ada`),i;if(r!==void 0){let b=i.reduce((x,v)=>x+v.size,0),E=D.reduce((x,v)=>x+v.size,0);if(b+E>r)return l?.(`O arquivo \xE9 muito grande, O tamanho m\xE1ximo permitido \xE9 ${H(r)}`),i}return B.current=!0,[...i,...D]},[i,t,o,r,l,z]),L=async a=>{if(a.target.files){let f=[...a.target.files];e(await c(f))}},ve=P(a=>{y.current?.value&&(y.current.value=""),e(i.filter((f,D)=>D!==a))},[e,i]),Fe=P(()=>{y.current?.value&&(y.current.value=""),e([])},[e]),xe=ro(()=>i?.map(a=>({size:a.size,type:a.type,name:a.name}))??[],[i]),Ce=n?`${n.toUpperCase()},${n.toLowerCase()}`:void 0;return{inputRef:y,isDragging:u,filesInfo:xe,treatedAccept:Ce,isProcessingZip:m,handleRemoveFile:ve,handleRemoveAllFiles:Fe,handleChangeFiles:L,handleDragEnter:a=>{_(a),d(!0)},handleDragLeave:a=>{_(a),d(!1)},handleDrop:async a=>{N(a),d(!1);let f=await me(a.dataTransfer,n);c(f)}}};import{jsx as k,jsxs as ze}from"react/jsx-runtime";var no=e=>{let{inputRef:t,filesInfo:r,treatedAccept:o,handleChangeFiles:n,handleRemoveFile:p,handleRemoveAllFiles:l,handleDragEnter:i,handleDragLeave:u,handleDrop:d,isDragging:m,isProcessingZip:g}=ge(e),y=e.placeholder??"Pressione para carregar os arquivos";return ze(j,{onDragOver:i,...e.slotProps?.root,children:[k(G,{"data-is-dragging":m,onDrop:d,onDragLeave:u,...e.slotProps?.overlay}),k(pe,{filesInfo:r,onRemoveFile:p,onRemoveAllFiles:l,showFilesSize:e.showFilesSize,slotProps:e.slotProps,slots:e.slots}),ze(K,{onClick:()=>t.current?.click(),"data-max-files":e.maxFiles,"data-has-files":!!r.length,"data-is-processing-zip":g,...e.slotProps?.labelContainer,children:[k(ce,{placeholder:y,isProcessingZip:g}),k("input",{ref:t,type:"file",accept:o,hidden:!0,onChange:n,multiple:e.maxFiles===void 0||e.maxFiles>1})]})]})};import{useEffect as ao,useState as lo}from"react";import{Dropzone as so,FileItem as po}from"@dropzone-ui/react";import{LIcon as co}from"@s_mart/core";import{Tooltip as mo,Typography as uo}from"@mui/material";import{lineTimes as fo}from"@s_mart/regular-icons";import{styled as io}from"@mui/material";import{colorPalette as De}from"@s_mart/tokens";var he=io("button")`
|
|
31
31
|
display: flex;
|
|
32
32
|
align-items: center;
|
|
33
33
|
justify-content: center;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s_mart/dropzone",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"main": "./dist/index.mjs",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"react": "^18.3.1",
|
|
47
47
|
"react-dom": "^18.3.1",
|
|
48
48
|
"typescript": ">=5.4.2",
|
|
49
|
+
"@s_mart/core": "10.0.2",
|
|
49
50
|
"@s_mart/light-icons": "6.0.12",
|
|
50
|
-
"@s_mart/regular-icons": "6.0.11",
|
|
51
51
|
"@s_mart/tokens": "6.0.0",
|
|
52
|
-
"@s_mart/
|
|
52
|
+
"@s_mart/regular-icons": "6.0.11"
|
|
53
53
|
},
|
|
54
54
|
"overrides": {
|
|
55
55
|
"react-is": "^18.3.1"
|