@zydon/common 2.7.63 → 2.7.65

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.
Files changed (109) hide show
  1. package/README.md +1 -0
  2. package/dist/chunk-2CY62UZ5.js +21 -0
  3. package/dist/chunk-2CY62UZ5.js.map +1 -0
  4. package/dist/{chunk-5NIMUEW5.js → chunk-6FG5S5PI.js} +2 -2
  5. package/dist/{chunk-VPKUUY5Q.js → chunk-CU7PKEY2.js} +2 -2
  6. package/dist/{chunk-MP2LAJS5.js → chunk-KQTA6B4Y.js} +2 -2
  7. package/dist/chunk-QVUHCBI2.js +35 -0
  8. package/dist/chunk-QVUHCBI2.js.map +1 -0
  9. package/dist/chunk-RPPQBAVO.js +12 -0
  10. package/dist/chunk-RPPQBAVO.js.map +1 -0
  11. package/dist/components/AvatarButton/index.js +2 -2
  12. package/dist/components/Common/index.js +2 -2
  13. package/dist/components/DataView/index.js +2 -2
  14. package/dist/components/DatePicker/index.d.ts +2 -1
  15. package/dist/components/DatePicker/index.js +3 -3
  16. package/dist/components/DatePicker/index.js.map +1 -1
  17. package/dist/components/DragContainer/index.js +2 -2
  18. package/dist/components/DragContainer/index.js.map +1 -1
  19. package/dist/components/DynamicDataView/index.js +2 -2
  20. package/dist/components/FileUpload/index.js +1 -4
  21. package/dist/components/FrameSkeleton/index.d.ts +1 -0
  22. package/dist/components/FrameSkeleton/index.js +2 -2
  23. package/dist/components/FrameSkeleton/index.js.map +1 -1
  24. package/dist/components/ImageCropModal/index.js +14 -4
  25. package/dist/components/ImageCropModal/index.js.map +1 -1
  26. package/dist/components/Incrementer/index.d.ts +0 -3
  27. package/dist/components/ListBundles/index.d.ts +0 -8
  28. package/dist/components/SearchInput/index.js +1 -1
  29. package/dist/components/SelectList/index.d.ts +7 -0
  30. package/dist/components/SelectList/index.js +10 -0
  31. package/dist/components/SelectList/index.js.map +1 -0
  32. package/dist/components/SelectableCards/index.js +2 -2
  33. package/dist/components/StateDisplay/index.d.ts +0 -42
  34. package/dist/components/SwapList/index.js +1 -1
  35. package/dist/components/ToggleTheme/index.js +2 -2
  36. package/dist/components/carousel/index.d.ts +0 -18
  37. package/dist/components/form/Codes/index.d.ts +2 -1
  38. package/dist/components/form/Codes/index.js +4 -4
  39. package/dist/components/form/Codes/index.js.map +1 -1
  40. package/dist/components/form/FileUpload/index.d.ts +0 -200
  41. package/dist/components/form/FileUpload/index.js +2 -5
  42. package/dist/components/form/FileUpload/index.js.map +1 -1
  43. package/dist/components/form/SelectList/index.d.ts +13 -0
  44. package/dist/components/form/SelectList/index.js +16 -0
  45. package/dist/components/form/SelectList/index.js.map +1 -0
  46. package/dist/components/form/SelectableCards/index.js +2 -2
  47. package/dist/hooks/useMount.d.ts +0 -20
  48. package/dist/hooks/useSnackbar.d.ts +7 -7
  49. package/dist/hooks/useThemeToggle.js +2 -2
  50. package/dist/hooks/useUpload.js +6 -1
  51. package/dist/hooks/useUpload.js.map +1 -1
  52. package/dist/hooks/useUploadImage.js +7 -2
  53. package/dist/hooks/useUploadImage.js.map +1 -1
  54. package/dist/hooks/useWindowFocus.d.ts +0 -3
  55. package/dist/index.d.ts +3 -5
  56. package/dist/index.js +2 -6
  57. package/dist/index.js.map +1 -1
  58. package/dist/theme/core/index.d.ts +1 -1
  59. package/dist/theme/styles/index.d.ts +12 -76
  60. package/dist/theme/theme-provider.js +2 -2
  61. package/dist/theme/with-settings/index.d.ts +0 -4
  62. package/dist/types/sectionProps.d.ts +2 -0
  63. package/dist/types/selectList.d.ts +31 -0
  64. package/dist/types/selectList.js +3 -0
  65. package/dist/types/selectList.js.map +1 -0
  66. package/dist/utils/compare.d.ts +0 -21
  67. package/dist/utils/dnd.js +4 -4
  68. package/dist/utils/dnd.js.map +1 -1
  69. package/dist/utils/execution.d.ts +0 -70
  70. package/dist/utils/object.d.ts +0 -6
  71. package/dist/utils/paymentValidators.d.ts +0 -6
  72. package/dist/utils/popup.d.ts +0 -7
  73. package/dist/utils/string.d.ts +0 -5
  74. package/package.json +6 -1
  75. package/dist/chunk-33C6UWPV.js +0 -7
  76. package/dist/chunk-33C6UWPV.js.map +0 -1
  77. package/dist/chunk-6WGKIN5L.js +0 -18
  78. package/dist/chunk-6WGKIN5L.js.map +0 -1
  79. package/dist/chunk-DTIGB5NW.js +0 -10
  80. package/dist/chunk-DTIGB5NW.js.map +0 -1
  81. package/dist/chunk-IEGF6HVV.js +0 -43
  82. package/dist/chunk-IEGF6HVV.js.map +0 -1
  83. package/dist/chunk-JFZOAS75.js +0 -23
  84. package/dist/chunk-JFZOAS75.js.map +0 -1
  85. package/dist/chunk-KR3DUHA6.js +0 -16
  86. package/dist/chunk-KR3DUHA6.js.map +0 -1
  87. package/dist/chunk-OTVEMGF2.js +0 -12
  88. package/dist/chunk-OTVEMGF2.js.map +0 -1
  89. package/dist/chunk-SBMEL2IJ.js +0 -9
  90. package/dist/chunk-SBMEL2IJ.js.map +0 -1
  91. package/dist/chunk-VYNBVZSA.js +0 -37
  92. package/dist/chunk-VYNBVZSA.js.map +0 -1
  93. package/dist/chunk-WQSRNCNF.js +0 -5
  94. package/dist/chunk-WQSRNCNF.js.map +0 -1
  95. package/dist/chunk-YCEQDXLR.js +0 -8
  96. package/dist/chunk-YCEQDXLR.js.map +0 -1
  97. package/dist/components/form/UploadAvatarWithCrop/index.d.ts +0 -21
  98. package/dist/components/form/UploadAvatarWithCrop/index.js +0 -23
  99. package/dist/components/form/UploadAvatarWithCrop/index.js.map +0 -1
  100. package/dist/components/form/UploadWithCrop/index.d.ts +0 -21
  101. package/dist/components/form/UploadWithCrop/index.js +0 -29
  102. package/dist/components/form/UploadWithCrop/index.js.map +0 -1
  103. package/dist/components/upload/index.d.ts +0 -70
  104. package/dist/components/upload/index.js +0 -31
  105. package/dist/components/upload/index.js.map +0 -1
  106. package/dist/{chunk-5NIMUEW5.js.map → chunk-6FG5S5PI.js.map} +0 -0
  107. package/dist/{chunk-VPKUUY5Q.js.map → chunk-CU7PKEY2.js.map} +0 -0
  108. package/dist/{chunk-MP2LAJS5.js.map → chunk-KQTA6B4Y.js.map} +0 -0
  109. package/dist/{index-5a5e5dc8.d.ts → index-c8f1e6e7.d.ts} +12 -12
@@ -7,21 +7,9 @@ import 'react-dropzone';
7
7
  import 'react-easy-crop';
8
8
  import '@dnd-kit/core';
9
9
 
10
- /**
11
- * Tipo para lazy query trigger do RTK Query
12
- * Aceita um ID e retorna uma promise com unwrap
13
- *
14
- * @example
15
- * ```tsx
16
- * const [getFileQuery] = useLazyGetFileQuery();
17
- * ```
18
- */
19
10
  type LazyQueryTrigger = (id: string) => {
20
11
  unwrap: () => Promise<FileGetResponse>;
21
12
  };
