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