@zydon/common 2.1.11 → 2.1.13
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-7JZ253Q4.js → chunk-AS522OS2.js} +7 -7
- package/dist/chunk-M6QHAL4V.js +7 -0
- package/dist/chunk-SSVWNWE5.js +14 -0
- package/dist/components/ImageCropModal/index.d.ts +2 -1
- package/dist/components/ImageCropModal/index.js +1 -1
- package/dist/components/form/UploadAvatarWithCrop/index.js +3 -3
- package/dist/components/form/UploadWithCrop/index.js +6 -6
- package/dist/components/upload/index.js +3 -3
- package/dist/hooks/useUploadImage.d.ts +1 -0
- package/dist/hooks/useUploadImage.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-CLFF2L7L.js +0 -7
- package/dist/chunk-UXRJ6YK5.js +0 -13
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { c, f } from './chunk-FYJCXJN6.js';
|
|
2
|
-
import { a as a$2 } from './chunk-
|
|
2
|
+
import { a as a$2 } from './chunk-SSVWNWE5.js';
|
|
3
3
|
import { a } from './chunk-W3IZQQL6.js';
|
|
4
4
|
import { i } from './chunk-D27ND54J.js';
|
|
5
|
-
import { a as a$1 } from './chunk-
|
|
5
|
+
import { a as a$1 } from './chunk-M6QHAL4V.js';
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
7
|
import { useDropzone } from 'react-dropzone';
|
|
8
8
|
import P from '@mui/material/Box';
|
|
9
|
-
import
|
|
9
|
+
import k from '@mui/material/Typography';
|
|
10
10
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
11
|
+
import N from '@mui/material/Dialog';
|
|
12
|
+
import T from '@mui/material/Stack';
|
|
13
13
|
|
|
14
|
-
function j({sx:p,error:s,file:e,disabled:l,helperText:c$1,...d}){let{getRootProps:g,getInputProps:v,isDragActive:u,isDragReject:y,fileRejections:m}=useDropzone({multiple:!1,disabled:l,accept:{"image/*":[]},...d}),r=!!e,i$1=y||!!s,[C,f]=useState("");useEffect(()=>{typeof e=="string"?f(e):e instanceof File&&f(URL.createObjectURL(e));},[e]);let w=r&&jsx("img",{alt:"avatar",src:C,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover"}}),b=jsxs(P,{className:"upload-placeholder",sx:{top:0,gap:1,left:0,width:1,height:1,zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:"text.disabled",flexDirection:"column",justifyContent:"center",bgcolor:o=>i(o.vars.palette.grey["500Channel"],.08),transition:o=>o.transitions.create(["opacity"],{duration:o.transitions.duration.shorter}),"&:hover":{opacity:.72},...i$1&&{color:"error.main",bgcolor:o=>i(o.vars.palette.error.mainChannel,.08)},...r&&{zIndex:9,opacity:0,color:"common.white",bgcolor:o=>i(o.vars.palette.grey["900Channel"],.64)}},children:[jsx(a,{icon:"ADD_IMAGE",width:32}),jsx(
|
|
14
|
+
function j({sx:p,error:s,file:e,disabled:l,helperText:c$1,...d}){let{getRootProps:g,getInputProps:v,isDragActive:u,isDragReject:y,fileRejections:m}=useDropzone({multiple:!1,disabled:l,accept:{"image/*":[]},...d}),r=!!e,i$1=y||!!s,[C,f]=useState("");useEffect(()=>{typeof e=="string"?f(e):e instanceof File&&f(URL.createObjectURL(e));},[e]);let w=r&&jsx("img",{alt:"avatar",src:C,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover"}}),b=jsxs(P,{className:"upload-placeholder",sx:{top:0,gap:1,left:0,width:1,height:1,zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:"text.disabled",flexDirection:"column",justifyContent:"center",bgcolor:o=>i(o.vars.palette.grey["500Channel"],.08),transition:o=>o.transitions.create(["opacity"],{duration:o.transitions.duration.shorter}),"&:hover":{opacity:.72},...i$1&&{color:"error.main",bgcolor:o=>i(o.vars.palette.error.mainChannel,.08)},...r&&{zIndex:9,opacity:0,color:"common.white",bgcolor:o=>i(o.vars.palette.grey["900Channel"],.64)}},children:[jsx(a,{icon:"ADD_IMAGE",width:32}),jsx(k,{variant:"caption",children:r?"Atualizar foto":"Enviar foto"})]}),R=jsxs(P,{sx:{width:1,height:1,overflow:"hidden",borderRadius:"50%",position:"relative"},children:[w,b]});return jsxs(Fragment,{children:[jsxs(P,{...g(),sx:{p:1,m:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:o=>`1px dashed ${i(o.vars.palette.grey["500Channel"],.2)}`,...u&&{opacity:.72},...l&&{opacity:.48,pointerEvents:"none"},...i$1&&{borderColor:"error.main"},...r&&{...i$1&&{bgcolor:o=>i(o.vars.palette.error.mainChannel,.08)},"&:hover .upload-placeholder":{opacity:1}},...p},children:[jsx("input",{...v()}),R]}),c$1&&c$1,jsx(c,{files:m})]})}var _=({onFileCropped:p,onImageUploaded:s,onCancel:e,aspect:l,label:c,image:d="",uploading:g,file:v,tabIndex:u,...y})=>{let{id:m,setCropModalOpen:r,handleRemove:i,cropModalOpen:C,cancelChanges:f$1,saveChanges:w,previewImage:b,setCropper:R,preview:o,closePreviewImage:L,saving:B}=a$1({onFileCropped:p,onImageUploaded:s,onCancel:e});return jsxs(Fragment,{children:[jsxs(T,{position:"relative",alignItems:"center",justifyContent:"center",children:[g&&jsx(f,{}),jsx(j,{...y,id:m,file:v,onDrop:I=>{if(I.length>0){r(!0);let x=new FileReader;x.addEventListener("load",()=>{let M=x.result?.toString()||"";s(M),p(void 0);}),x.readAsDataURL(I[0]);}},image:d,tabIndex:u})]}),jsx(a$2,{id:m,open:C,onClose:f$1,label:c,aspectRatio:l,imageSrc:d,onRemove:i,onSave:w,onPreview:b,onInitialized:R,loading:B}),jsx(N,{open:!!o,onClose:L,scroll:"body",PaperProps:{sx:{p:2}},children:o&&jsx("img",{src:o,alt:"Preview"})})]})},no=_;
|
|
15
15
|
|
|
16
|
-
export { j as a,
|
|
16
|
+
export { j as a, no as b };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a } from './chunk-W3MYAMTH.js';
|
|
2
|
+
import { useId, useState } from 'react';
|
|
3
|
+
import I from 'browser-image-compression';
|
|
4
|
+
|
|
5
|
+
var h=5242880,y=({onFileCropped:o,onImageUploaded:d,onCancel:i})=>{let l=useId(),[e,m]=useState(),[f,a$1,s]=a(),[u,r]=useState(),[v,g]=useState(!1);return {id:l,setCropModalOpen:s,handleRemove:()=>{o(void 0),d(void 0),s(!1);},toggleCropModalOpen:a$1,cropModalOpen:f,cancelChanges:()=>{i&&i(),s(!1);},saveChanges:()=>{e!==void 0&&e.getCroppedCanvas().toBlob(async p=>{try{if(!p)return;g(!0);let n=new File([p],"imagem.png",{type:"image/png"});if(console.log({file:n}),n.size>h){let C=await I(n,{maxSizeMB:5});o(C),a$1();return}o(n),a$1();}finally{g(!1);}},"image/png",1);},previewImage:()=>{e!==void 0&&r(e.getCroppedCanvas().toDataURL());},setCropper:m,preview:u,closePreviewImage:()=>r(void 0),saving:v}},x=y;
|
|
6
|
+
|
|
7
|
+
export { x as a };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { a } from './chunk-AWHFEAGA.js';
|
|
2
|
+
import { a as a$2 } from './chunk-T7I256S6.js';
|
|
3
|
+
import { a as a$3 } from './chunk-W3IZQQL6.js';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import M from '@mui/lab/LoadingButton';
|
|
6
|
+
import r from '@mui/material/Button';
|
|
7
|
+
import v from '@mui/material/Slider';
|
|
8
|
+
import a$1 from '@mui/material/Stack';
|
|
9
|
+
import B from '@mui/material/Typography';
|
|
10
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
var y=({id:p,open:u,onClose:e,label:g,onSave:s,onRemove:f,onPreview:h,imageSrc:C,aspectRatio:I,onInitialized:S,loading:k})=>{let[l,m]=useState(.5);return jsx(a,{open:u,onClose:e,dialogTitle:g,actions:jsxs(Fragment,{children:[jsx(r,{variant:"outlined",size:"medium",onClick:e,color:"inherit",children:"Cancelar"}),jsx(M,{variant:"contained",size:"medium",onClick:s,loading:k,children:"Salvar"})]}),fullWidth:!0,maxWidth:"sm",keepMounted:!0,children:jsxs(a$1,{gap:2,children:[jsx(a$2,{imageSrc:C,aspectRatio:I,onInitialized:S,zoom:l,onZoomChange:m}),jsxs(a$1,{gap:1.5,children:[jsxs(a$1,{width:1,direction:"row",gap:3,flex:1,alignItems:"center",children:[jsx(B,{variant:"body1",children:"Zoom"}),jsx(v,{value:l,onChange:(E,n)=>m(Array.isArray(n)?n[0]:n),min:.1,max:2,size:"medium",step:.0125})]}),jsxs(a$1,{direction:"row",gap:2,children:[jsx(r,{variant:"outlined",color:"inherit",size:"large",fullWidth:!0,startIcon:jsx(a$3,{icon:"DELETE_MARK_BUTTON_02"}),onClick:f,children:"Remover"}),jsx(r,{variant:"outlined",color:"inherit",size:"large",fullWidth:!0,startIcon:jsx(a$3,{icon:"PLAY_SIMPLE"}),onClick:h,children:"Pr\xE9-visualizar"}),jsx(r,{variant:"outlined",color:"inherit",size:"large",fullWidth:!0,startIcon:jsx(a$3,{icon:"SEARCH_IMAGE"}),component:"label",htmlFor:p,children:"Alterar"})]})]})]})})},Z=y;
|
|
13
|
+
|
|
14
|
+
export { Z as a };
|
|
@@ -11,8 +11,9 @@ interface ImageCropModalPros {
|
|
|
11
11
|
imageSrc?: string;
|
|
12
12
|
aspectRatio?: number;
|
|
13
13
|
onInitialized(instance: Cropper): void;
|
|
14
|
+
loading?: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
declare const ImageCropModal: ({ id, open, onClose, label, onSave, onRemove, onPreview, imageSrc, aspectRatio, onInitialized, }: ImageCropModalPros) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
declare const ImageCropModal: ({ id, open, onClose, label, onSave, onRemove, onPreview, imageSrc, aspectRatio, onInitialized, loading, }: ImageCropModalPros) => react_jsx_runtime.JSX.Element;
|
|
17
18
|
|
|
18
19
|
export { ImageCropModal as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b } from '../../../chunk-
|
|
1
|
+
import { b } from '../../../chunk-AS522OS2.js';
|
|
2
2
|
import '../../../chunk-FYJCXJN6.js';
|
|
3
|
-
import '../../../chunk-
|
|
3
|
+
import '../../../chunk-SSVWNWE5.js';
|
|
4
4
|
import '../../../chunk-AWHFEAGA.js';
|
|
5
5
|
import '../../../chunk-T7I256S6.js';
|
|
6
6
|
import '../../../chunk-SKUW6ZCP.js';
|
|
@@ -8,7 +8,7 @@ import '../../../chunk-W3IZQQL6.js';
|
|
|
8
8
|
import '../../../chunk-B7TRCCLA.js';
|
|
9
9
|
import '../../../chunk-D27ND54J.js';
|
|
10
10
|
import { a } from '../../../chunk-GA4A5P3S.js';
|
|
11
|
-
import '../../../chunk-
|
|
11
|
+
import '../../../chunk-M6QHAL4V.js';
|
|
12
12
|
import '../../../chunk-W3MYAMTH.js';
|
|
13
13
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
14
14
|
import W from '@mui/material/FormHelperText';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as d$1 } from '../../../chunk-TXLER7US.js';
|
|
2
2
|
import { d, e } from '../../../chunk-FYJCXJN6.js';
|
|
3
|
-
import { a as a$4 } from '../../../chunk-
|
|
3
|
+
import { a as a$4 } from '../../../chunk-SSVWNWE5.js';
|
|
4
4
|
import '../../../chunk-AWHFEAGA.js';
|
|
5
5
|
import '../../../chunk-T7I256S6.js';
|
|
6
6
|
import '../../../chunk-SKUW6ZCP.js';
|
|
@@ -9,16 +9,16 @@ import { a as a$3 } from '../../../chunk-W3IZQQL6.js';
|
|
|
9
9
|
import '../../../chunk-B7TRCCLA.js';
|
|
10
10
|
import '../../../chunk-D27ND54J.js';
|
|
11
11
|
import { a } from '../../../chunk-GA4A5P3S.js';
|
|
12
|
-
import { a as a$1 } from '../../../chunk-
|
|
12
|
+
import { a as a$1 } from '../../../chunk-M6QHAL4V.js';
|
|
13
13
|
import '../../../chunk-W3MYAMTH.js';
|
|
14
14
|
import '../../../chunk-2D6XUBFQ.js';
|
|
15
15
|
import '../../../chunk-ILHUUK4X.js';
|
|
16
16
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
17
|
-
import
|
|
17
|
+
import G from '@mui/material/FormHelperText';
|
|
18
18
|
import B from '@mui/material/Button';
|
|
19
|
-
import
|
|
19
|
+
import H from '@mui/material/Dialog';
|
|
20
20
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var L=({onFileCropped:r,onImageUploaded:i,onCancel:a,aspect:c,label:f,image:t="",uploading:n,file:l,tabIndex:p,...C})=>{let{id:m,setCropModalOpen:g,handleRemove:s,toggleCropModalOpen:u,cropModalOpen:h,cancelChanges:e$1,saveChanges:d$2,previewImage:F,setCropper:S,preview:v,closePreviewImage:T,saving:y}=a$1({onFileCropped:r,onImageUploaded:i,onCancel:a});return jsxs(Fragment,{children:[jsxs(d,{children:[n&&jsx(a$2,{}),jsx(d$1,{...C,id:m,file:l,onDrop:R=>{if(R.length>0){g(!0);let U=new FileReader;U.addEventListener("load",()=>{let _=U.result?.toString()||"";i(_),r(void 0);}),U.readAsDataURL(R[0]);}},image:t,tabIndex:p}),(l||t)&&jsxs(e,{className:"actions",children:[jsx(B,{color:"inherit",startIcon:jsx(a$3,{icon:"DELETE_MARK_BUTTON_02",color:"error.main"}),onClick:s,children:"Remover"}),jsx(B,{color:"inherit",startIcon:jsx(a$3,{icon:"SEARCH_IMAGE",color:"primary.maon"}),onClick:u,children:"Editar"})]})]}),jsx(a$4,{id:m,open:h,onClose:e$1,label:f,aspectRatio:c,imageSrc:t,onRemove:s,onSave:d$2,onPreview:F,onInitialized:S,loading:y}),jsx(H,{open:!!v,onClose:T,scroll:"body",PaperProps:{sx:{p:2}},children:v&&jsx("img",{src:v,alt:"Preview"})})]})},D=L;var K=({name:r,rules:i,helperText:a$1,aspect:c,label:f,image:t,onFileCropped:n,onImageUploaded:l,onCancel:p,...C})=>{let{control:m}=useFormContext(),{uploadFile:g,file:s,setFileValue:u}=a(r);return jsx(Controller,{name:r,control:m,rules:i,render:({field:{value:h},fieldState:{error:e}})=>jsx(D,{accept:{"image/*":[]},file:h?s:void 0,onFileCropped:d=>{g(d),n&&n(d);},onImageUploaded:l,onCancel:()=>{u(void 0),p&&p();},error:!!e,disableMultiple:!0,helperText:(!!e||a$1)&&jsx(G,{error:!!e,sx:{px:2},children:e?e?.message:a$1}),aspect:c,label:f,image:t,...C})})},ao=K;
|
|
23
23
|
|
|
24
|
-
export {
|
|
24
|
+
export { ao as default };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { a as UploadAvatar, b as UploadAvatarWithCrop, b as UploadWithCrop } from '../../chunk-
|
|
1
|
+
export { a as UploadAvatar, b as UploadAvatarWithCrop, b as UploadWithCrop } from '../../chunk-AS522OS2.js';
|
|
2
2
|
export { c as DeleteButton, a as MultiFilePreview, b as SingleFilePreview, d as Upload } from '../../chunk-TXLER7US.js';
|
|
3
3
|
export { c as RejectionFiles } from '../../chunk-FYJCXJN6.js';
|
|
4
|
-
import '../../chunk-
|
|
4
|
+
import '../../chunk-SSVWNWE5.js';
|
|
5
5
|
import '../../chunk-AWHFEAGA.js';
|
|
6
6
|
import '../../chunk-T7I256S6.js';
|
|
7
7
|
import '../../chunk-SKUW6ZCP.js';
|
|
8
8
|
import '../../chunk-W3IZQQL6.js';
|
|
9
9
|
import '../../chunk-B7TRCCLA.js';
|
|
10
10
|
import { i } from '../../chunk-D27ND54J.js';
|
|
11
|
-
import '../../chunk-
|
|
11
|
+
import '../../chunk-M6QHAL4V.js';
|
|
12
12
|
import '../../chunk-W3MYAMTH.js';
|
|
13
13
|
import '../../chunk-2D6XUBFQ.js';
|
|
14
14
|
import '../../chunk-ILHUUK4X.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as default } from '../chunk-
|
|
1
|
+
export { a as default } from '../chunk-M6QHAL4V.js';
|
|
2
2
|
import '../chunk-W3MYAMTH.js';
|
package/package.json
CHANGED
package/dist/chunk-CLFF2L7L.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-W3MYAMTH.js';
|
|
2
|
-
import { useId, useState } from 'react';
|
|
3
|
-
import C from 'browser-image-compression';
|
|
4
|
-
|
|
5
|
-
var w=5242880,I=({onFileCropped:o,onImageUploaded:p,onCancel:i})=>{let g=useId(),[e,l]=useState(),[m,s,a$1]=a(),[f,t]=useState();return {id:g,setCropModalOpen:a$1,handleRemove:()=>{o(void 0),p(void 0),a$1(!1);},toggleCropModalOpen:s,cropModalOpen:m,cancelChanges:()=>{i&&i(),a$1(!1);},saveChanges:()=>{e!==void 0&&e.getCroppedCanvas().toBlob(async r=>{if(!r)return;let n=new File([r],"imagem");if(console.log({file:n}),n.size>w){let u=await C(n,{maxSizeMB:5});o(u),s();return}o(n),s();},"image/png",1);},previewImage:()=>{e!==void 0&&t(e.getCroppedCanvas().toDataURL());},setCropper:l,preview:f,closePreviewImage:()=>t(void 0)}},U=I;
|
|
6
|
-
|
|
7
|
-
export { U as a };
|
package/dist/chunk-UXRJ6YK5.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-AWHFEAGA.js';
|
|
2
|
-
import { a as a$2 } from './chunk-T7I256S6.js';
|
|
3
|
-
import { a as a$3 } from './chunk-W3IZQQL6.js';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
import t from '@mui/material/Button';
|
|
6
|
-
import z from '@mui/material/Slider';
|
|
7
|
-
import a$1 from '@mui/material/Stack';
|
|
8
|
-
import M from '@mui/material/Typography';
|
|
9
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
|
-
|
|
11
|
-
var v=({id:p,open:u,onClose:n,label:s,onSave:g,onRemove:f,onPreview:h,imageSrc:C,aspectRatio:I,onInitialized:S})=>{let[l,m]=useState(.5);return jsx(a,{open:u,onClose:n,dialogTitle:s,actions:jsxs(Fragment,{children:[jsx(t,{variant:"outlined",size:"medium",onClick:n,color:"inherit",children:"Cancelar"}),jsx(t,{variant:"contained",size:"medium",onClick:g,children:"Salvar"})]}),fullWidth:!0,maxWidth:"sm",keepMounted:!0,children:jsxs(a$1,{gap:2,children:[jsx(a$2,{imageSrc:C,aspectRatio:I,onInitialized:S,zoom:l,onZoomChange:m}),jsxs(a$1,{gap:1.5,children:[jsxs(a$1,{width:1,direction:"row",gap:3,flex:1,alignItems:"center",children:[jsx(M,{variant:"body1",children:"Zoom"}),jsx(z,{value:l,onChange:(A,e)=>m(Array.isArray(e)?e[0]:e),min:.1,max:2,size:"medium",step:.0125})]}),jsxs(a$1,{direction:"row",gap:2,children:[jsx(t,{variant:"outlined",color:"inherit",size:"large",fullWidth:!0,startIcon:jsx(a$3,{icon:"DELETE_MARK_BUTTON_02"}),onClick:f,children:"Remover"}),jsx(t,{variant:"outlined",color:"inherit",size:"large",fullWidth:!0,startIcon:jsx(a$3,{icon:"PLAY_SIMPLE"}),onClick:h,children:"Pr\xE9-visualizar"}),jsx(t,{variant:"outlined",color:"inherit",size:"large",fullWidth:!0,startIcon:jsx(a$3,{icon:"SEARCH_IMAGE"}),component:"label",htmlFor:p,children:"Alterar"})]})]})]})})},w=v;
|
|
12
|
-
|
|
13
|
-
export { w as a };
|