22
- /**
23
- * Props base para componentes de upload integrados ao form
24
- */
25
13
  interface BaseFormUploadProps {
26
14
  name: string;
27
15
  rules?: RegisterOptions;
@@ -29,211 +17,23 @@ interface BaseFormUploadProps {
29
17
  disableRemove?: boolean;
30
18
  disableReorder?: boolean;
31
19
  }
32
- /**
33
- * Props para SingleImageUpload integrado ao form
34
- * Retorna apenas o resource_file_id no campo do formulário
35
- */
36
20
  interface FormSingleImageUploadProps extends Omit<SingleImageUploadProps, 'fileDetails' | 'onFileSelect' | 'onRemove' | 'name'>, BaseFormUploadProps {
37
21
  }
38
- /**
39
- * Props para MultiImageUpload integrado ao form
40
- * Retorna array de resource_file_ids no campo do formulário
41
- */
42
22
  interface FormMultiImageUploadProps extends Omit<MultiImageUploadProps, 'filesDetails' | 'onFilesSelect' | 'onRemove' | 'onRemoveAll' | 'name'>, BaseFormUploadProps {
43
23
  }
44
- /**
45
- * Props para SingleFileUpload integrado ao form
46
- * Retorna apenas o resource_file_id no campo do formulário
47
- */
48
24
  interface FormSingleFileUploadProps extends Omit<SingleFileUploadProps, 'fileDetails' | 'onFileSelect' | 'onRemove' | 'name'>, BaseFormUploadProps {
49
25
  }
50
- /**
51
- * Props para MultiFileUpload integrado ao form
52
- * Retorna array de resource_file_ids no campo do formulário
53
- */
54
26
  interface FormMultiFileUploadProps extends Omit<MultiFileUploadProps, 'filesDetails' | 'onFilesSelect' | 'onRemove' | 'onRemoveAll' | 'name'>, BaseFormUploadProps {
55
27
  }
56
28
 
57
- /**
58
- * AvatarUpload integrado ao React Hook Form
59
- * Componente especializado para upload de avatar (imagem circular de perfil)
60
- * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id
61
- *
62
- * @example
63
- * ```tsx
64
- * import { Form } from 'components/form';
65
- * import { AvatarUpload } from 'components/form/FileUpload';
66
- * import { useCreateFilesMutation, useGetFileQuery } from 'services/filesApi';
67
- *
68
- * interface FormData {
69
- * avatar_id: string | null;
70
- * }
71
- *
72
- * const ProfileForm = () => {
73
- * const createFilesMutation = useCreateFilesMutation();
74
- * const getFileQuery = useGetFileQuery();
75
- * const methods = useForm<FormData>();
76
- *
77
- * return (
78
- * <Form methods={methods} onSubmit={handleSubmit}>
79
- * <AvatarUpload
80
- * name="avatar_id"
81
- * createFilesMutation={createFilesMutation}
82
- * getFileQuery={getFileQuery}
83
- * />
84
- * </Form>
85
- * );
86
- * };
87
- * ```
88
- */
89
29
  declare const AvatarUpload: ({ name, rules, createFilesMutation, getFileQuery, disableRemove, aspectRatio, enableCrop, maxSize, ...other }: FormSingleImageUploadProps) => react_jsx_runtime.JSX.Element;
90
30
 
91
- /**
92
- * MultiFileUpload integrado ao React Hook Form
93
- * Gerencia automaticamente o estado dos arquivos e retorna array de resource_file_ids
94
- *
95
- * @example
96
- * ```tsx
97
- * import { Form } from 'components/form';
98
- * import { MultiFileUpload } from 'components/form/FileUpload';
99
- * import { useCreateFilesMutation } from 'services/filesApi';
100
- *
101
- * const FormExample = () => {
102
- * const createFilesMutation = useCreateFilesMutation();
103
- * const methods = useForm({
104
- * defaultValues: {
105
- * document_ids: [],
106
- * },
107
- * });
108
- *
109
- * const handleSubmit = (data: any) => {
110
- * console.log(data.document_ids); // Array de IDs
111
- * };
112
- *
113
- * return (
114
- * <Form methods={methods} onSubmit={handleSubmit}>
115
- * <MultiFileUpload
116
- * name="document_ids"
117
- * label="Documentos"
118
- * createFilesMutation={createFilesMutation}
119
- * maxFiles={5}
120
- * />
121
- * </Form>
122
- * );
123
- * };
124
- * ```
125
- */
126
31
  declare const MultiFileUpload: ({ name, rules, createFilesMutation, getFileQuery, disableRemove, disableReorder, ...other }: FormMultiFileUploadProps) => react_jsx_runtime.JSX.Element;
127
32
 
128
- /**
129
- * MultiImageUpload integrado ao React Hook Form
130
- * Gerencia automaticamente o estado dos arquivos e retorna array de resource_file_ids
131
- *
132
- * @example
133
- * ```tsx
134
- * import { Form } from 'components/form';
135
- * import { MultiImageUpload } from 'components/form/FileUpload';
136
- * import { useCreateFilesMutation } from 'services/filesApi';
137
- *
138
- * const FormExample = () => {
139
- * const createFilesMutation = useCreateFilesMutation();
140
- * const methods = useForm({
141
- * defaultValues: {
142
- * image_ids: [],
143
- * },
144
- * });
145
- *
146
- * const handleSubmit = (data: any) => {
147
- * console.log(data.image_ids); // Array de IDs
148
- * };
149
- *
150
- * return (
151
- * <Form methods={methods} onSubmit={handleSubmit}>
152
- * <MultiImageUpload
153
- * name="image_ids"
154
- * label="Imagens"
155
- * createFilesMutation={createFilesMutation}
156
- * maxFiles={5}
157
- * />
158
- * </Form>
159
- * );
160
- * };
161
- * ```
162
- */
163
33
  declare const MultiImageUpload: ({ name, rules, createFilesMutation, getFileQuery, disableRemove, disableReorder, ...other }: FormMultiImageUploadProps) => react_jsx_runtime.JSX.Element;
164
34
 
165
- /**
166
- * SingleFileUpload integrado ao React Hook Form
167
- * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id
168
- *
169
- * @example
170
- * ```tsx
171
- * import { Form } from 'components/form';
172
- * import { SingleFileUpload } from 'components/form/FileUpload';
173
- * import { useCreateFilesMutation } from 'services/filesApi';
174
- *
175
- * const FormExample = () => {
176
- * const createFilesMutation = useCreateFilesMutation();
177
- * const methods = useForm({
178
- * defaultValues: {
179
- * document_id: null,
180
- * },
181
- * });
182
- *
183
- * const handleSubmit = (data: any) => {
184
- * console.log(data.document_id); // ID do arquivo
185
- * };
186
- *
187
- * return (
188
- * <Form methods={methods} onSubmit={handleSubmit}>
189
- * <SingleFileUpload
190
- * name="document_id"
191
- * label="Documento"
192
- * createFilesMutation={createFilesMutation}
193
- * maxSize={1024 * 1024 * 10}
194
- * />
195
- * </Form>
196
- * );
197
- * };
198
- * ```
199
- */
200
35
  declare const SingleFileUpload: ({ name, rules, createFilesMutation, getFileQuery, disableRemove, ...other }: FormSingleFileUploadProps) => react_jsx_runtime.JSX.Element;
201
36
 
202
- /**
203
- * SingleImageUpload integrado ao React Hook Form
204
- * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id
205
- *
206
- * @example
207
- * ```tsx
208
- * import { Form } from 'components/form';
209
- * import { SingleImageUpload } from 'components/form/FileUpload';
210
- * import { useCreateFilesMutation } from 'services/filesApi';
211
- *
212
- * const FormExample = () => {
213
- * const createFilesMutation = useCreateFilesMutation();
214
- * const methods = useForm({
215
- * defaultValues: {
216
- * resource_id: null,
217
- * },
218
- * });
219
- *
220
- * const handleSubmit = (data: any) => {
221
- * console.log(data.resource_id); // ID do arquivo
222
- * };
223
- *
224
- * return (
225
- * <Form methods={methods} onSubmit={handleSubmit}>
226
- * <SingleImageUpload
227
- * name="resource_id"
228
- * label="Imagem"
229
- * createFilesMutation={createFilesMutation}
230
- * maxSize={1024 * 1024 * 5}
231
- * />
232
- * </Form>
233
- * );
234
- * };
235
- * ```
236
- */
237
37
  declare const SingleImageUpload: ({ name, rules, createFilesMutation, getFileQuery, disableRemove, hoverAlt, ...other }: FormSingleImageUploadProps) => react_jsx_runtime.JSX.Element;
238
38
 
239
39
  export { AvatarUpload, FileGetResponse, FormMultiFileUploadProps, FormMultiImageUploadProps, FormSingleFileUploadProps, FormSingleImageUploadProps, LazyQueryTrigger, MultiFileUpload, MultiImageUpload, SingleFileUpload, SingleImageUpload };
@@ -1,13 +1,10 @@
1
- import { r, o, p, q } from '../../../chunk-VYNBVZSA.js';
2
- import '../../../chunk-DTIGB5NW.js';
3
- import '../../../chunk-WQSRNCNF.js';
1
+ import { v, s, t, u } from '../../../chunk-QVUHCBI2.js';
4
2
  import '../../../chunk-ZFRNMT3P.js';
5
3
  import '../../../chunk-RFRLNTFN.js';
6
4
  import '../../../chunk-KGLU4CR2.js';
7
5
  import '../../../chunk-LNXA53QR.js';
8
6
  import '../../../chunk-OF6623HG.js';
9
7
  import '../../../chunk-N4DW7EIC.js';
10
- import '../../../chunk-33C6UWPV.js';
11
8
  import '../../../chunk-45OMMG7D.js';
12
9
  import '../../../chunk-6U5LS7MP.js';
13
10
  import '../../../chunk-NQNNMRLC.js';
@@ -20,7 +17,7 @@ import { useFormContext, Controller } from 'react-hook-form';
20
17
  import { useState, useEffect, useMemo, useRef } from 'react';
21
18
  import { jsx } from 'react/jsx-runtime';
22
19
 
23
- var h=(e,r)=>{let{setValue:l,watch:s}=useFormContext(),t=s(e),[o,i]=useState();return useEffect(()=>{if(!t){i(void 0);return}(async()=>{try{let a=await r(t).unwrap();i({id:a.id,url:a.url,name:a.name});}catch{i({id:t,url:""});}})();},[t,r]),{fileDetails:o,handleFileSelect:d=>{l(e,d.id,{shouldValidate:!0,shouldDirty:!0});},handleRemove:()=>{l(e,null,{shouldValidate:!0,shouldDirty:!0});}}},R=(e,r)=>{let{setValue:l,watch:s}=useFormContext(),t=s(e),o=useMemo(()=>t||[],[t]),[i,n]=useState([]),u=useRef(new Map);return useEffect(()=>{if(!o||o.length===0){n([]);return}(async()=>{try{let p=[...new Set(o)],c=u.current,F=p.filter(S=>!c.has(S));if(F.length>0){let S=F.map(async U=>{try{let g=await r(U).unwrap(),M={id:g.id,url:g.url,name:g.name};return c.set(U,M),M}catch{let g={id:U,url:""};return c.set(U,g),g}});await Promise.all(S);}let T=p.map(S=>c.get(S));n(T);}catch{n(o.map(p=>({id:p,url:""})));}})();},[o,r]),{currentValue:o,filesDetails:i,handleFilesSelect:m=>{let p=m.map(F=>F.id),c=[...new Set([...o,...p])];l(e,c,{shouldValidate:!0,shouldDirty:!0});},handleRemove:m=>{if(!m)return;let p=o.filter(c=>c!==m.id);l(e,p,{shouldValidate:!0,shouldDirty:!0});},handleReorder:(m,p)=>{let c=[...o],[F]=c.splice(m,1);c.splice(p,0,F),l(e,c,{shouldValidate:!0,shouldDirty:!0});}}};var E=({name:e,rules:r$1,createFilesMutation:l,getFileQuery:s,disableRemove:t,aspectRatio:o=1,enableCrop:i=!0,maxSize:n=5242880,...u})=>{let{control:d}=useFormContext(),{fileDetails:a,handleFileSelect:f,handleRemove:m}=h(e,s);return jsx(Controller,{name:e,control:d,rules:r$1,render:({fieldState:{error:p}})=>jsx(r,{name:e,fileDetails:a,createFilesMutation:l,onFileSelect:f,onRemove:t?void 0:m,aspectRatio:o,enableCrop:i,maxSize:n,error:p?.message,...u})})},G=E;var J=({name:e,rules:r,createFilesMutation:l,getFileQuery:s,disableRemove:t,disableReorder:o$1,...i})=>{let{control:n}=useFormContext(),{filesDetails:u,handleFilesSelect:d,handleRemove:a,handleReorder:f}=R(e,s);return jsx(Controller,{name:e,control:n,rules:r,render:({fieldState:{error:m}})=>jsx(o,{name:e,filesDetails:u,createFilesMutation:l,onFilesSelect:d,onRemove:t?void 0:a,onReorder:o$1?void 0:f,error:m?.message,...i})})},K=J;var W=({name:e,rules:r,createFilesMutation:l,getFileQuery:s,disableRemove:t,disableReorder:o,...i})=>{let{control:n}=useFormContext(),{filesDetails:u,handleFilesSelect:d,handleRemove:a,handleReorder:f}=R(e,s);return jsx(Controller,{name:e,control:n,rules:r,render:({fieldState:{error:m}})=>jsx(p,{name:e,filesDetails:u,createFilesMutation:l,onFilesSelect:d,onRemove:t?void 0:a,onReorder:o?void 0:f,error:m?.message,...i})})},X=W;var _=({name:e,rules:r,createFilesMutation:l,getFileQuery:s,disableRemove:t,...o})=>{let{control:i}=useFormContext(),{fileDetails:n,handleFileSelect:u,handleRemove:d}=h(e,s);return jsx(Controller,{name:e,control:i,rules:r,render:({fieldState:{error:a}})=>jsx(q,{name:e,fileDetails:n,createFilesMutation:l,onFileSelect:u,onRemove:t?void 0:d,error:a?.message,...o})})},$=_;var oe=({name:e,rules:r$1,createFilesMutation:l,getFileQuery:s,disableRemove:t,hoverAlt:o,...i})=>{let{control:n}=useFormContext(),{fileDetails:u,handleFileSelect:d,handleRemove:a}=h(e,s);return jsx(Controller,{name:e,control:n,rules:r$1,render:({fieldState:{error:f}})=>jsx(r,{name:e,fileDetails:u,createFilesMutation:l,onFileSelect:d,onRemove:t?void 0:a,error:f?.message,hoverAlt:o,...i})})},te=oe;
20
+ var h=(e,r)=>{let{setValue:l,watch:s}=useFormContext(),t=s(e),[o,i]=useState();return useEffect(()=>{if(!t){i(void 0);return}(async()=>{try{let a=await r(t).unwrap();i({id:a.id,url:a.url,name:a.name});}catch{i({id:t,url:""});}})();},[t,r]),{fileDetails:o,handleFileSelect:d=>{l(e,d.id,{shouldValidate:!0,shouldDirty:!0});},handleRemove:()=>{l(e,null,{shouldValidate:!0,shouldDirty:!0});}}},R=(e,r)=>{let{setValue:l,watch:s}=useFormContext(),t=s(e),o=useMemo(()=>t||[],[t]),[i,n]=useState([]),u=useRef(new Map);return useEffect(()=>{if(!o||o.length===0){n([]);return}(async()=>{try{let p=[...new Set(o)],c=u.current,F=p.filter(S=>!c.has(S));if(F.length>0){let S=F.map(async U=>{try{let g=await r(U).unwrap(),M={id:g.id,url:g.url,name:g.name};return c.set(U,M),M}catch{let g={id:U,url:""};return c.set(U,g),g}});await Promise.all(S);}let T=p.map(S=>c.get(S));n(T);}catch{n(o.map(p=>({id:p,url:""})));}})();},[o,r]),{currentValue:o,filesDetails:i,handleFilesSelect:m=>{let p=m.map(F=>F.id),c=[...new Set([...o,...p])];l(e,c,{shouldValidate:!0,shouldDirty:!0});},handleRemove:m=>{if(!m)return;let p=o.filter(c=>c!==m.id);l(e,p,{shouldValidate:!0,shouldDirty:!0});},handleReorder:(m,p)=>{let c=[...o],[F]=c.splice(m,1);c.splice(p,0,F),l(e,c,{shouldValidate:!0,shouldDirty:!0});}}};var E=({name:e,rules:r,createFilesMutation:l,getFileQuery:s,disableRemove:t,aspectRatio:o=1,enableCrop:i=!0,maxSize:n=5242880,...u})=>{let{control:d}=useFormContext(),{fileDetails:a,handleFileSelect:f,handleRemove:m}=h(e,s);return jsx(Controller,{name:e,control:d,rules:r,render:({fieldState:{error:p}})=>jsx(v,{name:e,fileDetails:a,createFilesMutation:l,onFileSelect:f,onRemove:t?void 0:m,aspectRatio:o,enableCrop:i,maxSize:n,error:p?.message,...u})})},G=E;var J=({name:e,rules:r,createFilesMutation:l,getFileQuery:s$1,disableRemove:t,disableReorder:o,...i})=>{let{control:n}=useFormContext(),{filesDetails:u,handleFilesSelect:d,handleRemove:a,handleReorder:f}=R(e,s$1);return jsx(Controller,{name:e,control:n,rules:r,render:({fieldState:{error:m}})=>jsx(s,{name:e,filesDetails:u,createFilesMutation:l,onFilesSelect:d,onRemove:t?void 0:a,onReorder:o?void 0:f,error:m?.message,...i})})},K=J;var W=({name:e,rules:r,createFilesMutation:l,getFileQuery:s,disableRemove:t$1,disableReorder:o,...i})=>{let{control:n}=useFormContext(),{filesDetails:u,handleFilesSelect:d,handleRemove:a,handleReorder:f}=R(e,s);return jsx(Controller,{name:e,control:n,rules:r,render:({fieldState:{error:m}})=>jsx(t,{name:e,filesDetails:u,createFilesMutation:l,onFilesSelect:d,onRemove:t$1?void 0:a,onReorder:o?void 0:f,error:m?.message,...i})})},X=W;var _=({name:e,rules:r,createFilesMutation:l,getFileQuery:s,disableRemove:t,...o})=>{let{control:i}=useFormContext(),{fileDetails:n,handleFileSelect:u$1,handleRemove:d}=h(e,s);return jsx(Controller,{name:e,control:i,rules:r,render:({fieldState:{error:a}})=>jsx(u,{name:e,fileDetails:n,createFilesMutation:l,onFileSelect:u$1,onRemove:t?void 0:d,error:a?.message,...o})})},$=_;var oe=({name:e,rules:r,createFilesMutation:l,getFileQuery:s,disableRemove:t,hoverAlt:o,...i})=>{let{control:n}=useFormContext(),{fileDetails:u,handleFileSelect:d,handleRemove:a}=h(e,s);return jsx(Controller,{name:e,control:n,rules:r,render:({fieldState:{error:f}})=>jsx(v,{name:e,fileDetails:u,createFilesMutation:l,onFileSelect:d,onRemove:t?void 0:a,error:f?.message,hoverAlt:o,...i})})},te=oe;
24
21
 
25
22
  export { G as AvatarUpload, K as MultiFileUpload, X as MultiImageUpload, $ as SingleFileUpload, te as SingleImageUpload };
26
23
  //# sourceMappingURL=out.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/form/FileUpload/AvatarUpload.tsx","../../../../src/components/form/FileUpload/useFormFileUpload.ts","../../../../src/components/form/FileUpload/MultiFileUpload.tsx","../../../../src/components/form/FileUpload/MultiImageUpload.tsx","../../../../src/components/form/FileUpload/SingleFileUpload.tsx","../../../../src/components/form/FileUpload/SingleImageUpload.tsx"],"names":["Controller","useFormContext","useEffect","useMemo","useRef","useState","useSingleFileUpload","name","getFileQuery","setValue","watch","value","fileDetails","setFileDetails","file","useMultiFileUpload","watchedValue","currentValue","filesDetails","setFilesDetails","cacheRef","uniqueIds","cache","newIds","id","promises","fallback","results","files","updatedIds","oldIndex","newIndex","removed","jsx","AvatarUpload","rules","createFilesMutation","disableRemove","aspectRatio","enableCrop","maxSize","other","control","handleFileSelect","handleRemove","error","SingleImageUpload_default","AvatarUpload_default","MultiFileUpload","disableReorder","handleFilesSelect","handleReorder","MultipleFileUpload_default","MultiFileUpload_default","MultiImageUpload","MultipleImageUpload_default","MultiImageUpload_default","SingleFileUpload","SingleFileUpload_default","SingleImageUpload","hoverAlt"],"mappings":"upBAAA,OAAS,cAAAA,EAAY,kBAAAC,MAAsB,kBCA3C,OAAS,aAAAC,EAAW,WAAAC,EAAS,UAAAC,EAAQ,YAAAC,MAAgB,QACrD,OAAS,kBAAAJ,MAAsB,kBASxB,IAAMK,EAAsB,CACjCC,EACAC,IACG,CACH,GAAM,CAAE,SAAAC,EAAU,MAAAC,CAAM,EAAIT,EAAe,EACrCU,EAAQ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AAMnD,EACN,YAAaK,EACb,oBAAqBwB,EACrB,aAAcO,EACd,SAAUN,EAAgB,OAAYO,EACtC,MAAOC,GAAO,QACb,GAAGJ,EACN,EAEJ,CAEJ,EAEOiB,EAAQD,EC5Ef,OAAS,cAAAzD,EAAY,kBAAAC,OAAsB,kBA+DnC,cAAAgC,MAAA,oBArBR,IAAM0B,GAAoB,CAAC,CACzB,KAAApD,EACA,MAAA4B,EACA,oBAAAC,EACA,aAAA5B,EACA,cAAA6B,EACA,SAAAuB,EACA,GAAGnB,CACL,IAAkC,CAChC,GAAM,CAAE,QAAAC,CAAQ,EAAIzC,GAAe,EAC7B,CAAE,YAAAW,EAAa,iBAAA+B,EAAkB,aAAAC,CAAa,EAAItC,EACtDC,EACAC,CACF,EAEA,OACEyB,EAACjC,EAAA,CACC,KAAMO,EACN,QAASmC,EACT,MAAOP,EACP,OAAQ,CAAC,CAAE,WAAY,CAAE,MAAAU,CAAM,CAAE,IAC/BZ,EAACa,EAAA,CACC,KAAMvC,EACN,YAAaK,EACb,oBAAqBwB,EACrB,aAAcO,EACd,SAAUN,EAAgB,OAAYO,EACtC,MAAOC,GAAO,QACd,SAAUe,EACT,GAAGnB,EACN,EAEJ,CAEJ,EAEOK,GAAQa","sourcesContent":["import { Controller, useFormContext } from 'react-hook-form';\n\nimport SingleImageUploadComponent from 'components/FileUpload/SingleImageUpload';\n\nimport { FormSingleImageUploadProps } from './props';\nimport { useSingleFileUpload } from './useFormFileUpload';\n\n/**\n * AvatarUpload integrado ao React Hook Form\n * Componente especializado para upload de avatar (imagem circular de perfil)\n * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { AvatarUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation, useGetFileQuery } from 'services/filesApi';\n *\n * interface FormData {\n * avatar_id: string | null;\n * }\n *\n * const ProfileForm = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const getFileQuery = useGetFileQuery();\n * const methods = useForm<FormData>();\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <AvatarUpload\n * name=\"avatar_id\"\n * createFilesMutation={createFilesMutation}\n * getFileQuery={getFileQuery}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst AvatarUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n aspectRatio = 1,\n enableCrop = true,\n maxSize = 5242880,\n ...other\n}: FormSingleImageUploadProps) => {\n const { control } = useFormContext();\n const { fileDetails, handleFileSelect, handleRemove } = useSingleFileUpload(\n name,\n getFileQuery,\n );\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <SingleImageUploadComponent\n name={name}\n fileDetails={fileDetails}\n createFilesMutation={createFilesMutation}\n onFileSelect={handleFileSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n aspectRatio={aspectRatio}\n enableCrop={enableCrop}\n maxSize={maxSize}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default AvatarUpload;\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFormContext } from 'react-hook-form';\n\nimport { FileDetails } from 'components/FileUpload/props';\n\nimport { LazyQueryTrigger } from './props';\n\n/**\n * Hook para gerenciar upload de arquivo único\n */\nexport const useSingleFileUpload = (\n name: string,\n getFileQuery: LazyQueryTrigger,\n) => {\n const { setValue, watch } = useFormContext();\n const value = watch(name);\n const [fileDetails, setFileDetails] = useState<FileDetails | undefined>();\n\n useEffect(() => {\n if (!value) {\n setFileDetails(undefined);\n return;\n }\n const fetchFile = async () => {\n try {\n const file = await getFileQuery(value).unwrap();\n setFileDetails({\n id: file.id,\n url: file.url,\n name: file.name,\n });\n } catch {\n setFileDetails({ id: value, url: '' });\n }\n };\n fetchFile();\n }, [value, getFileQuery]);\n\n const handleFileSelect = (file: FileDetails) => {\n setValue(name, file.id, { shouldValidate: true, shouldDirty: true });\n };\n\n const handleRemove = () => {\n setValue(name, null, { shouldValidate: true, shouldDirty: true });\n };\n\n return {\n fileDetails,\n handleFileSelect,\n handleRemove,\n };\n};\n\n/**\n * Hook para gerenciar upload de múltiplos arquivos\n */\nexport const useMultiFileUpload = (\n name: string,\n getFileQuery: LazyQueryTrigger,\n) => {\n const { setValue, watch } = useFormContext();\n const watchedValue = watch(name);\n const currentValue = useMemo(() => watchedValue || [], [watchedValue]);\n const [filesDetails, setFilesDetails] = useState<FileDetails[]>([]);\n const cacheRef = useRef<Map<string, FileDetails>>(new Map());\n\n useEffect(() => {\n if (!currentValue || currentValue.length === 0) {\n setFilesDetails([]);\n return;\n }\n const fetchFiles = async () => {\n try {\n // Remove duplicatas mantendo a ordem\n const uniqueIds = [...new Set(currentValue)] as string[];\n\n const cache = cacheRef.current;\n const newIds = uniqueIds.filter(id => !cache.has(id));\n\n if (newIds.length > 0) {\n const promises = newIds.map(async (id: string) => {\n try {\n const file = await getFileQuery(id).unwrap();\n const fileDetails = {\n id: file.id,\n url: file.url,\n name: file.name,\n };\n cache.set(id, fileDetails);\n return fileDetails;\n } catch {\n const fallback = { id, url: '' };\n cache.set(id, fallback);\n return fallback;\n }\n });\n await Promise.all(promises);\n }\n\n const results = uniqueIds.map(id => cache.get(id)!);\n setFilesDetails(results);\n } catch {\n setFilesDetails(currentValue.map((id: string) => ({ id, url: '' })));\n }\n };\n fetchFiles();\n }, [currentValue, getFileQuery]);\n\n const handleFilesSelect = (files: FileDetails[]) => {\n const newIds = files.map(file => file.id);\n const updatedIds = [...new Set([...currentValue, ...newIds])];\n setValue(name, updatedIds, {\n shouldValidate: true,\n shouldDirty: true,\n });\n };\n\n const handleRemove = (file?: { id: string }) => {\n if (!file) return;\n const updatedIds = currentValue.filter((id: string) => id !== file.id);\n setValue(name, updatedIds, {\n shouldValidate: true,\n shouldDirty: true,\n });\n };\n\n const handleReorder = (oldIndex: number, newIndex: number) => {\n const newIds = [...currentValue];\n const [removed] = newIds.splice(oldIndex, 1);\n newIds.splice(newIndex, 0, removed);\n setValue(name, newIds, {\n shouldValidate: true,\n shouldDirty: true,\n });\n };\n\n return {\n currentValue,\n filesDetails,\n handleFilesSelect,\n handleRemove,\n handleReorder,\n };\n};\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport MultiFileUploadComponent from 'components/FileUpload/MultipleFileUpload';\n\nimport { FormMultiFileUploadProps } from './props';\nimport { useMultiFileUpload } from './useFormFileUpload';\n\n/**\n * MultiFileUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado dos arquivos e retorna array de resource_file_ids\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { MultiFileUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * document_ids: [],\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.document_ids); // Array de IDs\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <MultiFileUpload\n * name=\"document_ids\"\n * label=\"Documentos\"\n * createFilesMutation={createFilesMutation}\n * maxFiles={5}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst MultiFileUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n disableReorder,\n ...other\n}: FormMultiFileUploadProps) => {\n const { control } = useFormContext();\n const { filesDetails, handleFilesSelect, handleRemove, handleReorder } =\n useMultiFileUpload(name, getFileQuery);\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <MultiFileUploadComponent\n name={name}\n filesDetails={filesDetails}\n createFilesMutation={createFilesMutation}\n onFilesSelect={handleFilesSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n onReorder={disableReorder ? undefined : handleReorder}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default MultiFileUpload;\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport MultiImageUploadComponent from 'components/FileUpload/MultipleImageUpload';\n\nimport { FormMultiImageUploadProps } from './props';\nimport { useMultiFileUpload } from './useFormFileUpload';\n\n/**\n * MultiImageUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado dos arquivos e retorna array de resource_file_ids\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { MultiImageUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * image_ids: [],\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.image_ids); // Array de IDs\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <MultiImageUpload\n * name=\"image_ids\"\n * label=\"Imagens\"\n * createFilesMutation={createFilesMutation}\n * maxFiles={5}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst MultiImageUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n disableReorder,\n ...other\n}: FormMultiImageUploadProps) => {\n const { control } = useFormContext();\n const { filesDetails, handleFilesSelect, handleRemove, handleReorder } =\n useMultiFileUpload(name, getFileQuery);\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <MultiImageUploadComponent\n name={name}\n filesDetails={filesDetails}\n createFilesMutation={createFilesMutation}\n onFilesSelect={handleFilesSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n onReorder={disableReorder ? undefined : handleReorder}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default MultiImageUpload;\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport SingleFileUploadComponent from 'components/FileUpload/SingleFileUpload';\n\nimport { FormSingleFileUploadProps } from './props';\nimport { useSingleFileUpload } from './useFormFileUpload';\n\n/**\n * SingleFileUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { SingleFileUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * document_id: null,\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.document_id); // ID do arquivo\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <SingleFileUpload\n * name=\"document_id\"\n * label=\"Documento\"\n * createFilesMutation={createFilesMutation}\n * maxSize={1024 * 1024 * 10}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst SingleFileUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n ...other\n}: FormSingleFileUploadProps) => {\n const { control } = useFormContext();\n const { fileDetails, handleFileSelect, handleRemove } = useSingleFileUpload(\n name,\n getFileQuery,\n );\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <SingleFileUploadComponent\n name={name}\n fileDetails={fileDetails}\n createFilesMutation={createFilesMutation}\n onFileSelect={handleFileSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default SingleFileUpload;\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport SingleImageUploadComponent from 'components/FileUpload/SingleImageUpload';\n\nimport { FormSingleImageUploadProps } from './props';\nimport { useSingleFileUpload } from './useFormFileUpload';\n\n/**\n * SingleImageUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { SingleImageUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * resource_id: null,\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.resource_id); // ID do arquivo\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <SingleImageUpload\n * name=\"resource_id\"\n * label=\"Imagem\"\n * createFilesMutation={createFilesMutation}\n * maxSize={1024 * 1024 * 5}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst SingleImageUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n hoverAlt,\n ...other\n}: FormSingleImageUploadProps) => {\n const { control } = useFormContext();\n const { fileDetails, handleFileSelect, handleRemove } = useSingleFileUpload(\n name,\n getFileQuery,\n );\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <SingleImageUploadComponent\n name={name}\n fileDetails={fileDetails}\n createFilesMutation={createFilesMutation}\n onFileSelect={handleFileSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n error={error?.message}\n hoverAlt={hoverAlt}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default SingleImageUpload;\n"]}
1
+ {"version":3,"sources":["../../../../src/components/form/FileUpload/AvatarUpload.tsx","../../../../src/components/form/FileUpload/useFormFileUpload.ts","../../../../src/components/form/FileUpload/MultiFileUpload.tsx","../../../../src/components/form/FileUpload/MultiImageUpload.tsx","../../../../src/components/form/FileUpload/SingleFileUpload.tsx","../../../../src/components/form/FileUpload/SingleImageUpload.tsx"],"names":["Controller","useFormContext","useEffect","useMemo","useRef","useState","useSingleFileUpload","name","getFileQuery","setValue","watch","value","fileDetails","setFileDetails","file","useMultiFileUpload","watchedValue","currentValue","filesDetails","setFilesDetails","cacheRef","uniqueIds","cache","newIds","id","promises","fallback","results","files","updatedIds","oldIndex","newIndex","removed","jsx","AvatarUpload","rules","createFilesMutation","disableRemove","aspectRatio","enableCrop","maxSize","other","control","handleFileSelect","handleRemove","error","SingleImageUpload_default","AvatarUpload_default","MultiFileUpload","disableReorder","handleFilesSelect","handleReorder","MultipleFileUpload_default","MultiFileUpload_default","MultiImageUpload","MultipleImageUpload_default","MultiImageU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AAA6B,EACA,GAAGI,CACL,IAAiC,CAC/B,GAAM,CAAE,QAAAC,CAAQ,EAAIzC,EAAe,EAC7B,CAAE,YAAAW,EAAa,iBAAA+B,EAAkB,aAAAC,CAAa,EAAItC,EACtDC,EACAC,CACF,EAEA,OACEyB,EAACjC,EAAA,CACC,KAAMO,EACN,QAASmC,EACT,MAAOP,EACP,OAAQ,CAAC,CAAE,WAAY,CAAE,MAAAU,CAAM,CAAE,IAC/BZ,EAACyB,EAAA,CACC,KAAMnD,EACN,YAAaK,EACb,oBAAqBwB,EACrB,aAAcO,EACd,SAAUN,EAAgB,OAAYO,EACtC,MAAOC,GAAO,QACb,GAAGJ,EACN,EAEJ,CAEJ,EAEOiB,EAAQD,EC5Ef,OAAS,cAAAzD,EAAY,kBAAAC,OAAsB,kBA+DnC,cAAAgC,MAAA,oBArBR,IAAM0B,GAAoB,CAAC,CACzB,KAAApD,EACA,MAAA4B,EACA,oBAAAC,EACA,aAAA5B,EACA,cAAA6B,EACA,SAAAuB,EACA,GAAGnB,CACL,IAAkC,CAChC,GAAM,CAAE,QAAAC,CAAQ,EAAIzC,GAAe,EAC7B,CAAE,YAAAW,EAAa,iBAAA+B,EAAkB,aAAAC,CAAa,EAAItC,EACtDC,EACAC,CACF,EAEA,OACEyB,EAACjC,EAAA,CACC,KAAMO,EACN,QAASmC,EACT,MAAOP,EACP,OAAQ,CAAC,CAAE,WAAY,CAAE,MAAAU,CAAM,CAAE,IAC/BZ,EAACa,EAAA,CACC,KAAMvC,EACN,YAAaK,EACb,oBAAqBwB,EACrB,aAAcO,EACd,SAAUN,EAAgB,OAAYO,EACtC,MAAOC,GAAO,QACd,SAAUe,EACT,GAAGnB,EACN,EAEJ,CAEJ,EAEOK,GAAQa","sourcesContent":["import { Controller, useFormContext } from 'react-hook-form';\n\nimport SingleImageUploadComponent from 'components/FileUpload/SingleImageUpload';\n\nimport { FormSingleImageUploadProps } from './props';\nimport { useSingleFileUpload } from './useFormFileUpload';\n\n/**\n * AvatarUpload integrado ao React Hook Form\n * Componente especializado para upload de avatar (imagem circular de perfil)\n * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { AvatarUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation, useGetFileQuery } from 'services/filesApi';\n *\n * interface FormData {\n * avatar_id: string | null;\n * }\n *\n * const ProfileForm = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const getFileQuery = useGetFileQuery();\n * const methods = useForm<FormData>();\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <AvatarUpload\n * name=\"avatar_id\"\n * createFilesMutation={createFilesMutation}\n * getFileQuery={getFileQuery}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst AvatarUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n aspectRatio = 1,\n enableCrop = true,\n maxSize = 5242880,\n ...other\n}: FormSingleImageUploadProps) => {\n const { control } = useFormContext();\n const { fileDetails, handleFileSelect, handleRemove } = useSingleFileUpload(\n name,\n getFileQuery,\n );\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <SingleImageUploadComponent\n name={name}\n fileDetails={fileDetails}\n createFilesMutation={createFilesMutation}\n onFileSelect={handleFileSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n aspectRatio={aspectRatio}\n enableCrop={enableCrop}\n maxSize={maxSize}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default AvatarUpload;\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFormContext } from 'react-hook-form';\n\nimport { FileDetails } from 'components/FileUpload/props';\n\nimport { LazyQueryTrigger } from './props';\n\n/**\n * Hook para gerenciar upload de arquivo único\n */\nexport const useSingleFileUpload = (\n name: string,\n getFileQuery: LazyQueryTrigger,\n) => {\n const { setValue, watch } = useFormContext();\n const value = watch(name);\n const [fileDetails, setFileDetails] = useState<FileDetails | undefined>();\n\n useEffect(() => {\n if (!value) {\n setFileDetails(undefined);\n return;\n }\n const fetchFile = async () => {\n try {\n const file = await getFileQuery(value).unwrap();\n setFileDetails({\n id: file.id,\n url: file.url,\n name: file.name,\n });\n } catch {\n setFileDetails({ id: value, url: '' });\n }\n };\n fetchFile();\n }, [value, getFileQuery]);\n\n const handleFileSelect = (file: FileDetails) => {\n setValue(name, file.id, { shouldValidate: true, shouldDirty: true });\n };\n\n const handleRemove = () => {\n setValue(name, null, { shouldValidate: true, shouldDirty: true });\n };\n\n return {\n fileDetails,\n handleFileSelect,\n handleRemove,\n };\n};\n\n/**\n * Hook para gerenciar upload de múltiplos arquivos\n */\nexport const useMultiFileUpload = (\n name: string,\n getFileQuery: LazyQueryTrigger,\n) => {\n const { setValue, watch } = useFormContext();\n const watchedValue = watch(name);\n const currentValue = useMemo(() => watchedValue || [], [watchedValue]);\n const [filesDetails, setFilesDetails] = useState<FileDetails[]>([]);\n const cacheRef = useRef<Map<string, FileDetails>>(new Map());\n\n useEffect(() => {\n if (!currentValue || currentValue.length === 0) {\n setFilesDetails([]);\n return;\n }\n const fetchFiles = async () => {\n try {\n // Remove duplicatas mantendo a ordem\n const uniqueIds = [...new Set(currentValue)] as string[];\n\n const cache = cacheRef.current;\n const newIds = uniqueIds.filter(id => !cache.has(id));\n\n if (newIds.length > 0) {\n const promises = newIds.map(async (id: string) => {\n try {\n const file = await getFileQuery(id).unwrap();\n const fileDetails = {\n id: file.id,\n url: file.url,\n name: file.name,\n };\n cache.set(id, fileDetails);\n return fileDetails;\n } catch {\n const fallback = { id, url: '' };\n cache.set(id, fallback);\n return fallback;\n }\n });\n await Promise.all(promises);\n }\n\n const results = uniqueIds.map(id => cache.get(id)!);\n setFilesDetails(results);\n } catch {\n setFilesDetails(currentValue.map((id: string) => ({ id, url: '' })));\n }\n };\n fetchFiles();\n }, [currentValue, getFileQuery]);\n\n const handleFilesSelect = (files: FileDetails[]) => {\n const newIds = files.map(file => file.id);\n const updatedIds = [...new Set([...currentValue, ...newIds])];\n setValue(name, updatedIds, {\n shouldValidate: true,\n shouldDirty: true,\n });\n };\n\n const handleRemove = (file?: { id: string }) => {\n if (!file) return;\n const updatedIds = currentValue.filter((id: string) => id !== file.id);\n setValue(name, updatedIds, {\n shouldValidate: true,\n shouldDirty: true,\n });\n };\n\n const handleReorder = (oldIndex: number, newIndex: number) => {\n const newIds = [...currentValue];\n const [removed] = newIds.splice(oldIndex, 1);\n newIds.splice(newIndex, 0, removed);\n setValue(name, newIds, {\n shouldValidate: true,\n shouldDirty: true,\n });\n };\n\n return {\n currentValue,\n filesDetails,\n handleFilesSelect,\n handleRemove,\n handleReorder,\n };\n};\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport MultiFileUploadComponent from 'components/FileUpload/MultipleFileUpload';\n\nimport { FormMultiFileUploadProps } from './props';\nimport { useMultiFileUpload } from './useFormFileUpload';\n\n/**\n * MultiFileUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado dos arquivos e retorna array de resource_file_ids\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { MultiFileUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * document_ids: [],\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.document_ids); // Array de IDs\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <MultiFileUpload\n * name=\"document_ids\"\n * label=\"Documentos\"\n * createFilesMutation={createFilesMutation}\n * maxFiles={5}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst MultiFileUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n disableReorder,\n ...other\n}: FormMultiFileUploadProps) => {\n const { control } = useFormContext();\n const { filesDetails, handleFilesSelect, handleRemove, handleReorder } =\n useMultiFileUpload(name, getFileQuery);\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <MultiFileUploadComponent\n name={name}\n filesDetails={filesDetails}\n createFilesMutation={createFilesMutation}\n onFilesSelect={handleFilesSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n onReorder={disableReorder ? undefined : handleReorder}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default MultiFileUpload;\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport MultiImageUploadComponent from 'components/FileUpload/MultipleImageUpload';\n\nimport { FormMultiImageUploadProps } from './props';\nimport { useMultiFileUpload } from './useFormFileUpload';\n\n/**\n * MultiImageUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado dos arquivos e retorna array de resource_file_ids\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { MultiImageUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * image_ids: [],\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.image_ids); // Array de IDs\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <MultiImageUpload\n * name=\"image_ids\"\n * label=\"Imagens\"\n * createFilesMutation={createFilesMutation}\n * maxFiles={5}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst MultiImageUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n disableReorder,\n ...other\n}: FormMultiImageUploadProps) => {\n const { control } = useFormContext();\n const { filesDetails, handleFilesSelect, handleRemove, handleReorder } =\n useMultiFileUpload(name, getFileQuery);\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <MultiImageUploadComponent\n name={name}\n filesDetails={filesDetails}\n createFilesMutation={createFilesMutation}\n onFilesSelect={handleFilesSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n onReorder={disableReorder ? undefined : handleReorder}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default MultiImageUpload;\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport SingleFileUploadComponent from 'components/FileUpload/SingleFileUpload';\n\nimport { FormSingleFileUploadProps } from './props';\nimport { useSingleFileUpload } from './useFormFileUpload';\n\n/**\n * SingleFileUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { SingleFileUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * document_id: null,\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.document_id); // ID do arquivo\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <SingleFileUpload\n * name=\"document_id\"\n * label=\"Documento\"\n * createFilesMutation={createFilesMutation}\n * maxSize={1024 * 1024 * 10}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst SingleFileUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n ...other\n}: FormSingleFileUploadProps) => {\n const { control } = useFormContext();\n const { fileDetails, handleFileSelect, handleRemove } = useSingleFileUpload(\n name,\n getFileQuery,\n );\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <SingleFileUploadComponent\n name={name}\n fileDetails={fileDetails}\n createFilesMutation={createFilesMutation}\n onFileSelect={handleFileSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n error={error?.message}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default SingleFileUpload;\n","import { Controller, useFormContext } from 'react-hook-form';\n\nimport SingleImageUploadComponent from 'components/FileUpload/SingleImageUpload';\n\nimport { FormSingleImageUploadProps } from './props';\nimport { useSingleFileUpload } from './useFormFileUpload';\n\n/**\n * SingleImageUpload integrado ao React Hook Form\n * Gerencia automaticamente o estado do arquivo e retorna apenas o resource_file_id\n *\n * @example\n * ```tsx\n * import { Form } from 'components/form';\n * import { SingleImageUpload } from 'components/form/FileUpload';\n * import { useCreateFilesMutation } from 'services/filesApi';\n *\n * const FormExample = () => {\n * const createFilesMutation = useCreateFilesMutation();\n * const methods = useForm({\n * defaultValues: {\n * resource_id: null,\n * },\n * });\n *\n * const handleSubmit = (data: any) => {\n * console.log(data.resource_id); // ID do arquivo\n * };\n *\n * return (\n * <Form methods={methods} onSubmit={handleSubmit}>\n * <SingleImageUpload\n * name=\"resource_id\"\n * label=\"Imagem\"\n * createFilesMutation={createFilesMutation}\n * maxSize={1024 * 1024 * 5}\n * />\n * </Form>\n * );\n * };\n * ```\n */\nconst SingleImageUpload = ({\n name,\n rules,\n createFilesMutation,\n getFileQuery,\n disableRemove,\n hoverAlt,\n ...other\n}: FormSingleImageUploadProps) => {\n const { control } = useFormContext();\n const { fileDetails, handleFileSelect, handleRemove } = useSingleFileUpload(\n name,\n getFileQuery,\n );\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ fieldState: { error } }) => (\n <SingleImageUploadComponent\n name={name}\n fileDetails={fileDetails}\n createFilesMutation={createFilesMutation}\n onFileSelect={handleFileSelect}\n onRemove={disableRemove ? undefined : handleRemove}\n error={error?.message}\n hoverAlt={hoverAlt}\n {...other}\n />\n )}\n />\n );\n};\n\nexport default SingleImageUpload;\n"]}
@@ -0,0 +1,13 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { BaseField } from '../../../types/baseField.js';
3
+ import { SelectListProps as SelectListProps$1 } from '../../../types/selectList.js';
4
+ import 'react-hook-form';
5
+ import 'react';
6
+
7
+ type SelectListProps = BaseField<Omit<SelectListProps$1, 'value' | 'onChange'>> & {
8
+ onChange?: (value: string | string[]) => void;
9
+ };
10
+
11
+ declare const SelectList: ({ name, rules, onChange, helperText, ...other }: SelectListProps) => react_jsx_runtime.JSX.Element;
12
+
13
+ export { SelectList as default };
@@ -0,0 +1,16 @@
1
+ import { a } from '../../../chunk-2CY62UZ5.js';
2
+ import '../../../chunk-RUABKHIV.js';
3
+ import '../../../chunk-RPPQBAVO.js';
4
+ import '../../../chunk-IJZCVZ32.js';
5
+ import '../../../chunk-6U5LS7MP.js';
6
+ import '../../../chunk-LEMPYV5U.js';
7
+ import '../../../chunk-NQNNMRLC.js';
8
+ import '../../../chunk-CIGSMWKF.js';
9
+ import { useFormContext, Controller } from 'react-hook-form';
10
+ import { jsx } from 'react/jsx-runtime';
11
+
12
+ var C=({name:l,rules:s,onChange:m,helperText:p,...c})=>{let{control:a$1}=useFormContext();return jsx(Controller,{name:l,control:a$1,rules:s,render:({field:e,fieldState:{error:t}})=>jsx(a,{...c,value:e.value,onChange:o=>{e.onChange(o),m?.(o);},error:!!t,helperText:t?.message||p})})},L=C;
13
+
14
+ export { L as default };
15
+ //# sourceMappingURL=out.js.map
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/form/SelectList/index.tsx"],"names":["Controller","useFormContext","jsx","SelectList","name","rules","onChange","helperText","other","control","field","error","SelectList_default","value"],"mappings":"oSAAA,OAAS,cAAAA,EAAY,kBAAAC,MAAsB,kBAgBjC,cAAAC,MAAA,oBAVV,IAAMC,EAAa,CAAC,CAAE,KAAAC,EAAM,MAAAC,EAAO,SAAAC,EAAU,WAAAC,EAAY,GAAGC,CAAM,IAAuB,CACvF,GAAM,CAAE,QAAAC,CAAQ,EAAIR,EAAe,EAEnC,OACEC,EAACF,EAAA,CACC,KAAMI,EACN,QAASK,EACT,MAAOJ,EACP,OAAQ,CAAC,CAAE,MAAAK,EAAO,WAAY,CAAE,MAAAC,CAAM,CAAE,IAEpCT,EAACU,EAAA,CACE,GAAGJ,EACJ,MAAOE,EAAM,MACb,SAAUG,GAAS,CACjBH,EAAM,SAASG,CAAK,EACpBP,IAAWO,CAAK,CAClB,EACA,MAAO,CAAC,CAACF,EACT,WAAYA,GAAO,SAAWJ,EAChC,EAGN,CAEJ,EAEOK,EAAQT","sourcesContent":["import { Controller, useFormContext } from 'react-hook-form';\n\nimport SelectListComponent from 'components/SelectList';\n\nimport { SelectListProps } from './props';\n\nconst SelectList = ({ name, rules, onChange, helperText, ...other }: SelectListProps) => {\n const { control } = useFormContext();\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field, fieldState: { error } }) => {\n return (\n <SelectListComponent\n {...other}\n value={field.value}\n onChange={value => {\n field.onChange(value);\n onChange?.(value);\n }}\n error={!!error}\n helperText={error?.message || helperText}\n />\n );\n }}\n />\n );\n};\n\nexport default SelectList;\n"]}
@@ -1,6 +1,6 @@
1
- import { a } from '../../../chunk-MP2LAJS5.js';
1
+ import { a } from '../../../chunk-KQTA6B4Y.js';
2
2
  import '../../../chunk-6ZSTKYGL.js';
