@mcurros2/microm 1.1.357-0 → 1.1.360-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 +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9215,7 +9215,7 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9215
9215
|
loadFilesOnMount
|
|
9216
9216
|
]);
|
|
9217
9217
|
(0, $b4te3$react.useEffect)(()=>()=>activeControllerRef.current?.abort(), []);
|
|
9218
|
-
const openImageEditor = (0, $b4te3$react.useCallback)(async (file)=>{
|
|
9218
|
+
const openImageEditor = (0, $b4te3$react.useCallback)(async (file, options)=>{
|
|
9219
9219
|
if (!editor) return null;
|
|
9220
9220
|
if (file) (0, $dE75A.getImageOutputSettings)(file, processingOptions);
|
|
9221
9221
|
return await new Promise(async (resolveEditor)=>{
|
|
@@ -9231,6 +9231,8 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9231
9231
|
sourceFile: file,
|
|
9232
9232
|
options: processingOptions,
|
|
9233
9233
|
...imageEditorProps,
|
|
9234
|
+
initiallyDirty: options?.initiallyDirty ?? !!file,
|
|
9235
|
+
onBeforeSave: options?.onBeforeSave,
|
|
9234
9236
|
onSave: (result)=>settle(result),
|
|
9235
9237
|
onCancel: ()=>settle(null)
|
|
9236
9238
|
}),
|
|
@@ -9259,15 +9261,15 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9259
9261
|
modals,
|
|
9260
9262
|
processingOptions
|
|
9261
9263
|
]);
|
|
9262
|
-
const processSelectedFile = (0, $b4te3$react.useCallback)(async (file)=>{
|
|
9264
|
+
const processSelectedFile = (0, $b4te3$react.useCallback)(async (file, editorOptions)=>{
|
|
9263
9265
|
if (editorProcessedFilesRef.current.has(file)) {
|
|
9264
9266
|
editorProcessedFilesRef.current.delete(file);
|
|
9265
9267
|
return onProcessFile ? await onProcessFile(file) : file;
|
|
9266
9268
|
}
|
|
9267
9269
|
if (onProcessFile) return await onProcessFile(file);
|
|
9268
|
-
if (editor) return await openImageEditor(file);
|
|
9269
|
-
|
|
9270
|
-
return
|
|
9270
|
+
if (editor) return await openImageEditor(file, editorOptions);
|
|
9271
|
+
const processedFile = imageProcessing ? await (0, $dE75A.processImageFileAutomatically)(file, processingOptions) : file;
|
|
9272
|
+
return processedFile;
|
|
9271
9273
|
}, [
|
|
9272
9274
|
editor,
|
|
9273
9275
|
imageProcessing,
|
|
@@ -9293,7 +9295,7 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9293
9295
|
maxTotalFilesSize,
|
|
9294
9296
|
totalUploadExceedsMaximumSizeText
|
|
9295
9297
|
]);
|
|
9296
|
-
const prepareSelectedFile = (0, $b4te3$react.useCallback)(async (file, excludedGUIDs = [])=>{
|
|
9298
|
+
const prepareSelectedFile = (0, $b4te3$react.useCallback)(async (file, excludedGUIDs = [], editorOptions)=>{
|
|
9297
9299
|
if (onValidateFile) {
|
|
9298
9300
|
const validation = await onValidateFile(file);
|
|
9299
9301
|
if (validation.error) {
|
|
@@ -9301,12 +9303,16 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9301
9303
|
return null;
|
|
9302
9304
|
}
|
|
9303
9305
|
}
|
|
9304
|
-
const
|
|
9306
|
+
const saveGuardRunsInEditor = editor === true && !onProcessFile && !editorProcessedFilesRef.current.has(file);
|
|
9307
|
+
const processedFile = await processSelectedFile(file, editorOptions);
|
|
9305
9308
|
if (!processedFile || !validateFileSize(processedFile, excludedGUIDs)) return null;
|
|
9306
9309
|
if (onBeforeUpload && !await onBeforeUpload(processedFile)) return null;
|
|
9310
|
+
if (!saveGuardRunsInEditor && editorOptions?.onBeforeSave && !await editorOptions.onBeforeSave(processedFile)) return null;
|
|
9307
9311
|
return processedFile;
|
|
9308
9312
|
}, [
|
|
9313
|
+
editor,
|
|
9309
9314
|
onBeforeUpload,
|
|
9315
|
+
onProcessFile,
|
|
9310
9316
|
onValidateFile,
|
|
9311
9317
|
processSelectedFile,
|
|
9312
9318
|
validateFileSize
|
|
@@ -9493,11 +9499,14 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9493
9499
|
editor,
|
|
9494
9500
|
findFile
|
|
9495
9501
|
]);
|
|
9496
|
-
const performReplacement = (0, $b4te3$react.useCallback)(async (currentFile, replacementSource, signal)=>{
|
|
9502
|
+
const performReplacement = (0, $b4te3$react.useCallback)(async (currentFile, replacementSource, signal, initiallyDirty = true)=>{
|
|
9497
9503
|
const currentGUID = currentFile.vc_fileguid;
|
|
9498
9504
|
const preparedFile = await prepareSelectedFile(replacementSource, [
|
|
9499
9505
|
currentGUID
|
|
9500
|
-
]
|
|
9506
|
+
], {
|
|
9507
|
+
initiallyDirty: initiallyDirty,
|
|
9508
|
+
onBeforeSave: async (candidateFile)=>!onBeforeReplace || await onBeforeReplace(currentFile, candidateFile)
|
|
9509
|
+
});
|
|
9501
9510
|
if (!preparedFile) return null;
|
|
9502
9511
|
const replacement = await uploadFile(preparedFile, signal);
|
|
9503
9512
|
if (replacement.cancelled) {
|
|
@@ -9562,6 +9571,7 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9562
9571
|
completeUpload,
|
|
9563
9572
|
deleteStoredFile,
|
|
9564
9573
|
loadFilesFromServer,
|
|
9574
|
+
onBeforeReplace,
|
|
9565
9575
|
prepareSelectedFile,
|
|
9566
9576
|
unspecifiedErrorWhenUploadingFileText,
|
|
9567
9577
|
uploadFile
|
|
@@ -9574,7 +9584,6 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9574
9584
|
try {
|
|
9575
9585
|
setErrorNotification(undefined);
|
|
9576
9586
|
setCancelledNotification(false);
|
|
9577
|
-
if (onBeforeReplace && !await onBeforeReplace(currentFile, replacementFile)) return null;
|
|
9578
9587
|
return await performReplacement(currentFile, replacementFile, controller.signal);
|
|
9579
9588
|
} catch (error) {
|
|
9580
9589
|
if (!(error instanceof Error && error.name === 'AbortError')) setErrorNotification(error instanceof Error ? error.message : String(error));
|
|
@@ -9586,7 +9595,6 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9586
9595
|
beginOperation,
|
|
9587
9596
|
findFile,
|
|
9588
9597
|
finishOperation,
|
|
9589
|
-
onBeforeReplace,
|
|
9590
9598
|
performReplacement
|
|
9591
9599
|
]);
|
|
9592
9600
|
const editImage = (0, $b4te3$react.useCallback)(async (file)=>{
|
|
@@ -9597,7 +9605,6 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9597
9605
|
try {
|
|
9598
9606
|
setErrorNotification(undefined);
|
|
9599
9607
|
setCancelledNotification(false);
|
|
9600
|
-
if (onBeforeReplace && !await onBeforeReplace(currentFile)) return null;
|
|
9601
9608
|
const blob = await client.downloadBlob(currentFile.documentURL, controller.signal);
|
|
9602
9609
|
const imageType = (0, $dE75A.getSupportedImageMimeType)(currentFile.file_name, blob.type);
|
|
9603
9610
|
if (!imageType) throw new Error(`The image format "${blob.type || currentFile.file_name}" cannot be processed in the browser.`);
|
|
@@ -9607,7 +9614,7 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9607
9614
|
type: imageType,
|
|
9608
9615
|
lastModified: Date.now()
|
|
9609
9616
|
});
|
|
9610
|
-
return await performReplacement(currentFile, sourceFile, controller.signal);
|
|
9617
|
+
return await performReplacement(currentFile, sourceFile, controller.signal, false);
|
|
9611
9618
|
} catch (error) {
|
|
9612
9619
|
if (!(error instanceof Error && error.name === 'AbortError')) setErrorNotification(error instanceof Error ? error.message : String(error));
|
|
9613
9620
|
return null;
|
|
@@ -9620,7 +9627,6 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9620
9627
|
client,
|
|
9621
9628
|
findFile,
|
|
9622
9629
|
finishOperation,
|
|
9623
|
-
onBeforeReplace,
|
|
9624
9630
|
performReplacement
|
|
9625
9631
|
]);
|
|
9626
9632
|
const captureImage = (0, $b4te3$react.useCallback)(async ()=>{
|
|
@@ -9726,7 +9732,7 @@ function $ad822dbf504c78b4$export$5c1c888d0d490e03(props) {
|
|
|
9726
9732
|
uploadFiles: (selectedFiles)=>actionsRef.current.uploadFiles(selectedFiles),
|
|
9727
9733
|
replaceFile: (fileGUID, replacementFile)=>actionsRef.current.replaceFile(fileGUID, replacementFile),
|
|
9728
9734
|
editImage: (file)=>actionsRef.current.editImage(file),
|
|
9729
|
-
openImageEditor: (file)=>actionsRef.current.openImageEditor(file),
|
|
9735
|
+
openImageEditor: (file, options)=>actionsRef.current.openImageEditor(file, options),
|
|
9730
9736
|
captureImage: ()=>actionsRef.current.captureImage(),
|
|
9731
9737
|
canEditImage: (file)=>actionsRef.current.canEditImage(file),
|
|
9732
9738
|
refreshFiles: ()=>actionsRef.current.refreshFiles(),
|
|
@@ -10008,10 +10014,11 @@ const $0cac5edaa1a7f2eb$export$6e31a2501ac1134a = {
|
|
|
10008
10014
|
rotateClockwiseLabel: 'Rotate right',
|
|
10009
10015
|
rotateCounterClockwiseLabel: 'Rotate left',
|
|
10010
10016
|
takePhotoLabel: 'Take photo',
|
|
10011
|
-
camera: true
|
|
10017
|
+
camera: true,
|
|
10018
|
+
initiallyDirty: true
|
|
10012
10019
|
};
|
|
10013
10020
|
const $0cac5edaa1a7f2eb$export$d0486c7a5136628 = (props)=>{
|
|
10014
|
-
const { sourceFile: sourceFile, options: options, onSave: onSave, onCancel: onCancel, saveLabel: saveLabel, cancelLabel: cancelLabel, rotateClockwiseLabel: rotateClockwiseLabel, rotateCounterClockwiseLabel: rotateCounterClockwiseLabel, takePhotoLabel: takePhotoLabel, camera: camera } = (0, $b4te3$mantinecore.useComponentDefaultProps)('ImageEditor', $0cac5edaa1a7f2eb$export$6e31a2501ac1134a, props);
|
|
10021
|
+
const { sourceFile: sourceFile, options: options, onSave: onSave, onBeforeSave: onBeforeSave, onCancel: onCancel, initiallyDirty: initiallyDirty, saveLabel: saveLabel, cancelLabel: cancelLabel, rotateClockwiseLabel: rotateClockwiseLabel, rotateCounterClockwiseLabel: rotateCounterClockwiseLabel, takePhotoLabel: takePhotoLabel, camera: camera } = (0, $b4te3$mantinecore.useComponentDefaultProps)('ImageEditor', $0cac5edaa1a7f2eb$export$6e31a2501ac1134a, props);
|
|
10015
10022
|
const [editorSource, setEditorSource] = (0, $b4te3$react.useState)(sourceFile);
|
|
10016
10023
|
const [cameraMode, setCameraMode] = (0, $b4te3$react.useState)(!sourceFile && camera !== false);
|
|
10017
10024
|
const [preparedImage, setPreparedImage] = (0, $b4te3$react.useState)();
|
|
@@ -10027,6 +10034,7 @@ const $0cac5edaa1a7f2eb$export$d0486c7a5136628 = (props)=>{
|
|
|
10027
10034
|
const [error, setError] = (0, $b4te3$react.useState)();
|
|
10028
10035
|
const cropEnabled = options.crop !== false;
|
|
10029
10036
|
const manualRotation = options.manualRotation;
|
|
10037
|
+
const dirty = !!editorSource && (initiallyDirty === true || editorSource !== sourceFile || crop.x !== 0 || crop.y !== 0 || zoom !== 1 || rotationDegrees !== 0);
|
|
10030
10038
|
(0, $b4te3$react.useEffect)(()=>{
|
|
10031
10039
|
setEditorSource(sourceFile);
|
|
10032
10040
|
setCameraMode(!sourceFile && camera !== false);
|
|
@@ -10081,12 +10089,13 @@ const $0cac5edaa1a7f2eb$export$d0486c7a5136628 = (props)=>{
|
|
|
10081
10089
|
manualRotation
|
|
10082
10090
|
]);
|
|
10083
10091
|
const save = (0, $b4te3$react.useCallback)(async ()=>{
|
|
10084
|
-
if (!editorSource || !preparedImage || cropEnabled && !croppedAreaPixels) return;
|
|
10092
|
+
if (!dirty || !editorSource || !preparedImage || cropEnabled && !croppedAreaPixels) return;
|
|
10085
10093
|
setSaving(true);
|
|
10086
10094
|
setError(undefined);
|
|
10087
10095
|
try {
|
|
10088
10096
|
const canvas = (0, $g81NG.renderEditedImage)(preparedImage.canvas, cropEnabled ? croppedAreaPixels : undefined, rotationDegrees, options);
|
|
10089
10097
|
const file = await (0, $dE75A.canvasToProcessedFile)(canvas, editorSource, options);
|
|
10098
|
+
if (onBeforeSave && !await onBeforeSave(file)) return;
|
|
10090
10099
|
await onSave(file);
|
|
10091
10100
|
} catch (e) {
|
|
10092
10101
|
setError(e instanceof Error ? e.message : String(e));
|
|
@@ -10096,7 +10105,9 @@ const $0cac5edaa1a7f2eb$export$d0486c7a5136628 = (props)=>{
|
|
|
10096
10105
|
}, [
|
|
10097
10106
|
cropEnabled,
|
|
10098
10107
|
croppedAreaPixels,
|
|
10108
|
+
dirty,
|
|
10099
10109
|
editorSource,
|
|
10110
|
+
onBeforeSave,
|
|
10100
10111
|
onSave,
|
|
10101
10112
|
options,
|
|
10102
10113
|
preparedImage,
|
|
@@ -10213,7 +10224,7 @@ const $0cac5edaa1a7f2eb$export$d0486c7a5136628 = (props)=>{
|
|
|
10213
10224
|
/*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
|
|
10214
10225
|
onClick: ()=>void save(),
|
|
10215
10226
|
loading: saving,
|
|
10216
|
-
disabled: !
|
|
10227
|
+
disabled: !dirty || !ready,
|
|
10217
10228
|
leftIcon: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$tablericonsreact.IconCheck), {
|
|
10218
10229
|
size: "1rem"
|
|
10219
10230
|
}),
|
|
@@ -10511,7 +10522,8 @@ function $150e740bf624ab8d$export$4c90be38156c1022(props) {
|
|
|
10511
10522
|
style: {
|
|
10512
10523
|
width: '100%',
|
|
10513
10524
|
maxHeight: '60vh',
|
|
10514
|
-
objectFit: '
|
|
10525
|
+
objectFit: 'cover',
|
|
10526
|
+
borderRadius: '1rem',
|
|
10515
10527
|
background: '#0f0e13',
|
|
10516
10528
|
display: !!captured || !streaming ? 'none' : 'inline-block'
|
|
10517
10529
|
}
|
|
@@ -10522,7 +10534,8 @@ function $150e740bf624ab8d$export$4c90be38156c1022(props) {
|
|
|
10522
10534
|
style: {
|
|
10523
10535
|
width: '100%',
|
|
10524
10536
|
maxHeight: '60vh',
|
|
10525
|
-
objectFit: '
|
|
10537
|
+
objectFit: 'cover',
|
|
10538
|
+
borderRadius: '1rem',
|
|
10526
10539
|
background: '#0f0e13'
|
|
10527
10540
|
}
|
|
10528
10541
|
}),
|