@zydon/common 2.4.28 → 2.4.30
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/chunk-S7QQBC4I.js +5 -0
- package/dist/components/FileThumbnail/index.d.ts +1 -1
- package/dist/components/FileUpload/index.d.ts +2 -2
- package/dist/components/FileUpload/index.js +10 -9
- package/dist/hooks/useMount.js +1 -5
- package/dist/{types-a88ac60d.d.ts → types-9d4e2f3e.d.ts} +16 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { F as FileThumbnailProps } from '../../types-
|
|
2
|
+
import { F as FileThumbnailProps } from '../../types-9d4e2f3e.js';
|
|
3
3
|
import '@mui/material/Stack';
|
|
4
4
|
import '@mui/material/styles';
|
|
5
5
|
import 'react-dropzone';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { H as HelperTextProps, M as MultiFilePreviewProps, S as SingleFilePreviewProps, a as FileUploadProps, E as ExtendFile, b as MultiFileUploadProps, c as MultiImageUploadProps, d as SingleFileUploadProps, e as SingleImageUploadProps } from '../../types-
|
|
4
|
-
export { C as ContentType, i as CreateFilesMutation, h as CropSize, D as DropZoneProps, f as FileContentType, j as FileCreateRequest, k as FileCreateResponse, n as FileGetResponse, l as FileQueryRequest, m as FileQueryResponse, g as FileUpload, P as PlaceholderProps, R as RejectionFilesProps, o as SortableItemProps, p as StyledDropZoneProps, q as StyledDropZonePropsType, T as ThumbnailBadgeProps } from '../../types-
|
|
3
|
+
import { H as HelperTextProps, M as MultiFilePreviewProps, S as SingleFilePreviewProps, a as FileUploadProps, E as ExtendFile, b as MultiFileUploadProps, c as MultiImageUploadProps, d as SingleFileUploadProps, e as SingleImageUploadProps } from '../../types-9d4e2f3e.js';
|
|
4
|
+
export { C as ContentType, i as CreateFilesMutation, h as CropSize, D as DropZoneProps, f as FileContentType, j as FileCreateRequest, k as FileCreateResponse, n as FileGetResponse, l as FileQueryRequest, m as FileQueryResponse, g as FileUpload, L as LoadingPreviewImageProps, P as PlaceholderProps, R as RejectionFilesProps, o as SortableItemProps, p as StyledDropZoneProps, q as StyledDropZonePropsType, T as ThumbnailBadgeProps } from '../../types-9d4e2f3e.js';
|
|
5
5
|
import { DropzoneOptions, useDropzone, FileRejection } from 'react-dropzone';
|
|
6
6
|
import { Area } from 'react-easy-crop';
|
|
7
7
|
import '@mui/material/Stack';
|
|
@@ -13,24 +13,25 @@ import { j } from '../../chunk-DMQW3LDF.js';
|
|
|
13
13
|
import { a as a$5 } from '../../chunk-YQ6K2DEP.js';
|
|
14
14
|
import '../../chunk-CHLVIVDD.js';
|
|
15
15
|
import '../../chunk-ILHUUK4X.js';
|
|
16
|
+
import { a as a$8 } from '../../chunk-S7QQBC4I.js';
|
|
16
17
|
import { a as a$7 } from '../../chunk-ONZBWH3C.js';
|
|
17
|
-
import { memo, useRef,
|
|
18
|
-
import
|
|
18
|
+
import { memo, useRef, useMemo, useCallback, useState, useEffect } from 'react';
|
|
19
|
+
import _o from '@mui/material/FormHelperText';
|
|
19
20
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
20
21
|
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
21
22
|
import { restrictToHorizontalAxis, restrictToParentElement, restrictToWindowEdges } from '@dnd-kit/modifiers';
|
|
22
23
|
import { useSortable, sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
|
|
23
24
|
import { m, AnimatePresence } from 'framer-motion';
|
|
24
25
|
import ie from '@mui/material/Stack';
|
|
25
|
-
import
|
|
26
|
+
import ke from '@mui/material/Typography';
|
|
26
27
|
import me from '@mui/material/Box';
|
|
27
|
-
import
|
|
28
|
-
import
|
|
28
|
+
import Mo from '@mui/material/IconButton';
|
|
29
|
+
import Co from '@mui/material/Paper';
|
|
29
30
|
import { styled, alpha } from '@mui/material/styles';
|
|
30
|
-
import
|
|
31
|
+
import Uo from '@mui/material/Badge';
|
|
31
32
|
import { useDropzone } from 'react-dropzone';
|
|
32
|
-
import
|
|
33
|
+
import Kr from '@mui/material/CircularProgress';
|
|
33
34
|
|
|
34
|
-
var So=({helperText:e,disabled:t,isError:r})=>e?jsx(Fo,{error:r,sx:a=>({mx:"14px",color:t?a.palette.grey[500]:void 0}),children:e}):null,N=memo(So);var Ae=styled(ie)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),Ee=styled(ie)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),Xe=styled(me,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:t,isError:r,disabled:a})=>({outline:"none",cursor:"pointer",overflow:"hidden",position:"relative",padding:e.spacing(5),borderRadius:e.shape.borderRadius,transition:e.transitions.create("padding"),backgroundColor:e.palette.background.neutral,border:`1px dashed ${alpha(e.palette.grey[500],.32)}`,...t&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...a&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(ie)(({theme:e})=>({display:"none",position:"absolute",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:12,width:"100%",height:"100%",backgroundColor:alpha(e.palette.primary.main,.9),zIndex:999,button:{"&, &:hover, &:focus":{backgroundColor:"#fff"}}}));var Ve=styled(_o)(({theme:e})=>({position:"relative",zIndex:999,pointerEvents:"auto",color:e.palette.grey[700],backgroundColor:e.palette.grey[100],"&:hover":{color:e.palette.grey[900],backgroundColor:e.palette.grey[300]}})),Le=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),He=styled(ie,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:t,isDragging:r})=>({width:t,height:100,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2,1,2,1),gap:e.spacing(1),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Ke=styled(m.div)(({theme:e,width:t,isDragging:r})=>({width:t,height:60,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Je=styled(a)(({theme:e})=>({top:16,right:16,zIndex:9,position:"absolute",color:e.palette.common.white,backgroundColor:alpha(e.palette.grey[900],.72),"&:hover":{backgroundColor:alpha(e.palette.grey[900],.48)}})),Qe=styled(me,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:t,disabled:r,hasError:a})=>({width:64,height:64,flexShrink:0,display:"flex",borderRadius:1,cursor:"pointer",alignItems:"center",color:e.palette.text.disabled,justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),border:`dashed 1px ${alpha(e.palette.grey[500],.16)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...a&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),Ye=styled(me)(({theme:e})=>({padding:e.spacing(1),top:0,left:0,width:"100%",height:"100%",position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",transition:"all 0.3s ease-in-out",filter:"blur(0)","&:hover":{filter:"blur(3px)"}})),eo=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"})(({theme:e,aspectRatio:t,height:r=1,width:a=1,isLoading:i,isUploading:l})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,aspectRatio:t,maxWidth:"calc(100% - 16px)",maxHeight:"calc(100% - 16px)",backgroundColor:e.palette.background.paper,height:r>=a?"100%":`calc(100% * ${t})`,width:r>a?`calc(${t} * 100%)`:"100%",transition:"all 0.5s ease-in-out",...i||l?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),oo=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:t})=>({width:"100%",height:"100%",objectFit:"cover",top:0,left:0,filter:"blur(1.5rem)",transform:"scale(1.1)",position:"absolute",zIndex:0,transition:"opacity 0.3s ease-in-out",...e&&{opacity:0},...t&&{opacity:.7,filter:"blur(2rem)"}})),ro=styled(ie)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Oo)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var Ce=styled(me,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:t,hasFile:r})=>({top:0,gap:e.spacing(1),left:0,width:"100%",height:"100%",zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:e.palette.text.disabled,flexDirection:"column",justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),transition:e.transitions.create(["opacity"],{duration:e.transitions.duration.shorter}),"&:hover":{opacity:.92},...t&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),to=styled(ie)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center"});styled(ie)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.grey[200],color:e.palette.text.disabled,height:160}));var io=styled(me,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:t,disabled:r,isError:a,hasFile:i})=>({padding:1,margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${alpha(e.palette.grey[500],.2)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...a&&{borderColor:"error.main"},...i&&{...a&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),ao=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),no=styled(a)(({theme:e})=>({backgroundColor:alpha(e.palette.grey[900],.72),color:e.palette.common.white,"&:hover":{backgroundColor:alpha(e.palette.grey[600],.64),color:e.palette.common.white},"& svg":{width:14,height:14}}));var zo=({onRemove:e,sx:t,file:r,disableDrag:a,attributes:i,listeners:l,innerWidth:p,isDragging:g})=>{let n=r?.id||r?.url||"";return jsx(Co,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Ke,{width:p,isDragging:g,"data-testid":`preview-multi-img-${n}`,...j().inUp,sx:t,children:[jsx(a$1,{disableDrag:a,...i,...l}),jsx(f,{tooltip:!0,imageView:!0,file:r}),jsx(Ee,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(no,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${n}`)},so=memo(zo);var Bo=({file:e$1,thumbnail:t,onRemove:r,sx:a$3,disableDrag:i=!1})=>{let l=e$1?.size||0,p=e$1?.name||e$1?.url||"",g=e$1?.id||e$1?.url||"",n=typeof e$1=="string",s=i?70:80,{attributes:c,listeners:P,setNodeRef:d,transform:m,transition:D,isDragging:I}=useSortable({id:g,disabled:i}),E={transform:x.Transform.toString(m),transition:D,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${s+8}px`,height:"68px"};return t&&e$1?jsx(Le,{ref:d,style:E,children:jsx(so,{innerWidth:s,isDragging:I,sx:a$3,file:e$1,disableDrag:i,attributes:c,listeners:P,onRemove:r})}):jsx(Le,{ref:d,style:{...E,height:"80px",width:`${s+38}px`},children:jsxs(He,{width:s+30,isDragging:I,"data-testid":`preview-multi-img-${g}`,...j().inUp,sx:a$3,children:[jsx(a$1,{disableDrag:i,...c,...P}),e$1&&jsx(f,{file:e$1}),jsxs(ie,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$2,{title:p,children:jsx(Te,{variant:"subtitle2",noWrap:!0,children:p})}),jsx(Te,{variant:"caption",sx:{color:"text.secondary"},children:n?"":e(l)})]}),jsx(Ee,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},co=memo(Bo);var er=({thumbnail:e,files:t,onRemove:r,onReorder:a,sx:i})=>{let l=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates}));if(!t?.length)return null;let p=n=>{let{active:s,over:c}=n;if(!(!s||!c||s.id===c.id)&&a){let P=t.findIndex(({id:m})=>m===s.id),d=t.findIndex(({id:m})=>m===c.id);P!==-1&&d!==-1&&a(P,d);}},g=jsx(AnimatePresence,{initial:!1,children:t.map(n=>jsx(co,{sx:i,file:n,onRemove:r,thumbnail:e,disableDrag:!a},n.id))});return a?jsx(DndContext,{sensors:l,collisionDetection:closestCenter,onDragEnd:p,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:t.map(n=>n.id),strategy:horizontalListSortingStrategy,children:g})}):g},ue=memo(er);var ir=({file:e,aspectRatio:t=1,isUploading:r,isLoading:a,onLoading:i,cropSize:l})=>{let p=useRef(null),g=typeof e=="string"?e:e.name,n=typeof e=="string"?e:URL.createObjectURL(e);useEffect(()=>{p.current&&!p.current.complete?i?.(!0):i?.(!1);},[p,i]);let s=typeof l=="number"?l*t:l?.width,c=typeof l=="number"?l:l?.height;return jsxs(Ye,{children:[jsx(eo,{aspectRatio:t,isLoading:a,isUploading:r,height:c,width:s,alt:g,src:n,ref:p,onLoad:()=>i?.(!1),onError:()=>i?.(!1)}),jsx(oo,{alt:g,src:n,isLoading:a,isUploading:r})]})},ze=memo(ir);var oi=e=>e.startsWith("image/"),uo=(e,t=.8)=>new Promise((r,a)=>{let i=document.createElement("canvas"),l=i.getContext("2d"),p=new Image;p.onload=()=>{i.width=p.width,i.height=p.height,l?(l.drawImage(p,0,0),i.toBlob(g=>{if(g){let n=new File([g],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(n);}else a(new Error("Falha ao converter para WebP"));},"image/webp",t)):a(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},p.onerror=()=>a(new Error("Falha ao carregar imagem")),p.src=URL.createObjectURL(e);});var sr=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:a,dropzoneOptions:i,enableCrop:l=!1,customAspectRatio:p,convertToWebp:g=!0,maxFiles:n,cropSize:s})=>{let{showErrorMessage:c}=a$7(),P=useMemo(()=>p||(s&&typeof s!="number"?s.width/s.height:1),[p,s]),[d,m]=useState([]),[D,I]=useState(!1),[E,R]=useState(null),[h,f]=useState(null),[u,x]=useState(""),[F,S]=useState(!1),[v,M]=useState([]),[G,_]=useState(0),O=useMemo(()=>e$1&&Array.isArray(e$1)?e$1.filter(o=>o instanceof File):e$1&&e$1 instanceof File?[e$1]:d,[e$1,d]),q=useMemo(()=>e$1&&Array.isArray(e$1)?null:e$1&&e$1 instanceof File?e$1:d[0]||null,[e$1,d]);useEffect(()=>{e$1&&(Array.isArray(e$1)?m(e$1.filter(o=>o instanceof File)):e$1 instanceof File?m([e$1]):e$1===null&&m([]));},[e$1]);let Z=useCallback(()=>{if(v.length>0&&l){let o=v[0];R(o),_(b=>b+1);let w=new FileReader;w.onload=()=>{x(w.result),I(!0);},w.readAsDataURL(o);}},[v,l]);useEffect(()=>{Z();},[Z]);let ee=useCallback((o,w)=>{f(w);},[]),oe=async()=>!E||!h?null:new Promise(o=>{let w=document.createElement("canvas"),b=w.getContext("2d"),W=new Image;W.onload=async()=>{let{width:de,height:V,x:Eo,y:wo}=h,xe=de,Pe=V;s&&(typeof s=="number"?(xe=s,Pe=s/P):(xe=s.width,Pe=s.height)),w.width=xe,w.height=Pe,b?(b.drawImage(W,Eo,wo,de,V,0,0,xe,Pe),w.toBlob(async We=>{if(We){let Me=new File([We],E.name,{type:E.type,lastModified:Date.now()});if(g)try{Me=await uo(Me);}catch(Do){c(Do,"Erro ao converter para WebP");}o(Me);}else o(null);},"image/png")):o(null);},W.src=u;}),re=async()=>{if(!(!E||!h)){S(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let b=n?[...O,o].slice(0,n):[...O,o];m(b),r?.(b);}else m([o]),t?.(o);let w=v.slice(1);M(w),I(!1),x(""),R(null),w.length>0&&setTimeout(()=>Z(),100);}catch(o){c(o,"Erro ao processar imagem");}finally{S(!1);}}},C=()=>{I(!1),x(""),R(null),M([]),_(0);},z=useCallback(o=>{if(o.length===0)return;if(i?.accept&&Object.keys(i.accept).some(b=>b.includes("image/"))&&l)if(Array.isArray(e$1)||e$1===void 0&&r){let b=o.filter(V=>V.type.startsWith("image/")),W=O.map(V=>V.name),de=b.filter(V=>!W.includes(V.name));if(de.length===0){c("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}M(de),_(0);}else {let b=o[0];R(b);let W=new FileReader;W.onload=()=>{x(W.result),I(!0);},W.readAsDataURL(b);}else if(Array.isArray(e$1)||e$1===void 0&&r){let b=n?[...O,...o].slice(0,n):[...O,...o];m(b),r?.(b);}else {let b=o[0];m([b]),t?.(b);}},[e$1,O,t,r,l,n,i,c]),T=useCallback(o=>{if(!o.length)return;let w=o[0]?.errors[0]?.code,b=i?.maxSize||3145728;c(w==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(b)}`):w==="file-invalid-type"?new Error("Formato de arquivo n\xE3o suportado"):o[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},[i?.maxSize,c]),{getRootProps:U,getInputProps:X,isDragActive:j,isDragReject:ye,fileRejections:_e}=useDropzone({onDrop:z,onDropRejected:T,...i}),Oe=useCallback(o=>{if(!o){m([]),a?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let w=d.filter(b=>b.name!==o.name);m(w),a?.(o),r&&r(w);}else m([]),a?.(o);},[e$1,d,r,a]),Ao=useCallback(()=>{m([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:q,files:O,aspectRatio:P,dropzoneProps:{getRootProps:U,getInputProps:X,isDragActive:j,isDragReject:ye,fileRejections:_e},cropState:{cropModalOpen:D,imagePreview:u,cropLoading:F,setCropModalOpen:I,onCropInitialized:ee,handleCropSave:re,handleCropCancel:C,currentImageIndex:G,totalPendingImages:v.length},handleRemove:Oe,clearFiles:Ao,setFiles:m}},k=sr;var Ne=(o=>(o.APPLICATION_OCTET_STREAM="application/octet-stream",o.IMAGE_JPEG="image/jpeg",o.IMAGE_JPG="image/jpg",o.IMAGE_PNG="image/png",o.IMAGE_GIF="image/gif",o.IMAGE_WEBP="image/webp",o.IMAGE_SVG="image/svg+xml",o.IMAGE_BMP="image/bmp",o.IMAGE_TIFF="image/tiff",o.IMAGE_ICO="image/x-icon",o.IMAGE_AVIF="image/avif",o.APPLICATION_PDF="application/pdf",o.TEXT_PLAIN="text/plain",o.TEXT_CSV="text/csv",o.APPLICATION_RTF="application/rtf",o.APPLICATION_MSWORD="application/msword",o.APPLICATION_DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",o.APPLICATION_MSEXCEL="application/vnd.ms-excel",o.APPLICATION_XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",o.APPLICATION_MSPOWERPOINT="application/vnd.ms-powerpoint",o.APPLICATION_PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",o.APPLICATION_ODT="application/vnd.oasis.opendocument.text",o.APPLICATION_ODS="application/vnd.oasis.opendocument.spreadsheet",o.APPLICATION_ODP="application/vnd.oasis.opendocument.presentation",o.APPLICATION_XML="application/xml",o.TEXT_XML="text/xml",o.TEXT_HTML="text/html",o.TEXT_CSS="text/css",o.APPLICATION_JSON="application/json",o.TEXT_JAVASCRIPT="text/javascript",o.APPLICATION_ZIP="application/zip",o.APPLICATION_GZIP="application/gzip",o.APPLICATION_RAR="application/vnd.rar",o.APPLICATION_7Z="application/x-7z-compressed",o.AUDIO_MPEG="audio/mpeg",o.AUDIO_WAV="audio/wav",o.AUDIO_OGG="audio/ogg",o.AUDIO_WEBM="audio/webm",o.AUDIO_AAC="audio/aac",o.VIDEO_MP4="video/mp4",o.VIDEO_MPEG="video/mpeg",o.VIDEO_OGG="video/ogg",o.VIDEO_WEBM="video/webm",o.VIDEO_QUICKTIME="video/quicktime",o))(Ne||{}),De=(e=>(e["application/octet-stream"]="APPLICATION_OCTET_STREAM",e["image/jpeg"]="IMAGE_JPEG",e["image/jpg"]="IMAGE_JPG",e["image/png"]="IMAGE_PNG",e["image/gif"]="IMAGE_GIF",e["image/webp"]="IMAGE_WEBP",e["image/svg+xml"]="IMAGE_SVG",e["image/bmp"]="IMAGE_BMP",e["image/tiff"]="IMAGE_TIFF",e["image/x-icon"]="IMAGE_ICO",e["image/avif"]="IMAGE_AVIF",e["application/pdf"]="APPLICATION_PDF",e["text/plain"]="TEXT_PLAIN",e["text/csv"]="TEXT_CSV",e["application/rtf"]="APPLICATION_RTF",e["application/msword"]="APPLICATION_MSWORD",e["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]="APPLICATION_DOCX",e["application/vnd.ms-excel"]="APPLICATION_MSEXCEL",e["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]="APPLICATION_XLSX",e["application/vnd.ms-powerpoint"]="APPLICATION_MSPOWERPOINT",e["application/vnd.openxmlformats-officedocument.presentationml.presentation"]="APPLICATION_PPTX",e["application/vnd.oasis.opendocument.text"]="APPLICATION_ODT",e["application/vnd.oasis.opendocument.spreadsheet"]="APPLICATION_ODS",e["application/vnd.oasis.opendocument.presentation"]="APPLICATION_ODP",e["application/xml"]="APPLICATION_XML",e["text/xml"]="TEXT_XML",e["text/html"]="TEXT_HTML",e["text/css"]="TEXT_CSS",e["application/json"]="APPLICATION_JSON",e["text/javascript"]="TEXT_JAVASCRIPT",e["application/zip"]="APPLICATION_ZIP",e["application/gzip"]="APPLICATION_GZIP",e["application/vnd.rar"]="APPLICATION_RAR",e["application/x-7z-compressed"]="APPLICATION_7Z",e["audio/mpeg"]="AUDIO_MPEG",e["audio/wav"]="AUDIO_WAV",e["audio/ogg"]="AUDIO_OGG",e["audio/webm"]="AUDIO_WEBM",e["audio/aac"]="AUDIO_AAC",e["video/mp4"]="VIDEO_MP4",e["video/mpeg"]="VIDEO_MPEG",e["video/ogg"]="VIDEO_OGG",e["video/webm"]="VIDEO_WEBM",e["video/quicktime"]="VIDEO_QUICKTIME",e))(De||{});var dr=({createFilesMutation:e,files:t,file:r,skip:a})=>{let{showErrorMessage:i}=a$7(),[l,p]=useState(!1),[g,n]=useState(!1),[s,c]=useState(null),[P,d]=useState(void 0),m=useMemo(()=>P?.[0],[P]),D=useMemo(()=>{if(!a)return r?[r]:t},[r,t,a]),I=useCallback(async h=>{if(!h?.length){d(void 0);return}try{n(!0);let f=await Promise.all(h.map(async({url:u,name:x,id:F},S)=>{let M=await(await fetch(u)).blob(),G=x||u.split("/").pop()||"image",_=new File([M],G,{type:M.type});return _.id=F,_.url=u,_.index=S,_}));d(f);}catch(f){console.error("Erro ao carregar preview dos arquivos:",f),d(void 0);}finally{n(!1);}},[]),E=g||l;return useEffect(()=>{I(D);},[D,I]),{filesPreview:P,filePreview:m,uploadFiles:async h=>{if(h?.length){p(!0);try{let f=h[0].type||"application/octet-stream",u=De[f];if(!u)throw new Error(`Tipo de arquivo n\xE3o suportado: ${f}`);let x=await e({files:[{content_type:u,name:h[0].name}]}).unwrap(),F=x.files.map(v=>v.id);return (await Promise.all(h.map(v=>fetch(x.files[0].url,{method:"PUT",headers:{"Content-Type":f},body:v})))).forEach(v=>{if(!v.ok)throw new Error(`Erro no upload: ${v.statusText}`)}),I(x.files),F}catch(f){throw c(f),i(f,"Erro no upload"),f}finally{p(!1);}}},isUploadingFiles:l,isLoadingPreview:g,isUploadOrLoadingFiles:E,uploadFilesError:s}},cr=dr;var gr=({sx:e,id:t,name:r,tabIndex:a,uploading:i,getRootProps:l,getInputProps:p,isDragActive:g,isError:n,disabled:s,dropZoneSxProps:c,dropZoneContent:P,children:d,...m})=>jsxs(Ae,{children:[i&&jsx(a$6,{"data-testid":"uploading-progress-bar"}),jsxs(me,{sx:{width:1,position:"relative",...e},children:[jsxs(Xe,{...l(),"data-testid":"drop-zone-styled-area",isError:n,isDragActive:g,disabled:!!s,sx:c,...m,children:[jsx("input",{...p(),id:t,tabIndex:a,name:r}),P]}),d]})]}),K=gr;var xr=({header:e,description:t,sx:r,...a})=>jsxs(ie,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...a,children:[jsx(a$3,{sx:{width:220}}),jsxs("div",{children:[jsx(Te,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(Te,{variant:"body2",sx:{color:"text.secondary"},children:t||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(Te,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),J=memo(xr);var hr=({onRemove:e,onReorder:t,onFilesSelect:r,id:a,disabled:i,error:l,helperText:p,files:g,thumbnail:n,dropZoneSxProps:s,uploading:c,tabIndex:P,maxFiles:d,...m})=>{let{files:D,dropzoneProps:I,handleRemove:E}=k({filesToUpload:g,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:i,...m},maxFiles:d}),{getRootProps:R,getInputProps:h,isDragActive:f,isDragReject:u}=I,x=!!D?.length,F=u||!!l;return jsxs(K,{id:a,uploading:c,disabled:i,dropZoneSxProps:s,tabIndex:P,getRootProps:R,getInputProps:h,isDragActive:f,isError:F,dropZoneContent:jsx(J,{}),children:[jsx(N,{disabled:i,helperText:p,isError:F}),x&&jsx(me,{sx:{my:3},children:jsx(ue,{files:D,thumbnail:!!n,onRemove:e?E:void 0,onReorder:t})})]})},vr=memo(hr);var Fr=({onFilesSelect:e,onRemove:t,onReorder:r,id:a,disabled:i,error:l,helperText:p,files:g,dropZoneSxProps:n,placeholderProps:s,placeholderAlt:c,uploading:P,tabIndex:d,maxFiles:m,aspectRatio:D,enableCrop:I=!0,convertToWebp:E=!0,cropSize:R,name:h,label:f,...u})=>{let{files:x,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:M}=k({filesToUpload:g,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,...u},enableCrop:I,customAspectRatio:D,convertToWebp:E,maxFiles:m,cropSize:R}),{getRootProps:G,getInputProps:_,isDragActive:O,isDragReject:q}=F,{cropModalOpen:Z,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:C,handleCropCancel:z,currentImageIndex:T,totalPendingImages:U}=S,X=!!x?.length,j=q||!!l,ye=useMemo(()=>{let _e=f??"Ajustar Imagem",Oe=U>1?` (${T} de ${U})`:"";return `${_e}${Oe}`},[f,U,T]);return jsxs(K,{id:a,name:h,uploading:P,disabled:i,dropZoneSxProps:n,tabIndex:d,getRootProps:G,getInputProps:_,isDragActive:O,isError:j,dropZoneContent:jsx(Fragment,{children:c?jsx(ie,{children:c}):jsx(J,{header:s?.header,description:s?.description})}),children:[jsx(N,{disabled:i,helperText:p,isError:j}),X&&jsx(Fragment,{children:jsx(me,{sx:{my:3,ml:.5},children:jsx(ue,{files:x,thumbnail:!0,onRemove:v,onReorder:r})})}),jsx(a$4,{open:Z,onClose:z,label:ye,imageSrc:ee,aspectRatio:M,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})},Sr=memo(Fr);var Lr=({onFileSelect:e$1,onRemove:t,file:r,id:a,disabled:i,error:l,helperText:p,sx:g,dropZoneSxProps:n,uploading:s,tabIndex:c,...P})=>{let{file:d,dropzoneProps:m$1,handleRemove:D}=k({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:i,...P}}),{getRootProps:I,getInputProps:E,isDragActive:R,isDragReject:h}=m$1,f$1=useCallback(S=>{S.stopPropagation(),D(d||void 0);},[d,D]),u=!!d,x=typeof d=="string",F=h||!!l;return jsx(K,{id:a,uploading:s,disabled:i,dropZoneSxProps:n,tabIndex:c,getRootProps:I,getInputProps:E,isDragActive:R,isError:F,dropZoneContent:jsxs(Fragment,{children:[!u&&jsx(J,{}),u&&jsxs(ie,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:S=>`solid 1px ${S.palette.divider}`,...g},children:[jsx(f,{file:d}),jsxs(ie,{flexGrow:1,sx:{minWidth:0},children:[jsx(Te,{variant:"subtitle2",noWrap:!0,children:x?d:d.name}),jsx(Te,{variant:"caption",sx:{color:"text.secondary"},children:x?"":e(d.size)})]}),t&&jsx(a$2,{title:"Remover arquivo",children:jsx(Ve,{edge:"end",size:"small",disabled:i,"aria-label":"Remover arquivo",onClick:f$1,children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(N,{disabled:i,helperText:p,isError:F})})},Cr=memo(Lr);var Br=({onRemove:e,onFileSelect:t,file:r,id:a,disabled:i,error:l,helperText:p,dropZoneSxProps:g,placeholderProps:n,placeholderAlt:s,uploading:c,tabIndex:P,aspectRatio:d,enableCrop:m=!0,convertToWebp:D=!0,name:I,label:E,cropSize:R,...h})=>{let[f,u]=useState(!1),{file:x,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:M}=k({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,...h},enableCrop:m,customAspectRatio:d,convertToWebp:D,cropSize:R}),{getRootProps:G,getInputProps:_,isDragActive:O,isDragReject:q}=F,{cropModalOpen:Z,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:C,handleCropCancel:z}=S,T=useCallback(()=>{v(x||void 0);},[x,v]),U=!!x,X=q||!!l,j=U?{opacity:0}:{opacity:1};return jsxs(Ae,{children:[(c||f)&&jsx(a$6,{}),jsxs(K,{id:a,uploading:c,disabled:i,dropZoneSxProps:g,tabIndex:P,getRootProps:G,getInputProps:_,isDragActive:O,isError:X,name:I,dropZoneContent:jsxs(Fragment,{children:[s?jsx(ie,{sx:j,children:s}):jsx(J,{sx:j,header:n?.title,description:n?.description}),U&&jsx(ze,{file:x,cropSize:R,isLoading:f,isUploading:c,onLoading:u,aspectRatio:M})]}),children:[jsx(N,{disabled:i,helperText:p,isError:X}),U&&e&&jsx(Je,{size:"small",onClick:T,disabled:i,label:"Remover arquivo",children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$4,{open:Z,onClose:z,label:E??"Ajustar Imagem",imageSrc:ee,aspectRatio:M,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})]})},Gr=memo(Br);var Xr=({onFileSelect:e,onRemove:t,file:r,disabled:a,label:i,id:l,tabIndex:p,error:g,helperText:n,sx:s,name:c,maxSize:P,uploading:d,aspectRatio:m=1,enableCrop:D=!0,convertToWebp:I=!0,cropSize:E,...R})=>{let[h,f]=useState(!1),{file:u,dropzoneProps:x,cropState:F,handleRemove:S}=k({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,maxSize:P,...R},enableCrop:D,customAspectRatio:m,convertToWebp:I,cropSize:E}),{getRootProps:v,getInputProps:M,isDragActive:G,isDragReject:_}=x,{cropModalOpen:O,imagePreview:q,cropLoading:Z,onCropInitialized:ee,handleCropSave:oe,handleCropCancel:re}=F,C=_||!!g,z=h||d,T=!!t,U=useMemo(()=>u?(f(!0),URL.createObjectURL(u)):"",[u]),X=()=>{f(!1);},j=()=>T&&u?()=>S(u):v().onClick;return jsxs(Fragment,{children:[jsxs(io,{sx:s,isError:C,isDragActive:G,hasFile:!!u,...v(),onClick:j(),children:[jsxs(ro,{children:[u&&jsx(ao,{alt:"Avatar Preview",src:U,onLoad:X,...z&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&z&&jsx(to,{children:jsx(qr,{size:135,thickness:1,color:"primary"})}),!u&&!z&&jsxs(Ce,{isError:C,hasFile:!1,children:[jsx(a$5,{icon:"ADD_IMAGE",width:32}),jsx(Te,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"text.disabled"},children:"Adicionar foto"})]}),u&&!z&&jsxs(Ce,{isError:C,hasFile:!0,children:[jsx(a$5,{icon:T?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(Te,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"common.white"},children:T?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:c,id:l,tabIndex:p,...M()}),jsx(ie,{spacing:.5,sx:{pt:1},children:jsx(N,{helperText:n,disabled:a,isError:C})}),u&&!z&&jsx(ie,{direction:"row",justifyContent:"center",spacing:1,sx:{pt:1,mb:-1},children:jsx(Te,{variant:"caption",component:"span",sx:{px:.75,cursor:"pointer",borderRadius:.75,color:"error.main","&:hover":{color:"error.dark",bgcolor:"background.default"}},onClick:()=>S(u),children:"Remover"})})]}),O&&q&&jsx(a$4,{open:O,onClose:re,label:i??"Ajustar Imagem",imageSrc:q,aspectRatio:m,onInitialized:ee,onSave:oe,loading:Z,cropSize:E,cropShape:"round"})]})},Vr=memo(Xr);var Qr=({error:e,name:t,disabled:r,sx:a,...i})=>{let{getRootProps:l,getInputProps:p,isDragActive:g,isDragReject:n}=useDropzone({disabled:r,...i}),s=n||e;return jsxs(Qe,{...l(),isDragActive:g,hasError:!!s,disabled:!!r,sx:a,"data-testid":"upload-box",children:[jsx("input",{name:t,...p()}),"Selecionar arquivo"]})},Yr=memo(Qr);
|
|
35
|
+
var Oo=({helperText:e,disabled:t,isError:r})=>e?jsx(_o,{error:r,sx:i=>({mx:"14px",color:t?i.palette.grey[500]:void 0}),children:e}):null,U=memo(Oo);var Ae=styled(ie)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),we=styled(ie)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),He=styled(me,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:t,isError:r,disabled:i})=>({outline:"none",cursor:"pointer",overflow:"hidden",position:"relative",padding:e.spacing(5),borderRadius:e.shape.borderRadius,transition:e.transitions.create("padding"),backgroundColor:e.palette.background.neutral,border:`1px dashed ${alpha(e.palette.grey[500],.32)}`,...t&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...i&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(ie)(({theme:e})=>({display:"none",position:"absolute",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:12,width:"100%",height:"100%",backgroundColor:alpha(e.palette.primary.main,.9),zIndex:999,button:{"&, &:hover, &:focus":{backgroundColor:"#fff"}}}));var Ve=styled(Mo)(({theme:e})=>({position:"relative",zIndex:999,pointerEvents:"auto",color:e.palette.grey[700],backgroundColor:e.palette.grey[100],"&:hover":{color:e.palette.grey[900],backgroundColor:e.palette.grey[300]}})),Me=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),Ke=styled(ie,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:t,isDragging:r})=>({width:t,height:100,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2,1,2,1),gap:e.spacing(1),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Je=styled(m.div)(({theme:e,width:t,isDragging:r})=>({width:t,height:60,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),Qe=styled(a)(({theme:e})=>({top:16,right:16,zIndex:9,position:"absolute",color:e.palette.common.white,backgroundColor:alpha(e.palette.grey[900],.72),"&:hover":{backgroundColor:alpha(e.palette.grey[900],.48)}})),Ye=styled(me,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:t,disabled:r,hasError:i})=>({width:64,height:64,flexShrink:0,display:"flex",borderRadius:1,cursor:"pointer",alignItems:"center",color:e.palette.text.disabled,justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),border:`dashed 1px ${alpha(e.palette.grey[500],.16)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),eo=styled(me)(({theme:e})=>({padding:e.spacing(1),top:0,left:0,width:"100%",height:"100%",position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",transition:"all 0.3s ease-in-out",filter:"blur(0)","&:hover":{filter:"blur(3px)"}})),oo=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"})(({theme:e,aspectRatio:t,height:r=1,width:i=1,maxWidth:a,maxHeight:p,isLoading:l,isUploading:g})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,aspectRatio:t,maxWidth:a,maxHeight:p,backgroundColor:e.palette.background.paper,height:r>=i?"100%":`calc(100% * ${t})`,width:r>i?`calc(${t} * 100%)`:"100%",transition:"all 0.5s ease-in-out",...l||g?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),ro=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:t})=>({width:"100%",height:"100%",objectFit:"cover",top:0,left:0,filter:"blur(1.5rem)",transform:"scale(1.1)",position:"absolute",zIndex:0,transition:"opacity 0.3s ease-in-out",...e&&{opacity:0},...t&&{opacity:.7,filter:"blur(2rem)"}})),to=styled(ie)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Co)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var Ce=styled(me,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:t,hasFile:r})=>({top:0,gap:e.spacing(1),left:0,width:"100%",height:"100%",zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:e.palette.text.disabled,flexDirection:"column",justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),transition:e.transitions.create(["opacity"],{duration:e.transitions.duration.shorter}),"&:hover":{opacity:.92},...t&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),io=styled(ie)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center"});styled(ie)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.grey[200],color:e.palette.text.disabled,height:160}));var ao=styled(me,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:t,disabled:r,isError:i,hasFile:a})=>({padding:1,margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${alpha(e.palette.grey[500],.2)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{borderColor:"error.main"},...a&&{...i&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),no=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),so=styled(a)(({theme:e})=>({backgroundColor:alpha(e.palette.grey[900],.72),color:e.palette.common.white,"&:hover":{backgroundColor:alpha(e.palette.grey[600],.64),color:e.palette.common.white},"& svg":{width:14,height:14}}));var No=({onRemove:e,sx:t,file:r,disableDrag:i,attributes:a,listeners:p,innerWidth:l,isDragging:g})=>{let n=r?.id||r?.url||"";return jsx(Uo,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Je,{width:l,isDragging:g,"data-testid":`preview-multi-img-${n}`,...j().inUp,sx:t,children:[jsx(a$1,{disableDrag:i,...a,...p}),jsx(f,{tooltip:!0,imageView:!0,file:r}),jsx(we,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(so,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${n}`)},lo=memo(No);var jo=({file:e$1,thumbnail:t,onRemove:r,sx:i,disableDrag:a$3=!1})=>{let p=e$1?.size||0,l=e$1?.name||e$1?.url||"",g=e$1?.id||e$1?.url||"",n=typeof e$1=="string",s=a$3?70:80,{attributes:m,listeners:f$1,setNodeRef:d,transform:c,transition:D,isDragging:b}=useSortable({id:g,disabled:a$3}),w={transform:x.Transform.toString(c),transition:D,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${s+8}px`,height:"68px"};return t&&e$1?jsx(Me,{ref:d,style:w,children:jsx(lo,{innerWidth:s,isDragging:b,sx:i,file:e$1,disableDrag:a$3,attributes:m,listeners:f$1,onRemove:r})}):jsx(Me,{ref:d,style:{...w,height:"80px",width:`${s+38}px`},children:jsxs(Ke,{width:s+30,isDragging:b,"data-testid":`preview-multi-img-${g}`,...j().inUp,sx:i,children:[jsx(a$1,{disableDrag:a$3,...m,...f$1}),e$1&&jsx(f,{file:e$1}),jsxs(ie,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$2,{title:l,children:jsx(ke,{variant:"subtitle2",noWrap:!0,children:l})}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:n?"":e(p)})]}),jsx(we,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo(jo);var tr=({thumbnail:e,files:t,onRemove:r,onReorder:i,sx:a})=>{let p=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates}));if(!t?.length)return null;let l=n=>{let{active:s,over:m}=n;if(!(!s||!m||s.id===m.id)&&i){let f=t.findIndex(({id:c})=>c===s.id),d=t.findIndex(({id:c})=>c===m.id);f!==-1&&d!==-1&&i(f,d);}},g=jsx(AnimatePresence,{initial:!1,children:t.map(n=>jsx(mo,{sx:a,file:n,onRemove:r,thumbnail:e,disableDrag:!i},n.id))});return i?jsx(DndContext,{sensors:p,collisionDetection:closestCenter,onDragEnd:l,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:t.map(n=>n.id),strategy:horizontalListSortingStrategy,children:g})}):g},ue=memo(tr);var ir=({...e})=>(a$8(()=>{e.onLoading?.(!0);}),jsx(oo,{...e})),uo=ir;var lr=({file:e,aspectRatio:t=1,isUploading:r,isLoading:i,onLoading:a,cropSize:p})=>{let l=useRef(null),g=useRef(null),n=typeof e=="string"?e:e.name,s=typeof e=="string"?e:URL.createObjectURL(e),m=typeof p=="number"?p*t:p?.width,f=typeof p=="number"?p:p?.height,d=useMemo(()=>`image-preview-${n}-${i}-${r}-rnd-${Math.random()}`,[n,i,r]),c=()=>{setTimeout(()=>{a?.(!1);},0);};return jsxs(eo,{ref:l,children:[jsx(uo,{aspectRatio:t,isLoading:i,isUploading:r,height:f,width:m,maxWidth:`calc(${l.current?.offsetWidth||m}px - 16px)`,maxHeight:`calc(${l.current?.offsetHeight||f}px - 16px)`,alt:n,src:s,ref:g,loading:"lazy",onLoad:c,onError:c},d),jsx(ro,{alt:n,src:s,isLoading:i,isUploading:r})]})},ze=memo(lr);var di=e=>e.startsWith("image/"),xo=(e,t=.8)=>new Promise((r,i)=>{let a=document.createElement("canvas"),p=a.getContext("2d"),l=new Image;l.onload=()=>{a.width=l.width,a.height=l.height,p?(p.drawImage(l,0,0),a.toBlob(g=>{if(g){let n=new File([g],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(n);}else i(new Error("Falha ao converter para WebP"));},"image/webp",t)):i(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},l.onerror=()=>i(new Error("Falha ao carregar imagem")),l.src=URL.createObjectURL(e);});var cr=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:i,dropzoneOptions:a,enableCrop:p=!1,customAspectRatio:l,convertToWebp:g=!0,maxFiles:n,cropSize:s})=>{let{showErrorMessage:m}=a$7(),f=useMemo(()=>l||(s&&typeof s!="number"?s.width/s.height:1),[l,s]),[d,c]=useState([]),[D,b]=useState(!1),[w,R]=useState(null),[h,P]=useState(null),[u,x]=useState(""),[F,S]=useState(!1),[v,L]=useState([]),[G,_]=useState(0),O=useMemo(()=>e$1&&Array.isArray(e$1)?e$1.filter(o=>o instanceof File):e$1&&e$1 instanceof File?[e$1]:d,[e$1,d]),q=useMemo(()=>e$1&&Array.isArray(e$1)?null:e$1&&e$1 instanceof File?e$1:d[0]||null,[e$1,d]);useEffect(()=>{e$1&&(Array.isArray(e$1)?c(e$1.filter(o=>o instanceof File)):e$1 instanceof File?c([e$1]):e$1===null&&c([]));},[e$1]);let Z=useCallback(()=>{if(v.length>0&&p){let o=v[0];R(o),_(I=>I+1);let E=new FileReader;E.onload=()=>{x(E.result),b(!0);},E.readAsDataURL(o);}},[v,p]);useEffect(()=>{Z();},[Z]);let ee=useCallback((o,E)=>{P(E);},[]),oe=async()=>!w||!h?null:new Promise(o=>{let E=document.createElement("canvas"),I=E.getContext("2d"),W=new Image;W.onload=async()=>{let{width:de,height:H,x:Ro,y:Fo}=h,Pe=de,xe=H;s&&(typeof s=="number"?(Pe=s,xe=s/f):(Pe=s.width,xe=s.height)),E.width=Pe,E.height=xe,I?(I.drawImage(W,Ro,Fo,de,H,0,0,Pe,xe),E.toBlob(async We=>{if(We){let Le=new File([We],w.name,{type:w.type,lastModified:Date.now()});if(g)try{Le=await xo(Le);}catch(So){m(So,"Erro ao converter para WebP");}o(Le);}else o(null);},"image/png")):o(null);},W.src=u;}),re=async()=>{if(!(!w||!h)){S(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let I=n?[...O,o].slice(0,n):[...O,o];c(I),r?.(I);}else c([o]),t?.(o);let E=v.slice(1);L(E),b(!1),x(""),R(null),E.length>0&&setTimeout(()=>Z(),100);}catch(o){m(o,"Erro ao processar imagem");}finally{S(!1);}}},C=()=>{b(!1),x(""),R(null),L([]),_(0);},z=useCallback(o=>{if(o.length===0)return;if(a?.accept&&Object.keys(a.accept).some(I=>I.includes("image/"))&&p)if(Array.isArray(e$1)||e$1===void 0&&r){let I=o.filter(H=>H.type.startsWith("image/")),W=O.map(H=>H.name),de=I.filter(H=>!W.includes(H.name));if(de.length===0){m("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}L(de),_(0);}else {let I=o[0];R(I);let W=new FileReader;W.onload=()=>{x(W.result),b(!0);},W.readAsDataURL(I);}else if(Array.isArray(e$1)||e$1===void 0&&r){let I=n?[...O,...o].slice(0,n):[...O,...o];c(I),r?.(I);}else {let I=o[0];c([I]),t?.(I);}},[e$1,O,t,r,p,n,a,m]),k=useCallback(o=>{if(!o.length)return;let E=o[0]?.errors[0]?.code,I=a?.maxSize||3145728;m(E==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(I)}`):E==="file-invalid-type"?new Error("Formato de arquivo n\xE3o suportado"):o[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},[a?.maxSize,m]),{getRootProps:T,getInputProps:X,isDragActive:j,isDragReject:ye,fileRejections:_e}=useDropzone({onDrop:z,onDropRejected:k,...a}),Oe=useCallback(o=>{if(!o){c([]),i?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let E=d.filter(I=>I.name!==o.name);c(E),i?.(o),r&&r(E);}else c([]),i?.(o);},[e$1,d,r,i]),Do=useCallback(()=>{c([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:q,files:O,aspectRatio:f,dropzoneProps:{getRootProps:T,getInputProps:X,isDragActive:j,isDragReject:ye,fileRejections:_e},cropState:{cropModalOpen:D,imagePreview:u,cropLoading:F,setCropModalOpen:b,onCropInitialized:ee,handleCropSave:re,handleCropCancel:C,currentImageIndex:G,totalPendingImages:v.length},handleRemove:Oe,clearFiles:Do,setFiles:c}},N=cr;var Ue=(o=>(o.APPLICATION_OCTET_STREAM="application/octet-stream",o.IMAGE_JPEG="image/jpeg",o.IMAGE_JPG="image/jpg",o.IMAGE_PNG="image/png",o.IMAGE_GIF="image/gif",o.IMAGE_WEBP="image/webp",o.IMAGE_SVG="image/svg+xml",o.IMAGE_BMP="image/bmp",o.IMAGE_TIFF="image/tiff",o.IMAGE_ICO="image/x-icon",o.IMAGE_AVIF="image/avif",o.APPLICATION_PDF="application/pdf",o.TEXT_PLAIN="text/plain",o.TEXT_CSV="text/csv",o.APPLICATION_RTF="application/rtf",o.APPLICATION_MSWORD="application/msword",o.APPLICATION_DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",o.APPLICATION_MSEXCEL="application/vnd.ms-excel",o.APPLICATION_XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",o.APPLICATION_MSPOWERPOINT="application/vnd.ms-powerpoint",o.APPLICATION_PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",o.APPLICATION_ODT="application/vnd.oasis.opendocument.text",o.APPLICATION_ODS="application/vnd.oasis.opendocument.spreadsheet",o.APPLICATION_ODP="application/vnd.oasis.opendocument.presentation",o.APPLICATION_XML="application/xml",o.TEXT_XML="text/xml",o.TEXT_HTML="text/html",o.TEXT_CSS="text/css",o.APPLICATION_JSON="application/json",o.TEXT_JAVASCRIPT="text/javascript",o.APPLICATION_ZIP="application/zip",o.APPLICATION_GZIP="application/gzip",o.APPLICATION_RAR="application/vnd.rar",o.APPLICATION_7Z="application/x-7z-compressed",o.AUDIO_MPEG="audio/mpeg",o.AUDIO_WAV="audio/wav",o.AUDIO_OGG="audio/ogg",o.AUDIO_WEBM="audio/webm",o.AUDIO_AAC="audio/aac",o.VIDEO_MP4="video/mp4",o.VIDEO_MPEG="video/mpeg",o.VIDEO_OGG="video/ogg",o.VIDEO_WEBM="video/webm",o.VIDEO_QUICKTIME="video/quicktime",o))(Ue||{}),De=(e=>(e["application/octet-stream"]="APPLICATION_OCTET_STREAM",e["image/jpeg"]="IMAGE_JPEG",e["image/jpg"]="IMAGE_JPG",e["image/png"]="IMAGE_PNG",e["image/gif"]="IMAGE_GIF",e["image/webp"]="IMAGE_WEBP",e["image/svg+xml"]="IMAGE_SVG",e["image/bmp"]="IMAGE_BMP",e["image/tiff"]="IMAGE_TIFF",e["image/x-icon"]="IMAGE_ICO",e["image/avif"]="IMAGE_AVIF",e["application/pdf"]="APPLICATION_PDF",e["text/plain"]="TEXT_PLAIN",e["text/csv"]="TEXT_CSV",e["application/rtf"]="APPLICATION_RTF",e["application/msword"]="APPLICATION_MSWORD",e["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]="APPLICATION_DOCX",e["application/vnd.ms-excel"]="APPLICATION_MSEXCEL",e["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]="APPLICATION_XLSX",e["application/vnd.ms-powerpoint"]="APPLICATION_MSPOWERPOINT",e["application/vnd.openxmlformats-officedocument.presentationml.presentation"]="APPLICATION_PPTX",e["application/vnd.oasis.opendocument.text"]="APPLICATION_ODT",e["application/vnd.oasis.opendocument.spreadsheet"]="APPLICATION_ODS",e["application/vnd.oasis.opendocument.presentation"]="APPLICATION_ODP",e["application/xml"]="APPLICATION_XML",e["text/xml"]="TEXT_XML",e["text/html"]="TEXT_HTML",e["text/css"]="TEXT_CSS",e["application/json"]="APPLICATION_JSON",e["text/javascript"]="TEXT_JAVASCRIPT",e["application/zip"]="APPLICATION_ZIP",e["application/gzip"]="APPLICATION_GZIP",e["application/vnd.rar"]="APPLICATION_RAR",e["application/x-7z-compressed"]="APPLICATION_7Z",e["audio/mpeg"]="AUDIO_MPEG",e["audio/wav"]="AUDIO_WAV",e["audio/ogg"]="AUDIO_OGG",e["audio/webm"]="AUDIO_WEBM",e["audio/aac"]="AUDIO_AAC",e["video/mp4"]="VIDEO_MP4",e["video/mpeg"]="VIDEO_MPEG",e["video/ogg"]="VIDEO_OGG",e["video/webm"]="VIDEO_WEBM",e["video/quicktime"]="VIDEO_QUICKTIME",e))(De||{});var ur=({createFilesMutation:e,files:t,file:r,skip:i})=>{let{showErrorMessage:a}=a$7(),[p,l]=useState(!1),[g,n]=useState(!1),[s,m]=useState(null),[f,d]=useState(void 0),c=useMemo(()=>f?.[0],[f]),D=useMemo(()=>{if(!i)return r?[r]:t},[r,t,i]),b=useCallback(async h=>{if(!h?.length){d(void 0);return}try{n(!0);let P=await Promise.all(h.map(async({url:u,name:x,id:F},S)=>{let L=await(await fetch(u)).blob(),G=x||u.split("/").pop()||"image",_=new File([L],G,{type:L.type});return _.id=F,_.url=u,_.index=S,_}));d(P);}catch(P){console.error("Erro ao carregar preview dos arquivos:",P),d(void 0);}finally{n(!1);}},[]),w=g||p;return useEffect(()=>{b(D);},[D,b]),{filesPreview:f,filePreview:c,uploadFiles:async h=>{if(h?.length){l(!0);try{let P=h[0].type||"application/octet-stream",u=De[P];if(!u)throw new Error(`Tipo de arquivo n\xE3o suportado: ${P}`);let x=await e({files:[{content_type:u,name:h[0].name}]}).unwrap(),F=x.files.map(v=>v.id);return (await Promise.all(h.map(v=>fetch(x.files[0].url,{method:"PUT",headers:{"Content-Type":P},body:v})))).forEach(v=>{if(!v.ok)throw new Error(`Erro no upload: ${v.statusText}`)}),b(x.files),F}catch(P){throw m(P),a(P,"Erro no upload"),P}finally{l(!1);}}},isUploadingFiles:p,isLoadingPreview:g,isUploadOrLoadingFiles:w,uploadFilesError:s}},fr=ur;var xr=({sx:e,id:t,name:r,tabIndex:i,uploading:a,getRootProps:p,getInputProps:l,isDragActive:g,isError:n,disabled:s,dropZoneSxProps:m,dropZoneContent:f,children:d,...c})=>jsxs(Ae,{children:[a&&jsx(a$6,{"data-testid":"uploading-progress-bar"}),jsxs(me,{sx:{width:1,position:"relative",...e},children:[jsxs(He,{...p(),"data-testid":"drop-zone-styled-area",isError:n,isDragActive:g,disabled:!!s,sx:m,...c,children:[jsx("input",{...l(),id:t,tabIndex:i,name:r}),f]}),d]})]}),K=xr;var hr=({header:e,description:t,sx:r,...i})=>jsxs(ie,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...i,children:[jsx(a$3,{sx:{width:220}}),jsxs("div",{children:[jsx(ke,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(ke,{variant:"body2",sx:{color:"text.secondary"},children:t||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(ke,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),J=memo(hr);var Er=({onRemove:e,onReorder:t,onFilesSelect:r,id:i,disabled:a,error:p,helperText:l,files:g,thumbnail:n,dropZoneSxProps:s,uploading:m,tabIndex:f,maxFiles:d,...c})=>{let{files:D,dropzoneProps:b,handleRemove:w}=N({filesToUpload:g,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:a,...c},maxFiles:d}),{getRootProps:R,getInputProps:h,isDragActive:P,isDragReject:u}=b,x=!!D?.length,F=u||!!p;return jsxs(K,{id:i,uploading:m,disabled:a,dropZoneSxProps:s,tabIndex:f,getRootProps:R,getInputProps:h,isDragActive:P,isError:F,dropZoneContent:jsx(J,{}),children:[jsx(U,{disabled:a,helperText:l,isError:F}),x&&jsx(me,{sx:{my:3},children:jsx(ue,{files:D,thumbnail:!!n,onRemove:e?w:void 0,onReorder:t})})]})},Dr=memo(Er);var Or=({onFilesSelect:e,onRemove:t,onReorder:r,id:i,disabled:a,error:p,helperText:l,files:g,dropZoneSxProps:n,placeholderProps:s,placeholderAlt:m,uploading:f,tabIndex:d,maxFiles:c,aspectRatio:D,enableCrop:b=!0,convertToWebp:w=!0,cropSize:R,name:h,label:P,...u})=>{let{files:x,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:L}=N({filesToUpload:g,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:a,...u},enableCrop:b,customAspectRatio:D,convertToWebp:w,maxFiles:c,cropSize:R}),{getRootProps:G,getInputProps:_,isDragActive:O,isDragReject:q}=F,{cropModalOpen:Z,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:C,handleCropCancel:z,currentImageIndex:k,totalPendingImages:T}=S,X=!!x?.length,j=q||!!p,ye=useMemo(()=>{let _e=P??"Ajustar Imagem",Oe=T>1?` (${k} de ${T})`:"";return `${_e}${Oe}`},[P,T,k]);return jsxs(K,{id:i,name:h,uploading:f,disabled:a,dropZoneSxProps:n,tabIndex:d,getRootProps:G,getInputProps:_,isDragActive:O,isError:j,dropZoneContent:jsx(Fragment,{children:m?jsx(ie,{children:m}):jsx(J,{header:s?.header,description:s?.description})}),children:[jsx(U,{disabled:a,helperText:l,isError:j}),X&&jsx(Fragment,{children:jsx(me,{sx:{my:3,ml:.5},children:jsx(ue,{files:x,thumbnail:!0,onRemove:v,onReorder:r})})}),jsx(a$4,{open:Z,onClose:z,label:ye,imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})},Lr=memo(Or);var Ur=({onFileSelect:e$1,onRemove:t,file:r,id:i,disabled:a,error:p,helperText:l,sx:g,dropZoneSxProps:n,uploading:s,tabIndex:m$1,...f$1})=>{let{file:d,dropzoneProps:c,handleRemove:D}=N({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:a,...f$1}}),{getRootProps:b,getInputProps:w,isDragActive:R,isDragReject:h}=c,P=useCallback(S=>{S.stopPropagation(),D(d||void 0);},[d,D]),u=!!d,x=typeof d=="string",F=h||!!p;return jsx(K,{id:i,uploading:s,disabled:a,dropZoneSxProps:n,tabIndex:m$1,getRootProps:b,getInputProps:w,isDragActive:R,isError:F,dropZoneContent:jsxs(Fragment,{children:[!u&&jsx(J,{}),u&&jsxs(ie,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:S=>`solid 1px ${S.palette.divider}`,...g},children:[jsx(f,{file:d}),jsxs(ie,{flexGrow:1,sx:{minWidth:0},children:[jsx(ke,{variant:"subtitle2",noWrap:!0,children:x?d:d.name}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:x?"":e(d.size)})]}),t&&jsx(a$2,{title:"Remover arquivo",children:jsx(Ve,{edge:"end",size:"small",disabled:a,"aria-label":"Remover arquivo",onClick:P,children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(U,{disabled:a,helperText:l,isError:F})})},Nr=memo(Ur);var Wr=({onRemove:e,onFileSelect:t,file:r,id:i,disabled:a,error:p,helperText:l,dropZoneSxProps:g,placeholderProps:n,placeholderAlt:s,uploading:m,tabIndex:f,aspectRatio:d,enableCrop:c=!0,convertToWebp:D=!0,name:b,label:w,cropSize:R,...h})=>{let[P,u]=useState(!1),{file:x,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:L}=N({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,...h},enableCrop:c,customAspectRatio:d,convertToWebp:D,cropSize:R}),{getRootProps:G,getInputProps:_,isDragActive:O,isDragReject:q}=F,{cropModalOpen:Z,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:C,handleCropCancel:z}=S,k=useCallback(()=>{v(x||void 0);},[x,v]),T=!!x,X=q||!!p,j=T?{opacity:0}:{opacity:1};return jsxs(Ae,{children:[(m||P)&&jsx(a$6,{}),jsxs(K,{id:i,uploading:m,disabled:a,dropZoneSxProps:g,tabIndex:f,getRootProps:G,getInputProps:_,isDragActive:O,isError:X,name:b,dropZoneContent:jsxs(Fragment,{children:[s?jsx(ie,{sx:j,children:s}):jsx(J,{sx:j,header:n?.title,description:n?.description}),T&&jsx(ze,{file:x,cropSize:R,isLoading:P,isUploading:m,onLoading:u,aspectRatio:L})]}),children:[jsx(U,{disabled:a,helperText:l,isError:X}),T&&e&&jsx(Qe,{size:"small",onClick:k,disabled:a,label:"Remover arquivo",children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$4,{open:Z,onClose:z,label:w??"Ajustar Imagem",imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})]})},$r=memo(Wr);var Jr=({onFileSelect:e,onRemove:t,file:r,disabled:i,label:a,id:p,tabIndex:l,error:g,helperText:n,sx:s,name:m,maxSize:f,uploading:d,aspectRatio:c=1,enableCrop:D=!0,convertToWebp:b=!0,cropSize:w,...R})=>{let[h,P]=useState(!1),{file:u,dropzoneProps:x,cropState:F,handleRemove:S}=N({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,maxSize:f,...R},enableCrop:D,customAspectRatio:c,convertToWebp:b,cropSize:w}),{getRootProps:v,getInputProps:L,isDragActive:G,isDragReject:_}=x,{cropModalOpen:O,imagePreview:q,cropLoading:Z,onCropInitialized:ee,handleCropSave:oe,handleCropCancel:re}=F,C=_||!!g,z=h||d,k=!!t,T=useMemo(()=>u?(P(!0),URL.createObjectURL(u)):"",[u]),X=()=>{P(!1);},j=()=>k&&u?()=>S(u):v().onClick;return jsxs(Fragment,{children:[jsxs(ao,{sx:s,isError:C,isDragActive:G,hasFile:!!u,...v(),onClick:j(),children:[jsxs(to,{children:[u&&jsx(no,{alt:"Avatar Preview",src:T,onLoad:X,...z&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&z&&jsx(io,{children:jsx(Kr,{size:135,thickness:1,color:"primary"})}),!u&&!z&&jsxs(Ce,{isError:C,hasFile:!1,children:[jsx(a$5,{icon:"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"text.disabled"},children:"Adicionar foto"})]}),u&&!z&&jsxs(Ce,{isError:C,hasFile:!0,children:[jsx(a$5,{icon:k?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"common.white"},children:k?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:m,id:p,tabIndex:l,...L()}),jsx(ie,{spacing:.5,sx:{pt:1},children:jsx(U,{helperText:n,disabled:i,isError:C})}),u&&!z&&jsx(ie,{direction:"row",justifyContent:"center",spacing:1,sx:{pt:1,mb:-1},children:jsx(ke,{variant:"caption",component:"span",sx:{px:.75,cursor:"pointer",borderRadius:.75,color:"error.main","&:hover":{color:"error.dark",bgcolor:"background.default"}},onClick:()=>S(u),children:"Remover"})})]}),O&&q&&jsx(a$4,{open:O,onClose:re,label:a??"Ajustar Imagem",imageSrc:q,aspectRatio:c,onInitialized:ee,onSave:oe,loading:Z,cropSize:w,cropShape:"round"})]})},Qr=memo(Jr);var rt=({error:e,name:t,disabled:r,sx:i,...a})=>{let{getRootProps:p,getInputProps:l,isDragActive:g,isDragReject:n}=useDropzone({disabled:r,...a}),s=n||e;return jsxs(Ye,{...p(),isDragActive:g,hasError:!!s,disabled:!!r,sx:i,"data-testid":"upload-box",children:[jsx("input",{name:t,...l()}),"Selecionar arquivo"]})},tt=memo(rt);
|
|
35
36
|
|
|
36
|
-
export {
|
|
37
|
+
export { Ue as ContentType, De as FileContentType, U as HelperText, ue as MultiFilePreview, Dr as MultipleFileUpload, Lr as MultipleImageUpload, ze as SingleFilePreview, Nr as SingleFileUpload, $r as SingleImageUpload, Qr as UploadAvatar, tt as UploadSimpleBox, xo as convertToWebP, di as isImageFile, N as useDropzoneUploader, fr as useFileUploadService };
|
package/dist/hooks/useMount.js
CHANGED
|
@@ -79,6 +79,21 @@ interface SingleFilePreviewProps extends StackProps {
|
|
|
79
79
|
onLoading?: (isLoading: boolean) => void;
|
|
80
80
|
isUploading?: boolean;
|
|
81
81
|
}
|
|
82
|
+
interface LoadingPreviewImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
83
|
+
aspectRatio: number;
|
|
84
|
+
height?: number | string;
|
|
85
|
+
width?: number | string;
|
|
86
|
+
maxWidth?: number | string;
|
|
87
|
+
maxHeight?: number | string;
|
|
88
|
+
isLoading?: boolean;
|
|
89
|
+
isUploading?: boolean;
|
|
90
|
+
cropSize?: CropSize;
|
|
91
|
+
onLoading?: (isLoading: boolean) => void;
|
|
92
|
+
alt?: string;
|
|
93
|
+
src?: string;
|
|
94
|
+
loading: 'lazy';
|
|
95
|
+
ref?: React.RefObject<HTMLImageElement>;
|
|
96
|
+
}
|
|
82
97
|
interface PlaceholderProps extends StackProps {
|
|
83
98
|
header?: React.ReactNode;
|
|
84
99
|
description?: React.ReactNode;
|
|
@@ -293,4 +308,4 @@ type FileThumbnailProps = StackProps & {
|
|
|
293
308
|
};
|
|
294
309
|
};
|
|
295
310
|
|
|
296
|
-
export { ContentType as C, DropZoneProps as D, ExtendFile as E, FileThumbnailProps as F, HelperTextProps as H, MultiFilePreviewProps as M, PlaceholderProps as P, RejectionFilesProps as R, SingleFilePreviewProps as S, ThumbnailBadgeProps as T, FileUploadProps as a, MultiFileUploadProps as b, MultiImageUploadProps as c, SingleFileUploadProps as d, SingleImageUploadProps as e, FileContentType as f, FileUpload as g, CropSize as h, CreateFilesMutation as i, FileCreateRequest as j, FileCreateResponse as k, FileQueryRequest as l, FileQueryResponse as m, FileGetResponse as n, SortableItemProps as o, StyledDropZoneProps as p, StyledDropZonePropsType as q };
|
|
311
|
+
export { ContentType as C, DropZoneProps as D, ExtendFile as E, FileThumbnailProps as F, HelperTextProps as H, LoadingPreviewImageProps as L, MultiFilePreviewProps as M, PlaceholderProps as P, RejectionFilesProps as R, SingleFilePreviewProps as S, ThumbnailBadgeProps as T, FileUploadProps as a, MultiFileUploadProps as b, MultiImageUploadProps as c, SingleFileUploadProps as d, SingleImageUploadProps as e, FileContentType as f, FileUpload as g, CropSize as h, CreateFilesMutation as i, FileCreateRequest as j, FileCreateResponse as k, FileQueryRequest as l, FileQueryResponse as m, FileGetResponse as n, SortableItemProps as o, StyledDropZoneProps as p, StyledDropZonePropsType as q };
|