3
- import '../../../chunk-OTVEMGF2.js';
3
+ import '../../../chunk-RPPQBAVO.js';
4
4
  import '../../../chunk-IJZCVZ32.js';
5
5
  import '../../../chunk-NIQW2J3M.js';
6
6
  import '../../../chunk-NQNNMRLC.js';
@@ -1,23 +1,3 @@
1
- /**
2
- * UseMount hook runs the callback only once when the component is mounted.
3
- *
4
- * @param callback - The callback to run when the component is mounted. Returns a cleanup function to run at the end of the component lifecycle.
5
- * @example
6
- * Here's an example with negative numbers:
7
- * ```
8
- * useMount(() => {
9
- * document.addEventListener('resize', () => {
10
- * // do something
11
- * });
12
- *
13
- * return () => {
14
- * document.removeEventListener('resize', () => {
15
- * // cleanup event listener
16
- * });
17
- * };
18
- * });
19
- * ```
20
- */
21
1
  declare const useMount: (callback: () => void | (() => void)) => void;
22
2
 
23
3
  export { useMount as default };
@@ -4,13 +4,13 @@ import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  declare const useSnackbar: () => {
7
- toast: ((message: ReactNode | (() => ReactNode), data?: ExternalToast | undefined) => string | number) & {
8
- success: (message: string | number | boolean | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | (() => ReactNode) | null | undefined, data?: ExternalToast | undefined) => string | number;
9
- info: (message: string | number | boolean | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | (() => ReactNode) | null | undefined, data?: ExternalToast | undefined) => string | number;
10
- warning: (message: string | number | boolean | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | (() => ReactNode) | null | undefined, data?: ExternalToast | undefined) => string | number;
11
- error: (message: string | number | boolean | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | (() => ReactNode) | null | undefined, data?: ExternalToast | undefined) => string | number;
7
+ toast: ((message: (() => ReactNode) | ReactNode, data?: ExternalToast | undefined) => string | number) & {
8
+ success: (message: string | number | boolean | (() => ReactNode) | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null | undefined, data?: ExternalToast | undefined) => string | number;
9
+ info: (message: string | number | boolean | (() => ReactNode) | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null | undefined, data?: ExternalToast | undefined) => string | number;
10
+ warning: (message: string | number | boolean | (() => ReactNode) | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null | undefined, data?: ExternalToast | undefined) => string | number;
11
+ error: (message: string | number | boolean | (() => ReactNode) | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null | undefined, data?: ExternalToast | undefined) => string | number;
12
12
  custom: (jsx: (id: string | number) => react.ReactElement<any, string | react.JSXElementConstructor<any>>, data?: ExternalToast | undefined) => string | number;
13
- message: (message: string | number | boolean | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | (() => ReactNode) | null | undefined, data?: ExternalToast | undefined) => string | number;
13
+ message: (message: string | number | boolean | (() => ReactNode) | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null | undefined, data?: ExternalToast | undefined) => string | number;
14
14
  promise: <ToastData>(promise: Promise<ToastData> | (() => Promise<ToastData>), data?: ({
15
15
  className?: string | undefined;
16
16
  style?: react.CSSProperties | undefined;
@@ -45,7 +45,7 @@ declare const useSnackbar: () => {
45
45
  unwrap: () => Promise<ToastData>;
46
46
  };
47
47
  dismiss: (id?: string | number | undefined) => string | number;
48
- loading: (message: string | number | boolean | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | (() => ReactNode) | null | undefined, data?: ExternalToast | undefined) => string | number;
48
+ loading: (message: string | number | boolean | (() => ReactNode) | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null | undefined, data?: ExternalToast | undefined) => string | number;
49
49
  } & {
50
50
  getHistory: () => (sonner.ToastT | sonner.ToastToDismiss)[];
51
51
  getToasts: () => (sonner.ToastT | sonner.ToastToDismiss)[];
@@ -1,12 +1,12 @@
1
1
  export { a as useThemeToggle } from '../chunk-UHXAPEIF.js';
2
- import '../chunk-VPKUUY5Q.js';
2
+ import '../chunk-CU7PKEY2.js';
3
3
  import '../chunk-LDGBS7ZI.js';
4
- import '../chunk-WUFEPE2G.js';
5
4
  import '../chunk-2WG6OWB4.js';
6
5
  import '../chunk-6W52DPH4.js';
7
6
  import '../chunk-TWSAWMZ3.js';
8
7
  import '../chunk-ROVD7OGE.js';
9
8
  import '../chunk-EQYL7U3J.js';
9
+ import '../chunk-WUFEPE2G.js';
10
10
  import '../chunk-GLRLKFPS.js';
11
11
  //# sourceMappingURL=out.js.map
12
12
  //# sourceMappingURL=useThemeToggle.js.map
@@ -1,3 +1,8 @@
1
- export { a as default } from '../chunk-YCEQDXLR.js';
1
+ import { useState } from 'react';
2
+ import { useFormContext } from 'react-hook-form';
3
+
4
+ function F(t,i){let{watch:r,setValue:n}=useFormContext(),[u,o]=useState(i),l=r(t)||[];return {uploadFile:async e=>{if(!e){n(t,void 0),o(void 0);return}n(t,e),o(Object.assign(e,{preview:URL.createObjectURL(e)}));},uploadFiles:async e=>{n(t,[...l,...e.map(s=>Object.assign(s,{preview:URL.createObjectURL(s)}))]);},handleDeleteFile:()=>{n(t,void 0),o(void 0);},handleRemoveAll:()=>{n(t,void 0);},handleRemove:e=>{let s=l.filter(a=>a!==e);n(t,s);},file:u,setFileValue:o}}var b=F;
5
+
6
+ export { b as default };
2
7
  //# sourceMappingURL=out.js.map
3
8
  //# sourceMappingURL=useUpload.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/hooks/useUpload.ts"],"names":["useState","useFormContext","useUpload","fieldName","urlImage","watch","setValue","fileValue","setFileValue","filesValues","file","files","filteredItems","f","useUpload_default"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,QACzB,OAAS,kBAAAC,MAAsB,kBAI/B,SAASC,EAAUC,EAAmBC,EAAmB,CACvD,GAAM,CAAE,MAAAC,EAAO,SAAAC,CAAS,EAAIL,EAAe,EACrC,CAACM,EAAWC,CAAY,EAAIR,EAChCI,CACF,EACMK,EAAwBJ,EAAMF,CAAS,GAAK,CAAC,EA4CnD,MAAO,CACL,WA3CiB,MAAOO,GAAgB,CACxC,GAAI,CAACA,EAAM,CACTJ,EAASH,EAAW,MAAS,EAC7BK,EAAa,MAAS,EACtB,OAGFF,EAASH,EAAWO,CAAI,EAExBF,EACE,OAAO,OAAOE,EAAM,CAClB,QAAS,IAAI,gBAAgBA,CAAI,CACnC,CAAC,CACH,CACF,EA8BE,YA5BkB,MAAOC,GAAkB,CAC3CL,EAASH,EAAW,CAClB,GAAGM,EACH,GAAGE,EAAM,IAAKD,GACZ,OAAO,OAAOA,EAAM,CAClB,QAAS,IAAI,gBAAgBA,CAAI,CACnC,CAAC,CACH,CACF,CAAC,CACH,EAoBE,iBAlBuB,IAAM,CAC7BJ,EAASH,EAAW,MAAS,EAC7BK,EAAa,MAAS,CACxB,EAgBE,gBAdsB,IAAM,CAC5BF,EAASH,EAAW,MAAS,CAC/B,EAaE,aAXoBO,GAAwB,CAC5C,IAAME,EAAgBH,EAAY,OAAOI,GAAKA,IAAMH,CAAI,EAExDJ,EAASH,EAAWS,CAAa,CACnC,EAQE,KAAML,EACN,aAAAC,CACF,CACF,CAEA,IAAOM,EAAQZ","sourcesContent":["import { useState } from 'react';\nimport { useFormContext } from 'react-hook-form';\n\nimport { CustomFile } from 'types/upload';\n\nfunction useUpload(fieldName: string, urlImage?: string) {\n const { watch, setValue } = useFormContext();\n const [fileValue, setFileValue] = useState<CustomFile | string | undefined>(\n urlImage,\n );\n const filesValues: string[] = watch(fieldName) || [];\n\n const uploadFile = async (file?: File) => {\n if (!file) {\n setValue(fieldName, undefined);\n setFileValue(undefined);\n return;\n }\n\n setValue(fieldName, file);\n\n setFileValue(\n Object.assign(file, {\n preview: URL.createObjectURL(file),\n }),\n );\n };\n\n const uploadFiles = async (files: File[]) => {\n setValue(fieldName, [\n ...filesValues,\n ...files.map((file: Blob | MediaSource) =>\n Object.assign(file, {\n preview: URL.createObjectURL(file),\n }),\n ),\n ]);\n };\n\n const handleDeleteFile = () => {\n setValue(fieldName, undefined);\n setFileValue(undefined);\n };\n\n const handleRemoveAll = () => {\n setValue(fieldName, undefined);\n };\n\n const handleRemove = (file: File | string) => {\n const filteredItems = filesValues.filter(f => f !== file);\n\n setValue(fieldName, filteredItems);\n };\n\n return {\n uploadFile,\n uploadFiles,\n handleDeleteFile,\n handleRemoveAll,\n handleRemove,\n file: fileValue,\n setFileValue,\n };\n}\n\nexport default useUpload;\n"]}
@@ -1,4 +1,9 @@
1
- export { a as default } from '../chunk-SBMEL2IJ.js';
2
- import '../chunk-E3R7W7GK.js';
1
+ import { a } from '../chunk-E3R7W7GK.js';
2
+ import { useId, useState } from 'react';
3
+ import I from 'browser-image-compression';
4
+
5
+ var h=5242880,y=({onFileCropped:n,onImageUploaded:d,onCancel:i})=>{let l=useId(),[e,m]=useState(),[f,o,a$1]=a(),[u,r]=useState(),[v,p]=useState(!1);return {id:l,setCropModalOpen:a$1,handleRemove:()=>{n(void 0),d(void 0),a$1(!1);},toggleCropModalOpen:o,cropModalOpen:f,cancelChanges:()=>{i&&i(),a$1(!1);},saveChanges:()=>{e!==void 0&&e.getCroppedCanvas().toBlob(async g=>{try{if(!g)return;p(!0);let s=new File([g],"imagem.png",{type:"image/png"});if(s.size>h){let C=await I(s,{maxSizeMB:5});n(C),o();return}n(s),o();}finally{p(!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 default };
3
8
  //# sourceMappingURL=out.js.map
4
9
  //# sourceMappingURL=useUploadImage.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/hooks/useUploadImage.ts"],"names":["useId","useState","imageCompression","FIVE_MB","useUploadImage","onFileCropped","onImageUploaded","onCancel","id","cropper","setCropper","cropModalOpen","toggleCropModalOpen","setCropModalOpen","useToggle_default","preview","setPreview","saving","setSaving","blob","file","compressedFile","useUploadImage_default"],"mappings":"yCACA,OAAS,SAAAA,EAAO,YAAAC,MAAgB,QAChC,OAAOC,MAAsB,4BAU7B,IAAMC,EAAU,QAEVC,EAAiB,CAAC,CACtB,cAAAC,EACA,gBAAAC,EACA,SAAAC,CACF,IAAa,CACX,IAAMC,EAAKR,EAAM,EACX,CAACS,EAASC,CAAU,EAAIT,EAAc,EACtC,CAACU,EAAeC,EAAqBC,CAAgB,EAAIC,EAAU,EACnE,CAACC,EAASC,CAAU,EAAIf,EAAiB,EACzC,CAACgB,EAAQC,CAAS,EAAIjB,EAAS,EAAK,EAuD1C,MAAO,CACL,GAAAO,EACA,iBAAAK,EACA,aATmB,IAAM,CACzBR,EAAc,MAAS,EACvBC,EAAgB,MAAS,EACzBO,EAAiB,EAAK,CACxB,EAME,oBAAAD,EACA,cAAAD,EACA,cA3DoB,IAAM,CACtBJ,GAAUA,EAAS,EACvBM,EAAiB,EAAK,CACxB,EAyDE,YA/CkB,IAAM,CACpBJ,IAAY,QAEhBA,EAAQ,iBAAiB,EAAE,OACzB,MAAOU,GAAc,CACnB,GAAI,CACF,GAAI,CAACA,EAAM,OAEXD,EAAU,EAAI,EAEd,IAAME,EAAO,IAAI,KAAK,CAACD,CAAI,EAAG,aAAc,CAAE,KAAM,WAAY,CAAC,EAEjE,GAAIC,EAAK,KAAOjB,EAAS,CACvB,IAAMkB,EAAiB,MAAMnB,EAAiBkB,EAAM,CAClD,UAAW,CACb,CAAC,EAEDf,EAAcgB,CAAc,EAC5BT,EAAoB,EAEpB,OAGFP,EAAce,CAAI,EAClBR,EAAoB,CACtB,QAAE,CACAM,EAAU,EAAK,CACjB,CACF,EACA,YACA,CACF,CACF,EAgBE,aAxDmB,IAAM,CACrBT,IAAY,QAEhBO,EAAWP,EAAQ,iBAAiB,EAAE,UAAU,CAAC,CACnD,EAqDE,WAAAC,EACA,QAAAK,EACA,kBArDwB,IAAMC,EAAW,MAAS,EAsDlD,OAAAC,CACF,CACF,EAEOK,EAAQlB","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useId, useState } from 'react';\nimport imageCompression from 'browser-image-compression';\n\nimport useToggle from './useToggle';\n\ninterface Props {\n onFileCropped(file?: File): void;\n onImageUploaded(image?: string): void;\n onCancel?: VoidFunction;\n}\n\nconst FIVE_MB = 5242880;\n\nconst useUploadImage = ({\n onFileCropped,\n onImageUploaded,\n onCancel,\n}: Props) => {\n const id = useId();\n const [cropper, setCropper] = useState<any>();\n const [cropModalOpen, toggleCropModalOpen, setCropModalOpen] = useToggle();\n const [preview, setPreview] = useState<string>();\n const [saving, setSaving] = useState(false);\n\n const cancelChanges = () => {\n if (onCancel) onCancel();\n setCropModalOpen(false);\n };\n\n const previewImage = () => {\n if (cropper === undefined) return;\n\n setPreview(cropper.getCroppedCanvas().toDataURL());\n };\n\n const closePreviewImage = () => setPreview(undefined);\n\n const saveChanges = () => {\n if (cropper === undefined) return;\n\n cropper.getCroppedCanvas().toBlob(\n async (blob: any) => {\n try {\n if (!blob) return;\n\n setSaving(true);\n\n const file = new File([blob], 'imagem.png', { type: 'image/png' });\n\n if (file.size > FIVE_MB) {\n const compressedFile = await imageCompression(file, {\n maxSizeMB: 5,\n });\n\n onFileCropped(compressedFile);\n toggleCropModalOpen();\n\n return;\n }\n\n onFileCropped(file);\n toggleCropModalOpen();\n } finally {\n setSaving(false);\n }\n },\n 'image/png',\n 1,\n );\n };\n\n const handleRemove = () => {\n onFileCropped(undefined);\n onImageUploaded(undefined);\n setCropModalOpen(false);\n };\n\n return {\n id,\n setCropModalOpen,\n handleRemove,\n toggleCropModalOpen,\n cropModalOpen,\n cancelChanges,\n saveChanges,\n previewImage,\n setCropper,\n preview,\n closePreviewImage,\n saving,\n };\n};\n\nexport default useUploadImage;\n"]}
@@ -1,6 +1,3 @@
1
- /**
2
- * @returns boolean - true quando a aba está visível/focada, false quando está oculta
3
- */
4
1
  declare function useWindowFocus(): boolean;
5
2
 
6
3
  export { useWindowFocus as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CustomShadows } from './index-5a5e5dc8.js';
2
- export { d as ColorType, k as action, j as background, l as basePalette, o as colorSchemes, h as common, c as components, a as createShadowColor, b as customShadows, n as darkPalette, r as defaultFont, f as error, g as grey, i as info, m as lightPalette, p as primary, u as primaryFont, s as secondary, v as secondaryFont, q as shadows, e as success, t as text, x as typography, w as warning } from './index-5a5e5dc8.js';
1
+ import { C as CustomShadows } from './index-c8f1e6e7.js';
2
+ export { d as ColorType, k as action, j as background, l as basePalette, o as colorSchemes, h as common, c as components, a as createShadowColor, b as customShadows, n as darkPalette, r as defaultFont, f as error, g as grey, i as info, m as lightPalette, p as primary, u as primaryFont, s as secondary, v as secondaryFont, q as shadows, e as success, t as text, x as typography, w as warning } from './index-c8f1e6e7.js';
3
3
  export { S as SettingsContextValue, _ as SettingsProvider, T as ThemeProviderProps, u as useSettingsContext } from './settings-provider-38d09283.js';
4
4
  export { THEME_CONFIG, default as ThemeProvider } from './theme/theme-provider.js';
5
5
  import { S as SettingsState } from './settings-583c107c.js';
@@ -147,6 +147,4 @@ declare module '@mui/material/styles' {
147
147
  }
148
148
  }
149
149
 
150
- declare const test: () => boolean;
151
-
152
- export { SettingsState, createTheme, test };
150
+ export { SettingsState, createTheme };
package/dist/index.js CHANGED
@@ -1,16 +1,12 @@
1
1
  export { a as useThemeToggle } from './chunk-UHXAPEIF.js';
2
- export { b as ThemeProvider, a as createTheme } from './chunk-VPKUUY5Q.js';
2
+ export { b as ThemeProvider, a as createTheme } from './chunk-CU7PKEY2.js';
3
3
  import './chunk-LDGBS7ZI.js';
4
- import './chunk-WUFEPE2G.js';
5
4
  export { c as SettingsProvider, b as useSettingsContext } from './chunk-2WG6OWB4.js';
6
5
  export { b as defaultFont, c as primaryFont, d as secondaryFont, a as shadows, e as typography } from './chunk-6W52DPH4.js';
7
6
  import './chunk-TWSAWMZ3.js';
8
7
  import './chunk-ROVD7OGE.js';
9
8
  export { l as action, k as background, m as basePalette, p as colorSchemes, i as common, a as components, q as createShadowColor, r as customShadows, o as darkPalette, h as error, b as grey, e as info, n as lightPalette, c as primary, d as secondary, f as success, j as text, g as warning } from './chunk-EQYL7U3J.js';
9
+ import './chunk-WUFEPE2G.js';
10
10
  export { a as THEME_CONFIG, q as bgBlur, p as bgGradient, o as borderGradient, j as createPaletteChannel, h as hexToRgbChannel, i as hexToRgbaChannel, l as hideScrollX, m as hideScrollY, r as maxLine, c as mediaQueries, t as menuItem, s as paper, f as pxToRem, e as remToPx, g as responsiveFontSizes, d as setFont, b as stylesMode, n as textGradient, k as varAlpha } from './chunk-GLRLKFPS.js';
11
-
12
- var Y=()=>!0;
13
-
14
- export { Y as test };
15
11
  //# sourceMappingURL=out.js.map
16
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["test"],"mappings":"ioBA8KA,IAAMA,EAAO,IAAM","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport { CustomShadows } from './types/shadows';\n\n// @ts-ignore\ndeclare module '@mui/material/styles/createPalette' {\n interface CommonColors {\n whiteChannel: string;\n blackChannel: string;\n }\n interface TypeText {\n disabledChannel: string;\n }\n interface TypeBackground {\n neutral: string;\n neutralChannel: string;\n }\n interface SimplePaletteColorOptions {\n lighter: string;\n darker: string;\n lighterChannel: string;\n darkerChannel: string;\n }\n interface PaletteColor {\n lighter: string;\n darker: string;\n lighterChannel: string;\n darkerChannel: string;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/styles' {\n interface ThemeVars {\n // @ts-ignore\n transitions: Theme['transitions'];\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material' {\n interface Color {\n ['50Channel']: string;\n ['100Channel']: string;\n ['200Channel']: string;\n ['300Channel']: string;\n ['400Channel']: string;\n ['500Channel']: string;\n ['600Channel']: string;\n ['700Channel']: string;\n ['800Channel']: string;\n ['900Channel']: string;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/styles' {\n interface TypographyVariants {\n fontSecondaryFamily: React.CSSProperties['fontFamily'];\n fontWeightSemiBold: React.CSSProperties['fontWeight'];\n }\n interface TypographyVariantsOptions {\n fontSecondaryFamily?: React.CSSProperties['fontFamily'];\n fontWeightSemiBold?: React.CSSProperties['fontWeight'];\n }\n interface ThemeVars {\n // @ts-ignore\n typography: Theme['typography'];\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/AvatarGroup' {\n interface AvatarGroupPropsVariantOverrides {\n compact: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/Badge' {\n interface BadgePropsVariantOverrides {\n alway: true;\n busy: true;\n online: true;\n offline: true;\n invisible: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/Fab' {\n interface FabPropsVariantOverrides {\n outlined: true;\n outlinedExtended: true;\n soft: true;\n softExtended: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/ButtonGroup' {\n interface ButtonGroupPropsVariantOverrides {\n soft: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/Button' {\n interface ButtonPropsVariantOverrides {\n soft: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/Chip' {\n interface ChipPropsVariantOverrides {\n soft: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/Pagination' {\n interface PaginationPropsVariantOverrides {\n soft: true;\n }\n\n interface PaginationPropsColorOverrides {\n info: true;\n success: true;\n warning: true;\n error: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/Slider' {\n interface SliderPropsColorOverrides {\n inherit: true;\n }\n}\n\n// @ts-ignore\ndeclare module '@mui/material/styles' {\n interface Theme {\n customShadows: CustomShadows;\n }\n interface ThemeOptions {\n customShadows?: CustomShadows;\n }\n interface ThemeVars {\n customShadows: CustomShadows;\n }\n}\n\nimport './global.css';\n\n// Theme exports\nexport type { ThemeProviderProps } from './theme/props';\nexport type { SettingsContextValue } from './theme/props';\nexport { default as SettingsProvider } from './theme/settings-provider';\nexport {\n THEME_CONFIG,\n default as ThemeProvider,\n useSettingsContext,\n} from './theme/theme-provider';\nexport type { SettingsState } from './types/settings';\n\n// Core theme utilities\nexport * from './theme/core';\nexport { createTheme } from './theme/create-theme';\nexport * from './theme/styles';\n\n// Hooks exports\nexport { useThemeToggle } from './hooks/useThemeToggle';\n\nconst test = () => true;\n\nexport { test };\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- export { d as ColorType, k as action, j as background, l as basePalette, o as colorSchemes, h as common, c as components, a as createShadowColor, b as customShadows, n as darkPalette, r as defaultFont, f as error, g as grey, i as info, m as lightPalette, p as primary, u as primaryFont, s as secondary, v as secondaryFont, q as shadows, e as success, t as text, x as typography, w as warning } from '../../index-5a5e5dc8.js';
1
+ export { d as ColorType, k as action, j as background, l as basePalette, o as colorSchemes, h as common, c as components, a as createShadowColor, b as customShadows, n as darkPalette, r as defaultFont, f as error, g as grey, i as info, m as lightPalette, p as primary, u as primaryFont, s as secondary, v as secondaryFont, q as shadows, e as success, t as text, x as typography, w as warning } from '../../index-c8f1e6e7.js';
2
2
  import '@mui/lab/TimelineConnector';
3
3
  import '@mui/system';
4
4
  import '@mui/lab/TimelineDot';