@zydon/common 2.7.15 → 2.7.17

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