@zydon/common 2.5.17 → 2.5.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,356 +0,0 @@
1
- import { StackProps } from '@mui/material/Stack';
2
- import { SxProps, Theme } from '@mui/material/styles';
3
- import { DropzoneOptions, DropzoneRootProps, FileRejection, DropzoneInputProps, useDropzone } from 'react-dropzone';
4
- import { Area } from 'react-easy-crop';
5
- import { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
6
-
7
- interface ExtendFile extends File {
8
- id?: string;
9
- url?: string;
10
- index?: number;
11
- }
12
- interface FileUpload {
13
- url: string;
14
- file: ExtendFile;
15
- contentType: string;
16
- resourceIds: string[];
17
- }
18
- type CropSize = {
19
- width: number;
20
- height: number;
21
- } | number;
22
- type CreateFilesMutation = (files: ExtendFile[]) => Promise<string[] | undefined>;
23
- interface FileCreateRequest {
24
- files: Array<{
25
- content_type: keyof typeof ContentType;
26
- name: string;
27
- }>;
28
- }
29
- interface FileCreateResponse {
30
- files: Array<{
31
- id: string;
32
- name: string;
33
- organization_id: string;
34
- url: string;
35
- status: 'PENDING' | 'COMPLETED' | 'FAILED';
36
- content_type: string;
37
- content_length: number;
38
- created_by: string;
39
- created_at: string;
40
- updated_by: string;
41
- updated_at: string;
42
- }>;
43
- }
44
- interface FileQueryRequest {
45
- ids: string[];
46
- }
47
- interface FileQueryResponse {
48
- files: Array<{
49
- id: string;
50
- name: string;
51
- organization_id: string;
52
- url: string;
53
- status: 'PENDING' | 'COMPLETED' | 'FAILED';
54
- content_type: string;
55
- content_length: number;
56
- created_by: string;
57
- created_at: string;
58
- updated_by: string;
59
- updated_at: string;
60
- }>;
61
- }
62
- interface FileGetResponse {
63
- id: string;
64
- name: string;
65
- organization_id: string;
66
- url: string;
67
- status: 'PENDING' | 'COMPLETED' | 'FAILED';
68
- content_type: string;
69
- content_length: number;
70
- created_by: string;
71
- created_at: string;
72
- updated_by: string;
73
- updated_at: string;
74
- }
75
- interface SingleFilePreviewProps extends StackProps {
76
- file: ExtendFile;
77
- aspectRatio?: number;
78
- isLoading?: boolean;
79
- cropSize?: CropSize;
80
- onLoading?: (isLoading: boolean) => void;
81
- isUploading?: boolean;
82
- maxWidth?: number;
83
- maxHeight?: number;
84
- }
85
- interface LoadingPreviewImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
86
- aspectRatio: number;
87
- maxWidth?: number | string;
88
- maxHeight?: number | string;
89
- isLoading?: boolean;
90
- isUploading?: boolean;
91
- cropSize?: CropSize;
92
- onLoading?: (isLoading: boolean) => void;
93
- alt?: string;
94
- src?: string;
95
- loading: 'lazy';
96
- }
97
- interface PlaceholderProps extends StackProps {
98
- header?: React.ReactNode;
99
- description?: React.ReactNode;
100
- }
101
- interface SingleFileUploadProps extends DropzoneOptions {
102
- onFileSelect: (file: ExtendFile, callback: (files: ExtendFile[]) => void) => void;
103
- onRemove?: (file?: ExtendFile) => void;
104
- placeholderProps?: PlaceholderProps;
105
- placeholderAlt?: React.ReactNode;
106
- file?: ExtendFile;
107
- name?: string;
108
- label?: string;
109
- id?: string;
110
- disabled?: boolean;
111
- error?: string;
112
- helperText?: string | React.ReactNode;
113
- sx?: SxProps<Theme>;
114
- dropZoneSxProps?: SxProps<Theme>;
115
- uploading?: boolean;
116
- tabIndex?: number;
117
- maxSize?: number;
118
- }
119
- interface SingleImageUploadProps extends SingleFileUploadProps {
120
- aspectRatio?: number;
121
- enableCrop?: boolean;
122
- convertToWebp?: boolean;
123
- cropSize?: CropSize;
124
- maxWidth?: number;
125
- maxHeight?: number;
126
- }
127
- interface MultiFileUploadProps extends Omit<SingleFileUploadProps, 'file' | 'onFileSelect'> {
128
- onFilesSelect: (files: File[], callback?: (files: ExtendFile[]) => void) => void;
129
- onRemoveAll?: (files?: File | ExtendFile[]) => void;
130
- onReorder?: (oldIndex: number, newIndex: number, files: File | ExtendFile[]) => void;
131
- files?: ExtendFile[];
132
- maxFiles?: number;
133
- thumbnail?: boolean;
134
- }
135
- interface MultiImageUploadProps extends MultiFileUploadProps {
136
- aspectRatio?: number;
137
- enableCrop?: boolean;
138
- convertToWebp?: boolean;
139
- cropSize?: CropSize;
140
- maxWidth?: number;
141
- maxHeight?: number;
142
- }
143
- interface SortableItemProps extends StackProps {
144
- onRemove?: (file?: ExtendFile) => void;
145
- file?: ExtendFile;
146
- thumbnail?: boolean;
147
- disableDrag?: boolean;
148
- }
149
- interface MultiFilePreviewProps extends StackProps {
150
- onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
151
- onRemove?: (file?: ExtendFile) => void;
152
- files: ExtendFile[];
153
- lastNode?: React.ReactNode;
154
- firstNode?: React.ReactNode;
155
- thumbnail: boolean;
156
- slotProps?: {
157
- thumbnail?: Omit<FileThumbnailProps, 'file'>;
158
- };
159
- }
160
- interface StyledDropZoneProps extends StackProps {
161
- isDragActive: boolean;
162
- isError: boolean;
163
- disabled: boolean;
164
- }
165
- type StyledDropZonePropsType = Omit<DropzoneRootProps, 'children' | 'onDrop' | 'onError'> & StyledDropZoneProps;
166
- interface RejectionFilesProps extends StackProps {
167
- files: FileRejection[];
168
- }
169
- interface ThumbnailBadgeProps {
170
- onRemove?: (file?: ExtendFile) => void;
171
- file: ExtendFile;
172
- attributes: DraggableAttributes;
173
- listeners: DraggableSyntheticListeners;
174
- innerWidth: number;
175
- isDragging: boolean;
176
- disableDrag?: boolean;
177
- sx?: SxProps<Theme>;
178
- }
179
- interface DropZoneProps {
180
- sx?: SxProps;
181
- uploading?: boolean;
182
- id?: string;
183
- tabIndex?: number;
184
- getRootProps: () => DropzoneRootProps;
185
- getInputProps: () => DropzoneInputProps;
186
- isDragActive: boolean;
187
- isError: boolean;
188
- disabled?: boolean;
189
- dropZoneSxProps?: SxProps<Theme>;
190
- dropZoneContent?: React.ReactNode;
191
- children?: React.ReactNode;
192
- name?: string;
193
- }
194
- interface FileUploadProps {
195
- createFilesMutation: (params: FileCreateRequest) => {
196
- unwrap: () => Promise<FileCreateResponse>;
197
- };
198
- filesUrl: Array<string | undefined>;
199
- }
200
- interface HelperTextProps {
201
- helperText?: string | React.ReactNode;
202
- disabled?: boolean;
203
- isError?: boolean;
204
- }
205
- interface UseDropzoneUploaderProps {
206
- onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
207
- onFileSelect?: (file: File, callback: (files: ExtendFile[]) => void) => void;
208
- onFilesSelect?: (files: File[], callback: (files: ExtendFile[]) => void) => void;
209
- onRemove?: (file?: ExtendFile) => void;
210
- filesPreview?: ExtendFile[];
211
- dropzoneOptions?: Omit<DropzoneOptions, 'onDrop' | 'onDropRejected'>;
212
- enableCrop?: boolean;
213
- customAspectRatio?: number;
214
- convertToWebp?: boolean;
215
- maxFiles?: number;
216
- cropSize?: {
217
- width: number;
218
- height: number;
219
- } | number;
220
- uploading?: boolean;
221
- }
222
- interface UseDropzoneUploaderReturn {
223
- file: ExtendFile | null;
224
- files: ExtendFile[];
225
- aspectRatio: number;
226
- dropzoneProps: {
227
- getRootProps: ReturnType<typeof useDropzone>['getRootProps'];
228
- getInputProps: ReturnType<typeof useDropzone>['getInputProps'];
229
- isDragActive: boolean;
230
- isDragReject: boolean;
231
- fileRejections: readonly FileRejection[];
232
- };
233
- cropState: {
234
- cropModalOpen: boolean;
235
- imagePreview: string;
236
- cropLoading: boolean;
237
- setCropModalOpen: React.Dispatch<React.SetStateAction<boolean>>;
238
- onCropInitialized: (croppedArea: Area, croppedAreaPixels: Area) => void;
239
- handleCropSave: () => Promise<void>;
240
- handleCropCancel: () => void;
241
- currentImageIndex: number;
242
- totalPendingImages: number;
243
- };
244
- setInitialFiles?: (files: ExtendFile[]) => void;
245
- handleRemove: (fileToRemove?: ExtendFile) => void;
246
- handleReorder: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
247
- }
248
- declare enum ContentType {
249
- APPLICATION_OCTET_STREAM = "application/octet-stream",
250
- IMAGE_JPEG = "image/jpeg",
251
- IMAGE_JPG = "image/jpg",
252
- IMAGE_PNG = "image/png",
253
- IMAGE_GIF = "image/gif",
254
- IMAGE_WEBP = "image/webp",
255
- IMAGE_SVG = "image/svg+xml",
256
- IMAGE_BMP = "image/bmp",
257
- IMAGE_TIFF = "image/tiff",
258
- IMAGE_ICO = "image/x-icon",
259
- IMAGE_AVIF = "image/avif",
260
- APPLICATION_PDF = "application/pdf",
261
- TEXT_PLAIN = "text/plain",
262
- TEXT_CSV = "text/csv",
263
- APPLICATION_RTF = "application/rtf",
264
- APPLICATION_MSWORD = "application/msword",
265
- APPLICATION_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
266
- APPLICATION_MSEXCEL = "application/vnd.ms-excel",
267
- APPLICATION_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
268
- APPLICATION_MSPOWERPOINT = "application/vnd.ms-powerpoint",
269
- APPLICATION_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
270
- APPLICATION_ODT = "application/vnd.oasis.opendocument.text",
271
- APPLICATION_ODS = "application/vnd.oasis.opendocument.spreadsheet",
272
- APPLICATION_ODP = "application/vnd.oasis.opendocument.presentation",
273
- APPLICATION_XML = "application/xml",
274
- TEXT_XML = "text/xml",
275
- TEXT_HTML = "text/html",
276
- TEXT_CSS = "text/css",
277
- APPLICATION_JSON = "application/json",
278
- TEXT_JAVASCRIPT = "text/javascript",
279
- APPLICATION_ZIP = "application/zip",
280
- APPLICATION_GZIP = "application/gzip",
281
- APPLICATION_RAR = "application/vnd.rar",
282
- APPLICATION_7Z = "application/x-7z-compressed",
283
- AUDIO_MPEG = "audio/mpeg",
284
- AUDIO_WAV = "audio/wav",
285
- AUDIO_OGG = "audio/ogg",
286
- AUDIO_WEBM = "audio/webm",
287
- AUDIO_AAC = "audio/aac",
288
- VIDEO_MP4 = "video/mp4",
289
- VIDEO_MPEG = "video/mpeg",
290
- VIDEO_OGG = "video/ogg",
291
- VIDEO_WEBM = "video/webm",
292
- VIDEO_QUICKTIME = "video/quicktime"
293
- }
294
- declare enum FileContentType {
295
- 'application/octet-stream' = "APPLICATION_OCTET_STREAM",
296
- 'image/jpeg' = "IMAGE_JPEG",
297
- 'image/jpg' = "IMAGE_JPG",
298
- 'image/png' = "IMAGE_PNG",
299
- 'image/gif' = "IMAGE_GIF",
300
- 'image/webp' = "IMAGE_WEBP",
301
- 'image/svg+xml' = "IMAGE_SVG",
302
- 'image/bmp' = "IMAGE_BMP",
303
- 'image/tiff' = "IMAGE_TIFF",
304
- 'image/x-icon' = "IMAGE_ICO",
305
- 'image/avif' = "IMAGE_AVIF",
306
- 'application/pdf' = "APPLICATION_PDF",
307
- 'text/plain' = "TEXT_PLAIN",
308
- 'text/csv' = "TEXT_CSV",
309
- 'application/rtf' = "APPLICATION_RTF",
310
- 'application/msword' = "APPLICATION_MSWORD",
311
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' = "APPLICATION_DOCX",
312
- 'application/vnd.ms-excel' = "APPLICATION_MSEXCEL",
313
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' = "APPLICATION_XLSX",
314
- 'application/vnd.ms-powerpoint' = "APPLICATION_MSPOWERPOINT",
315
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation' = "APPLICATION_PPTX",
316
- 'application/vnd.oasis.opendocument.text' = "APPLICATION_ODT",
317
- 'application/vnd.oasis.opendocument.spreadsheet' = "APPLICATION_ODS",
318
- 'application/vnd.oasis.opendocument.presentation' = "APPLICATION_ODP",
319
- 'application/xml' = "APPLICATION_XML",
320
- 'text/xml' = "TEXT_XML",
321
- 'text/html' = "TEXT_HTML",
322
- 'text/css' = "TEXT_CSS",
323
- 'application/json' = "APPLICATION_JSON",
324
- 'text/javascript' = "TEXT_JAVASCRIPT",
325
- 'application/zip' = "APPLICATION_ZIP",
326
- 'application/gzip' = "APPLICATION_GZIP",
327
- 'application/vnd.rar' = "APPLICATION_RAR",
328
- 'application/x-7z-compressed' = "APPLICATION_7Z",
329
- 'audio/mpeg' = "AUDIO_MPEG",
330
- 'audio/wav' = "AUDIO_WAV",
331
- 'audio/ogg' = "AUDIO_OGG",
332
- 'audio/webm' = "AUDIO_WEBM",
333
- 'audio/aac' = "AUDIO_AAC",
334
- 'video/mp4' = "VIDEO_MP4",
335
- 'video/mpeg' = "VIDEO_MPEG",
336
- 'video/ogg' = "VIDEO_OGG",
337
- 'video/webm' = "VIDEO_WEBM",
338
- 'video/quicktime' = "VIDEO_QUICKTIME"
339
- }
340
-
341
- type FileThumbnailProps = StackProps & {
342
- tooltip?: boolean;
343
- file: ExtendFile;
344
- imageView?: boolean;
345
- sx?: SxProps<Theme>;
346
- onDownload?: () => void;
347
- onRemove?: () => void;
348
- slotProps?: {
349
- img?: SxProps<Theme>;
350
- icon?: SxProps<Theme>;
351
- removeBtn?: SxProps<Theme>;
352
- downloadBtn?: SxProps<Theme>;
353
- };
354
- };
355
-
356
- export { ContentType as C, DropZoneProps as D, ExtendFile as E, FileThumbnailProps as F, HelperTextProps as H, LoadingPreviewImageProps as L, MultiFilePreviewProps as M, PlaceholderProps as P, RejectionFilesProps as R, SingleFilePreviewProps as S, ThumbnailBadgeProps as T, UseDropzoneUploaderProps as U, UseDropzoneUploaderReturn as a, FileUploadProps as b, MultiFileUploadProps as c, MultiImageUploadProps as d, SingleFileUploadProps as e, SingleImageUploadProps as f, FileContentType as g, FileUpload as h, CropSize as i, CreateFilesMutation as j, FileCreateRequest as k, FileCreateResponse as l, FileQueryRequest as m, FileQueryResponse as n, FileGetResponse as o, SortableItemProps as p, StyledDropZoneProps as q, StyledDropZonePropsType as r };