@emailmaker/filemanager 0.10.47 → 0.10.48
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/file-manager.css +30 -2
- package/file-manager.esm.js +9 -9
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/hooks/core/files/useFilesAPI.d.ts +1 -1
- package/notification.d.ts +11 -0
- package/package.json +1 -1
- package/types.d.ts +2 -0
- package/utils/errorMessages.d.ts +17 -0
- package/utils/fileValidation.d.ts +1 -0
- package/utils/svgParseUtils.d.ts +47 -0
|
@@ -8,7 +8,7 @@ export interface UseFilesAPIActions {
|
|
|
8
8
|
onStartBatch?: (files: globalThis.File[]) => void;
|
|
9
9
|
onProgress: (fileName: string, progress: number) => void;
|
|
10
10
|
onComplete: (fileName: string) => void;
|
|
11
|
-
onError: (fileName: string, error: string) => void;
|
|
11
|
+
onError: (fileName: string, error: string, index?: number) => void;
|
|
12
12
|
onBatchComplete?: (result: {
|
|
13
13
|
files: globalThis.File[];
|
|
14
14
|
successes: string[];
|
package/notification.d.ts
CHANGED
|
@@ -181,6 +181,7 @@ declare namespace Notify {
|
|
|
181
181
|
export interface OperationSuccessPayload extends ItemContextPayload {
|
|
182
182
|
successCount: number;
|
|
183
183
|
totalCount: number;
|
|
184
|
+
eventSource?: UploadEventSource;
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
/**
|
|
@@ -205,6 +206,7 @@ declare namespace Notify {
|
|
|
205
206
|
* Used to differentiate between soft delete (trash) and hard delete operations.
|
|
206
207
|
*/
|
|
207
208
|
isTrashMove?: boolean;
|
|
209
|
+
eventSource?: UploadEventSource;
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
/**
|
|
@@ -273,11 +275,17 @@ declare namespace Notify {
|
|
|
273
275
|
error: FileManageErrorInfo;
|
|
274
276
|
}
|
|
275
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Source of the upload event: 'upload' for file picker/drag-drop, 'uploadByUrl' for URL upload.
|
|
280
|
+
*/
|
|
281
|
+
export type UploadEventSource = 'upload' | 'uploadByUrl';
|
|
282
|
+
|
|
276
283
|
/**
|
|
277
284
|
* Payload for file upload operations.
|
|
278
285
|
*/
|
|
279
286
|
export interface FileUploadPayload extends SingleItemPayload {
|
|
280
287
|
uploadId?: string;
|
|
288
|
+
eventSource?: UploadEventSource;
|
|
281
289
|
}
|
|
282
290
|
|
|
283
291
|
/**
|
|
@@ -326,6 +334,7 @@ declare namespace Notify {
|
|
|
326
334
|
url?: string | null;
|
|
327
335
|
folderId?: string | null;
|
|
328
336
|
folderName?: string | null;
|
|
337
|
+
eventSource?: UploadEventSource;
|
|
329
338
|
}
|
|
330
339
|
|
|
331
340
|
/**
|
|
@@ -550,6 +559,8 @@ declare namespace Notify {
|
|
|
550
559
|
FILE_UPLOAD_ITEM_SUCCESS: FileUploadPayload;
|
|
551
560
|
|
|
552
561
|
TRASH_CLEARED_SUCCESS: never;
|
|
562
|
+
|
|
563
|
+
FOLDER_NOT_FOUND_NAVIGATE: never;
|
|
553
564
|
}
|
|
554
565
|
|
|
555
566
|
/**
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -392,6 +392,8 @@ export interface Config {
|
|
|
392
392
|
customTheme?: CustomTheme;
|
|
393
393
|
UNSPLASH_KEY?: string;
|
|
394
394
|
APP_NAME_UNSPLASH?: string;
|
|
395
|
+
/** Ключ Streamline API (добавляется на прокси, не передаётся с клиента). */
|
|
396
|
+
STREAMLINE_API_KEY?: string;
|
|
395
397
|
/** Переопределение URL прокси Streamline (по умолчанию /streamline). Ключ добавляется на прокси. */
|
|
396
398
|
STREAMLINE_BASE_URL?: string;
|
|
397
399
|
handleTranslate?: (input: string, opts: {
|
package/utils/errorMessages.d.ts
CHANGED
|
@@ -24,6 +24,23 @@ export declare const inferErrorCodeFromMessageForUrlUpload: (message: string | u
|
|
|
24
24
|
* Пытается извлечь IFileManagerApiError из unknown.
|
|
25
25
|
*/
|
|
26
26
|
export declare const asFileManagerApiError: (error: unknown) => FileManageErrorInfo;
|
|
27
|
+
/** Ключ для сообщения о размере файла с параметрами */
|
|
28
|
+
export declare const FILE_TOO_LARGE_WITH_SIZE_KEY = "File too large ({{size}}). Maximum allowed size: {{maxSize}}";
|
|
29
|
+
/** Ключ для превышения лимита файлов в батче (allowed, received) */
|
|
30
|
+
export declare const BATCH_ITEM_LIMIT_EXCEEDED_WITH_COUNT_KEY = "Maximum number of files exceeded. Allowed: {{allowed}}, received: {{received}}";
|
|
31
|
+
/**
|
|
32
|
+
* Возвращает сообщение об ошибке для отображения при загрузке.
|
|
33
|
+
* Поддерживает параметры для FileTooLarge (size, maxSize) и BatchItemLimitExceeded/exceeded_max_files (allowed, received).
|
|
34
|
+
*/
|
|
35
|
+
export declare const getUploadErrorMessage: (error: unknown, t: TFunction, context?: {
|
|
36
|
+
fileSize?: number;
|
|
37
|
+
maxSize?: number;
|
|
38
|
+
}) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Проверяет, что ошибка — path_folder_not_found (папка уже не существует).
|
|
41
|
+
* При удалении это считается успехом — цель достигнута.
|
|
42
|
+
*/
|
|
43
|
+
export declare const isPathFolderNotFoundError: (error: unknown) => boolean;
|
|
27
44
|
/**
|
|
28
45
|
* Возвращает сообщение для отображения при ошибке загрузки по URL.
|
|
29
46
|
* Приоритет: код ошибки → понятное сообщение бэкенда → общий fallback.
|
|
@@ -32,6 +32,7 @@ export declare const validateFileUrl: (url: string) => Promise<FileValidationRes
|
|
|
32
32
|
export declare const getFileCategory: (file: File) => string;
|
|
33
33
|
export declare const formatFileSize: (bytes: number) => string;
|
|
34
34
|
export declare const formatFileSizeShort: (bytes?: number) => string;
|
|
35
|
+
export declare const formatFileSizeDisplay: (value?: number | string) => string;
|
|
35
36
|
/**
|
|
36
37
|
* Генерирует уникальное имя файла: если name уже есть в existingNames, добавляет _1 (или _2, _3 и т.д.).
|
|
37
38
|
* @param name — исходное имя файла (с расширением)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Утилиты для парсинга SVG: определение количества цветов, толщины линий и стиля иконок.
|
|
3
|
+
* Поддерживает атрибуты и inline style, градиенты (linear и radial), различные форматы цветов.
|
|
4
|
+
*/
|
|
5
|
+
/** Конвертирует цвет в hex для ColorPicker (rgb, rgba, имя → #rrggbb) */
|
|
6
|
+
export declare function colorToHex(raw: string): string;
|
|
7
|
+
/** Нормализует цвет к hex для сравнения (без учёта прозрачности для уникальности) */
|
|
8
|
+
export declare function normalizeColorForCompare(raw: string): string | null;
|
|
9
|
+
export interface SvgParseResult {
|
|
10
|
+
/** Уникальные цвета (fill/stroke/stop-color) */
|
|
11
|
+
colors: string[];
|
|
12
|
+
/** Количество элементов с fill */
|
|
13
|
+
fillsCount: number;
|
|
14
|
+
/** Количество элементов с stroke */
|
|
15
|
+
strokesCount: number;
|
|
16
|
+
/** Есть градиенты */
|
|
17
|
+
hasGradient: boolean;
|
|
18
|
+
/** Извлечённый stroke-width или undefined */
|
|
19
|
+
strokeWidth: number | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Парсит SVG и возвращает метаданные для определения стиля family */
|
|
22
|
+
export declare function parseSvgForFamily(svg: string): SvgParseResult;
|
|
23
|
+
/** Агрегирует результаты по нескольким SVG */
|
|
24
|
+
export declare function aggregateSvgParseResults(results: SvgParseResult[]): SvgParseResult;
|
|
25
|
+
/**
|
|
26
|
+
* Строит карту: нормализованный цвет → индекс переменной (1, 2, 3...).
|
|
27
|
+
* Порядок — по первому появлению цвета (сначала svg, затем shape-элементы).
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildFillColorToVarIndexMap(svg: string): Map<string, number>;
|
|
30
|
+
/**
|
|
31
|
+
* Единая карта цветов: fill и stroke в порядке появления.
|
|
32
|
+
* Используется для правильного отображения обводки (stroke) как отдельного цвета.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildUnifiedColorToVarIndexMap(svg: string): Map<string, number>;
|
|
35
|
+
/** Аналогично для stroke. Учитывает stroke на <svg> — наследуется paths. */
|
|
36
|
+
export declare function buildStrokeColorToVarIndexMap(svg: string): Map<string, number>;
|
|
37
|
+
/**
|
|
38
|
+
* Извлекает цвета из SVG в том же порядке, что и buildUnifiedColorToVarIndexMap.
|
|
39
|
+
* Возвращает [color1, color2, color3] — сырые значения для пикеров.
|
|
40
|
+
*/
|
|
41
|
+
export declare function extractColorsInUnifiedOrder(svg: string): string[];
|
|
42
|
+
/** Извлекает цвета для установки в пикеры (stops, fills, strokes по приоритету) */
|
|
43
|
+
export declare function extractColorsForPickers(svg: string): {
|
|
44
|
+
fills: string[];
|
|
45
|
+
strokes: string[];
|
|
46
|
+
stops: string[];
|
|
47
|
+
};
|