@jobber/components-native 0.89.4 → 0.90.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.89.4",
3
+ "version": "0.90.0",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -94,5 +94,5 @@
94
94
  "react-native-safe-area-context": "^5.4.0",
95
95
  "react-native-svg": ">=12.0.0"
96
96
  },
97
- "gitHead": "adc76ab79cbad1b62fa1d3ff35020f061b390292"
97
+ "gitHead": "39c1c0fc8175f82c32c7636b972712a710fbf527"
98
98
  }
@@ -49,7 +49,7 @@ export function Form(_a) {
49
49
  React.createElement(ErrorMessageProvider, null, child)));
50
50
  }
51
51
  // eslint-disable-next-line max-statements
52
- function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSubmitSuccess, bannerErrors, bannerMessages, initialValues, mode = "onTouched", reValidateMode = "onChange", formRef, saveButtonLabel, renderStickySection, localCacheKey, localCacheExclude, localCacheId, secondaryActions, saveButtonOffset, showStickySaveButton = false, renderFooter, }) {
52
+ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSubmitSuccess, bannerErrors, bannerMessages, initialValues, mode = "onTouched", reValidateMode = "onChange", formRef, saveButtonLabel, renderStickySection, localCacheKey, localCacheExclude, localCacheId, secondaryActions, saveButtonOffset, showStickySaveButton = false, renderFooter, UNSAFE_allowDiscardLocalCacheWhenOffline, }) {
53
53
  var _a;
54
54
  const { scrollViewRef, bottomViewRef, scrollToTop } = useFormViewRefs();
55
55
  const [saveButtonHeight, setSaveButtonHeight] = useState(0);
@@ -65,6 +65,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
65
65
  scrollViewRef,
66
66
  saveButtonHeight,
67
67
  messageBannerHeight,
68
+ UNSAFE_allowDiscardLocalCacheWhenOffline,
68
69
  });
69
70
  const { windowHeight, headerHeight } = useScreenInformation();
70
71
  const [keyboardHeight, setKeyboardHeight] = useState(0);
@@ -1,7 +1,7 @@
1
1
  import { useForm } from "react-hook-form";
2
2
  import { useAtlantisContext } from "../../AtlantisContext";
3
3
  import { useAtlantisFormContext } from "../context/AtlantisFormContext";
4
- export function useInternalForm({ mode, reValidateMode, initialValues, formRef, localCacheKey, localCacheId, scrollViewRef, saveButtonHeight, messageBannerHeight, }) {
4
+ export function useInternalForm({ mode, reValidateMode, initialValues, formRef, localCacheKey, localCacheId, scrollViewRef, saveButtonHeight, messageBannerHeight, UNSAFE_allowDiscardLocalCacheWhenOffline = false, }) {
5
5
  const { useConfirmBeforeBack, useInternalFormLocalCache } = useAtlantisFormContext();
6
6
  const { isOnline } = useAtlantisContext();
7
7
  const formMethods = useForm({
@@ -20,11 +20,14 @@ export function useInternalForm({ mode, reValidateMode, initialValues, formRef,
20
20
  messageBannerHeight,
21
21
  scrollViewRef });
22
22
  }
23
+ const shouldRemoveCacheOnBack = UNSAFE_allowDiscardLocalCacheWhenOffline
24
+ ? true
25
+ : isOnline;
23
26
  const removeListenerRef = useConfirmBeforeBack({
24
27
  alwaysPreventBack: isSubmitting,
25
28
  shouldShowAlert: isDirty,
26
- onAcceptEvent: isOnline ? removeLocalCache : undefined,
27
- showLostProgressMessage: isOnline || !clientSideSaveOn ? true : false,
29
+ onAcceptEvent: shouldRemoveCacheOnBack ? removeLocalCache : undefined,
30
+ showLostProgressMessage: shouldRemoveCacheOnBack || !clientSideSaveOn ? true : false,
28
31
  });
29
32
  return {
30
33
  setLocalCache,