@emailmaker/filemanager 0.10.89 → 0.10.90

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 (35) hide show
  1. package/{129.533eb7b36d92578d2ead.js → 129.1f7048a0e93daec2ca44.js} +27 -27
  2. package/adapters/DataSourceProxyBase.d.ts +225 -0
  3. package/adapters/FailedRequestCache.d.ts +20 -0
  4. package/adapters/MutationRegistry.d.ts +6 -0
  5. package/adapters/PathAwareStorageAdapter.d.ts +70 -0
  6. package/adapters/TreeCache.d.ts +181 -0
  7. package/components/FileContent/renderers/FileTableView.d.ts +1 -1
  8. package/components/FileModals/FileModals.d.ts +1 -1
  9. package/components/Tag/index.d.ts +1 -1
  10. package/file-manager-IconsTab-CgBriMBe.js +2 -0
  11. package/file-manager-ImageCodeGenerator-BoVEEDJM.js +2 -0
  12. package/file-manager-JsBarcode-rSv58QnO.js +2 -0
  13. package/file-manager-browser-Bk6AOO-_.js +2 -0
  14. package/file-manager-index-B3Ea-yTf.js +10 -0
  15. package/file-manager.css +176 -160
  16. package/file-manager.esm.js +1 -1
  17. package/file-manager.js +10499 -61577
  18. package/{fm-icons-tab.d9174776dd6a2cd3d05e.js → fm-icons-tab.9fb59ff579663a515590.js} +19 -21
  19. package/{fm-image-code-generator.078531875a31b8f35911.js → fm-image-code-generator.50fded261e49f2abdf2b.js} +46 -47
  20. package/helpers/urls.d.ts +1 -0
  21. package/hooks/core/types.d.ts +1 -1
  22. package/hooks/core/useFolders.d.ts +1 -1
  23. package/hooks/notifications/index.d.ts +1 -1
  24. package/hooks/notifications/useNotificationsBase.d.ts +9 -0
  25. package/hooks/useFolderSelectionMenu.d.ts +1 -1
  26. package/index.d.ts +7 -0
  27. package/notification.d.ts +7 -1
  28. package/package.json +8 -2
  29. package/types/storage.d.ts +411 -0
  30. package/types.d.ts +7 -2
  31. package/file-manager-IconsTab-BB0044jH.js +0 -2
  32. package/file-manager-ImageCodeGenerator-D7H2_EZi.js +0 -2
  33. package/file-manager-JsBarcode-CB7r374U.js +0 -2
  34. package/file-manager-browser-C6quQUxe.js +0 -2
  35. package/file-manager-index-D14X20BS.js +0 -62
