@jobber/components-native 0.95.2-JOB-141866-acfcddc.7 → 0.95.2-JOB-141866-80fe04c.8
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 +2 -2
- package/dist/src/Form/Form.js +9 -10
- package/dist/src/InputText/InputText.js +35 -20
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Form/Form.tsx +15 -14
- package/src/InputText/InputText.tsx +19 -21
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.95.2-JOB-141866-
|
|
3
|
+
"version": "0.95.2-JOB-141866-80fe04c.8+80fe04c86",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"react-native-safe-area-context": "^5.4.0",
|
|
97
97
|
"react-native-svg": ">=12.0.0"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "80fe04c86fc91e07591231460c32bc3194072bdc"
|
|
100
100
|
}
|
package/dist/src/Form/Form.js
CHANGED
|
@@ -18,7 +18,7 @@ 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, { useMemo, useState } from "react";
|
|
22
22
|
import { FormProvider } from "react-hook-form";
|
|
23
23
|
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
24
24
|
import { Keyboard, Platform, View, findNodeHandle } from "react-native";
|
|
@@ -39,7 +39,7 @@ import { FormSaveButton } from "./components/FormSaveButton";
|
|
|
39
39
|
import { useSaveButtonPosition } from "./hooks/useSaveButtonPosition";
|
|
40
40
|
import { FormCache } from "./components/FormCache/FormCache";
|
|
41
41
|
import { useAtlantisFormContext } from "./context/AtlantisFormContext";
|
|
42
|
-
import { InputAccessoriesProvider
|
|
42
|
+
import { InputAccessoriesProvider } from "../InputText";
|
|
43
43
|
import { tokens } from "../utils/design";
|
|
44
44
|
import { ErrorMessageProvider } from "../ErrorMessageWrapper";
|
|
45
45
|
export function Form(_a) {
|
|
@@ -54,7 +54,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
54
54
|
const { scrollViewRef, bottomViewRef, scrollToTop } = useFormViewRefs();
|
|
55
55
|
const [saveButtonHeight, setSaveButtonHeight] = useState(0);
|
|
56
56
|
const [messageBannerHeight, setMessageBannerHeight] = useState(0);
|
|
57
|
-
const { setIsScrolling } = useInputAccessoriesContext();
|
|
57
|
+
// const { setIsScrolling } = useInputAccessoriesContext();
|
|
58
58
|
const { formMethods, handleSubmit, isSubmitting, removeListenerRef, setLocalCache, } = useInternalForm({
|
|
59
59
|
mode,
|
|
60
60
|
reValidateMode,
|
|
@@ -82,8 +82,11 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
82
82
|
keyboardScreenY,
|
|
83
83
|
});
|
|
84
84
|
const [isSecondaryActionLoading, setIsSecondaryActionLoading] = useState(false);
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
const { calculatedKeyboardHeight } = useMemo(() => {
|
|
86
|
+
return {
|
|
87
|
+
calculatedKeyboardHeight: keyboardHeight - (paddingBottom + KEYBOARD_SAVE_BUTTON_DISTANCE),
|
|
88
|
+
};
|
|
89
|
+
}, [paddingBottom, keyboardHeight]);
|
|
87
90
|
useScrollToError({
|
|
88
91
|
formState: formMethods.formState,
|
|
89
92
|
refNode: findNodeHandle(scrollViewRef.current),
|
|
@@ -108,11 +111,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
108
111
|
(isSubmitting || isSecondaryActionLoading) && React.createElement(FormMask, null),
|
|
109
112
|
React.createElement(FormCache, { localCacheKey: localCacheKey, localCacheExclude: localCacheExclude, setLocalCache: setLocalCache }),
|
|
110
113
|
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 },
|
|
111
|
-
React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll: true, 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
|
|
112
|
-
setIsScrolling(true);
|
|
113
|
-
}, onScrollEndDrag: () => {
|
|
114
|
-
setIsScrolling(false);
|
|
115
|
-
} }),
|
|
114
|
+
React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll: true, 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 }),
|
|
116
115
|
React.createElement(View, { onLayout: ({ nativeEvent }) => {
|
|
117
116
|
setFormContentHeight(nativeEvent.layout.height);
|
|
118
117
|
} },
|
|
@@ -7,7 +7,6 @@ import { useInputAccessoriesContext } from "./context";
|
|
|
7
7
|
import { useFormController } from "../hooks";
|
|
8
8
|
import { InputFieldWrapper } from "../InputFieldWrapper";
|
|
9
9
|
import { useCommonInputStyles } from "../InputFieldWrapper/CommonInputStyles.style";
|
|
10
|
-
import { useScreenInformation } from "../Form/hooks/useScreenInformation";
|
|
11
10
|
/**
|
|
12
11
|
* Buffer zone in pixels for offscreen detection.
|
|
13
12
|
* This makes the detection more sensitive by marking the component as offscreen
|
|
@@ -48,7 +47,7 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
48
47
|
placeholderTextColor: "transparent",
|
|
49
48
|
}));
|
|
50
49
|
const _name = name !== null && name !== void 0 ? name : field.name;
|
|
51
|
-
const { inputAccessoryID, register, unregister, setFocusedInput, canFocusNext, onFocusNext,
|
|
50
|
+
const { inputAccessoryID, register, unregister, setFocusedInput, canFocusNext, onFocusNext, } = useInputAccessoriesContext();
|
|
52
51
|
useEffect(() => {
|
|
53
52
|
_name &&
|
|
54
53
|
register(_name, () => {
|
|
@@ -83,23 +82,40 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
83
82
|
}
|
|
84
83
|
const styles = useStyles();
|
|
85
84
|
const commonInputStyles = useCommonInputStyles();
|
|
86
|
-
const { headerHeight, windowHeight } = useScreenInformation();
|
|
85
|
+
// const { headerHeight, windowHeight } = useScreenInformation();
|
|
87
86
|
// State to track if the InputText component can fully fit on screen
|
|
88
87
|
// (i.e., it's completely visible). Use this state to handle visibility issues.
|
|
89
|
-
const [canFullyFitOnScreen, setCanFullyFitOnScreen] = useState(true);
|
|
88
|
+
// const [canFullyFitOnScreen, setCanFullyFitOnScreen] = useState(true);
|
|
90
89
|
return (React.createElement(InputFieldWrapper, { prefix: prefix, suffix: suffix, hasValue: hasValue, placeholderMode: placeholderMode, assistiveText: assistiveText, focused: focused, error: error, invalid: invalid, placeholder: placeholder, disabled: disabled, onClear: handleClear, showClearAction: showClear, styleOverride: styleOverride, toolbar: toolbar, toolbarVisibility: toolbarVisibility, loading: loading, loadingType: loadingType },
|
|
91
|
-
React.createElement(TextInput
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
React.createElement(TextInput
|
|
91
|
+
// onLayout={(event: LayoutChangeEvent) => {
|
|
92
|
+
// event.target?.measureInWindow((_, y, __, height) => {
|
|
93
|
+
// // Check if component can't fully fit on screen (height only)
|
|
94
|
+
// // Account for headerHeight at the top of the screen and buffer zone
|
|
95
|
+
// const visibleTop = headerHeight + KEYBOARD_AWARE_DETECTION_BUFFER; // Top of visible area (below header) with buffer
|
|
96
|
+
// const visibleBottom =
|
|
97
|
+
// windowHeight - KEYBOARD_AWARE_DETECTION_BUFFER; // Bottom of visible area with buffer
|
|
98
|
+
// const isOffScreen =
|
|
99
|
+
// y < visibleTop || // Top edge is behind or above the header (with buffer)
|
|
100
|
+
// y + height > visibleBottom; // Bottom edge is below the window (with buffer)
|
|
101
|
+
// setCanFullyFitOnScreen(!isOffScreen);
|
|
102
|
+
// });
|
|
103
|
+
// }}
|
|
104
|
+
, Object.assign({
|
|
105
|
+
// onLayout={(event: LayoutChangeEvent) => {
|
|
106
|
+
// event.target?.measureInWindow((_, y, __, height) => {
|
|
107
|
+
// // Check if component can't fully fit on screen (height only)
|
|
108
|
+
// // Account for headerHeight at the top of the screen and buffer zone
|
|
109
|
+
// const visibleTop = headerHeight + KEYBOARD_AWARE_DETECTION_BUFFER; // Top of visible area (below header) with buffer
|
|
110
|
+
// const visibleBottom =
|
|
111
|
+
// windowHeight - KEYBOARD_AWARE_DETECTION_BUFFER; // Bottom of visible area with buffer
|
|
112
|
+
// const isOffScreen =
|
|
113
|
+
// y < visibleTop || // Top edge is behind or above the header (with buffer)
|
|
114
|
+
// y + height > visibleBottom; // Bottom edge is below the window (with buffer)
|
|
115
|
+
// setCanFullyFitOnScreen(!isOffScreen);
|
|
116
|
+
// });
|
|
117
|
+
// }}
|
|
118
|
+
inputAccessoryViewID: inputAccessoryID || undefined, testID: testID, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, spellCheck: spellCheck, style: [
|
|
103
119
|
commonInputStyles.input,
|
|
104
120
|
styles.inputPaddingTop,
|
|
105
121
|
!miniLabelActive && commonInputStyles.inputEmpty,
|
|
@@ -115,14 +131,13 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
115
131
|
],
|
|
116
132
|
// Prevent focus during scroll for multiline inputs to avoid
|
|
117
133
|
// the input focusing when the user is trying to scroll the form
|
|
118
|
-
readOnly
|
|
119
|
-
|
|
120
|
-
editable: !disabled, keyboardType: keyboard, value: inputTransform(internalValue), autoFocus: autoFocus, autoComplete: autoComplete, multiline: multiline,
|
|
134
|
+
// readOnly={readonly || (multiline && isScrolling && !focused)}
|
|
135
|
+
readOnly: readonly, editable: !disabled, keyboardType: keyboard, value: inputTransform(internalValue), autoFocus: autoFocus, autoComplete: autoComplete, multiline: multiline,
|
|
121
136
|
// Makes sure it doesn't jump to the top of the screen when the keyboard is shown and a new line is added.
|
|
122
137
|
// State for tracking if the input should be scrollable.
|
|
123
138
|
// This is tech debt related to an issue where keyboard aware scrollview doesn't work if `scrollEnabled` is true. However,
|
|
124
139
|
// when `scrollEnabled` is false it causes an issue where super long text inputs will jump to the top when a new line is added to the bottom of the input.
|
|
125
|
-
scrollEnabled: Platform.OS === "ios"
|
|
140
|
+
scrollEnabled: Platform.OS === "ios", textContentType: textContentType, onChangeText: handleChangeText, onSubmitEditing: handleOnSubmitEditing, returnKeyType: returnKeyType, blurOnSubmit: shouldBlurOnSubmit, accessibilityLabel: accessibilityLabel || placeholder, accessibilityHint: accessibilityHint, accessibilityState: { busy: loading }, secureTextEntry: secureTextEntry }, androidA11yProps, { onFocus: event => {
|
|
126
141
|
_name && setFocusedInput(_name);
|
|
127
142
|
setFocused(true);
|
|
128
143
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|