@mcurros2/microm 1.1.89-0 → 1.1.92-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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +77 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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,6 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
|
|
|
444
457
|
}, [
|
|
445
458
|
initialFormMode
|
|
446
459
|
]);
|
|
447
|
-
// Validation, InitialValues, InitialDirty
|
|
448
|
-
const addValidation = (0, $b4te3$react.useCallback)((column, validation)=>{
|
|
449
|
-
var _a;
|
|
450
|
-
if (validation) validationObject.current[column.name] = validation;
|
|
451
|
-
if (initialFormMode === "add" || forceDirty) initialDirty.current[column.name] = column.value !== "" || column.value !== null || column.value !== undefined ? true : false;
|
|
452
|
-
initialValues.current[column.name] = (_a = column.value) !== null && _a !== void 0 ? _a : "";
|
|
453
|
-
}, [
|
|
454
|
-
forceDirty,
|
|
455
|
-
initialFormMode
|
|
456
|
-
]);
|
|
457
|
-
const removeValidation = (0, $b4te3$react.useCallback)((column)=>{
|
|
458
|
-
delete validationObject.current[column.name];
|
|
459
|
-
}, []);
|
|
460
460
|
const result = (0, $b4te3$react.useMemo)(()=>({
|
|
461
461
|
form: form,
|
|
462
462
|
formMode: formMode,
|
|
@@ -47831,6 +47831,33 @@ $parcel$export(module.exports, "EntityFormPage", function () { return $637861954
|
|
|
47831
47831
|
|
|
47832
47832
|
parcelRequire("7xGLy");
|
|
47833
47833
|
var $gYKfx = parcelRequire("gYKfx");
|
|
47834
|
+
var $637861954d3d6876$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
47835
|
+
function adopt(value) {
|
|
47836
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
47837
|
+
resolve(value);
|
|
47838
|
+
});
|
|
47839
|
+
}
|
|
47840
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
47841
|
+
function fulfilled(value) {
|
|
47842
|
+
try {
|
|
47843
|
+
step(generator.next(value));
|
|
47844
|
+
} catch (e) {
|
|
47845
|
+
reject(e);
|
|
47846
|
+
}
|
|
47847
|
+
}
|
|
47848
|
+
function rejected(value) {
|
|
47849
|
+
try {
|
|
47850
|
+
step(generator["throw"](value));
|
|
47851
|
+
} catch (e) {
|
|
47852
|
+
reject(e);
|
|
47853
|
+
}
|
|
47854
|
+
}
|
|
47855
|
+
function step(result) {
|
|
47856
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
47857
|
+
}
|
|
47858
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47859
|
+
});
|
|
47860
|
+
};
|
|
47834
47861
|
var $637861954d3d6876$var$__rest = undefined && undefined.__rest || function(s, e) {
|
|
47835
47862
|
var t = {};
|
|
47836
47863
|
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -47844,13 +47871,16 @@ const $637861954d3d6876$export$e73f1d9fe021a92b = {
|
|
|
47844
47871
|
defaultLoadingComponent: (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Skeleton), {})
|
|
47845
47872
|
};
|
|
47846
47873
|
function $637861954d3d6876$export$bf63b1212bff1393(props) {
|
|
47847
|
-
const _a = (0, $b4te3$mantinecore.useComponentDefaultProps)("EntityFormPage", $637861954d3d6876$export$e73f1d9fe021a92b, props), { entityConstructor: entityConstructor, client: client, defaultLoadingComponent: defaultLoadingComponent } = _a, rest = $637861954d3d6876$var$__rest(_a, [
|
|
47874
|
+
const _a = (0, $b4te3$mantinecore.useComponentDefaultProps)("EntityFormPage", $637861954d3d6876$export$e73f1d9fe021a92b, props), { entityConstructor: entityConstructor, client: client, defaultLoadingComponent: defaultLoadingComponent, saveBeforeLocalNavigation: saveBeforeLocalNavigation, saveBeforeRemoteNavigation: saveBeforeRemoteNavigation } = _a, rest = $637861954d3d6876$var$__rest(_a, [
|
|
47848
47875
|
"entityConstructor",
|
|
47849
47876
|
"client",
|
|
47850
|
-
"defaultLoadingComponent"
|
|
47877
|
+
"defaultLoadingComponent",
|
|
47878
|
+
"saveBeforeLocalNavigation",
|
|
47879
|
+
"saveBeforeRemoteNavigation"
|
|
47851
47880
|
]);
|
|
47852
47881
|
const [entityForm, setEntityForm] = (0, $b4te3$react.useState)(null);
|
|
47853
47882
|
const entityRef = (0, $b4te3$react.useRef)(null);
|
|
47883
|
+
const entity = entityRef.current;
|
|
47854
47884
|
// MMC: note that rest properties are not used in the useEffect dependency array as using ...rest will create a new object on every render
|
|
47855
47885
|
(0, $b4te3$react.useEffect)(()=>{
|
|
47856
47886
|
if (!entityRef.current) entityRef.current = entityConstructor(client);
|
|
@@ -47868,6 +47898,38 @@ function $637861954d3d6876$export$bf63b1212bff1393(props) {
|
|
|
47868
47898
|
client,
|
|
47869
47899
|
entityConstructor
|
|
47870
47900
|
]);
|
|
47901
|
+
// save before navigation
|
|
47902
|
+
(0, $b4te3$react.useEffect)(()=>{
|
|
47903
|
+
const handleBeforeUnload = ()=>$637861954d3d6876$var$__awaiter(this, void 0, void 0, function*() {
|
|
47904
|
+
try {
|
|
47905
|
+
if (saveBeforeRemoteNavigation && entity) yield entity.API.editData();
|
|
47906
|
+
} catch (ex) {
|
|
47907
|
+
console.error("SaveBeforeRemoteNavigation", ex);
|
|
47908
|
+
}
|
|
47909
|
+
});
|
|
47910
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
47911
|
+
return ()=>{
|
|
47912
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
47913
|
+
};
|
|
47914
|
+
}, [
|
|
47915
|
+
saveBeforeRemoteNavigation
|
|
47916
|
+
]);
|
|
47917
|
+
const prevLocationRef = (0, $b4te3$react.useRef)(window.location.hash);
|
|
47918
|
+
(0, $b4te3$react.useEffect)(()=>{
|
|
47919
|
+
const handleLocalNavigation = ()=>$637861954d3d6876$var$__awaiter(this, void 0, void 0, function*() {
|
|
47920
|
+
try {
|
|
47921
|
+
if (saveBeforeLocalNavigation && entity && prevLocationRef.current !== window.location.hash) yield entity.API.editData();
|
|
47922
|
+
} catch (ex) {
|
|
47923
|
+
console.error("SaveBeforeLocalNavigation", ex);
|
|
47924
|
+
}
|
|
47925
|
+
});
|
|
47926
|
+
window.addEventListener("hashchange", handleLocalNavigation);
|
|
47927
|
+
return ()=>{
|
|
47928
|
+
window.removeEventListener("hashchange", handleLocalNavigation);
|
|
47929
|
+
};
|
|
47930
|
+
}, [
|
|
47931
|
+
saveBeforeLocalNavigation
|
|
47932
|
+
]);
|
|
47871
47933
|
return (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$reactjsxruntime.Fragment), {
|
|
47872
47934
|
children: entityForm || defaultLoadingComponent
|
|
47873
47935
|
});
|