@@ -0,0 +1,411 @@
1
+ /**
2
+ * Storage-provider contract types.
3
+ * These types define the interface between the file-manager package and any backend storage implementation.
4
+ */
5
+ export type MayBePromise<T> = T | Promise<T>;
6
+ export interface FileManagerApiErrorInfo {
7
+ message?: string;
8
+ code?: string | number;
9
+ status?: number;
10
+ raw?: unknown;
11
+ stack?: string;
12
+ }
13
+ export interface OperationResult<T = void> {
14
+ /**
15
+ * Unique identifier of the item that was processed.
16
+ * This should match the ID of the original item from the request.
17
+ */
18
+ requestId?: string;
19
+ success?: boolean;
20
+ data?: T;
21
+ error?: FileManagerApiErrorInfo;
22
+ }
23
+ export type BatchResult<T> = {
24
+ success: boolean;
25
+ error?: FileManagerApiErrorInfo;
26
+ detailed?: OperationResult<T>[];
27
+ };
28
+ /**
29
+ * File information.
30
+ */
31
+ export interface FileSystemItem {
32
+ /** Unique file identifier */
33
+ id: string;
34
+ /** File name */
35
+ name: string;
36
+ /** Identifier of the folder the file belongs to. Empty string means root; null means no folder assigned. */
37
+ folderId: string | null;
38
+ /** Item type - file or folder */
39
+ isFolder?: boolean;
40
+ /** File size */
41
+ size?: number;
42
+ /** File creation or upload date */
43
+ date?: string;
44
+ /** File MIME type */
45
+ type?: string;
46
+ /** File download URL (used if `getFile` method is not implemented) */
47
+ url?: string;
48
+ /** File thumbnail */
49
+ thumbnail?: string;
50
+ /** Alternative thumbnail URL */
51
+ thumbnailUrl?: string;
52
+ /** Image dimensions (width x height) */
53
+ dimensions?: string;
54
+ /** Aspect ratio */
55
+ aspectRatio?: string;
56
+ /** File extension */
57
+ extension?: string;
58
+ /** Whether the file is selected in the UI */
59
+ selected?: boolean;
60
+ /** Date when the file was last edited */
61
+ lastEdited?: string;
62
+ /** Number of children items (for folders) */
63
+ childrenCount?: number;
64
+ }
65
+ /**
66
+ * Represents partial updates to a file system item after an operation.
67
+ * Contains only the fields that were changed during the operation.
68
+ */
69
+ export type FileSystemItemUpdate = Partial<FileSystemItem> & {
70
+ id: string;
71
+ };
72
+ /**
73
+ * Options for {@link StorageProvider.getFileData} when loading file bytes (blob).
74
+ */
75
+ export interface GetFileDataOptions {
76
+ /**
77
+ * When `true`, bypass the HTTP cache (`fetch` with `cache: 'no-store'`).
78
+ * When `false`, allow normal browser caching.
79
+ * When omitted, normal browser caching is used unless a caller applies a one-shot bypass after overwrite.
80
+ */
81
+ forceReload?: boolean;
82
+ }
83
+ /**
84
+ * API response with pagination details.
85
+ */
86
+ export interface StorageApiPaginationResponse {
87
+ /** Current page number */
88
+ page: number;
89
+ /** Number of items per page */
90
+ limit: number;
91
+ /** Total number of items */
92
+ total: number;
93
+ /** Total number of pages */
94
+ totalPages: number;
95
+ /** Whether there is a next page */
96
+ hasNext: boolean;
97
+ /** Whether there is a previous page */
98
+ hasPrev: boolean;
99
+ }
100
+ /**
101
+ * Sorting state.
102
+ */
103
+ export interface StorageSortState {
104
+ /** Field to sort by */
105
+ sortBy: 'name' | 'size' | 'date' | 'type';
106
+ /** Sort order */
107
+ sortOrder: 'asc' | 'desc';
108
+ }
109
+ export interface StorageProviderController {
110
+ /**
111
+ * Invalidates the cache for a specific file system item.
112
+ *
113
+ * This method should be called when an item's data has changed externally
114
+ * and the cached version is no longer valid. After invalidation, the next
115
+ * access to this item will trigger a fresh fetch from the storage backend.
116
+ *
117
+ * @param itemId - The unique identifier of the file or folder to invalidate
118
+ */
119
+ invalidateItemCache(itemId: string): void;
120
+ /**
121
+ * Retrieves a cached file system item.
122
+ *
123
+ * @param itemId - The unique identifier of the file or folder
124
+ * @returns The cached item or undefined if not found in cache
125
+ */
126
+ getCachedItem(itemId: string): FileSystemItem | undefined;
127
+ }
128
+ export interface StorageUploadFileItemInput {
129
+ /**
130
+ * Arbitrary identifier used to match an upload result with this item.
131
+ * If not provided, the result is matched by the order of items.
132
+ */
133
+ requestId?: string;
134
+ /** File name. */
135
+ name: string;
136
+ /** File size in bytes. */
137
+ size: number;
138
+ /** MIME type of the file. */
139
+ type: string;
140
+ /** Target folder ID, or null if not applicable. */
141
+ folderId?: string | null;
142
+ /** File data as a Blob or File. */
143
+ data: Blob | File;
144
+ /** Optional file extension. */
145
+ extension?: string;
146
+ }
147
+ export interface StorageUploadFilesRequest {
148
+ /**
149
+ * List of files to upload. The order of items matters — if `requestId`
150
+ * is omitted, results are matched to items by index.
151
+ */
152
+ items: StorageUploadFileItemInput[];
153
+ /** Target folder ID for batch upload, or null. */
154
+ folderId?: string | null;
155
+ }
156
+ /**
157
+ * Interface for storage providers.
158
+ * Defines the contract for different storage backends (e.g., cloud APIs, REST services).
159
+ */
160
+ export interface StorageProvider {
161
+ /**
162
+ * @default false
163
+ * Client-side check for existing files or folders
164
+ */
165
+ validateDuplicates?: boolean;
166
+ /**
167
+ * Use the path as an identifier for folders
168
+ */
169
+ pathMode?: boolean;
170
+ /**
171
+ * Custom identifier for the root folder.
172
+ * - This ID will be used internally for the root of the file tree.
173
+ * - Defaults to an empty string `''` if not provided.
174
+ */
175
+ rootId?: string;
176
+ /**
177
+ * Path to the trash/recycle bin folder.
178
+ * - Used when `useSoftDelete` is enabled or for trash operations.
179
+ * - The provider will resolve this path to an actual folder ID.
180
+ */
181
+ trashPath?: string;
182
+ /**
183
+ * Path to the temporary folder for uploads and transient files.
184
+ * - Used for operations where temporary storage is needed.
185
+ * - The provider will resolve this path to an actual folder ID.
186
+ */
187
+ tempPath?: string;
188
+ /**
189
+ * @default true
190
+ */
191
+ ensureFolderTrailingSlash?: boolean;
192
+ /**
193
+ * Utility method for finding system files/folders by path.
194
+ * By default, searches for folders through getFiles method.
195
+ *
196
+ * @param path - Path to the file or folder
197
+ * @returns The found item or undefined if not found
198
+ */
199
+ findItemByPath?(path: string): MayBePromise<FileSystemItem | undefined>;
200
+ /**
201
+ * Clear cache for the specified folder path.
202
+ * @param pathFolder - Path to folder inside project
203
+ */
204
+ clearCache?(pathFolder?: string | null): MayBePromise<void>;
205
+ /**
206
+ * Sets the controller for cache management.
207
+ *
208
+ * This method provides the storage provider with a controller interface
209
+ * that allows it to communicate cache invalidation requests back to the file manager.
210
+ *
211
+ * @param controller - The controller instance for cache management
212
+ */
213
+ setController?(controller: StorageProviderController): MayBePromise<void>;
214
+ /**
215
+ * Enables client-side soft delete implementation.
216
+ * When enabled, delete operations will move items to trashPath instead of permanent deletion.
217
+ *
218
+ * @note If your backend already implements soft delete, keep this disabled
219
+ * to avoid double soft-delete logic.
220
+ *
221
+ * @default false
222
+ */
223
+ useSoftDelete?: boolean;
224
+ /**
225
+ * Retrieve the file content as a binary blob.
226
+ *
227
+ * ⚠️ If this method is not implemented, the file will be downloaded
228
+ * using the `url` property from the `FileInfo` object.
229
+ *
230
+ * @param file - File object
231
+ * @param options - See {@link GetFileDataOptions}
232
+ * @returns File contents as a Blob
233
+ */
234
+ getFileData?: (file: FileSystemItem, options?: GetFileDataOptions) => MayBePromise<Blob>;
235
+ /**
236
+ * Get URL for file access
237
+ * @param file - File object
238
+ * @returns File URL
239
+ */
240
+ getUrl?: (file: FileSystemItem) => MayBePromise<string>;
241
+ /**
242
+ * Get thumbnail URL for file
243
+ * @param file - File object
244
+ * @returns Thumbnail URL
245
+ */
246
+ getThumbnailUrl?: (file: FileSystemItem) => MayBePromise<string>;
247
+ /**
248
+ * Retrieve a list of files and folders.
249
+ * Supports filtering, sorting, and pagination.
250
+ *
251
+ * @param options.folderId - Parent folder (or undefined for root)
252
+ * @param options.search - Search query
253
+ * @param options.sortBy - Field to sort by
254
+ * @param options.sortOrder - Sort direction
255
+ * @param options.page - Page number
256
+ * @param options.limit - Number of items per page
257
+ * @param options.itemType - Filter by item type
258
+ * @returns List of files/folders and optional pagination details
259
+ */
260
+ getItems: (options: {
261
+ folderId?: string;
262
+ search?: string;
263
+ sortBy?: StorageSortState['sortBy'];
264
+ sortOrder?: StorageSortState['sortOrder'];
265
+ page?: number;
266
+ limit?: number;
267
+ itemType: 'all' | 'file' | 'folder';
268
+ }) => MayBePromise<{
269
+ items: FileSystemItem[];
270
+ pagination?: Partial<StorageApiPaginationResponse>;
271
+ }>;
272
+ /**
273
+ * Create a new folder.
274
+ *
275
+ * @param name - Folder name
276
+ * @param parent - Parent folder (or undefined for root)
277
+ * @returns The created folder object
278
+ */
279
+ createFolder: (name: string, parentid?: string, is_force_create?: boolean) => MayBePromise<FileSystemItem>;
280
+ /**
281
+ * Rename an item (file or folder).
282
+ *
283
+ * @param options.item - Item to rename (file or folder)
284
+ * @param options.newName - New item name
285
+ * @returns Updated item with changed fields
286
+ */
287
+ renameItem?: (item: FileSystemItem, newName: string) => MayBePromise<FileSystemItemUpdate>;
288
+ /**
289
+ * Delete an item (file or folder).
290
+ * When useSoftDelete is enabled, moves item to trashPath instead of permanent deletion.
291
+ *
292
+ * @param item - Item to delete (file or folder)
293
+ * @throws {Error} If deletion fails
294
+ */
295
+ deleteItem?: (item: FileSystemItem, options: {
296
+ permanent: boolean;
297
+ }) => MayBePromise<void>;
298
+ /**
299
+ * Upload a file.
300
+ *
301
+ * @param file.name - File name
302
+ * @param file.size - File size
303
+ * @param file.type - MIME type
304
+ * @param file.folderId - Target folder (or undefined for root)
305
+ * @param file.data - File data
306
+ * @returns The uploaded file with changed fields
307
+ */
308
+ uploadFile?: (file: {
309
+ name: string;
310
+ size: number;
311
+ type: string;
312
+ folderId?: string;
313
+ data: Blob | File;
314
+ thumbnail?: string;
315
+ dimensions?: string;
316
+ aspectRatio?: string;
317
+ extension?: string;
318
+ }) => MayBePromise<FileSystemItemUpdate>;
319
+ /**
320
+ * Uploads multiple files and returns a batch result containing metadata
321
+ * for each uploaded file.
322
+ */
323
+ uploadFiles?: (request: StorageUploadFilesRequest) => MayBePromise<BatchResult<FileSystemItem>>;
324
+ /**
325
+ * Upload a file by URL.
326
+ *
327
+ * ⚠️ Implementation should check if the file already belongs
328
+ * to the current server. If it does, return the existing file object
329
+ * instead of uploading it again.
330
+ *
331
+ * @param url - File URL
332
+ * @param folderId - Target folder (or undefined for root). If not specified,
333
+ * uses the root folder.
334
+ * @param options - Optional. eventSource — upload origin for integrator logic
335
+ * (e.g. disable proxy when uploading from stock sources: imageStock, iconStock, gif).
336
+ * @returns The uploaded or existing complete file object
337
+ */
338
+ uploadFileByUrl: (url: string, folderId?: string, options?: {
339
+ eventSource?: 'upload' | 'uploadByUrl' | 'pixie' | 'iconStock' | 'imageStock' | 'gif';
340
+ }) => MayBePromise<FileSystemItem>;
341
+ /**
342
+ * Delete multiple items (files or folders).
343
+ *
344
+ * @param items - Array of items to delete (files or folders)
345
+ * @param options - Delete options
346
+ * @returns Batch operation result with success/failure details
347
+ */
348
+ deleteItems?: (items: FileSystemItem[], options: {
349
+ permanent: boolean;
350
+ }) => MayBePromise<BatchResult<never>>;
351
+ /**
352
+ * Move a single item to the target folder
353
+ * @param item - Item to move (file or folder)
354
+ * @param targetFolderId - Destination folder. If undefined, uses root folder
355
+ * @returns The moved item with changed fields
356
+ */
357
+ moveItem?: (item: FileSystemItem, targetFolderId?: string) => MayBePromise<FileSystemItemUpdate>;
358
+ /**
359
+ * Move multiple items to the target folder
360
+ * @param items - Array of items to move (files or folders)
361
+ * @param targetFolderId - Destination folder. If undefined, uses root folder
362
+ * @returns Batch operation result with success/failure details
363
+ */
364
+ moveItems?: (items: FileSystemItem[], targetFolderId?: string) => MayBePromise<BatchResult<FileSystemItemUpdate>>;
365
+ /**
366
+ * Clear all items from trash folder permanently
367
+ * @returns Result object with success flag and optional count of deleted items
368
+ */
369
+ cleanTrash?: () => MayBePromise<{
370
+ success: boolean;
371
+ deletedCount?: number;
372
+ }>;
373
+ /**
374
+ * Copy a single item to the target folder
375
+ * @param item - Item to copy (file or folder)
376
+ * @param targetFolderId - Destination folder. If undefined, uses root folder
377
+ * @returns The copied item with changed fields
378
+ */
379
+ copyItem?: (item: FileSystemItem, targetFolderId?: string) => MayBePromise<FileSystemItemUpdate>;
380
+ /**
381
+ * Copy multiple items to the target folder
382
+ * @param items - Array of items to copy (files or folders)
383
+ * @param targetFolderId - Destination folder. If undefined, uses root folder
384
+ * @returns Batch operation result with success/failure details
385
+ */
386
+ copyItems?: (items: FileSystemItem[], targetFolderId?: string) => MayBePromise<BatchResult<FileSystemItemUpdate>>;
387
+ /**
388
+ * Find a file by its URL.
389
+ * Implementation should check if the file already belongs to the current server.
390
+ * @param url - File URL
391
+ * @param folderId - Target folder (or undefined for root)
392
+ * @returns The existing file object if found, otherwise undefined
393
+ */
394
+ findFileByUrl?: (url: string, folderId?: string) => MayBePromise<FileSystemItem | undefined>;
395
+ /**
396
+ * Update file metadata or content.
397
+ *
398
+ * @param file - File to update
399
+ * @param updates - Object with fields to update (name, type, data, thumbnail, etc.)
400
+ * @returns Updated file with changed fields
401
+ */
402
+ updateFile?: (file: FileSystemItem, updates: {
403
+ name?: string;
404
+ type?: string;
405
+ data?: Blob | string;
406
+ thumbnail?: string;
407
+ dimensions?: string;
408
+ aspectRatio?: string;
409
+ extension?: string;
410
+ }) => MayBePromise<FileSystemItemUpdate>;
411
+ }
package/types.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import React, { ReactNode, RefObject } from 'react';
2
- import { FormInstance } from 'antd/es/form';
2
+ import type { FormInstance } from 'antd';
3
3
  import { MY_FILES, GIF, STOCK_IMAGES, ICONS, AI, IMAGE_CODES, EDITOR, IMAGE_EXTENSIONS } from './constants';
