@emailmaker/filemanager 0.10.68 → 0.10.69

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.
@@ -1,8 +1,13 @@
1
1
  import { FormInstance } from 'antd/es/form';
2
- import { File, Folder, FileManagerDataProviders, PaginationState, PathItem, MenuItem, FilesQueryParams, LibraryMenuKey } from '../../types';
2
+ import { File, Folder, FileManagerDataProviders, PaginationState, PathItem, MenuItem, FilesQueryParams, LibraryMenuKey, SortOptionType } from '../../types';
3
3
  export type SortByType = 'name' | 'size' | 'date' | 'type';
4
4
  export type SortOrderType = 'asc' | 'desc';
5
- export type SortOptionType = 'date-desc' | 'date-asc' | 'size-desc' | 'size-asc' | 'name-asc' | 'name-desc' | 'type-asc';
5
+ export type { SortOptionType };
6
+ /** Полный список опций сортировки в дропдауне (порядок отображения). */
7
+ export declare const ALL_SORT_OPTIONS: {
8
+ value: SortOptionType;
9
+ labelKey: string;
10
+ }[];
6
11
  export declare const parseSortOption: (option: SortOptionType) => {
7
12
  sortBy: SortByType;
8
13
  sortOrder: SortOrderType;
package/index.d.ts CHANGED
@@ -17,7 +17,7 @@ export { FileContent } from './components/FileContent/FileContent';
17
17
  export { FileModals } from './components/FileModals/FileModals';
18
18
  export { FolderSidebar } from './components/FolderSidebar/FolderSidebar';
19
19
  export { installResizeObserverErrorHandler, uninstallResizeObserverErrorHandler } from './utils/resizeObserverHandler';
20
- export { type Folder, type File, type PathItem, type MenuItem, type FileManagerOptions, type FileManagerHookReturn, type FileManagerErrorCode, type IFileManagerApiError, } from './types';
20
+ export { type Folder, type File, type PathItem, type MenuItem, type FileManagerOptions, type FileManagerHookReturn, type FileManagerErrorCode, type IFileManagerApiError, type SortOptionType, } from './types';
21
21
  export { FileManagerApiError } from './shared/fileManagerApiError';
22
22
  export { mapHttpStatusToErrorCode } from './shared/mapHttpStatusToErrorCode';
23
23
  export { type InitPixieEditorOptions, type Options as FileManagerInitOptions, type UniversalInitOptions, } from './file-manager';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailmaker/filemanager",
3
- "version": "0.10.68",
3
+ "version": "0.10.69",
4
4
  "main": "./file-manager.js",
5
5
  "module": "./file-manager.esm.js",
6
6
  "types": "./index.d.ts",
@@ -6,5 +6,7 @@ export interface FileListContext {
6
6
  folderFileCounts: Record<string, number>;
7
7
  features: Record<string, boolean | undefined>;
8
8
  t: TFunction;
9
+ /** См. Config.previewFallbackToFileUrl */
10
+ previewFallbackToFileUrl?: boolean;
9
11
  }
10
12
  export declare const fileListAdapter: ListItemAdapter<AppFile, FileListContext, FileListRowModel>;
@@ -8,6 +8,7 @@ interface UseFileListEngineParams {
8
8
  features: Record<string, boolean | undefined>;
9
9
  t: TFunction;
10
10
  viewMode: 'table' | 'grid';
11
+ previewFallbackToFileUrl?: boolean;
11
12
  }
12
13
  interface UseFileListEngineResult {
13
14
  rowModels: FileListRowModel[];
@@ -22,5 +23,5 @@ interface UseFileListEngineResult {
22
23
  * Здесь файловый менеджер только передаёт сырые данные и контекст derive-логики,
23
24
  * а само ядро уже отвечает за reuse row-model и подготовку render-window.
24
25
  */
25
- export declare function useFileListEngine({ files, folderFileCounts, features, t, viewMode, }: UseFileListEngineParams): UseFileListEngineResult;
26
+ export declare function useFileListEngine({ files, folderFileCounts, features, t, viewMode, previewFallbackToFileUrl, }: UseFileListEngineParams): UseFileListEngineResult;
26
27
  export {};
package/types.d.ts CHANGED
@@ -44,8 +44,11 @@ export interface PixieSavePayload {
44
44
  blob: UploadBinary;
45
45
  mimeType: string;
46
46
  thumbnail: string;
47
+ /** Обычное сохранение или «Сохранить как копию». */
47
48
  mode: 'save' | 'saveCopy';
48
49
  }
50
+ /** Передаётся вторым аргументом в `onEditorOk` после сохранения из Pixie. */
51
+ export type EditorSaveMeta = Pick<PixieSavePayload, 'mode'>;
49
52
  export interface PathItem {
50
53
  id: string;
51
54
  name: string;
@@ -152,7 +155,7 @@ export interface FileManagerOptions {
152
155
  id: string;
153
156
  folderId: string | undefined;
154
157
  name: string;
155
- }) => void | Promise<void>;
158
+ }, meta?: EditorSaveMeta) => void | Promise<void>;
156
159
  config?: Config;
157
160
  customIcons?: CustomIcons;
158
161
  dragDropIcon?: string;
@@ -368,6 +371,8 @@ interface Limits {
368
371
  export type CustomTheme = Partial<import('antd/es/theme/interface').AliasToken> & {
369
372
  [key: string]: string | number | boolean | undefined;
370
373
  };
374
+ /** Варианты комбинированной сортировки в списке файлов (значение Select). */
375
+ export type SortOptionType = 'date-desc' | 'date-asc' | 'size-desc' | 'size-asc' | 'name-asc' | 'name-desc' | 'type-asc';
371
376
  export interface Config {
372
377
  theme?: 'light' | 'dark' | 'system';
373
378
  disableMockServer?: boolean;
@@ -406,10 +411,24 @@ export interface Config {
406
411
  dataProcessingMode?: 'server' | 'client' | 'auto';
407
412
  enableClientSideProcessing?: boolean;
408
413
  disablePagination?: boolean;
409
- /** При false (или при disablePagination) — пагинации нет, фронт проверяет дубликаты имён и добавляет _1 */
414
+ /** При false (или при disablePagination) — пагинации нет в UI и в запросах списка (без page/limit). */
410
415
  hasPagination?: boolean;
411
- /** Наличие пагинации. При false проверка дубликатов имён папок при создании и при copy/move */
416
+ /** Наличие пагинации на бэкенде (отображение постраничности и т.п.). */
412
417
  paginationAvailable?: boolean;
418
+ /**
419
+ * Клиент устраняет дубликаты имён при загрузке, копии из Pixie, URL, batch, copy/move, создании папки.
420
+ * Отдельно от настроек пагинации (`disablePagination`, `hasPagination`, `paginationAvailable`).
421
+ */
422
+ dedupeUploadNamesOnClient?: boolean;
423
+ /**
424
+ * Если нет thumbnail/thumbnailUrl, для превью в таблице/плитке использовать `file.url` (только изображения).
425
+ */
426
+ previewFallbackToFileUrl?: boolean;
427
+ /**
428
+ * Сохранять копию из Pixie в текущую папку исходного файла.
429
+ * По умолчанию copy-save идёт через `noFolder` во временную папку на стороне хоста.
430
+ */
431
+ saveCopyToCurrentFolder?: boolean;
413
432
  enableTrashFolder?: boolean;
414
433
  staticData?: {
415
434
  files?: File[];
@@ -462,6 +481,8 @@ export interface Config {
462
481
  /** Alias для compessorUrl с корректным написанием. */
463
482
  compressorUrl?: string;
464
483
  multiSelect?: boolean;
484
+ /** Белый список сортировок для отображения в дропдауне. Если не указан — доступны все. */
485
+ sortOptions?: SortOptionType[];
465
486
  defaultFolderName?: string;
466
487
  availableImageExtensions?: Array<(typeof IMAGE_EXTENSIONS)[number]>;
467
488
  /** Настройки обработки имен файлов при загрузке */
@@ -635,7 +656,7 @@ export interface FileManagerProps {
635
656
  id: string;
636
657
  folderId: string | undefined;
637
658
  name: string;
638
- }) => void;
659
+ }, meta?: EditorSaveMeta) => void;
639
660
  searchQuery?: string;
640
661
  sortBySize?: string;
641
662
  dataProviders?: FileManagerDataProviders;
@@ -0,0 +1,6 @@
1
+ import type { Config } from '../types';
2
+ /**
3
+ * Флаг `Config.dedupeUploadNamesOnClient`: клиент подбирает уникальные имена при загрузке,
4
+ * копии из Pixie, upload по URL, batch, copy/move, создании папки.
5
+ */
6
+ export declare function isDedupeUploadNamesOnClientEnabled(config?: Pick<Config, 'dedupeUploadNamesOnClient'>): boolean;
@@ -0,0 +1,5 @@
1
+ import type { FileManagerDataProviders } from '../types';
2
+ /**
3
+ * Уникальное имя файла в папке (клиент), если включён `Config.dedupeUploadNamesOnClient`.
4
+ */
5
+ export declare function resolveUniqueUploadNameWithProvider(dataProviders: FileManagerDataProviders | undefined, originalName: string, folderId?: string | null, noFolder?: boolean, dedupeUploadNamesOnClient?: boolean): Promise<string>;
@@ -3,3 +3,8 @@
3
3
  * Убирает hash, трекинговые query-параметры, нормализует host и сортирует query.
4
4
  */
5
5
  export declare function normalizeExternalFileUrl(url: string): string;
6
+ /**
7
+ * Совпадает ли origin URL с текущей страницей (protocol + host + port).
8
+ * Для same-origin прокси не используем — загрузка напрямую.
9
+ */
10
+ export declare function isUrlSameOriginAsCurrentPage(url: string): boolean;
@@ -2,6 +2,7 @@ type TFunction = (key: string) => string;
2
2
  /**
3
3
  * Валидация URL на фронте без дополнительных запросов.
4
4
  * Проверяет: формат, протокол (только http/https), SSRF (localhost, приватные IP).
5
+ * Если приложение открыто с localhost, URL на localhost разрешены (удобство локальной разработки).
5
6
  *
6
7
  * @param url - строка URL для проверки
7
8
  * @param t - функция перевода для сообщений об ошибках