@mcurros2/microm 1.1.88-0 → 1.1.91-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 +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -194,7 +194,7 @@ const $8b0c683387a5432f$export$659b17aab7c47d60 = {
|
|
|
194
194
|
cancelSaveOnUnmount: true
|
|
195
195
|
};
|
|
196
196
|
function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
|
|
197
|
-
const { entity: entity, initialFormMode: initialFormMode, validateInputOnBlur: validateInputOnBlur, validateInputOnChange: validateInputOnChange, onSaved: onSaved, onCancel: onCancel, getDataOnInit: getDataOnInit, forceDirty: forceDirty, initialShowDescriptionInFields: initialShowDescriptionInFields, saveAndGetOverride: saveAndGetOverride, noSaveOnSubmit: noSaveOnSubmit, bindedColumnNames: bindedColumnNames, saveAndGetOnSubmit: saveAndGetOnSubmit, cancelGetOnUnmount: cancelGetOnUnmount, cancelSaveOnUnmount: cancelSaveOnUnmount } = (0, $b4te3$mantinecore.useComponentDefaultProps)("", $8b0c683387a5432f$export$659b17aab7c47d60, props);
|
|
197
|
+
const { entity: entity, initialFormMode: initialFormMode, validateInputOnBlur: validateInputOnBlur, validateInputOnChange: validateInputOnChange, onSaved: onSaved, onCancel: onCancel, getDataOnInit: getDataOnInit, forceDirty: forceDirty, initialShowDescriptionInFields: initialShowDescriptionInFields, saveAndGetOverride: saveAndGetOverride, noSaveOnSubmit: noSaveOnSubmit, bindedColumnNames: bindedColumnNames, saveAndGetOnSubmit: saveAndGetOnSubmit, cancelGetOnUnmount: cancelGetOnUnmount, cancelSaveOnUnmount: cancelSaveOnUnmount, saveBeforeRemoteNavigation: saveBeforeRemoteNavigation, saveBeforeLocalNavigation: saveBeforeLocalNavigation } = (0, $b4te3$mantinecore.useComponentDefaultProps)("", $8b0c683387a5432f$export$659b17aab7c47d60, props);
|
|
198
198
|
const [status, setStatus] = (0, $b4te3$react.useState)({}); // Initial queryStatus is empty on purpose to not disable fields before data is loaded
|
|
199
199
|
const notifyValidationErrorState = (0, $b4te3$react.useState)(false);
|
|
200
200
|
const [, setNotifyValidationError] = notifyValidationErrorState;
|
|
@@ -412,6 +412,19 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
|
|
|
412
412
|
setNotifyValidationError,
|
|
413
413
|
saveAndGetOnSubmit
|
|
414
414
|
]);
|
|
415
|
+
// Validation, InitialValues, InitialDirty
|
|
416
|
+
const addValidation = (0, $b4te3$react.useCallback)((column, validation)=>{
|
|
417
|
+
var _a;
|
|
418
|
+
if (validation) validationObject.current[column.name] = validation;
|
|
419
|
+
if (initialFormMode === "add" || forceDirty) initialDirty.current[column.name] = column.value !== "" || column.value !== null || column.value !== undefined ? true : false;
|
|
420
|
+
initialValues.current[column.name] = (_a = column.value) !== null && _a !== void 0 ? _a : "";
|
|
421
|
+
}, [
|
|
422
|
+
forceDirty,
|
|
423
|
+
initialFormMode
|
|
424
|
+
]);
|
|
425
|
+
const removeValidation = (0, $b4te3$react.useCallback)((column)=>{
|
|
426
|
+
delete validationObject.current[column.name];
|
|
427
|
+
}, []);
|
|
415
428
|
(0, $b4te3$react.useEffect)(()=>{
|
|
416
429
|
const cancellation = getAbortController.current;
|
|
417
430
|
if (getDataOnInit) {
|
|
@@ -444,19 +457,40 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
|
|
|
444
457
|
}, [
|
|
445
458
|
initialFormMode
|
|
446
459
|
]);
|
|
447
|
-
//
|
|
448
|
-
|
|
449
|
-
var
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
460
|
+
// save before navigation
|
|
461
|
+
(0, $b4te3$react.useEffect)(()=>{
|
|
462
|
+
const handleBeforeUnload = ()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
|
|
463
|
+
try {
|
|
464
|
+
if (saveBeforeRemoteNavigation) yield entity.API.editData();
|
|
465
|
+
} catch (ex) {
|
|
466
|
+
console.error("SaveBeforeRemoteNavigation", ex);
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
470
|
+
return ()=>{
|
|
471
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
472
|
+
};
|
|
453
473
|
}, [
|
|
454
|
-
|
|
455
|
-
|
|
474
|
+
entity.API,
|
|
475
|
+
saveBeforeRemoteNavigation
|
|
476
|
+
]);
|
|
477
|
+
const prevLocationRef = (0, $b4te3$react.useRef)(window.location.hash);
|
|
478
|
+
(0, $b4te3$react.useEffect)(()=>{
|
|
479
|
+
const handleLocalNavigation = ()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
|
|
480
|
+
try {
|
|
481
|
+
if (saveBeforeLocalNavigation && prevLocationRef.current !== window.location.hash) yield entity.API.editData();
|
|
482
|
+
} catch (ex) {
|
|
483
|
+
console.error("SaveBeforeRemoteNavigation", ex);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
window.addEventListener("hashchange", handleLocalNavigation);
|
|
487
|
+
return ()=>{
|
|
488
|
+
window.removeEventListener("hashchange", handleLocalNavigation);
|
|
489
|
+
};
|
|
490
|
+
}, [
|
|
491
|
+
entity.API,
|
|
492
|
+
saveBeforeLocalNavigation
|
|
456
493
|
]);
|
|
457
|
-
const removeValidation = (0, $b4te3$react.useCallback)((column)=>{
|
|
458
|
-
delete validationObject.current[column.name];
|
|
459
|
-
}, []);
|
|
460
494
|
const result = (0, $b4te3$react.useMemo)(()=>({
|
|
461
495
|
form: form,
|
|
462
496
|
formMode: formMode,
|
|
@@ -48244,8 +48278,8 @@ function $a2f8dbbe67378f4d$export$82ae7c22f1133bd2(props) {
|
|
|
48244
48278
|
hasOpened.current = false;
|
|
48245
48279
|
if (onModalClosed) onModalClosed();
|
|
48246
48280
|
},
|
|
48247
|
-
onModalSaved: (status
|
|
48248
|
-
if (onModalSaved) yield onModalSaved(status
|
|
48281
|
+
onModalSaved: (status)=>$a2f8dbbe67378f4d$var$__awaiter(this, void 0, void 0, function*() {
|
|
48282
|
+
if (onModalSaved) yield onModalSaved(status);
|
|
48249
48283
|
})
|
|
48250
48284
|
});
|
|
48251
48285
|
});
|