@jobber/components-native 0.95.2-JOB-141866-ccf6ba8.10 → 0.95.2-JOB-141866-5052098.24
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/ContentOverlay/ContentOverlay.js +2 -1
- package/dist/src/Form/Form.js +9 -11
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +2 -2
- package/dist/src/InputText/InputText.js +7 -27
- package/dist/src/hooks/index.js +0 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/Form/types.d.ts +7 -0
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +2 -3
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/package.json +2 -2
- package/src/ContentOverlay/ContentOverlay.tsx +2 -1
- package/src/Form/Form.tsx +11 -13
- package/src/Form/types.ts +8 -0
- package/src/InputFieldWrapper/InputFieldWrapper.tsx +1 -10
- package/src/InputText/InputText.tsx +5 -30
- package/src/InputText/context/InputAccessoriesProvider.test.tsx +0 -1
- package/src/hooks/index.ts +0 -1
- /package/dist/src/{hooks → ContentOverlay/hooks}/useKeyboardVisibility.js +0 -0
- /package/dist/types/src/{hooks → ContentOverlay/hooks}/useKeyboardVisibility.d.ts +0 -0
- /package/src/{hooks → ContentOverlay/hooks}/useKeyboardVisibility.test.ts +0 -0
- /package/src/{hooks → ContentOverlay/hooks}/useKeyboardVisibility.ts +0 -0
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-5052098.24+505209802",
|
|
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": "5052098024ddd00b6992954ce35278a551c13ed4"
|
|
100
100
|
}
|
|
@@ -2,10 +2,11 @@ import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, u
|
|
|
2
2
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
3
|
import { AccessibilityInfo, Platform, View, findNodeHandle, useWindowDimensions, } from "react-native";
|
|
4
4
|
import { Portal } from "react-native-portalize";
|
|
5
|
+
import { useKeyboardVisibility } from "./hooks/useKeyboardVisibility";
|
|
5
6
|
import { useStyles } from "./ContentOverlay.style";
|
|
6
7
|
import { useViewLayoutHeight } from "./hooks/useViewLayoutHeight";
|
|
7
8
|
import { UNSAFE_WrappedModalize } from "./UNSAFE_WrappedModalize";
|
|
8
|
-
import { useIsScreenReaderEnabled
|
|
9
|
+
import { useIsScreenReaderEnabled } from "../hooks";
|
|
9
10
|
import { IconButton } from "../IconButton";
|
|
10
11
|
import { Heading } from "../Heading";
|
|
11
12
|
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
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, {
|
|
21
|
+
import React, { 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";
|
|
@@ -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, UNSAFE_allowDiscardLocalCacheWhenOffline, }) {
|
|
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, disableKeyboardAwareScroll = false, renderFooter, UNSAFE_allowDiscardLocalCacheWhenOffline, }) {
|
|
53
53
|
var _a;
|
|
54
54
|
const { scrollViewRef, bottomViewRef, scrollToTop } = useFormViewRefs();
|
|
55
55
|
const [saveButtonHeight, setSaveButtonHeight] = useState(0);
|
|
@@ -81,11 +81,8 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
81
81
|
keyboardScreenY,
|
|
82
82
|
});
|
|
83
83
|
const [isSecondaryActionLoading, setIsSecondaryActionLoading] = useState(false);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
calculatedKeyboardHeight: keyboardHeight - (paddingBottom + KEYBOARD_SAVE_BUTTON_DISTANCE),
|
|
87
|
-
};
|
|
88
|
-
}, [paddingBottom, keyboardHeight]);
|
|
84
|
+
const extraViewHeight = paddingBottom + KEYBOARD_SAVE_BUTTON_DISTANCE;
|
|
85
|
+
const calculatedKeyboardHeight = keyboardHeight - extraViewHeight;
|
|
89
86
|
useScrollToError({
|
|
90
87
|
formState: formMethods.formState,
|
|
91
88
|
refNode: findNodeHandle(scrollViewRef.current),
|
|
@@ -103,6 +100,9 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
103
100
|
onKeyboardDidShow: handleKeyboardShow,
|
|
104
101
|
},
|
|
105
102
|
});
|
|
103
|
+
const onLayout = (event) => {
|
|
104
|
+
setMessageBannerHeight(event.nativeEvent.layout.height);
|
|
105
|
+
};
|
|
106
106
|
const styles = useStyles();
|
|
107
107
|
const { edgeToEdgeEnabled } = useAtlantisFormContext();
|
|
108
108
|
return (React.createElement(FormProvider, Object.assign({}, formMethods),
|
|
@@ -110,13 +110,11 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
110
110
|
(isSubmitting || isSecondaryActionLoading) && React.createElement(FormMask, null),
|
|
111
111
|
React.createElement(FormCache, { localCacheKey: localCacheKey, localCacheExclude: localCacheExclude, setLocalCache: setLocalCache }),
|
|
112
112
|
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 },
|
|
113
|
-
React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll:
|
|
113
|
+
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 }),
|
|
114
114
|
React.createElement(View, { onLayout: ({ nativeEvent }) => {
|
|
115
115
|
setFormContentHeight(nativeEvent.layout.height);
|
|
116
116
|
} },
|
|
117
|
-
React.createElement(View, { onLayout:
|
|
118
|
-
setMessageBannerHeight(nativeEvent.layout.height);
|
|
119
|
-
} },
|
|
117
|
+
React.createElement(View, { onLayout: onLayout },
|
|
120
118
|
React.createElement(FormMessageBanner, { bannerMessages: bannerMessages }),
|
|
121
119
|
React.createElement(FormErrorBanner, { networkError: bannerErrors === null || bannerErrors === void 0 ? void 0 : bannerErrors.networkError, bannerError: bannerErrors === null || bannerErrors === void 0 ? void 0 : bannerErrors.bannerError })),
|
|
122
120
|
React.createElement(View, { style: styles.formChildContainer },
|
|
@@ -11,7 +11,7 @@ import { Text } from "../Text";
|
|
|
11
11
|
import { ActivityIndicator } from "../ActivityIndicator";
|
|
12
12
|
export const INPUT_FIELD_WRAPPER_GLIMMERS_TEST_ID = "ATL-InputFieldWrapper-Glimmers";
|
|
13
13
|
export const INPUT_FIELD_WRAPPER_SPINNER_TEST_ID = "ATL-InputFieldWrapper-Spinner";
|
|
14
|
-
export function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix, placeholderMode = "normal", hasValue = false, error, focused = false, children, onClear, showClearAction = false, styleOverride, toolbar, toolbarVisibility = "while-editing", loading = false, loadingType = "spinner",
|
|
14
|
+
export function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix, placeholderMode = "normal", hasValue = false, error, focused = false, children, onClear, showClearAction = false, styleOverride, toolbar, toolbarVisibility = "while-editing", loading = false, loadingType = "spinner", }) {
|
|
15
15
|
fieldAffixRequiredPropsCheck([prefix, suffix]);
|
|
16
16
|
const handleClear = onClear !== null && onClear !== void 0 ? onClear : noopClear;
|
|
17
17
|
warnIfClearActionWithNoOnClear(onClear, showClearAction);
|
|
@@ -29,7 +29,7 @@ export function InputFieldWrapper({ invalid, disabled, placeholder, assistiveTex
|
|
|
29
29
|
(Boolean(invalid) || error) && styles.inputInvalid,
|
|
30
30
|
disabled && styles.disabled,
|
|
31
31
|
styleOverride === null || styleOverride === void 0 ? void 0 : styleOverride.container,
|
|
32
|
-
]
|
|
32
|
+
] },
|
|
33
33
|
React.createElement(View, { style: styles.field },
|
|
34
34
|
(prefix === null || prefix === void 0 ? void 0 : prefix.icon) && (React.createElement(PrefixIcon, { disabled: disabled, focused: focused, inputInvalid: inputInvalid, icon: prefix.icon })),
|
|
35
35
|
React.createElement(View, { style: [styles.inputContainer] },
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import React, { forwardRef,
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
2
2
|
import { Platform, TextInput } from "react-native";
|
|
3
3
|
import identity from "lodash/identity";
|
|
4
4
|
import { useShowClear } from "@jobber/hooks";
|
|
5
5
|
import { useStyles } from "./InputText.style";
|
|
6
6
|
import { useInputAccessoriesContext } from "./context";
|
|
7
|
-
import { useFormController
|
|
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
|
-
// import { useScreenInformation } from "../Form/hooks/useScreenInformation";
|
|
12
|
-
/**
|
|
13
|
-
* Buffer zone in pixels for offscreen detection.
|
|
14
|
-
* This makes the detection more sensitive by marking the component as offscreen
|
|
15
|
-
* even if it's technically still visible but within this buffer distance from the edge.
|
|
16
|
-
*/
|
|
17
|
-
// 44 (accessory bar height) + 20 (buffer)
|
|
18
|
-
const KEYBOARD_AWARE_DETECTION_BUFFER = 40;
|
|
19
10
|
export const InputText = forwardRef(InputTextInternal);
|
|
20
11
|
// eslint-disable-next-line max-statements
|
|
21
12
|
function InputTextInternal({ invalid, disabled, readonly = false, name, placeholder, assistiveText, showMiniLabel = true, keyboard, value: controlledValue, defaultValue, autoFocus, autoComplete = "off", spellCheck, textContentType = "none", validations, onChangeText, onSubmitEditing, onFocus, accessibilityLabel, accessibilityHint, autoCorrect, autoCapitalize, onBlur, multiline = false, prefix, suffix, transform = {}, clearable = multiline ? "never" : "while-editing", testID, secureTextEntry, styleOverride, toolbar, toolbarVisibility, loading, loadingType, }, ref) {
|
|
@@ -84,20 +75,7 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
84
75
|
}
|
|
85
76
|
const styles = useStyles();
|
|
86
77
|
const commonInputStyles = useCommonInputStyles();
|
|
87
|
-
|
|
88
|
-
const { keyboardHeight } = useKeyboardVisibility();
|
|
89
|
-
const maxHeight = useDeferredValue(windowHeight -
|
|
90
|
-
headerHeight -
|
|
91
|
-
keyboardHeight -
|
|
92
|
-
KEYBOARD_AWARE_DETECTION_BUFFER);
|
|
93
|
-
const [inputHeight, setInputHeight] = useState(0);
|
|
94
|
-
const enableScroll = useDeferredValue(inputHeight > maxHeight);
|
|
95
|
-
return (React.createElement(InputFieldWrapper, { scrollViewHackOnLayout: event => {
|
|
96
|
-
var _a;
|
|
97
|
-
(_a = event.target) === null || _a === void 0 ? void 0 : _a.measureInWindow((_, y, __, height) => {
|
|
98
|
-
setInputHeight(height);
|
|
99
|
-
});
|
|
100
|
-
}, 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 },
|
|
78
|
+
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 },
|
|
101
79
|
React.createElement(TextInput, Object.assign({ inputAccessoryViewID: inputAccessoryID || undefined, testID: testID, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, spellCheck: spellCheck, style: [
|
|
102
80
|
commonInputStyles.input,
|
|
103
81
|
styles.inputPaddingTop,
|
|
@@ -112,11 +90,13 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
112
90
|
styleOverride === null || styleOverride === void 0 ? void 0 : styleOverride.inputText,
|
|
113
91
|
loading && loadingType === "glimmer" && { color: "transparent" },
|
|
114
92
|
], readOnly: readonly, editable: !disabled, keyboardType: keyboard, value: inputTransform(internalValue), autoFocus: autoFocus, autoComplete: autoComplete, multiline: multiline,
|
|
93
|
+
// TODO: JOB-147156 This is a HACK for multiline inputs on iOS scrolling issue.
|
|
94
|
+
// This hack should be removed once we swap keyboard aware libraries in JOB-147156
|
|
95
|
+
// If this is needed then we need to figure out a better solution.
|
|
115
96
|
// Makes sure it doesn't jump to the top of the screen when the keyboard is shown and a new line is added.
|
|
116
|
-
// State for tracking if the input should be scrollable.
|
|
117
97
|
// This is tech debt related to an issue where keyboard aware scrollview doesn't work if `scrollEnabled` is true. However,
|
|
118
98
|
// 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.
|
|
119
|
-
scrollEnabled: Platform.OS === "ios" &&
|
|
99
|
+
scrollEnabled: Platform.OS === "ios" && multiline, textContentType: textContentType, onChangeText: handleChangeText, onSubmitEditing: handleOnSubmitEditing, returnKeyType: returnKeyType, blurOnSubmit: shouldBlurOnSubmit, accessibilityLabel: accessibilityLabel || placeholder, accessibilityHint: accessibilityHint, accessibilityState: { busy: loading }, secureTextEntry: secureTextEntry }, androidA11yProps, { onFocus: event => {
|
|
120
100
|
_name && setFocusedInput(_name);
|
|
121
101
|
setFocused(true);
|
|
122
102
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
package/dist/src/hooks/index.js
CHANGED