@mcurros2/microm 1.1.93-0 → 1.1.94-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.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, saveBeforeLocalNavigation: saveBeforeLocalNavigation, saveBeforeRemoteNavigation: saveBeforeRemoteNavigation } = (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;
@@ -457,6 +457,38 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
457
457
  }, [
458
458
  initialFormMode
459
459
  ]);
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 saveAndGet();
465
+ } catch (ex) {
466
+ console.error("SaveBeforeRemoteNavigation", ex);
467
+ }
468
+ });
469
+ window.addEventListener("beforeunload", handleBeforeUnload);
470
+ return ()=>{
471
+ window.removeEventListener("beforeunload", handleBeforeUnload);
472
+ };
473
+ }, [
474
+ saveBeforeRemoteNavigation
475
+ ]);
476
+ const prevLocationRef = (0, $b4te3$react.useRef)(window.location.hash);
477
+ (0, $b4te3$react.useEffect)(()=>{
478
+ const handleLocalNavigation = ()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
479
+ try {
480
+ if (saveBeforeLocalNavigation && prevLocationRef.current !== window.location.hash) yield saveAndGet();
481
+ } catch (ex) {
482
+ console.error("SaveBeforeLocalNavigation", ex);
483
+ }
484
+ });
485
+ window.addEventListener("hashchange", handleLocalNavigation);
486
+ return ()=>{
487
+ window.removeEventListener("hashchange", handleLocalNavigation);
488
+ };
489
+ }, [
490
+ saveBeforeLocalNavigation
491
+ ]);
460
492
  const result = (0, $b4te3$react.useMemo)(()=>({
461
493
  form: form,
462
494
  formMode: formMode,
@@ -47831,33 +47863,6 @@ $parcel$export(module.exports, "EntityFormPage", function () { return $637861954
47831
47863
 
47832
47864
  parcelRequire("7xGLy");
47833
47865
  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
- };
47861
47866
  var $637861954d3d6876$var$__rest = undefined && undefined.__rest || function(s, e) {
47862
47867
  var t = {};
47863
47868
  for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -47871,12 +47876,10 @@ const $637861954d3d6876$export$e73f1d9fe021a92b = {
47871
47876
  defaultLoadingComponent: (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Skeleton), {})
47872
47877
  };
47873
47878
  function $637861954d3d6876$export$bf63b1212bff1393(props) {
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, [
47879
+ const _a = (0, $b4te3$mantinecore.useComponentDefaultProps)("EntityFormPage", $637861954d3d6876$export$e73f1d9fe021a92b, props), { entityConstructor: entityConstructor, client: client, defaultLoadingComponent: defaultLoadingComponent } = _a, rest = $637861954d3d6876$var$__rest(_a, [
47875
47880
  "entityConstructor",
47876
47881
  "client",
47877
- "defaultLoadingComponent",
47878
- "saveBeforeLocalNavigation",
47879
- "saveBeforeRemoteNavigation"
47882
+ "defaultLoadingComponent"
47880
47883
  ]);
47881
47884
  const [entityForm, setEntityForm] = (0, $b4te3$react.useState)(null);
47882
47885
  const entityRef = (0, $b4te3$react.useRef)(null);
@@ -47897,38 +47900,6 @@ function $637861954d3d6876$export$bf63b1212bff1393(props) {
47897
47900
  client,
47898
47901
  entityConstructor
47899
47902
  ]);
47900
- // save before navigation
47901
- (0, $b4te3$react.useEffect)(()=>{
47902
- const handleBeforeUnload = ()=>$637861954d3d6876$var$__awaiter(this, void 0, void 0, function*() {
47903
- try {
47904
- if (saveBeforeRemoteNavigation && entityRef.current) yield entityRef.current.API.editData();
47905
- } catch (ex) {
47906
- console.error("SaveBeforeRemoteNavigation", ex);
47907
- }
47908
- });
47909
- window.addEventListener("beforeunload", handleBeforeUnload);
47910
- return ()=>{
47911
- window.removeEventListener("beforeunload", handleBeforeUnload);
47912
- };
47913
- }, [
47914
- saveBeforeRemoteNavigation
47915
- ]);
47916
- const prevLocationRef = (0, $b4te3$react.useRef)(window.location.hash);
47917
- (0, $b4te3$react.useEffect)(()=>{
47918
- const handleLocalNavigation = ()=>$637861954d3d6876$var$__awaiter(this, void 0, void 0, function*() {
47919
- try {
47920
- if (saveBeforeLocalNavigation && entityRef.current && prevLocationRef.current !== window.location.hash) yield entityRef.current.API.editData();
47921
- } catch (ex) {
47922
- console.error("SaveBeforeLocalNavigation", ex);
47923
- }
47924
- });
47925
- window.addEventListener("hashchange", handleLocalNavigation);
47926
- return ()=>{
47927
- window.removeEventListener("hashchange", handleLocalNavigation);
47928
- };
47929
- }, [
47930
- saveBeforeLocalNavigation
47931
- ]);
47932
47903
  return (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$reactjsxruntime.Fragment), {
47933
47904
  children: entityForm || defaultLoadingComponent
47934
47905
  });