@zydon/common 2.4.46 → 2.4.48
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.
|
@@ -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-0e4f1933.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, L as LoadingPreviewImageProps, 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-0e4f1933.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-0e4f1933.js';
|
|
5
5
|
import { DropzoneOptions, useDropzone, FileRejection } from 'react-dropzone';
|
|
6
6
|
import { Area } from 'react-easy-crop';
|
|
7
7
|
import '@mui/material/Stack';
|
|
@@ -58,8 +58,8 @@ interface UseDropzoneUploaderReturn {
|
|
|
58
58
|
declare const useDropzoneUploader: ({ filesToUpload, onFileSelect, onFilesSelect, onRemove, dropzoneOptions, enableCrop, customAspectRatio, convertToWebp, maxFiles, cropSize, }: UseDropzoneUploaderProps) => UseDropzoneUploaderReturn;
|
|
59
59
|
|
|
60
60
|
declare const useFileUploadService: ({ createFilesMutation, queryFiles, fileIds, files, file, skip, }: FileUploadProps) => {
|
|
61
|
-
filesPreview:
|
|
62
|
-
filePreview:
|
|
61
|
+
filesPreview: ExtendFile[] | undefined;
|
|
62
|
+
filePreview: ExtendFile | undefined;
|
|
63
63
|
uploadFiles: (files: File[]) => Promise<string[] | undefined>;
|
|
64
64
|
isUploadingFiles: boolean;
|
|
65
65
|
isLoadingPreview: boolean;
|
|
@@ -15,23 +15,23 @@ import '../../chunk-CHLVIVDD.js';
|
|
|
15
15
|
import '../../chunk-ILHUUK4X.js';
|
|
16
16
|
import { a as a$1 } from '../../chunk-S7QQBC4I.js';
|
|
17
17
|
import { a as a$8 } from '../../chunk-ONZBWH3C.js';
|
|
18
|
-
import { memo, forwardRef, useState, useLayoutEffect,
|
|
19
|
-
import
|
|
18
|
+
import { memo, forwardRef, useState, useLayoutEffect, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
19
|
+
import Mo from '@mui/material/FormHelperText';
|
|
20
20
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
21
21
|
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
22
22
|
import { restrictToHorizontalAxis, restrictToParentElement, restrictToWindowEdges } from '@dnd-kit/modifiers';
|
|
23
23
|
import { useSortable, sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
|
|
24
24
|
import { m, AnimatePresence } from 'framer-motion';
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
25
|
+
import ae from '@mui/material/Stack';
|
|
26
|
+
import Ge from '@mui/material/Typography';
|
|
27
|
+
import xe from '@mui/material/Box';
|
|
28
|
+
import Uo from '@mui/material/IconButton';
|
|
29
|
+
import ko from '@mui/material/Paper';
|
|
30
30
|
import { styled, alpha } from '@mui/material/styles';
|
|
31
|
-
import
|
|
31
|
+
import Bo from '@mui/material/Badge';
|
|
32
32
|
import { useDropzone } from 'react-dropzone';
|
|
33
|
-
import
|
|
33
|
+
import at from '@mui/material/CircularProgress';
|
|
34
34
|
|
|
35
|
-
var Mo=({helperText:e,disabled:t,isError:r})=>e?jsx(Lo,{error:r,sx:a=>({mx:"14px",color:t?a.palette.grey[500]:void 0}),children:e}):null,k=memo(Mo);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}}),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(zo)(({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: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}})),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"&&e!=="maxWidth"&&e!=="maxHeight"})(({theme:e,aspectRatio:t,height:r=1,width:a=1,maxWidth:i,maxHeight:l,isLoading:d,isUploading:c})=>({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:i,maxHeight:l,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",...d||c?{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(No)(({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: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)"}}})),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 Bo=({onRemove:e,sx:t,file:r,disableDrag:a,attributes:i,listeners:l,innerWidth:d,isDragging:c})=>{let s=r?.id||r?.url;return s?jsx(ko,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Je,{width:d,isDragging:c,"data-testid":`preview-multi-img-${s}`,...j().inUp,sx:t,children:[jsx(a$2,{disableDrag:a,...i,...l}),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-${s}`):null},lo=memo(Bo);var $o=({file:e$1,thumbnail:t,onRemove:r,sx:a$1,disableDrag:i=!1})=>{let l=e$1?.size||0,d=e$1?.name||e$1?.url||e$1?.id,c=e$1?.id||e$1?.url||"",s=typeof e$1=="string",n=i?70:80,{attributes:p,listeners:x$1,setNodeRef:m,transform:g,transition:D,isDragging:w}=useSortable({id:c,disabled:i}),h={transform:x.Transform.toString(g),transition:D,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${n+8}px`,height:"68px"};return t&&e$1?jsx(Me,{ref:m,style:h,children:jsx(lo,{innerWidth:n,isDragging:w,sx:a$1,file:e$1,disableDrag:i,attributes:p,listeners:x$1,onRemove:r})}):jsx(Me,{ref:m,style:{...h,height:"80px",width:`${n+38}px`},children:jsxs(Ke,{width:n+30,isDragging:w,"data-testid":`preview-multi-img-${c}`,...j().inUp,sx:a$1,children:[jsx(a$2,{disableDrag:i,...p,...x$1}),e$1&&jsx(f,{file:e$1}),jsxs(ie,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:d,children:jsx(ke,{variant:"subtitle2",noWrap:!0,children:d})}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:s?"":e(l)})]}),jsx(we,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo($o);var ar=({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 d=s=>{let{active:n,over:p}=s;if(!(!n||!p||n.id===p.id)&&a){let x=t.findIndex(({id:g})=>g===n.id),m=t.findIndex(({id:g})=>g===p.id);x!==-1&&m!==-1&&a(x,m);}},c=jsx(AnimatePresence,{initial:!1,children:t.map(s=>jsx(mo,{sx:i,file:s,onRemove:r,thumbnail:e,disableDrag:!a},s.id))});return a?jsx(DndContext,{sensors:l,collisionDetection:closestCenter,onDragEnd:d,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:t.map(s=>s.id),strategy:horizontalListSortingStrategy,children:c})}):c},ue=memo(ar);var fo=forwardRef(({onLoading:e,width:t,height:r,...a},i)=>{let[l,d]=useState("calc(100% - 16px)"),[c,s]=useState("calc(100% - 16px)");a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof i=="object"&&i?.current?e?.(!i.current.complete):e?.(!1);},[i,e]);function n(){if(typeof i=="object"&&i?.current&&t&&r){let{width:p,height:x}=i.current.getBoundingClientRect(),m=Number(t)<p?t:p,g=Number(r)<x?r:x;d(`calc(${m}px - 16px)`),s(`calc(${g}px - 16px)`);}e?.(!1);}return jsx(oo,{...a,ref:i,maxWidth:l,maxHeight:c,onLoad:n,onError:n})});fo.displayName="LoadingPreviewImage";var xo=fo;var mr=({file:e,aspectRatio:t=1,isUploading:r,isLoading:a,onLoading:i,cropSize:l})=>{let d=useRef(null),c=e?.id||e?.url||e?.name,s=e?.name||e?.url||e?.id,n=e?.url||URL.createObjectURL(e),p=typeof l=="number"?l*t:l?.width,x=typeof l=="number"?l:l?.height,m=useMemo(()=>`image-preview-${c}-${r}`,[c,r]);return c?jsxs(eo,{children:[jsx(xo,{aspectRatio:t,isLoading:a,isUploading:r,height:x,width:p,alt:s,src:n,ref:d,loading:"lazy",onLoading:i},m),jsx(ro,{alt:s,src:n,isLoading:a,isUploading:r})]}):null},ze=memo(mr);var ui=e=>e.startsWith("image/"),Io=(e,t=.8)=>new Promise((r,a)=>{let i=document.createElement("canvas"),l=i.getContext("2d"),d=new Image;d.onload=()=>{i.width=d.width,i.height=d.height,l?(l.drawImage(d,0,0),i.toBlob(c=>{if(c){let s=new File([c],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(s);}else a(new Error("Falha ao converter para WebP"));},"image/webp",t)):a(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},d.onerror=()=>a(new Error("Falha ao carregar imagem")),d.src=URL.createObjectURL(e);});var fr=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:a,dropzoneOptions:i,enableCrop:l=!1,customAspectRatio:d,convertToWebp:c=!0,maxFiles:s,cropSize:n})=>{let{showErrorMessage:p}=a$8(),x=useMemo(()=>d||(n&&typeof n!="number"?n.width/n.height:1),[d,n]),[m,g]=useState([]),[D,w]=useState(!1),[h,P]=useState(null),[y,_]=useState(null),[u,f]=useState(""),[I,v]=useState(!1),[F,L]=useState([]),[O,z]=useState(0),R=useMemo(()=>e$1&&Array.isArray(e$1)?e$1.filter(o=>o instanceof File):e$1&&e$1 instanceof File?[e$1]:m,[e$1,m]),M=useMemo(()=>e$1&&Array.isArray(e$1)?null:e$1&&e$1 instanceof File?e$1:m[0]||null,[e$1,m]);useEffect(()=>{e$1&&(Array.isArray(e$1)?g(e$1.filter(o=>o instanceof File)):e$1 instanceof File?g([e$1]):e$1===null&&g([]));},[e$1]);let j=useCallback(()=>{if(F.length>0&&l){let o=F[0];P(o),z(b=>b+1);let E=new FileReader;E.onload=()=>{f(E.result),w(!0);},E.readAsDataURL(o);}},[F,l]);useEffect(()=>{j();},[j]);let ee=useCallback((o,E)=>{_(E);},[]),oe=async()=>!h||!y?null:new Promise(o=>{let E=document.createElement("canvas"),b=E.getContext("2d"),$=new Image;$.onload=async()=>{let{width:de,height:X,x:So,y:yo}=y,xe=de,Pe=X;n&&(typeof n=="number"?(xe=n,Pe=n/x):(xe=n.width,Pe=n.height)),E.width=xe,E.height=Pe,b?(b.drawImage($,So,yo,de,X,0,0,xe,Pe),E.toBlob(async We=>{if(We){let Le=new File([We],h.name,{type:h.type,lastModified:Date.now()});if(c)try{Le=await Io(Le);}catch(_o){p(_o,"Erro ao converter para WebP");}o(Le);}else o(null);},"image/png")):o(null);},$.src=u;}),re=async()=>{if(!(!h||!y)){v(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let b=s?[...R,o].slice(0,s):[...R,o];g(b),r?.(b);}else g([o]),t?.(o);let E=F.slice(1);L(E),w(!1),f(""),P(null),E.length>0&&setTimeout(()=>j(),100);}catch(o){p(o,"Erro ao processar imagem");}finally{v(!1);}}},N=()=>{w(!1),f(""),P(null),L([]),z(0);},U=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(X=>X.type.startsWith("image/")),$=R.map(X=>X.name),de=b.filter(X=>!$.includes(X.name));if(de.length===0){p("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}L(de),z(0);}else {let b=o[0];P(b);let $=new FileReader;$.onload=()=>{f($.result),w(!0);},$.readAsDataURL(b);}else if(Array.isArray(e$1)||e$1===void 0&&r){let b=s?[...R,...o].slice(0,s):[...R,...o];g(b),r?.(b);}else {let b=o[0];g([b]),t?.(b);}},[e$1,R,t,r,l,s,i,p]),G=useCallback(o=>{if(!o.length)return;let E=o[0]?.errors[0]?.code,b=i?.maxSize||3145728;p(E==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(b)}`):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");},[i?.maxSize,p]),{getRootProps:T,getInputProps:q,isDragActive:W,isDragReject:ye,fileRejections:_e}=useDropzone({onDrop:U,onDropRejected:G,...i}),Oe=useCallback(o=>{if(!o){g([]),a?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let E=m.filter(b=>b.name!==o.name);g(E),a?.(o),r&&r(E);}else g([]),a?.(o);},[e$1,m,r,a]),Ro=useCallback(()=>{g([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:M,files:R,aspectRatio:x,dropzoneProps:{getRootProps:T,getInputProps:q,isDragActive:W,isDragReject:ye,fileRejections:_e},cropState:{cropModalOpen:D,imagePreview:u,cropLoading:I,setCropModalOpen:w,onCropInitialized:ee,handleCropSave:re,handleCropCancel:N,currentImageIndex:O,totalPendingImages:F.length},handleRemove:Oe,clearFiles:Ro,setFiles:g}},B=fr;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 Pr=({createFilesMutation:e,queryFiles:t,fileIds:r,files:a,file:i,skip:l})=>{let{showErrorMessage:d}=a$8(),[c,s]=useState(!1),[n,p]=useState(!1),[x,m]=useState(null),[g,D]=useState(void 0),w=useMemo(()=>g?.[0],[g]),h=useMemo(()=>{if(!l)return i?[i]:a},[i,a,l]),P=useCallback(async u=>{if(!u?.length){D(void 0),p(!1);return}try{p(!0);let f=await Promise.all(u.map(async({url:I,name:v,id:F},L)=>{let z=await(await fetch(I)).blob(),R=v||I.split("/").pop()||"image",M=new File([z],R,{type:z.type});return M.id=F,M.url=I,M.index=L,M}));D(f);}catch(f){console.error("Erro ao carregar preview dos arquivos:",f),D(void 0);}finally{p(!1);}},[]);useEffect(()=>{!r?.length||!t?P(void 0):t({ids:r}).unwrap().then(({files:u})=>{p(!0);let f=r.map(I=>u.find(v=>v.id===I)).filter(I=>!!I);P(f);});},[r,t,P]);let y=n||c;return useEffect(()=>{P(h);},[h,P]),{filesPreview:g,filePreview:w,uploadFiles:async u=>{if(u?.length){s(!0);try{let f=u[0].type||"application/octet-stream",I=De[f];if(!I)throw new Error(`Tipo de arquivo n\xE3o suportado: ${f}`);let v=await e({files:[{content_type:I,name:u[0].name}]}).unwrap(),F=v.files.map(O=>O.id);return (await Promise.all(u.map(O=>fetch(v.files[0].url,{method:"PUT",headers:{"Content-Type":f},body:O})))).forEach(O=>{if(!O.ok)throw new Error(`Erro no upload: ${O.statusText}`)}),P(v.files),F}catch(f){throw m(f),d(f,"Erro no upload"),f}finally{s(!1);}}},isUploadingFiles:c,isLoadingPreview:n,isUploadOrLoadingFiles:y,uploadFilesError:x}},Ir=Pr;var hr=({sx:e,id:t,name:r,tabIndex:a,uploading:i,getRootProps:l,getInputProps:d,isDragActive:c,isError:s,disabled:n,dropZoneSxProps:p,dropZoneContent:x,children:m,...g})=>jsxs(Ae,{children:[i&&jsx(a$7,{"data-testid":"uploading-progress-bar"}),jsxs(me,{sx:{width:1,position:"relative",...e},children:[jsxs(Xe,{...l(),"data-testid":"drop-zone-styled-area",isError:s,isDragActive:c,disabled:!!n,sx:p,...g,children:[jsx("input",{...d(),id:t,tabIndex:a,name:r}),x]}),m]})]}),K=hr;var wr=({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$4,{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(wr);var Rr=({onRemove:e,onReorder:t,onFilesSelect:r,id:a,disabled:i,error:l,helperText:d,files:c,thumbnail:s,dropZoneSxProps:n,uploading:p,tabIndex:x,maxFiles:m,...g})=>{let{files:D,dropzoneProps:w,handleRemove:h}=B({filesToUpload:c,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:i,...g},maxFiles:m}),{getRootProps:P,getInputProps:y,isDragActive:_,isDragReject:u}=w,f=!!D?.length,I=u||!!l;return jsxs(K,{id:a,uploading:p,disabled:i,dropZoneSxProps:n,tabIndex:x,getRootProps:P,getInputProps:y,isDragActive:_,isError:I,dropZoneContent:jsx(J,{}),children:[jsx(k,{disabled:i,helperText:d,isError:I}),f&&jsx(me,{sx:{my:3},children:jsx(ue,{files:D,thumbnail:!!s,onRemove:e?h:void 0,onReorder:t})})]})},Sr=memo(Rr);var Cr=({onFilesSelect:e,onRemove:t,onReorder:r,id:a,disabled:i,error:l,helperText:d,files:c,dropZoneSxProps:s,placeholderProps:n,placeholderAlt:p,uploading:x,tabIndex:m,maxFiles:g,aspectRatio:D,enableCrop:w=!0,convertToWebp:h=!0,cropSize:P,name:y,label:_,...u})=>{let{files:f,dropzoneProps:I,cropState:v,handleRemove:F,aspectRatio:L}=B({filesToUpload:c,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,...u},enableCrop:w,customAspectRatio:D,convertToWebp:h,maxFiles:g,cropSize:P}),{getRootProps:O,getInputProps:z,isDragActive:R,isDragReject:M}=I,{cropModalOpen:j,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:N,handleCropCancel:U,currentImageIndex:G,totalPendingImages:T}=v,q=!!f?.length,W=M||!!l,ye=useMemo(()=>{let _e=_??"Ajustar Imagem",Oe=T>1?` (${G} de ${T})`:"";return `${_e}${Oe}`},[_,T,G]);return jsxs(K,{id:a,name:y,uploading:x,disabled:i,dropZoneSxProps:s,tabIndex:m,getRootProps:O,getInputProps:z,isDragActive:R,isError:W,dropZoneContent:jsx(Fragment,{children:p?jsx(ie,{children:p}):jsx(J,{header:n?.header,description:n?.description})}),children:[jsx(k,{disabled:i,helperText:d,isError:W}),q&&jsx(Fragment,{children:jsx(me,{sx:{my:3,ml:.5},children:jsx(ue,{files:f,thumbnail:!0,onRemove:F,onReorder:r})})}),jsx(a$5,{open:j,onClose:U,label:ye,imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:N,loading:oe,cropSize:P})]})},zr=memo(Cr);var Br=({onFileSelect:e$1,onRemove:t,file:r,id:a,disabled:i,error:l,helperText:d,sx:c,dropZoneSxProps:s,uploading:n,tabIndex:p,...x})=>{let{file:m$1,dropzoneProps:g,handleRemove:D}=B({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:i,...x}}),{getRootProps:w,getInputProps:h,isDragActive:P,isDragReject:y}=g,_=useCallback(v=>{v.stopPropagation(),D(m$1||void 0);},[m$1,D]),u=!!m$1,f$1=typeof m$1=="string",I=y||!!l;return jsx(K,{id:a,uploading:n,disabled:i,dropZoneSxProps:s,tabIndex:p,getRootProps:w,getInputProps:h,isDragActive:P,isError:I,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:v=>`solid 1px ${v.palette.divider}`,...c},children:[jsx(f,{file:m$1}),jsxs(ie,{flexGrow:1,sx:{minWidth:0},children:[jsx(ke,{variant:"subtitle2",noWrap:!0,children:f$1?m$1:m$1.name}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:f$1?"":e(m$1.size)})]}),t&&jsx(a$3,{title:"Remover arquivo",children:jsx(Ve,{edge:"end",size:"small",disabled:i,"aria-label":"Remover arquivo",onClick:_,children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(k,{disabled:i,helperText:d,isError:I})})},Gr=memo(Br);var qr=({onRemove:e,onFileSelect:t,file:r,id:a,disabled:i,error:l,helperText:d,dropZoneSxProps:c,placeholderProps:s,placeholderAlt:n,uploading:p,tabIndex:x,aspectRatio:m,enableCrop:g=!0,convertToWebp:D=!0,name:w,label:h,cropSize:P,...y})=>{let[_,u]=useState(!1),{file:f,dropzoneProps:I,cropState:v,handleRemove:F,aspectRatio:L}=B({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,...y},enableCrop:g,customAspectRatio:m,convertToWebp:D,cropSize:P}),{getRootProps:O,getInputProps:z,isDragActive:R,isDragReject:M}=I,{cropModalOpen:j,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:N,handleCropCancel:U}=v,G=useCallback(()=>{F(f||void 0);},[f,F]),T=!!f,q=M||!!l,W=T?{opacity:0}:{opacity:1};return jsxs(Ae,{children:[(p||_)&&jsx(a$7,{}),jsxs(K,{id:a,uploading:p,disabled:i,dropZoneSxProps:c,tabIndex:x,getRootProps:O,getInputProps:z,isDragActive:R,isError:q,name:w,dropZoneContent:jsxs(Fragment,{children:[n?jsx(ie,{sx:W,children:n}):jsx(J,{sx:W,header:s?.title,description:s?.description}),T&&jsx(ze,{file:f,cropSize:P,isLoading:_,isUploading:p,onLoading:u,aspectRatio:L})]}),children:[jsx(k,{disabled:i,helperText:d,isError:q}),T&&e&&jsx(Qe,{size:"small",onClick:G,disabled:i,label:"Remover arquivo",children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$5,{open:j,onClose:U,label:h??"Ajustar Imagem",imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:N,loading:oe,cropSize:P})]})]})},Xr=memo(qr);var et=({onFileSelect:e,onRemove:t,file:r,disabled:a,label:i,id:l,tabIndex:d,error:c,helperText:s,sx:n,name:p,maxSize:x,uploading:m,aspectRatio:g=1,enableCrop:D=!0,convertToWebp:w=!0,cropSize:h,...P})=>{let[y,_]=useState(!1),{file:u,dropzoneProps:f,cropState:I,handleRemove:v}=B({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,maxSize:x,...P},enableCrop:D,customAspectRatio:g,convertToWebp:w,cropSize:h}),{getRootProps:F,getInputProps:L,isDragActive:O,isDragReject:z}=f,{cropModalOpen:R,imagePreview:M,cropLoading:j,onCropInitialized:ee,handleCropSave:oe,handleCropCancel:re}=I,N=z||!!c,U=y||m,G=!!t,T=useMemo(()=>u?(_(!0),URL.createObjectURL(u)):"",[u]),q=()=>{_(!1);},W=()=>G&&u?()=>v(u):F().onClick;return jsxs(Fragment,{children:[jsxs(ao,{sx:n,isError:N,isDragActive:O,hasFile:!!u,...F(),onClick:W(),children:[jsxs(to,{children:[u&&jsx(no,{alt:"Avatar Preview",src:T,onLoad:q,...U&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&U&&jsx(io,{children:jsx(Yr,{size:135,thickness:1,color:"primary"})}),!u&&!U&&jsxs(Ce,{isError:N,hasFile:!1,children:[jsx(a$6,{icon:"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:N?"error.main":"text.disabled"},children:"Adicionar foto"})]}),u&&!U&&jsxs(Ce,{isError:N,hasFile:!0,children:[jsx(a$6,{icon:G?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:N?"error.main":"common.white"},children:G?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:p,id:l,tabIndex:d,...L()}),jsx(ie,{spacing:.5,sx:{pt:1},children:jsx(k,{helperText:s,disabled:a,isError:N})}),u&&!U&&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:()=>v(u),children:"Remover"})})]}),R&&M&&jsx(a$5,{open:R,onClose:re,label:i??"Ajustar Imagem",imageSrc:M,aspectRatio:g,onInitialized:ee,onSave:oe,loading:j,cropSize:h,cropShape:"round"})]})},ot=memo(et);var at=({error:e,name:t,disabled:r,sx:a,...i})=>{let{getRootProps:l,getInputProps:d,isDragActive:c,isDragReject:s}=useDropzone({disabled:r,...i}),n=s||e;return jsxs(Ye,{...l(),isDragActive:c,hasError:!!n,disabled:!!r,sx:a,"data-testid":"upload-box",children:[jsx("input",{name:t,...d()}),"Selecionar arquivo"]})},nt=memo(at);
|
|
35
|
+
var Co=({helperText:e,disabled:t,isError:r})=>e?jsx(Mo,{error:r,sx:a=>({mx:"14px",color:t?a.palette.grey[500]:void 0}),children:e}):null,W=memo(Co);var Fe=styled(ae)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),Re=styled(ae)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),Ke=styled(xe,{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(ae)(({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 Je=styled(Uo)(({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]}})),Ce=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),Qe=styled(ae,{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)"})),Ye=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)"})),eo=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)}})),oo=styled(xe,{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}})),ro=styled(xe)(({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)"}})),to=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"&&e!=="maxWidth"&&e!=="maxHeight"})(({theme:e,aspectRatio:t,height:r=1,width:a=1,maxWidth:i,maxHeight:l,isLoading:s,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:i,maxHeight:l,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",...s||g?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),io=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)"}})),ao=styled(ae)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(ko)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var ze=styled(xe,{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)}})),no=styled(ae)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center"});styled(ae)(({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 so=styled(xe,{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)"}}})),lo=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),po=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 Go=({onRemove:e,sx:t,file:r,disableDrag:a,attributes:i,listeners:l,innerWidth:s,isDragging:g})=>{let d=r?.id||r?.url;return d?jsx(Bo,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Ye,{width:s,isDragging:g,"data-testid":`preview-multi-img-${d}`,...j().inUp,sx:t,children:[jsx(a$2,{disableDrag:a,...i,...l}),jsx(f,{tooltip:!0,imageView:!0,file:r}),jsx(Re,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(po,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${d}`):null},co=memo(Go);var Ho=({file:e$1,thumbnail:t,onRemove:r,sx:a$1,disableDrag:i=!1})=>{let l=e$1?.size||0,s=e$1?.name||e$1?.url||e$1?.id,g=e$1?.id||e$1?.url||"",d=typeof e$1=="string",n=i?70:80,{attributes:p,listeners:h,setNodeRef:m,transform:c,transition:v,isDragging:E}=useSortable({id:g,disabled:i}),y={transform:x.Transform.toString(c),transition:v,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${n+8}px`,height:"68px"};return t&&e$1?jsx(Ce,{ref:m,style:y,children:jsx(co,{innerWidth:n,isDragging:E,sx:a$1,file:e$1,disableDrag:i,attributes:p,listeners:h,onRemove:r})}):jsx(Ce,{ref:m,style:{...y,height:"80px",width:`${n+38}px`},children:jsxs(Qe,{width:n+30,isDragging:E,"data-testid":`preview-multi-img-${g}`,...j().inUp,sx:a$1,children:[jsx(a$2,{disableDrag:i,...p,...h}),e$1&&jsx(f,{file:e$1}),jsxs(ae,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:s,children:jsx(Ge,{variant:"subtitle2",noWrap:!0,children:s})}),jsx(Ge,{variant:"caption",sx:{color:"text.secondary"},children:d?"":e(l)})]}),jsx(Re,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},uo=memo(Ho);var lr=({thumbnail:e,files:t,onRemove:r,onReorder:a,sx:i})=>{let l=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),s=useMemo(()=>t.map((n,p)=>(n.id||(n.id=`${Date.now()}-${p}`),n)),[t]),g=useCallback(n=>{let{active:p,over:h}=n;if(!(!p||!h||p.id===h.id)&&a){let m=s.findIndex(({id:v})=>v===p.id),c=s.findIndex(({id:v})=>v===h.id);m!==-1&&c!==-1&&a(m,c,s);}},[s,a]);if(!s?.length)return null;let d=jsx(AnimatePresence,{initial:!1,children:s.map(n=>jsx(uo,{sx:i,id:`preview-file-${n.id}`,file:n,onRemove:r,thumbnail:e,disableDrag:!a},`preview-file-${n.id}`))});return a?jsx(DndContext,{sensors:l,collisionDetection:closestCenter,onDragEnd:g,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:s.map(n=>n.id),strategy:horizontalListSortingStrategy,children:d})}):d},be=memo(lr);var Po=forwardRef(({onLoading:e,width:t,height:r,...a},i)=>{let[l,s]=useState("calc(100% - 16px)"),[g,d]=useState("calc(100% - 16px)");a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof i=="object"&&i?.current?e?.(!i.current.complete):e?.(!1);},[i,e]);function n(){if(typeof i=="object"&&i?.current&&t&&r){let{width:p,height:h}=i.current.getBoundingClientRect(),m=Number(t)<p?t:p,c=Number(r)<h?r:h;s(`calc(${m}px - 16px)`),d(`calc(${c}px - 16px)`);}e?.(!1);}return jsx(to,{...a,ref:i,maxWidth:l,maxHeight:g,onLoad:n,onError:n})});Po.displayName="LoadingPreviewImage";var bo=Po;var fr=({file:e,aspectRatio:t=1,isUploading:r,isLoading:a,onLoading:i,cropSize:l})=>{let s=useRef(null),g=e?.id||e?.url||e?.name,d=e?.name||e?.url||e?.id,n=e?.url||URL.createObjectURL(e),p=typeof l=="number"?l*t:l?.width,h=typeof l=="number"?l:l?.height,m=useMemo(()=>`image-preview-${g}-${r}`,[g,r]);return g?jsxs(ro,{children:[jsx(bo,{aspectRatio:t,isLoading:a,isUploading:r,height:h,width:p,alt:d,src:n,ref:s,loading:"lazy",onLoading:i},m),jsx(io,{alt:d,src:n,isLoading:a,isUploading:r})]}):null},Ue=memo(fr);var hi=e=>e.startsWith("image/"),ho=(e,t=.8)=>new Promise((r,a)=>{let i=document.createElement("canvas"),l=i.getContext("2d"),s=new Image;s.onload=()=>{i.width=s.width,i.height=s.height,l?(l.drawImage(s,0,0),i.toBlob(g=>{if(g){let d=new File([g],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(d);}else a(new Error("Falha ao converter para WebP"));},"image/webp",t)):a(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},s.onerror=()=>a(new Error("Falha ao carregar imagem")),s.src=URL.createObjectURL(e);});var br=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:a,dropzoneOptions:i,enableCrop:l=!1,customAspectRatio:s,convertToWebp:g=!0,maxFiles:d,cropSize:n})=>{let{showErrorMessage:p}=a$8(),h=useMemo(()=>s||(n&&typeof n!="number"?n.width/n.height:1),[s,n]),[m,c]=useState([]),[v,E]=useState(!1),[y,F]=useState(null),[R,L]=useState(null),[b,f]=useState(""),[x,P]=useState(!1),[u,A]=useState([]),[O,w]=useState(0),_=useMemo(()=>e$1&&Array.isArray(e$1)?e$1.filter(o=>o instanceof File):e$1&&e$1 instanceof File?[e$1]:m,[e$1,m]),C=useMemo(()=>e$1&&Array.isArray(e$1)?null:e$1&&e$1 instanceof File?e$1:m[0]||null,[e$1,m]);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 B=useCallback(()=>{if(u.length>0&&l){let o=u[0];F(o),w(I=>I+1);let D=new FileReader;D.onload=()=>{f(D.result),E(!0);},D.readAsDataURL(o);}},[u,l]);useEffect(()=>{B();},[B]);let U=useCallback((o,D)=>{L(D);},[]),oe=async()=>!y||!R?null:new Promise(o=>{let D=document.createElement("canvas"),I=D.getContext("2d"),j=new Image;j.onload=async()=>{let{width:ue,height:V,x:yo,y:_o}=R,he=ue,ve=V;n&&(typeof n=="number"?(he=n,ve=n/h):(he=n.width,ve=n.height)),D.width=he,D.height=ve,I?(I.drawImage(j,yo,_o,ue,V,0,0,he,ve),D.toBlob(async He=>{if(He){let Me=new File([He],y.name,{type:y.type,lastModified:Date.now()});if(g)try{Me=await ho(Me);}catch(Oo){p(Oo,"Erro ao converter para WebP");}o(Me);}else o(null);},"image/png")):o(null);},j.src=b;}),re=async()=>{if(!(!y||!R)){P(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let I=d?[..._,o].slice(-d):[..._,o];c(I),r?.(I);}else c([o]),t?.(o);let D=u.slice(1);A(D),E(!1),f(""),F(null),D.length>0&&setTimeout(()=>B(),100);}catch(o){p(o,"Erro ao processar imagem");}finally{P(!1);}}},k=()=>{E(!1),f(""),F(null),A([]),w(0);},G=useCallback(o=>{if(o.length===0)return;if(i?.accept&&Object.keys(i.accept).some(I=>I.includes("image/"))&&l)if(Array.isArray(e$1)||e$1===void 0&&r){let I=o.filter(V=>V.type.startsWith("image/")),j=_.map(V=>V.name),ue=I.filter(V=>!j.includes(V.name));if(ue.length===0){p("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}A(ue),w(0);}else {let I=o[0];F(I);let j=new FileReader;j.onload=()=>{f(j.result),E(!0);},j.readAsDataURL(I);}else if(Array.isArray(e$1)||e$1===void 0&&r){let I=d?[..._,...o].slice(-d):[..._,...o];c(I),r?.(I);}else {let I=o[0];c([I]),t?.(I);}},[e$1,_,t,r,l,d,i,p]),H=useCallback(o=>{if(!o.length)return;let D=o[0]?.errors[0]?.code,I=i?.maxSize||3145728;p(D==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(I)}`):D==="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,p]),{getRootProps:N,getInputProps:T,isDragActive:q,isDragReject:ge,fileRejections:te}=useDropzone({onDrop:G,onDropRejected:H,...i}),ne=useCallback(o=>{if(!o){c([]),a?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let D=m.filter(I=>I.name!==o.name);c(D),a?.(o),r&&r(D);}else c([]),a?.(o);},[e$1,m,r,a]),se=useCallback(()=>{c([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:C,files:_,aspectRatio:h,dropzoneProps:{getRootProps:N,getInputProps:T,isDragActive:q,isDragReject:ge,fileRejections:te},cropState:{cropModalOpen:v,imagePreview:b,cropLoading:x,setCropModalOpen:E,onCropInitialized:U,handleCropSave:re,handleCropCancel:k,currentImageIndex:O,totalPendingImages:u.length},handleRemove:ne,clearFiles:se,setFiles:c}},Z=br;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||{}),ye=(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))(ye||{});var vr=({createFilesMutation:e,queryFiles:t,fileIds:r,files:a,file:i,skip:l})=>{let{showErrorMessage:s}=a$8(),[g,d]=useState(!1),[n,p]=useState(!1),[h,m]=useState(null),[c,v]=useState(void 0),E=useRef([]),y=useMemo(()=>c?.[0],[c]),F=useMemo(()=>{if(!l)return i?[i]:a},[i,a,l]),R=useCallback(async(f,x)=>{if(!f?.length){x?.append||v(void 0),p(!1);return}try{p(!0);let P=await Promise.all(f.map(async({url:u,name:A,id:O},w)=>{let C=await(await fetch(u)).blob(),B=A||u.split("/").pop()||"image",U=new File([C],B,{type:C.type});return U.id=O,U.url=u,U.index=w,U}));v(u=>{let A=x?.append?[...u||[],...P]:P;return x?.order?x.order.map(O=>A.find(w=>w.id===O)).filter(O=>!!O):A});}catch(P){console.error("Erro ao carregar preview dos arquivos:",P),x?.append||v(void 0);}finally{p(!1);}},[]);useEffect(()=>{(!r?.length||!t)&&(R(void 0),E.current=[]);},[r,t,R]),useEffect(()=>{if(!r?.length||!t)return;let f=r.filter(x=>!E.current.includes(x));if(!f.length){c?.every((P,u)=>P.id===r[u])||v(P=>P&&r.map(u=>P.find(A=>A.id===u)).filter(u=>!!u)),E.current=r;return}t({ids:f}).unwrap().then(({files:x})=>{let P=f.map(u=>x.find(A=>A.id===u)).filter(u=>!!u);R(P,{append:!0,order:r}),E.current=r;});},[r,t,R,c]);let L=n||g;return useEffect(()=>{R(F);},[F,R]),{filesPreview:c,filePreview:y,uploadFiles:async f=>{if(f?.length){d(!0);try{let x=f[0].type||"application/octet-stream",P=ye[x];if(!P)throw new Error(`Tipo de arquivo n\xE3o suportado: ${x}`);let u=await e({files:[{content_type:P,name:f[0].name}]}).unwrap(),A=u.files.map(w=>w.id);return (await Promise.all(f.map(w=>fetch(u.files[0].url,{method:"PUT",headers:{"Content-Type":x},body:w})))).forEach(w=>{if(!w.ok)throw new Error(`Erro no upload: ${w.statusText}`)}),R(u.files),A}catch(x){throw m(x),s(x,"Erro no upload"),x}finally{d(!1);}}},isUploadingFiles:g,isLoadingPreview:n,isUploadOrLoadingFiles:L,uploadFilesError:h}},Ar=vr;var wr=({sx:e,id:t,name:r,tabIndex:a,uploading:i,getRootProps:l,getInputProps:s,isDragActive:g,isError:d,disabled:n,dropZoneSxProps:p,dropZoneContent:h,children:m,...c})=>jsxs(Fe,{children:[i&&jsx(a$7,{"data-testid":"uploading-progress-bar"}),jsxs(xe,{sx:{width:1,position:"relative",...e},children:[jsxs(Ke,{...l(),"data-testid":"drop-zone-styled-area",isError:d,isDragActive:g,disabled:!!n,sx:p,...c,children:[jsx("input",{...s(),id:t,tabIndex:a,name:r}),h]}),m]})]}),J=wr;var Rr=({header:e,description:t,sx:r,...a})=>jsxs(ae,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...a,children:[jsx(a$4,{sx:{width:220}}),jsxs("div",{children:[jsx(Ge,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(Ge,{variant:"body2",sx:{color:"text.secondary"},children:t||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(Ge,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),Q=memo(Rr);var Lr=({onRemove:e,onReorder:t,onFilesSelect:r,id:a,disabled:i,error:l,helperText:s,files:g,thumbnail:d,dropZoneSxProps:n,uploading:p,tabIndex:h,maxFiles:m,...c})=>{let{files:v,dropzoneProps:E,handleRemove:y,setFiles:F}=Z({filesToUpload:g,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:i,...c},maxFiles:m}),{getRootProps:R,getInputProps:L,isDragActive:b,isDragReject:f}=E,x=useCallback((A,O)=>{F(w=>{let _=[...w],[C]=_.splice(A,1);return _.splice(O,0,C),t?.(A,O,_),_});},[t,F]),P=!!v?.length,u=f||!!l;return jsxs(J,{id:a,uploading:p,disabled:i,dropZoneSxProps:n,tabIndex:h,getRootProps:R,getInputProps:L,isDragActive:b,isError:u,dropZoneContent:jsx(Q,{}),children:[jsx(W,{disabled:i,helperText:s,isError:u}),P&&jsx(xe,{sx:{my:3},children:jsx(be,{files:v,thumbnail:!!d,onRemove:e?y:void 0,onReorder:t?x:void 0})})]})},Mr=memo(Lr);var Br=({onFilesSelect:e,onRemove:t,onReorder:r,id:a,disabled:i,error:l,helperText:s,files:g,dropZoneSxProps:d,placeholderProps:n,placeholderAlt:p,uploading:h,tabIndex:m,maxFiles:c,aspectRatio:v,enableCrop:E=!0,convertToWebp:y=!0,cropSize:F,name:R,label:L,...b})=>{let{files:f,dropzoneProps:x,cropState:P,handleRemove:u,aspectRatio:A,setFiles:O}=Z({filesToUpload:g,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,...b},enableCrop:E,customAspectRatio:v,convertToWebp:y,maxFiles:c,cropSize:F}),{getRootProps:w,getInputProps:_,isDragActive:C,isDragReject:B}=x,{cropModalOpen:U,imagePreview:oe,cropLoading:re,onCropInitialized:k,handleCropSave:G,handleCropCancel:H,currentImageIndex:N,totalPendingImages:T}=P,q=useCallback((se,o)=>{O(D=>{let I=[...D],[j]=I.splice(se,1);return I.splice(o,0,j),r?.(se,o,I),I});},[r,O]),ge=!!f?.length,te=B||!!l,ne=useMemo(()=>{let se=L??"Ajustar Imagem",o=T>1?` (${N} de ${T})`:"";return `${se}${o}`},[L,T,N]);return jsxs(J,{id:a,name:R,uploading:h,disabled:i,dropZoneSxProps:d,tabIndex:m,getRootProps:w,getInputProps:_,isDragActive:C,isError:te,dropZoneContent:jsx(Fragment,{children:p?jsx(ae,{children:p}):jsx(Q,{header:n?.header,description:n?.description})}),children:[jsx(W,{disabled:i,helperText:s,isError:te}),ge&&jsx(Fragment,{children:jsx(xe,{sx:{my:3,ml:.5},children:jsx(be,{files:f,thumbnail:!0,onRemove:u,onReorder:r?q:void 0})})}),jsx(a$5,{open:U,onClose:H,label:ne,imageSrc:oe,aspectRatio:A,onInitialized:k,onSave:G,loading:re,cropSize:F})]})},Gr=memo(Br);var Hr=({onFileSelect:e$1,onRemove:t,file:r,id:a,disabled:i,error:l,helperText:s,sx:g,dropZoneSxProps:d,uploading:n,tabIndex:p,...h})=>{let{file:m$1,dropzoneProps:c,handleRemove:v}=Z({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:i,...h}}),{getRootProps:E,getInputProps:y,isDragActive:F,isDragReject:R}=c,L=useCallback(P=>{P.stopPropagation(),v(m$1||void 0);},[m$1,v]),b=!!m$1,f$1=typeof m$1=="string",x=R||!!l;return jsx(J,{id:a,uploading:n,disabled:i,dropZoneSxProps:d,tabIndex:p,getRootProps:E,getInputProps:y,isDragActive:F,isError:x,dropZoneContent:jsxs(Fragment,{children:[!b&&jsx(Q,{}),b&&jsxs(ae,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:P=>`solid 1px ${P.palette.divider}`,...g},children:[jsx(f,{file:m$1}),jsxs(ae,{flexGrow:1,sx:{minWidth:0},children:[jsx(Ge,{variant:"subtitle2",noWrap:!0,children:f$1?m$1:m$1.name}),jsx(Ge,{variant:"caption",sx:{color:"text.secondary"},children:f$1?"":e(m$1.size)})]}),t&&jsx(a$3,{title:"Remover arquivo",children:jsx(Je,{edge:"end",size:"small",disabled:i,"aria-label":"Remover arquivo",onClick:L,children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(W,{disabled:i,helperText:s,isError:x})})},Xr=memo(Hr);var Yr=({onRemove:e,onFileSelect:t,file:r,id:a,disabled:i,error:l,helperText:s,dropZoneSxProps:g,placeholderProps:d,placeholderAlt:n,uploading:p,tabIndex:h,aspectRatio:m,enableCrop:c=!0,convertToWebp:v=!0,name:E,label:y,cropSize:F,...R})=>{let[L,b]=useState(!1),{file:f,dropzoneProps:x,cropState:P,handleRemove:u,aspectRatio:A}=Z({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,...R},enableCrop:c,customAspectRatio:m,convertToWebp:v,cropSize:F}),{getRootProps:O,getInputProps:w,isDragActive:_,isDragReject:C}=x,{cropModalOpen:B,imagePreview:U,cropLoading:oe,onCropInitialized:re,handleCropSave:k,handleCropCancel:G}=P,H=useCallback(()=>{u(f||void 0);},[f,u]),N=!!f,T=C||!!l,q=N?{opacity:0}:{opacity:1};return jsxs(Fe,{children:[(p||L)&&jsx(a$7,{}),jsxs(J,{id:a,uploading:p,disabled:i,dropZoneSxProps:g,tabIndex:h,getRootProps:O,getInputProps:w,isDragActive:_,isError:T,name:E,dropZoneContent:jsxs(Fragment,{children:[n?jsx(ae,{sx:q,children:n}):jsx(Q,{sx:q,header:d?.title,description:d?.description}),N&&jsx(Ue,{file:f,cropSize:F,isLoading:L,isUploading:p,onLoading:b,aspectRatio:A})]}),children:[jsx(W,{disabled:i,helperText:s,isError:T}),N&&e&&jsx(eo,{size:"small",onClick:H,disabled:i,label:"Remover arquivo",children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$5,{open:B,onClose:G,label:y??"Ajustar Imagem",imageSrc:U,aspectRatio:A,onInitialized:re,onSave:k,loading:oe,cropSize:F})]})]})},et=memo(Yr);var nt=({onFileSelect:e,onRemove:t,file:r,disabled:a,label:i,id:l,tabIndex:s,error:g,helperText:d,sx:n,name:p,maxSize:h,uploading:m,aspectRatio:c=1,enableCrop:v=!0,convertToWebp:E=!0,cropSize:y,...F})=>{let[R,L]=useState(!1),{file:b,dropzoneProps:f,cropState:x,handleRemove:P}=Z({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,maxSize:h,...F},enableCrop:v,customAspectRatio:c,convertToWebp:E,cropSize:y}),{getRootProps:u,getInputProps:A,isDragActive:O,isDragReject:w}=f,{cropModalOpen:_,imagePreview:C,cropLoading:B,onCropInitialized:U,handleCropSave:oe,handleCropCancel:re}=x,k=w||!!g,G=R||m,H=!!t,N=useRef(""),T=useRef();useEffect(()=>{if(!b){N.current="",T.current=void 0;return}let te=b.id??`${b.name}-${b.size}-${b.lastModified}`;if(T.current===te)return;T.current=te,L(!0);let ne=URL.createObjectURL(b);return N.current=ne,()=>{URL.revokeObjectURL(ne);}},[b]);let q=()=>{L(!1);},ge=()=>H&&b?()=>P(b):u().onClick;return jsxs(Fragment,{children:[jsxs(so,{sx:n,isError:k,isDragActive:O,hasFile:!!b,...u(),onClick:ge(),children:[jsxs(ao,{children:[b&&jsx(lo,{alt:"Avatar Preview",src:N.current,onLoad:q,...G&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),b&&G&&jsx(no,{children:jsx(at,{size:135,thickness:1,color:"primary"})}),!b&&!G&&jsxs(ze,{isError:k,hasFile:!1,children:[jsx(a$6,{icon:"ADD_IMAGE",width:32}),jsx(Ge,{variant:"caption",textAlign:"center",sx:{color:k?"error.main":"text.disabled"},children:"Adicionar foto"})]}),b&&!G&&jsxs(ze,{isError:k,hasFile:!0,children:[jsx(a$6,{icon:H?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(Ge,{variant:"caption",textAlign:"center",sx:{color:k?"error.main":"common.white"},children:H?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:p,id:l,tabIndex:s,...A()}),jsx(ae,{spacing:.5,sx:{pt:1},children:jsx(W,{helperText:d,disabled:a,isError:k})}),b&&!G&&jsx(ae,{direction:"row",justifyContent:"center",spacing:1,sx:{pt:1,mb:-1},children:jsx(Ge,{variant:"caption",component:"span",sx:{px:.75,cursor:"pointer",borderRadius:.75,color:"error.main","&:hover":{color:"error.dark",bgcolor:"background.default"}},onClick:()=>P(b),children:"Remover"})})]}),_&&C&&jsx(a$5,{open:_,onClose:re,label:i??"Ajustar Imagem",imageSrc:C,aspectRatio:c,onInitialized:U,onSave:oe,loading:B,cropSize:y,cropShape:"round"})]})},st=memo(nt);var ct=({error:e,name:t,disabled:r,sx:a,...i})=>{let{getRootProps:l,getInputProps:s,isDragActive:g,isDragReject:d}=useDropzone({disabled:r,...i}),n=d||e;return jsxs(oo,{...l(),isDragActive:g,hasError:!!n,disabled:!!r,sx:a,"data-testid":"upload-box",children:[jsx("input",{name:t,...s()}),"Selecionar arquivo"]})},mt=memo(ct);
|
|
36
36
|
|
|
37
|
-
export {
|
|
37
|
+
export { Ne as ContentType, ye as FileContentType, W as HelperText, be as MultiFilePreview, Mr as MultipleFileUpload, Gr as MultipleImageUpload, Ue as SingleFilePreview, Xr as SingleFileUpload, et as SingleImageUpload, st as UploadAvatar, mt as UploadSimpleBox, ho as convertToWebP, hi as isImageFile, Z as useDropzoneUploader, Ar as useFileUploadService };
|
|
@@ -3,22 +3,22 @@ import { SxProps, Theme } from '@mui/material/styles';
|
|
|
3
3
|
import { DropzoneOptions, DropzoneRootProps, FileRejection, DropzoneInputProps } from 'react-dropzone';
|
|
4
4
|
import { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
|
|
5
5
|
|
|
6
|
-
interface FileUpload {
|
|
7
|
-
url: string;
|
|
8
|
-
file: File;
|
|
9
|
-
contentType: string;
|
|
10
|
-
resourceIds: string[];
|
|
11
|
-
}
|
|
12
6
|
interface ExtendFile extends File {
|
|
13
7
|
id?: string;
|
|
14
8
|
url?: string;
|
|
15
9
|
index?: number;
|
|
16
10
|
}
|
|
11
|
+
interface FileUpload {
|
|
12
|
+
url: string;
|
|
13
|
+
file: ExtendFile;
|
|
14
|
+
contentType: string;
|
|
15
|
+
resourceIds: string[];
|
|
16
|
+
}
|
|
17
17
|
type CropSize = {
|
|
18
18
|
width: number;
|
|
19
19
|
height: number;
|
|
20
20
|
} | number;
|
|
21
|
-
type CreateFilesMutation = (files:
|
|
21
|
+
type CreateFilesMutation = (files: ExtendFile[]) => Promise<string[] | undefined>;
|
|
22
22
|
interface FileCreateRequest {
|
|
23
23
|
files: Array<{
|
|
24
24
|
content_type: keyof typeof ContentType;
|
|
@@ -98,11 +98,11 @@ interface PlaceholderProps extends StackProps {
|
|
|
98
98
|
description?: React.ReactNode;
|
|
99
99
|
}
|
|
100
100
|
interface SingleFileUploadProps extends DropzoneOptions {
|
|
101
|
-
onFileSelect: (file?:
|
|
102
|
-
onRemove?: (file?:
|
|
101
|
+
onFileSelect: (file?: ExtendFile) => void;
|
|
102
|
+
onRemove?: (file?: ExtendFile) => void;
|
|
103
103
|
placeholderProps?: PlaceholderProps;
|
|
104
104
|
placeholderAlt?: React.ReactNode;
|
|
105
|
-
file?:
|
|
105
|
+
file?: ExtendFile;
|
|
106
106
|
name?: string;
|
|
107
107
|
label?: string;
|
|
108
108
|
id?: string;
|
|
@@ -122,10 +122,10 @@ interface SingleImageUploadProps extends SingleFileUploadProps {
|
|
|
122
122
|
cropSize?: CropSize;
|
|
123
123
|
}
|
|
124
124
|
interface MultiFileUploadProps extends Omit<SingleFileUploadProps, 'file' | 'onFileSelect'> {
|
|
125
|
-
onFilesSelect: (files?:
|
|
126
|
-
onRemoveAll?: (files?:
|
|
127
|
-
onReorder?: (oldIndex: number, newIndex: number) => void;
|
|
128
|
-
files?:
|
|
125
|
+
onFilesSelect: (files?: ExtendFile[]) => void;
|
|
126
|
+
onRemoveAll?: (files?: ExtendFile[]) => void;
|
|
127
|
+
onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
|
|
128
|
+
files?: ExtendFile[];
|
|
129
129
|
maxFiles?: number;
|
|
130
130
|
thumbnail?: boolean;
|
|
131
131
|
}
|
|
@@ -142,7 +142,7 @@ interface SortableItemProps extends StackProps {
|
|
|
142
142
|
disableDrag?: boolean;
|
|
143
143
|
}
|
|
144
144
|
interface MultiFilePreviewProps extends StackProps {
|
|
145
|
-
onReorder?: (oldIndex: number, newIndex: number) => void;
|
|
145
|
+
onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
|
|
146
146
|
onRemove?: (file?: ExtendFile) => void;
|
|
147
147
|
files: ExtendFile[];
|
|
148
148
|
lastNode?: React.ReactNode;
|