@jobber/components-native 0.81.1 → 0.81.2-cleanup-fo-1e1db4e.33
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 +16 -10
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Form/Form.test.tsx +26 -0
- package/src/Form/Form.tsx +17 -10
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.2-cleanup-fo-1e1db4e.33+1e1db4e5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"react-native-safe-area-context": "^4.5.2",
|
|
81
81
|
"react-native-svg": ">=12.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "1e1db4e51bfb455c15a597be0e3e882044b7da01"
|
|
84
84
|
}
|
package/dist/src/Form/Form.js
CHANGED
|
@@ -106,7 +106,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
106
106
|
React.createElement(React.Fragment, null,
|
|
107
107
|
(isSubmitting || isSecondaryActionLoading) && React.createElement(FormMask, null),
|
|
108
108
|
React.createElement(FormCache, { localCacheKey: localCacheKey, localCacheExclude: localCacheExclude, setLocalCache: setLocalCache }),
|
|
109
|
-
React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(), submit:
|
|
109
|
+
React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(), submit: callHandleSubmit, isFormSubmitting: isSubmitting, saveButtonLabel: saveButtonLabel, shouldRenderActionBar: saveButtonPosition === "sticky", renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, setSaveButtonHeight: setSaveButtonHeight, saveButtonOffset: saveButtonOffset },
|
|
110
110
|
React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll: true, keyboardOpeningTime: Platform.OS === "ios" ? tokens["timing-slowest"] : 0, keyboardShouldPersistTaps: "handled", ref: scrollViewRef }, keyboardProps, { extraHeight: headerHeight, contentContainerStyle: !keyboardHeight && styles.scrollContentContainer }),
|
|
111
111
|
React.createElement(View, { onLayout: ({ nativeEvent }) => {
|
|
112
112
|
setFormContentHeight(nativeEvent.layout.height);
|
|
@@ -117,7 +117,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
117
117
|
React.createElement(View, { style: styles.formChildContainer },
|
|
118
118
|
React.createElement(React.Fragment, null,
|
|
119
119
|
React.createElement(View, { style: styles.formContent }, children),
|
|
120
|
-
saveButtonPosition === "inline" && (React.createElement(View, { style: styles.fixedSaveButton }, renderStickySection ? (renderStickySection(
|
|
120
|
+
saveButtonPosition === "inline" && (React.createElement(View, { style: styles.fixedSaveButton }, renderStickySection ? (renderStickySection(callHandleSubmit, saveButtonLabel, isSubmitting)) : (React.createElement(FormSaveButton, { primaryAction: callHandleSubmit, label: saveButtonLabel, loading: isSubmitting, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, onOpenBottomSheet: () => setIsBottomSheetOpen(true), onCloseBottomSheet: () => setIsBottomSheetOpen(false) })))),
|
|
121
121
|
renderFooter))),
|
|
122
122
|
React.createElement(View, { style: styles.safeArea, ref: bottomViewRef })))),
|
|
123
123
|
React.createElement(FormMessage, null)));
|
|
@@ -141,6 +141,18 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
141
141
|
setKeyboardHeight(0);
|
|
142
142
|
setKeyboardScreenY(0);
|
|
143
143
|
}
|
|
144
|
+
function callHandleSubmit() {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
var _a;
|
|
147
|
+
let result;
|
|
148
|
+
yield handleSubmit((data) => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const saveResult = yield internalSubmit(data);
|
|
150
|
+
result = saveResult;
|
|
151
|
+
}))();
|
|
152
|
+
(_a = removeListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(removeListenerRef);
|
|
153
|
+
onSubmitSuccess(result);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
144
156
|
function internalSubmit(data) {
|
|
145
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
158
|
let performSubmit = true;
|
|
@@ -149,13 +161,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
149
161
|
}
|
|
150
162
|
if (performSubmit) {
|
|
151
163
|
Keyboard.dismiss();
|
|
152
|
-
return onSubmit(data)
|
|
153
|
-
.then((result) => {
|
|
154
|
-
var _a;
|
|
155
|
-
(_a = removeListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(removeListenerRef);
|
|
156
|
-
onSubmitSuccess(result);
|
|
157
|
-
})
|
|
158
|
-
.catch(handleSubmitCatch);
|
|
164
|
+
return onSubmit(data).catch(handleSubmitCatch);
|
|
159
165
|
}
|
|
160
166
|
});
|
|
161
167
|
}
|
|
@@ -177,7 +183,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
177
183
|
}
|
|
178
184
|
function handleRetry() {
|
|
179
185
|
clearFormErrors();
|
|
180
|
-
return
|
|
186
|
+
return callHandleSubmit();
|
|
181
187
|
}
|
|
182
188
|
function calculateSaveButtonOffset() {
|
|
183
189
|
if (saveButtonOffset) {
|