@mcurros2/microm 1.1.345-0 → 1.1.346-0

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/dist/index.d.ts CHANGED
@@ -1122,7 +1122,7 @@ export class FileStoreProcessDef extends EntityDefinition {
1122
1122
  export class FileStoreProcess extends Entity<FileStoreProcessDef> {
1123
1123
  constructor(client: MicroMClient, parentKeys?: {});
1124
1124
  }
1125
- interface ImageEditorProps {
1125
+ export interface ImageEditorProps {
1126
1126
  sourceFile: File;
1127
1127
  options: ResolvedBrowserImageProcessingOptions;
1128
1128
  onSave: (file: File) => Promise<void> | void;
@@ -1145,11 +1145,9 @@ export interface UploadProgressReport {
1145
1145
  vc_fileguid?: string;
1146
1146
  thumbnailURL?: string;
1147
1147
  }
1148
- export interface UseFileUploadReturnType {
1149
- uploadFiles: (selectedFiles: File[]) => Promise<UploadProgressReport[]>;
1150
- editImage: (report: UploadProgressReport) => Promise<UploadProgressReport | null>;
1151
- deleteFile: (fileGUID: string) => Promise<DBStatusResult>;
1152
- downloadFile: (fileUrl: string, fileName?: string) => Promise<void>;
1148
+ export interface UseFileUploadSnapshot {
1149
+ files: readonly UploadProgressReport[];
1150
+ /** @deprecated Use files instead. */
1153
1151
  uploadProgress: Record<string, UploadProgressReport>;
1154
1152
  fileProcessID: string;
1155
1153
  maxIndividualFileSize?: number;
@@ -1158,17 +1156,36 @@ export interface UseFileUploadReturnType {
1158
1156
  errorNotification?: string;
1159
1157
  cancelledNotification?: boolean;
1160
1158
  uploadingNotification?: boolean;
1161
- clearNotifications?: () => void;
1162
- cancelUpload?: () => void;
1163
1159
  loadingNotification?: boolean;
1160
+ processing: boolean;
1161
+ editorEnabled: boolean;
1162
+ }
1163
+ interface UseFileUploadActions {
1164
+ uploadFiles: (selectedFiles: File[]) => Promise<UploadProgressReport[]>;
1165
+ replaceFile: (fileGUID: string, replacementFile: File) => Promise<UploadProgressReport | null>;
1166
+ editImage: (file: string | UploadProgressReport) => Promise<UploadProgressReport | null>;
1167
+ openImageEditor: (file: File) => Promise<File | null>;
1168
+ canEditImage: (file: string | UploadProgressReport) => boolean;
1169
+ refreshFiles: () => Promise<Record<string, UploadProgressReport>>;
1170
+ deleteFile: (fileGUID: string) => Promise<DBStatusResult>;
1171
+ downloadFile: (fileUrl: string, fileName?: string) => Promise<void>;
1172
+ clearNotifications: () => void;
1173
+ cancelUpload: () => void;
1174
+ }
1175
+ export interface UseFileUploadReturnType extends UseFileUploadSnapshot, UseFileUploadActions {
1176
+ subscribe: (listener: () => void) => () => void;
1177
+ getSnapshot: () => UseFileUploadSnapshot;
1164
1178
  }
1179
+ export function useFileUploadSnapshot(uploadAPI: UseFileUploadReturnType): UseFileUploadSnapshot;
1165
1180
  export type ValidateFileReturnType = {
1166
1181
  error: boolean;
1167
1182
  message?: string;
1168
1183
  };
1169
1184
  export type UploadCompletionResult = ValidateFileReturnType & {
1185
+ /** @deprecated Uploaded files now remain in the canonical files list until deleted. */
1170
1186
  removeFromQueue?: boolean;
1171
1187
  };
1188
+ export type ImageEditorConfigurationProps = Partial<Pick<ImageEditorProps, 'saveLabel' | 'cancelLabel' | 'rotateClockwiseLabel' | 'rotateCounterClockwiseLabel'>>;
1172
1189
  export interface UseFileUploadProps {
1173
1190
  client: MicroMClient;
1174
1191
  fileProcessColumn: EntityColumn<string>;
@@ -1182,9 +1199,14 @@ export interface UseFileUploadProps {
1182
1199
  totalUploadExceedsMaximumSizeText?: string;
1183
1200
  onCancel?: () => void;
1184
1201
  editor?: boolean;
1202
+ imageProcessing?: BrowserImageProcessingOptions;
1203
+ imageEditorTitle?: ReactNode;
1204
+ imageEditorProps?: ImageEditorConfigurationProps;
1205
+ imageEditorModalProps?: MicroMModalSettings;
1185
1206
  onValidateFile?: (file: File) => Promise<ValidateFileReturnType>;
1186
1207
  onProcessFile?: (file: File) => Promise<File | null>;
1187
1208
  onBeforeUpload?: (file: File) => Promise<boolean>;
1209
+ onBeforeReplace?: (currentFile: UploadProgressReport, replacementFile?: File) => Promise<boolean>;
1188
1210
  onUploadComplete?: (report: UploadProgressReport) => Promise<UploadCompletionResult | void>;
1189
1211
  thumbnailMaxSize?: number;
1190
1212
  thumbnailQuality?: number;
@@ -1200,7 +1222,7 @@ export interface FileUploaderProps extends Omit<DropzoneProps, 'children' | 'onD
1200
1222
  FilesText?: string;
1201
1223
  EachFileShouldNotExceedText?: string;
1202
1224
  uploadAPI: UseFileUploadReturnType;
1203
- onDelete?: (fileGUID: string) => boolean;
1225
+ onDelete?: (fileGUID: string) => boolean | Promise<boolean>;
1204
1226
  imageProps?: ImageProps;
1205
1227
  closeText?: string;
1206
1228
  cancelledText?: string;
@@ -1211,17 +1233,21 @@ export interface FileUploaderProps extends Omit<DropzoneProps, 'children' | 'onD
1211
1233
  parentFormAPI?: UseEntityFormReturnType;
1212
1234
  editor?: boolean;
1213
1235
  editImageLabel?: string;
1236
+ replaceFileGUID?: string;
1237
+ replaceExistingFile?: boolean;
1214
1238
  }
1215
1239
  export const FileUploaderDefaultProps: Partial<FileUploaderProps>;
1216
1240
  export function FileUploader(props: FileUploaderProps): JSX.Element;
1217
1241
  export interface FilesUploadFormProps extends UseFileUploadProps {
1218
1242
  fileProcessColumn: EntityColumn<string>;
1219
1243
  onOK?: (fileprocess_id: string, uploadProgress: Record<string, UploadProgressReport>) => void;
1220
- onDelete?: (fileGUID: string) => boolean;
1244
+ onDelete?: (fileGUID: string) => boolean | Promise<boolean>;
1221
1245
  helpMessage?: string;
1222
- uploaderProps?: Omit<FileUploaderProps, 'uploadAPI' | 'abortSignal' | 'editor'>;
1246
+ uploaderProps?: Omit<FileUploaderProps, 'uploadAPI' | 'editor'>;
1223
1247
  okLabel?: string;
1224
1248
  showOKButton?: boolean;
1249
+ /** Reuse an existing hook instance instead of creating an uploader owned by this form. */
1250
+ uploadAPI?: UseFileUploadReturnType;
1225
1251
  }
1226
1252
  export const FilesUploadFormDefaultProps: Partial<FilesUploadFormProps>;
1227
1253
  export function FilesUploadForm(props: FilesUploadFormProps): JSX.Element;
@@ -1233,8 +1259,9 @@ export interface ModalFileUploadProps {
1233
1259
  onClosed?: () => void;
1234
1260
  modalProps?: ModalSettings;
1235
1261
  modalTitle?: string;
1236
- filesUploadFormProps: Omit<FilesUploadFormProps, 'fileProcessColumn' | 'uploaderProps' | 'client' | 'onOK' | 'onCancel'>;
1237
- uploaderProps?: Omit<FileUploaderProps, 'uploadAPI' | 'abortSignal' | 'editor'>;
1262
+ uploadAPI?: UseFileUploadReturnType;
1263
+ filesUploadFormProps: Omit<FilesUploadFormProps, 'fileProcessColumn' | 'uploaderProps' | 'client' | 'onOK' | 'onCancel' | 'uploadAPI'>;
1264
+ uploaderProps?: Omit<FileUploaderProps, 'uploadAPI' | 'editor'>;
1238
1265
  }
1239
1266
  export const UseFileUploadFormOpenDefaultProps: Partial<ModalFileUploadProps>;
1240
1267
  export function useFilesUploadForm(): (props: ModalFileUploadProps) => Promise<void>;