4
4
  import type { InputRef } from 'antd';
5
+ import type { TextAreaRef } from 'antd/es/input/TextArea';
5
6
  import type { FileManageErrorInfo, Notify, NotifyEvent } from './notification';
6
7
  export * from './notification';
7
8
  export interface Folder {
@@ -164,6 +165,10 @@ export interface FileManagerOptions {
164
165
  handleNotify?: NotifyListener<NotifyEvent>;
165
166
  handleError?: NotifyListener<Notify.ErrorEvent>;
166
167
  handleSuccess?: NotifyListener<Notify.SuccessEvent>;
168
+ /** Резолвер DOM-контейнера для модальных окон FM.
169
+ * Позволяет направить портал antd Modal внутрь file-manager-modal-root,
170
+ * чтобы модалки оставались в контексте стилей (в т.ч. Shadow DOM). */
171
+ getModalContainer?: () => HTMLElement;
167
172
  }
168
173
  /**
169
174
  * Результат операции
@@ -694,7 +699,7 @@ export interface ImageAIProps {
694
699
  customRequest: (file: {
695
700
  file: globalThis.File;
696
701
  }) => Promise<void | File>;
697
- inputAiRef: RefObject<HTMLTextAreaElement>;
702
+ inputAiRef: RefObject<TextAreaRef>;
698
703
  isImageUploaded: boolean;
699
704
  setIsImageUploaded: (val: boolean) => void;
700
705
  aiImageRequest: string;