@emailmaker/filemanager 0.0.3 → 0.0.4
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/ImageAI/SlideShowForImageAI/SlideShowForImageAI.d.ts +1 -0
- package/components/ImageAI/useImageAIGeneration/useImageAIGeneration.d.ts +1 -1
- package/file-manager.css +1 -1
- package/file-manager.esm.js +1 -1
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- 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/package.json +1 -1
- package/sample-files.json +105 -0
- package/types.d.ts +28 -9
- package/utils/jsonDataProvider.d.ts +60 -0
- package/utils/sortHelpers.d.ts +3 -0
|
@@ -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 {};
|
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
|
@@ -127,6 +127,8 @@ export interface FileManagerDataProviders {
|
|
|
127
127
|
getFiles: (options: {
|
|
128
128
|
folderId?: string;
|
|
129
129
|
search?: string;
|
|
130
|
+
sortBy?: SortState['sortBy'];
|
|
131
|
+
sortOrder?: SortState['sortOrder'];
|
|
130
132
|
}) => Promise<File[]>;
|
|
131
133
|
createFolder: (data: {
|
|
132
134
|
name: string;
|
|
@@ -226,6 +228,12 @@ export interface Config {
|
|
|
226
228
|
locale?: string;
|
|
227
229
|
mode?: 'fileManager' | 'imageCenter' | 'plugin';
|
|
228
230
|
enabledTabs?: string[];
|
|
231
|
+
dataProcessingMode?: 'server' | 'client' | 'auto';
|
|
232
|
+
enableClientSideProcessing?: boolean;
|
|
233
|
+
staticData?: {
|
|
234
|
+
files?: File[];
|
|
235
|
+
folders?: Folder[];
|
|
236
|
+
};
|
|
229
237
|
customTheme?: {
|
|
230
238
|
colors?: {
|
|
231
239
|
primary?: string;
|
|
@@ -265,11 +273,16 @@ export interface Config {
|
|
|
265
273
|
/** billing page url */
|
|
266
274
|
billingPageUrl?: string;
|
|
267
275
|
notification?: void;
|
|
268
|
-
sendAIImageRequest?:
|
|
269
|
-
sseQuery?: () =>
|
|
276
|
+
sendAIImageRequest?: (params: object) => Promise<unknown>;
|
|
277
|
+
sseQuery?: (params: object) => void;
|
|
270
278
|
customLocale?: object;
|
|
271
279
|
activeLibraryItem?: LibraryMenuKey;
|
|
272
280
|
fileForEdit?: string;
|
|
281
|
+
messages?: MessageType[];
|
|
282
|
+
handleLimitUsageEmitter?: {
|
|
283
|
+
fire: (args: object) => void;
|
|
284
|
+
};
|
|
285
|
+
token?: Partial<import('antd/es/theme/interface').AliasToken>;
|
|
273
286
|
}
|
|
274
287
|
export type LibraryMenuKey = typeof MY_FILES | typeof GIF | typeof STOCK_IMAGES | typeof AI | typeof EDITOR;
|
|
275
288
|
export interface GifItem {
|
|
@@ -322,12 +335,11 @@ export interface ImageStockProps {
|
|
|
322
335
|
customRequest: (data: string) => void;
|
|
323
336
|
}
|
|
324
337
|
export interface ImageAIProps {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}) => void;
|
|
338
|
+
customRequest: (file: {
|
|
339
|
+
file: globalThis.File;
|
|
340
|
+
}) => Promise<void | File>;
|
|
329
341
|
aiTabRef: RefObject<HTMLElement>;
|
|
330
|
-
inputAiRef: RefObject<
|
|
342
|
+
inputAiRef: React.RefObject<HTMLTextAreaElement>;
|
|
331
343
|
isImageUploaded: boolean;
|
|
332
344
|
setIsImageUploaded: (val: boolean) => void;
|
|
333
345
|
aiImageRequest: string;
|
|
@@ -342,9 +354,9 @@ export interface ArrowProps {
|
|
|
342
354
|
onClick?: () => void;
|
|
343
355
|
}
|
|
344
356
|
export interface UseImageAIGenerationProps {
|
|
345
|
-
|
|
357
|
+
setFrameHeight: React.Dispatch<React.SetStateAction<string | number>>;
|
|
346
358
|
customRequest: (args: {
|
|
347
|
-
file: File;
|
|
359
|
+
file: globalThis.File;
|
|
348
360
|
}) => void;
|
|
349
361
|
aiTabRef: React.RefObject<HTMLElement>;
|
|
350
362
|
isImageUploaded: boolean;
|
|
@@ -379,4 +391,11 @@ export interface UseImageAIGenerationReturn {
|
|
|
379
391
|
setCurrentReqId: React.Dispatch<React.SetStateAction<string | null>>;
|
|
380
392
|
limitsInPlugin: boolean;
|
|
381
393
|
}
|
|
394
|
+
export type MessageType = {
|
|
395
|
+
status?: string;
|
|
396
|
+
images?: unknown[];
|
|
397
|
+
progress?: number;
|
|
398
|
+
data?: unknown;
|
|
399
|
+
[key: string]: unknown;
|
|
400
|
+
};
|
|
382
401
|
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
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<File[]>;
|
|
21
|
+
createFolder: (data: {
|
|
22
|
+
name: string;
|
|
23
|
+
parentId?: string | null;
|
|
24
|
+
}) => Promise<Folder>;
|
|
25
|
+
deleteFolder: (folderId: string) => Promise<boolean>;
|
|
26
|
+
uploadFile: (file: {
|
|
27
|
+
name: string;
|
|
28
|
+
size: string;
|
|
29
|
+
type: string;
|
|
30
|
+
folderId?: string | null;
|
|
31
|
+
data: Blob | string;
|
|
32
|
+
thumbnail?: string;
|
|
33
|
+
dimensions?: string;
|
|
34
|
+
aspectRatio?: string;
|
|
35
|
+
extension?: string;
|
|
36
|
+
}) => Promise<File>;
|
|
37
|
+
uploadFileByUrl: (data: {
|
|
38
|
+
url: string;
|
|
39
|
+
folderId?: string | null;
|
|
40
|
+
noFolder?: boolean;
|
|
41
|
+
}) => Promise<File>;
|
|
42
|
+
deleteFile: (fileId: string) => Promise<boolean>;
|
|
43
|
+
renameFile: (fileId: string, newName: string) => Promise<File>;
|
|
44
|
+
moveItem: (options: {
|
|
45
|
+
itemId: string;
|
|
46
|
+
targetFolderId: string;
|
|
47
|
+
isFolder: boolean;
|
|
48
|
+
}) => Promise<boolean>;
|
|
49
|
+
private getFileTypeFromExtension;
|
|
50
|
+
exportToJSON: () => {
|
|
51
|
+
files: File[];
|
|
52
|
+
folders: Folder[];
|
|
53
|
+
};
|
|
54
|
+
clear: () => void;
|
|
55
|
+
getStats: () => {
|
|
56
|
+
totalFiles: number;
|
|
57
|
+
totalFolders: number;
|
|
58
|
+
filesByType: Record<string, number>;
|
|
59
|
+
};
|
|
60
|
+
}
|