@mcurros2/microm 1.1.107-0 → 1.1.108-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
@@ -430,6 +430,17 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
430
430
  const removeValidation = (0, $b4te3$react.useCallback)((column)=>{
431
431
  delete validationObject.current[column.name];
432
432
  }, []);
433
+ const silentSave = (0, $b4te3$react.useCallback)(()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
434
+ try {
435
+ form.validate();
436
+ if (!(0, $iKzSR.areValuesObjectsEqual)(form.values, lastGetValues.current)) yield saveAndGet();
437
+ } catch (ex) {
438
+ console.error("SilentSave", ex);
439
+ }
440
+ }), [
441
+ form,
442
+ saveAndGet
443
+ ]);
433
444
  // getDataOnInit
434
445
  (0, $b4te3$react.useEffect)(()=>{
435
446
  const cancellation = getAbortController.current;
@@ -466,35 +477,21 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
466
477
  // save before navigation
467
478
  (0, $b4te3$react.useEffect)(()=>{
468
479
  const handleBeforeUnload = ()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
469
- try {
470
- if (saveBeforeRemoteNavigation) {
471
- form.validate();
472
- if (!(0, $iKzSR.areValuesObjectsEqual)(form.values, lastGetValues.current)) yield saveAndGet();
473
- }
474
- } catch (ex) {
475
- console.error("SaveBeforeRemoteNavigation", ex);
476
- }
480
+ if (saveBeforeRemoteNavigation) yield silentSave();
477
481
  });
478
482
  window.addEventListener("beforeunload", handleBeforeUnload);
479
483
  return ()=>{
480
484
  window.removeEventListener("beforeunload", handleBeforeUnload);
481
485
  };
482
486
  }, [
483
- form,
484
- saveAndGet,
485
- saveBeforeRemoteNavigation
487
+ saveBeforeRemoteNavigation,
488
+ silentSave
486
489
  ]);
487
490
  const prevLocationRef = (0, $b4te3$react.useRef)(window.location.hash);
491
+ // savew before local navigation
488
492
  (0, $b4te3$react.useEffect)(()=>{
489
493
  const handleLocalNavigation = ()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
490
- try {
491
- if (saveBeforeLocalNavigation && form.isDirty() && prevLocationRef.current !== window.location.hash) {
492
- form.validate();
493
- if (!(0, $iKzSR.areValuesObjectsEqual)(form.values, lastGetValues.current)) yield saveAndGet();
494
- }
495
- } catch (ex) {
496
- console.error("SaveBeforeLocalNavigation", ex);
497
- }
494
+ if (saveBeforeLocalNavigation && form.isDirty() && prevLocationRef.current !== window.location.hash) yield silentSave();
498
495
  });
499
496
  window.addEventListener("hashchange", handleLocalNavigation);
500
497
  return ()=>{
@@ -502,8 +499,8 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
502
499
  };
503
500
  }, [
504
501
  form,
505
- saveAndGet,
506
- saveBeforeLocalNavigation
502
+ saveBeforeLocalNavigation,
503
+ silentSave
507
504
  ]);
508
505
  const result = (0, $b4te3$react.useMemo)(()=>({
509
506
  form: form,
@@ -523,7 +520,8 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
523
520
  clearAsyncError: clearAsyncError,
524
521
  clearAllAsyncErrors: clearAllAsyncErrors,
525
522
  isFormValid: isFormValid,
526
- isFormFieldValid: isFormFieldValid
523
+ isFormFieldValid: isFormFieldValid,
524
+ silentSave: silentSave
527
525
  }), [
528
526
  addValidation,
529
527
  clearAllAsyncErrors,
@@ -542,7 +540,8 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
542
540
  saveAndGetOverride,
543
541
  setAsyncError,
544
542
  showDescriptionState,
545
- status
543
+ status,
544
+ silentSave
546
545
  ]);
547
546
  return result;
548
547
  }