@emailmaker/filemanager 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/CustomUploadIcon/CustomUploadIcon.d.ts +8 -0
- package/components/CustomUploadIcon/index.d.ts +1 -0
- package/components/FileContent/FileContent.d.ts +2 -2
- package/components/FileManagerApp/FileManagerApp.d.ts +2 -26
- package/components/ImageAI/SlideShowForImageAI/SlideShowForImageAI.d.ts +1 -0
- package/components/ImageAI/useImageAIGeneration/useImageAIGeneration.d.ts +1 -1
- package/components/SafeImage/SafeImage.d.ts +3 -0
- package/components/SafeImage/index.d.ts +1 -0
- package/components/index.d.ts +2 -0
- package/constants/index.d.ts +3 -0
- package/file-manager.css +1906 -1
- package/file-manager.esm.js +27110 -1
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/file-manager.js.LICENSE.txt +15 -0
- package/helpers/files/index.d.ts +2 -0
- package/hooks/core/files/useFilesAPI.d.ts +1 -0
- package/hooks/core/useFiles.d.ts +1 -0
- package/hooks/useHybridSortAndFilter.d.ts +24 -0
- package/hooks/useNotifications.d.ts +8 -0
- package/package.json +1 -1
- package/sample-files.json +105 -0
- package/types.d.ts +69 -10
- package/utils/imageCache.d.ts +10 -0
- package/utils/jsonDataProvider.d.ts +63 -0
- package/utils/sortHelpers.d.ts +3 -0
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
15
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
17
|
+
|
|
18
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
19
|
+
and limitations under the License.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
|
|
7
22
|
/**
|
|
8
23
|
* @license
|
|
9
24
|
* Lodash <https://lodash.com/>
|
|
@@ -12,5 +12,6 @@ export interface UseFilesAPIActions {
|
|
|
12
12
|
handleAddFileByUrl: (url?: string | null, noFolder?: boolean) => Promise<AppFile | void>;
|
|
13
13
|
handleDroppedFiles: (droppedFiles: globalThis.File[]) => Promise<void>;
|
|
14
14
|
getFileData: (fileId: string) => Promise<Blob | undefined>;
|
|
15
|
+
uploadFileWithProvider: (file: globalThis.File) => Promise<void>;
|
|
15
16
|
}
|
|
16
17
|
export declare const useFilesAPI: () => UseFilesAPIActions;
|
package/hooks/core/useFiles.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface UseFilesActions {
|
|
|
30
30
|
showCopyModal: () => void;
|
|
31
31
|
handleCopyCancel: () => void;
|
|
32
32
|
handleCopyOk: () => Promise<void>;
|
|
33
|
+
uploadFileWithProvider: (file: globalThis.File) => Promise<AppFile | void>;
|
|
33
34
|
}
|
|
34
35
|
export declare const useFiles: () => FileManagerHookBase & {
|
|
35
36
|
state: UseFilesState;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { File, FilesQueryParams, Config } from '../types';
|
|
2
|
+
import { SortByType, SortOrderType } from './core/types';
|
|
3
|
+
interface UseHybridSortAndFilterProps {
|
|
4
|
+
files: File[];
|
|
5
|
+
config?: Config;
|
|
6
|
+
onServerRequest?: (params: FilesQueryParams) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
interface UseHybridSortAndFilterReturn {
|
|
9
|
+
processedFiles: File[];
|
|
10
|
+
handleSearch: (searchTerm: string) => void;
|
|
11
|
+
handleSort: (sortBy: SortByType, sortOrder: SortOrderType) => void;
|
|
12
|
+
handlePaginationChange: (page: number, pageSize?: number) => void;
|
|
13
|
+
isClientSideProcessing: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const useHybridSortAndFilter: ({ files, config, onServerRequest, }: UseHybridSortAndFilterProps) => UseHybridSortAndFilterReturn;
|
|
16
|
+
export declare const useClientSideFileProcessing: (files: File[], searchTerm: string, sortBy: SortByType, sortOrder: SortOrderType, currentPage?: number, pageSize?: number) => {
|
|
17
|
+
processedFiles: File[];
|
|
18
|
+
paginatedFiles: File[];
|
|
19
|
+
totalFiles: number;
|
|
20
|
+
totalPages: number;
|
|
21
|
+
hasNextPage: boolean;
|
|
22
|
+
hasPrevPage: boolean;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useNotifications: () => {
|
|
2
|
+
error: (args: import("antd").NotificationArgsProps) => void;
|
|
3
|
+
open: (args: import("antd").NotificationArgsProps) => void;
|
|
4
|
+
success: (args: import("antd").NotificationArgsProps) => void;
|
|
5
|
+
info: (args: import("antd").NotificationArgsProps) => void;
|
|
6
|
+
warning: (args: import("antd").NotificationArgsProps) => void;
|
|
7
|
+
destroy(key?: React.Key): void;
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
{
|
|
4
|
+
"id": "sample-1",
|
|
5
|
+
"name": "Красивый закат.jpg",
|
|
6
|
+
"size": "2845",
|
|
7
|
+
"date": "2024-01-15T10:30:00Z",
|
|
8
|
+
"folderId": "",
|
|
9
|
+
"type": "image",
|
|
10
|
+
"url": "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400&h=300&fit=crop",
|
|
11
|
+
"thumbnailUrl": "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=150&h=100&fit=crop",
|
|
12
|
+
"extension": "jpg",
|
|
13
|
+
"isFolder": false,
|
|
14
|
+
"selected": false,
|
|
15
|
+
"dimensions": "1920x1080",
|
|
16
|
+
"aspectRatio": "16:9"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "sample-2",
|
|
20
|
+
"name": "Горы и озеро.jpg",
|
|
21
|
+
"size": "3200",
|
|
22
|
+
"date": "2024-01-10T14:20:00Z",
|
|
23
|
+
"folderId": "nature-folder",
|
|
24
|
+
"type": "image",
|
|
25
|
+
"url": "https://images.unsplash.com/photo-1464822759380-8ed769e99d5c?w=400&h=300&fit=crop",
|
|
26
|
+
"thumbnailUrl": "https://images.unsplash.com/photo-1464822759380-8ed769e99d5c?w=150&h=100&fit=crop",
|
|
27
|
+
"extension": "jpg",
|
|
28
|
+
"isFolder": false,
|
|
29
|
+
"selected": false,
|
|
30
|
+
"dimensions": "1920x1280",
|
|
31
|
+
"aspectRatio": "3:2"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "sample-3",
|
|
35
|
+
"name": "Отчет_2024.pdf",
|
|
36
|
+
"size": "1250",
|
|
37
|
+
"date": "2024-01-12T09:15:00Z",
|
|
38
|
+
"folderId": "documents-folder",
|
|
39
|
+
"type": "document",
|
|
40
|
+
"url": "https://via.placeholder.com/400x300/2196F3/white?text=PDF+Document",
|
|
41
|
+
"thumbnailUrl": "https://via.placeholder.com/150x100/2196F3/white?text=PDF",
|
|
42
|
+
"extension": "pdf",
|
|
43
|
+
"isFolder": false,
|
|
44
|
+
"selected": false
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "sample-4",
|
|
48
|
+
"name": "Презентация.pptx",
|
|
49
|
+
"size": "4500",
|
|
50
|
+
"date": "2024-01-08T16:45:00Z",
|
|
51
|
+
"folderId": "documents-folder",
|
|
52
|
+
"type": "document",
|
|
53
|
+
"url": "https://via.placeholder.com/400x300/FF9800/white?text=PowerPoint",
|
|
54
|
+
"thumbnailUrl": "https://via.placeholder.com/150x100/FF9800/white?text=PPT",
|
|
55
|
+
"extension": "pptx",
|
|
56
|
+
"isFolder": false,
|
|
57
|
+
"selected": false
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "sample-5",
|
|
61
|
+
"name": "Лес в тумане.jpg",
|
|
62
|
+
"size": "2100",
|
|
63
|
+
"date": "2024-01-05T11:30:00Z",
|
|
64
|
+
"folderId": "nature-folder",
|
|
65
|
+
"type": "image",
|
|
66
|
+
"url": "https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=400&h=300&fit=crop",
|
|
67
|
+
"thumbnailUrl": "https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=150&h=100&fit=crop",
|
|
68
|
+
"extension": "jpg",
|
|
69
|
+
"isFolder": false,
|
|
70
|
+
"selected": false,
|
|
71
|
+
"dimensions": "1920x1280",
|
|
72
|
+
"aspectRatio": "3:2"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "sample-6",
|
|
76
|
+
"name": "Архивные_данные.zip",
|
|
77
|
+
"size": "15600",
|
|
78
|
+
"date": "2024-01-01T08:00:00Z",
|
|
79
|
+
"folderId": "",
|
|
80
|
+
"type": "archive",
|
|
81
|
+
"url": "https://via.placeholder.com/400x300/795548/white?text=ZIP+Archive",
|
|
82
|
+
"thumbnailUrl": "https://via.placeholder.com/150x100/795548/white?text=ZIP",
|
|
83
|
+
"extension": "zip",
|
|
84
|
+
"isFolder": false,
|
|
85
|
+
"selected": false
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"folders": [
|
|
89
|
+
{
|
|
90
|
+
"id": "nature-folder",
|
|
91
|
+
"name": "🌲 Природа",
|
|
92
|
+
"parentId": null
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"id": "documents-folder",
|
|
96
|
+
"name": "📄 Документы",
|
|
97
|
+
"parentId": null
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "photos-subfolder",
|
|
101
|
+
"name": "📷 Фотографии",
|
|
102
|
+
"parentId": "nature-folder"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import React, { ReactNode, RefObject } from 'react';
|
|
|
2
2
|
import { FormInstance } from 'antd/es/form';
|
|
3
3
|
import { MY_FILES, GIF, STOCK_IMAGES, AI, EDITOR } from './constants';
|
|
4
4
|
import type { InputRef } from 'antd';
|
|
5
|
+
import { NotificationInstance } from 'antd/es/notification/interface';
|
|
5
6
|
export interface Folder {
|
|
6
7
|
id: string;
|
|
7
8
|
name: string;
|
|
@@ -120,6 +121,7 @@ export interface FileManagerOptions {
|
|
|
120
121
|
publicPath?: string;
|
|
121
122
|
customIcons?: CustomIcons;
|
|
122
123
|
dragDropIcon?: string;
|
|
124
|
+
notification?: Partial<Omit<NotificationInstance, 'destroy'>>;
|
|
123
125
|
}
|
|
124
126
|
export interface FileManagerDataProviders {
|
|
125
127
|
getFile: (fileId: string) => Promise<Blob>;
|
|
@@ -127,7 +129,14 @@ export interface FileManagerDataProviders {
|
|
|
127
129
|
getFiles: (options: {
|
|
128
130
|
folderId?: string;
|
|
129
131
|
search?: string;
|
|
130
|
-
|
|
132
|
+
sortBy?: SortState['sortBy'];
|
|
133
|
+
sortOrder?: SortState['sortOrder'];
|
|
134
|
+
page?: number;
|
|
135
|
+
limit?: number;
|
|
136
|
+
}) => Promise<{
|
|
137
|
+
files: File[];
|
|
138
|
+
pagination?: Partial<ApiPaginationResponse>;
|
|
139
|
+
}>;
|
|
131
140
|
createFolder: (data: {
|
|
132
141
|
name: string;
|
|
133
142
|
parentId?: string | null;
|
|
@@ -226,6 +235,12 @@ export interface Config {
|
|
|
226
235
|
locale?: string;
|
|
227
236
|
mode?: 'fileManager' | 'imageCenter' | 'plugin';
|
|
228
237
|
enabledTabs?: string[];
|
|
238
|
+
dataProcessingMode?: 'server' | 'client' | 'auto';
|
|
239
|
+
enableClientSideProcessing?: boolean;
|
|
240
|
+
staticData?: {
|
|
241
|
+
files?: File[];
|
|
242
|
+
folders?: Folder[];
|
|
243
|
+
};
|
|
229
244
|
customTheme?: {
|
|
230
245
|
colors?: {
|
|
231
246
|
primary?: string;
|
|
@@ -265,11 +280,16 @@ export interface Config {
|
|
|
265
280
|
/** billing page url */
|
|
266
281
|
billingPageUrl?: string;
|
|
267
282
|
notification?: void;
|
|
268
|
-
sendAIImageRequest?:
|
|
269
|
-
sseQuery?: () =>
|
|
283
|
+
sendAIImageRequest?: (params: object) => Promise<unknown>;
|
|
284
|
+
sseQuery?: (params: object) => void;
|
|
270
285
|
customLocale?: object;
|
|
271
286
|
activeLibraryItem?: LibraryMenuKey;
|
|
272
287
|
fileForEdit?: string;
|
|
288
|
+
messages?: MessageType[];
|
|
289
|
+
handleLimitUsageEmitter?: {
|
|
290
|
+
fire: (args: object) => void;
|
|
291
|
+
};
|
|
292
|
+
token?: Partial<import('antd/es/theme/interface').AliasToken>;
|
|
273
293
|
}
|
|
274
294
|
export type LibraryMenuKey = typeof MY_FILES | typeof GIF | typeof STOCK_IMAGES | typeof AI | typeof EDITOR;
|
|
275
295
|
export interface GifItem {
|
|
@@ -322,12 +342,11 @@ export interface ImageStockProps {
|
|
|
322
342
|
customRequest: (data: string) => void;
|
|
323
343
|
}
|
|
324
344
|
export interface ImageAIProps {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}) => void;
|
|
345
|
+
customRequest: (file: {
|
|
346
|
+
file: globalThis.File;
|
|
347
|
+
}) => Promise<void | File>;
|
|
329
348
|
aiTabRef: RefObject<HTMLElement>;
|
|
330
|
-
inputAiRef: RefObject<
|
|
349
|
+
inputAiRef: RefObject<HTMLTextAreaElement>;
|
|
331
350
|
isImageUploaded: boolean;
|
|
332
351
|
setIsImageUploaded: (val: boolean) => void;
|
|
333
352
|
aiImageRequest: string;
|
|
@@ -342,9 +361,9 @@ export interface ArrowProps {
|
|
|
342
361
|
onClick?: () => void;
|
|
343
362
|
}
|
|
344
363
|
export interface UseImageAIGenerationProps {
|
|
345
|
-
|
|
364
|
+
setFrameHeight: React.Dispatch<React.SetStateAction<string | number>>;
|
|
346
365
|
customRequest: (args: {
|
|
347
|
-
file: File;
|
|
366
|
+
file: globalThis.File;
|
|
348
367
|
}) => void;
|
|
349
368
|
aiTabRef: React.RefObject<HTMLElement>;
|
|
350
369
|
isImageUploaded: boolean;
|
|
@@ -379,4 +398,44 @@ export interface UseImageAIGenerationReturn {
|
|
|
379
398
|
setCurrentReqId: React.Dispatch<React.SetStateAction<string | null>>;
|
|
380
399
|
limitsInPlugin: boolean;
|
|
381
400
|
}
|
|
401
|
+
export type MessageType = {
|
|
402
|
+
status?: string;
|
|
403
|
+
images?: unknown[];
|
|
404
|
+
progress?: number;
|
|
405
|
+
data?: unknown;
|
|
406
|
+
[key: string]: unknown;
|
|
407
|
+
};
|
|
408
|
+
export interface FileManagerProps {
|
|
409
|
+
publicPath?: string;
|
|
410
|
+
config?: Config;
|
|
411
|
+
currentPath?: string;
|
|
412
|
+
onPathChange?: (path: string[]) => void;
|
|
413
|
+
onChangeSelection?: (files: File[]) => void;
|
|
414
|
+
searchQuery?: string;
|
|
415
|
+
sortBySize?: string;
|
|
416
|
+
dataProviders?: FileManagerDataProviders;
|
|
417
|
+
apiEndpoints?: {
|
|
418
|
+
getFolders?: string;
|
|
419
|
+
getFiles?: string;
|
|
420
|
+
createFolder?: string;
|
|
421
|
+
deleteFolder?: string;
|
|
422
|
+
addFile?: string;
|
|
423
|
+
deleteFile?: string;
|
|
424
|
+
renameFile?: string;
|
|
425
|
+
moveFile?: string;
|
|
426
|
+
updateFile?: string;
|
|
427
|
+
};
|
|
428
|
+
customIcons?: CustomIcons;
|
|
429
|
+
dragDropIcon?: string;
|
|
430
|
+
notification?: Partial<Omit<NotificationInstance, 'destroy'>>;
|
|
431
|
+
}
|
|
432
|
+
export interface SafeImageProps {
|
|
433
|
+
src?: string;
|
|
434
|
+
alt: string;
|
|
435
|
+
className?: string;
|
|
436
|
+
width?: number;
|
|
437
|
+
height?: number;
|
|
438
|
+
preview?: boolean;
|
|
439
|
+
file?: File;
|
|
440
|
+
}
|
|
382
441
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const getCachedImage: (fileId: string) => string | undefined;
|
|
2
|
+
export declare const setCachedImage: (fileId: string, imageData: string) => void;
|
|
3
|
+
export declare const hasCachedImage: (fileId: string) => boolean;
|
|
4
|
+
export declare const getImageCacheStats: () => {
|
|
5
|
+
size: number;
|
|
6
|
+
maxSize: number;
|
|
7
|
+
cleanupBatchSize: number;
|
|
8
|
+
usage: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const clearImageCache: () => void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FileManagerDataProviders, File, Folder, Config } from '../types';
|
|
2
|
+
export declare class JSONDataProvider implements FileManagerDataProviders {
|
|
3
|
+
private files;
|
|
4
|
+
private folders;
|
|
5
|
+
constructor(config?: Config);
|
|
6
|
+
loadFromJSON: (data: {
|
|
7
|
+
files?: File[];
|
|
8
|
+
folders?: Folder[];
|
|
9
|
+
}) => void;
|
|
10
|
+
loadFromURL: (url: string) => Promise<void>;
|
|
11
|
+
addFiles: (newFiles: File[]) => void;
|
|
12
|
+
addFolders: (newFolders: Folder[]) => void;
|
|
13
|
+
getFile: (fileId: string) => Promise<Blob>;
|
|
14
|
+
getFolders: () => Promise<Folder[]>;
|
|
15
|
+
getFiles: (options?: {
|
|
16
|
+
folderId?: string;
|
|
17
|
+
search?: string;
|
|
18
|
+
sortBy?: "name" | "size" | "date" | "type";
|
|
19
|
+
sortOrder?: "asc" | "desc";
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
files: File[];
|
|
22
|
+
total: number;
|
|
23
|
+
}>;
|
|
24
|
+
createFolder: (data: {
|
|
25
|
+
name: string;
|
|
26
|
+
parentId?: string | null;
|
|
27
|
+
}) => Promise<Folder>;
|
|
28
|
+
deleteFolder: (folderId: string) => Promise<boolean>;
|
|
29
|
+
uploadFile: (file: {
|
|
30
|
+
name: string;
|
|
31
|
+
size: string;
|
|
32
|
+
type: string;
|
|
33
|
+
folderId?: string | null;
|
|
34
|
+
data: Blob | string;
|
|
35
|
+
thumbnail?: string;
|
|
36
|
+
dimensions?: string;
|
|
37
|
+
aspectRatio?: string;
|
|
38
|
+
extension?: string;
|
|
39
|
+
}) => Promise<File>;
|
|
40
|
+
uploadFileByUrl: (data: {
|
|
41
|
+
url: string;
|
|
42
|
+
folderId?: string | null;
|
|
43
|
+
noFolder?: boolean;
|
|
44
|
+
}) => Promise<File>;
|
|
45
|
+
deleteFile: (fileId: string) => Promise<boolean>;
|
|
46
|
+
renameFile: (fileId: string, newName: string) => Promise<File>;
|
|
47
|
+
moveItem: (options: {
|
|
48
|
+
itemId: string;
|
|
49
|
+
targetFolderId: string;
|
|
50
|
+
isFolder: boolean;
|
|
51
|
+
}) => Promise<boolean>;
|
|
52
|
+
private getFileTypeFromExtension;
|
|
53
|
+
exportToJSON: () => {
|
|
54
|
+
files: File[];
|
|
55
|
+
folders: Folder[];
|
|
56
|
+
};
|
|
57
|
+
clear: () => void;
|
|
58
|
+
getStats: () => {
|
|
59
|
+
totalFiles: number;
|
|
60
|
+
totalFolders: number;
|
|
61
|
+
filesByType: Record<string, number>;
|
|
62
|
+
};
|
|
63
|
+
}
|