@jobber/components-native 0.97.2-edicleanu-753c899.26 → 0.98.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.97.2-edicleanu-753c899.26+753c89916",
3
+ "version": "0.98.0",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "lodash": "^4.17.21",
46
46
  "react-hook-form": "^7.52.0",
47
47
  "react-intl": "^7.1.11",
48
- "react-native-keyboard-aware-scroll-view": "^0.9.5",
48
+ "react-native-keyboard-controller": "^1.20.7",
49
49
  "react-native-modalize": "^2.0.13",
50
50
  "react-native-portalize": "^1.0.7",
51
51
  "react-native-toast-message": "^2.1.6",
@@ -54,8 +54,6 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@gorhom/bottom-sheet": "^5.2.8",
57
- "@jobber/design": "^0.92.1-edicleanu-753c899.11+753c89916",
58
- "@jobber/hooks": "^2.19.4-edicleanu-753c899.153+753c89916",
59
57
  "@react-native-community/datetimepicker": "^8.4.5",
60
58
  "@react-native/babel-preset": "^0.82.1",
61
59
  "@storybook/addon-a11y": "9.1.19",
@@ -83,7 +81,6 @@
83
81
  "@babel/core": "^7.4.5",
84
82
  "@gorhom/bottom-sheet": "^5.2.8",
85
83
  "@jobber/design": "*",
86
- "@jobber/hooks": "*",
87
84
  "@react-native-community/datetimepicker": ">=6.7.0",
88
85
  "date-fns": "^2.30.0",
89
86
  "date-fns-tz": "^2.0.0",
@@ -91,7 +88,7 @@
91
88
  "react-intl": "^6 || ^7",
92
89
  "react-native": ">=0.79.5",
93
90
  "react-native-gesture-handler": ">=2.22.0",
94
- "react-native-keyboard-aware-scroll-view": "^0.9.5",
91
+ "react-native-keyboard-controller": "^1.20.7",
95
92
  "react-native-modal-datetime-picker": " >=13.0.0",
96
93
  "react-native-modalize": "^2.0.13",
97
94
  "react-native-portalize": "^1.0.7",
@@ -99,5 +96,5 @@
99
96
  "react-native-safe-area-context": "^5.4.0",
100
97
  "react-native-svg": ">=12.0.0"
101
98
  },
102
- "gitHead": "753c89916463f315fb49fd21988a7b20e34f65f4"
99
+ "gitHead": "b74ecd2ea6e3aadd70bf9b46dd999bdb40458a13"
103
100
  }
@@ -18,13 +18,13 @@ var __rest = (this && this.__rest) || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
- import React, { useState } from "react";
21
+ import React, { useCallback, useEffect, useState } from "react";
22
22
  import { FormProvider } from "react-hook-form";
23
- import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
23
+ import { KeyboardAwareScrollView, KeyboardEvents, } from "react-native-keyboard-controller";
24
24
  import { Keyboard, Platform, View, findNodeHandle } from "react-native";
25
25
  import { useStyles } from "./Form.style";
26
26
  import { FormErrorBanner } from "./components/FormErrorBanner";
27
- import { KEYBOARD_SAVE_BUTTON_DISTANCE } from "./constants";
27
+ import { KEYBOARD_SAVE_BUTTON_DISTANCE, KEYBOARD_TOP_PADDING_AUTO_SCROLL, } from "./constants";
28
28
  import { FormMessageBanner } from "./components/FormMessageBanner";
29
29
  import { FormSubmitErrorType } from "./types";
30
30
  import { FormMask } from "./components/FormMask";
@@ -68,7 +68,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
68
68
  messageBannerHeight,
69
69
  UNSAFE_allowDiscardLocalCacheWhenOffline,
70
70
  });
71
- const { windowHeight, headerHeight } = useScreenInformation();
71
+ const { windowHeight } = useScreenInformation();
72
72
  const [keyboardHeight, setKeyboardHeight] = useState(0);
73
73
  const [keyboardScreenY, setKeyboardScreenY] = useState(0);
74
74
  const [formContentHeight, setFormContentHeight] = useState(0);
@@ -88,19 +88,38 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
88
88
  formState: formMethods.formState,
89
89
  refNode: findNodeHandle(scrollViewRef.current),
90
90
  setFocus: formMethods.setFocus,
91
- scrollToPosition: (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToPosition,
91
+ scrollTo: (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo,
92
92
  });
93
93
  const handleOfflineSubmit = useOfflineHandler();
94
- const keyboardProps = Platform.select({
95
- ios: {
96
- onKeyboardWillHide: handleKeyboardHide,
97
- onKeyboardWillShow: handleKeyboardShow,
98
- },
99
- android: {
100
- onKeyboardDidHide: handleKeyboardHide,
101
- onKeyboardDidShow: handleKeyboardShow,
102
- },
103
- });
94
+ const handleKeyboardShow = useCallback((event) => {
95
+ setKeyboardHeight(event.height);
96
+ setKeyboardScreenY(windowHeight - event.height);
97
+ }, [windowHeight]);
98
+ const handleKeyboardHide = useCallback(() => {
99
+ var _a;
100
+ (_a = bottomViewRef === null || bottomViewRef === void 0 ? void 0 : bottomViewRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(
101
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
102
+ (_x, y, _width, _height) => {
103
+ var _a;
104
+ // This fixes extra whitespace below the form if it was scrolled down while the keyboard was open
105
+ // i.e. a View below the form is higher than the bottom of the window
106
+ if (y < windowHeight) {
107
+ (_a = scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToEnd();
108
+ }
109
+ });
110
+ setKeyboardHeight(0);
111
+ setKeyboardScreenY(0);
112
+ }, [bottomViewRef, scrollViewRef, windowHeight]);
113
+ useEffect(() => {
114
+ const showEvent = Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow";
115
+ const hideEvent = Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide";
116
+ const showListener = KeyboardEvents.addListener(showEvent, handleKeyboardShow);
117
+ const hideListener = KeyboardEvents.addListener(hideEvent, handleKeyboardHide);
118
+ return () => {
119
+ showListener.remove();
120
+ hideListener.remove();
121
+ };
122
+ }, [handleKeyboardHide, handleKeyboardShow]);
104
123
  const onLayout = (event) => {
105
124
  setMessageBannerHeight(event.nativeEvent.layout.height);
106
125
  };
@@ -111,7 +130,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
111
130
  (isSubmitting || isSecondaryActionLoading) && React.createElement(FormMask, null),
112
131
  React.createElement(FormCache, { localCacheKey: localCacheKey, localCacheExclude: localCacheExclude, setLocalCache: setLocalCache }),
113
132
  React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(), submit: handleSubmit(internalSubmit), isFormSubmitting: isSubmitting, saveButtonLabel: saveButtonLabel, shouldRenderActionBar: saveButtonPosition === "sticky", renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, setSaveButtonHeight: setSaveButtonHeight, saveButtonOffset: saveButtonOffset },
114
- React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll: !disableKeyboardAwareScroll, enableOnAndroid: edgeToEdgeEnabled, keyboardOpeningTime: Platform.OS === "ios" ? tokens["timing-slowest"] : 0, keyboardShouldPersistTaps: "handled", ref: scrollViewRef }, keyboardProps, { extraHeight: headerHeight, extraScrollHeight: edgeToEdgeEnabled ? tokens["space-large"] : 0, contentContainerStyle: !keyboardHeight && styles.scrollContentContainer }),
133
+ React.createElement(KeyboardAwareScrollView, { disableScrollOnKeyboardHide: true, enabled: !disableKeyboardAwareScroll, keyboardShouldPersistTaps: "handled", ref: scrollViewRef, bottomOffset: KEYBOARD_TOP_PADDING_AUTO_SCROLL, extraKeyboardSpace: edgeToEdgeEnabled ? tokens["space-large"] : 0, contentContainerStyle: !keyboardHeight && styles.scrollContentContainer },
115
134
  React.createElement(View, { onLayout: ({ nativeEvent }) => {
116
135
  setFormContentHeight(nativeEvent.layout.height);
117
136
  } },
@@ -127,26 +146,6 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
127
146
  renderFooter))),
128
147
  React.createElement(View, { style: styles.safeArea, ref: bottomViewRef })))),
129
148
  React.createElement(FormMessage, null)));
130
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
- function handleKeyboardShow(frames) {
132
- setKeyboardScreenY(frames.endCoordinates.screenY);
133
- setKeyboardHeight(frames.endCoordinates.height);
134
- }
135
- function handleKeyboardHide() {
136
- var _a;
137
- (_a = bottomViewRef === null || bottomViewRef === void 0 ? void 0 : bottomViewRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(
138
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
139
- (_x, y, _width, _height) => {
140
- var _a;
141
- // This fixes extra whitespace below the form if it was scrolled down while the keyboard was open
142
- // i.e. a View below the form is higher than the bottom of the window
143
- if (y < windowHeight) {
144
- (_a = scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToEnd();
145
- }
146
- });
147
- setKeyboardHeight(0);
148
- setKeyboardScreenY(0);
149
- }
150
149
  function internalSubmit(data) {
151
150
  return __awaiter(this, void 0, void 0, function* () {
152
151
  let performSubmit = true;
@@ -4,7 +4,7 @@ export function useFormViewRefs() {
4
4
  const bottomViewRef = useRef(null);
5
5
  const scrollToTop = useCallback(() => {
6
6
  var _a;
7
- (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToPosition(0, 0);
7
+ (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({ x: 0, y: 0, animated: true });
8
8
  }, [scrollViewRef]);
9
9
  return {
10
10
  scrollViewRef: scrollViewRef,
@@ -2,7 +2,7 @@ import { useCallback, useState } from "react";
2
2
  import { Keyboard, Platform } from "react-native";
3
3
  import { useIsScreenReaderEnabled } from "../../../hooks";
4
4
  import { useErrorMessageContext } from "../../../ErrorMessageWrapper";
5
- export function useScrollToError({ formState: { errors, isValid, submitCount }, refNode, setFocus, scrollToPosition, }) {
5
+ export function useScrollToError({ formState: { errors, isValid, submitCount }, refNode, setFocus, scrollTo, }) {
6
6
  const [submitCounter, setSubmitCounter] = useState(submitCount);
7
7
  const isScreenReaderEnabled = useIsScreenReaderEnabled();
8
8
  const manuallyScrollToElement = useManuallyScrollToElement(handleScroll, refNode);
@@ -36,7 +36,7 @@ export function useScrollToError({ formState: { errors, isValid, submitCount },
36
36
  */
37
37
  const isAndroidWithScreenReader = isScreenReaderEnabled && Platform.OS === "android";
38
38
  const shouldAnimateScroll = !isAndroidWithScreenReader;
39
- scrollToPosition === null || scrollToPosition === void 0 ? void 0 : scrollToPosition(x, y, shouldAnimateScroll);
39
+ scrollTo === null || scrollTo === void 0 ? void 0 : scrollTo({ x, y, animated: shouldAnimateScroll });
40
40
  }
41
41
  }
42
42
  function focusInputWithRHF(errors, setFocus) {