@jobber/components-native 0.81.2-cleanup-fo-1e1db4e.33 → 0.81.2-fix-select-7f307df.38
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 +10 -16
- package/dist/src/Select/Select.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Form/Form.test.tsx +0 -26
- package/src/Form/Form.tsx +10 -17
- package/src/Select/Select.tsx +9 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.81.2-
|
|
3
|
+
"version": "0.81.2-fix-select-7f307df.38+7f307dff",
|
|
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": "7f307dff03481897a00c9ee1fd346d6b3efd5cb2"
|
|
84
84
|
}
|
package/src/Form/Form.test.tsx
CHANGED
|
@@ -300,32 +300,6 @@ describe("Form", () => {
|
|
|
300
300
|
});
|
|
301
301
|
});
|
|
302
302
|
|
|
303
|
-
it("should call onSubmitSuccess after submit promise resolves", async () => {
|
|
304
|
-
onSubmitMock.mockImplementationOnce(() => {
|
|
305
|
-
return Promise.resolve({
|
|
306
|
-
resolvedPromiseData: "passed",
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
const { getByLabelText } = render(<FormTest onSubmit={onSubmitMock} />);
|
|
310
|
-
const saveButton = getByLabelText(saveButtonText);
|
|
311
|
-
|
|
312
|
-
const newValue = "New Value";
|
|
313
|
-
fireEvent.changeText(getByLabelText(testInputTextPlaceholder), newValue);
|
|
314
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
315
|
-
|
|
316
|
-
fireEvent(getByLabelText(switchLabel), "onValueChange", true);
|
|
317
|
-
expect(onChangeSwitchMock).toHaveBeenCalled();
|
|
318
|
-
|
|
319
|
-
fireEvent.press(saveButton);
|
|
320
|
-
|
|
321
|
-
await waitFor(() => {
|
|
322
|
-
expect(onSubmitMock).toHaveBeenCalled();
|
|
323
|
-
});
|
|
324
|
-
expect(onSuccessMock).toHaveBeenCalledWith({
|
|
325
|
-
resolvedPromiseData: "passed",
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
|
|
329
303
|
it("should dismiss keyboard when form is saved", async () => {
|
|
330
304
|
const keyboardDismissSpy = jest.spyOn(Keyboard, "dismiss");
|
|
331
305
|
const { getByLabelText } = render(<FormTest onSubmit={onSubmitMock} />);
|
package/src/Form/Form.tsx
CHANGED
|
@@ -152,7 +152,7 @@ function InternalForm<T extends FieldValues, S>({
|
|
|
152
152
|
|
|
153
153
|
<FormBody
|
|
154
154
|
keyboardHeight={calculateSaveButtonOffset()}
|
|
155
|
-
submit={
|
|
155
|
+
submit={handleSubmit(internalSubmit)}
|
|
156
156
|
isFormSubmitting={isSubmitting}
|
|
157
157
|
saveButtonLabel={saveButtonLabel}
|
|
158
158
|
shouldRenderActionBar={saveButtonPosition === "sticky"}
|
|
@@ -195,13 +195,13 @@ function InternalForm<T extends FieldValues, S>({
|
|
|
195
195
|
<View style={styles.fixedSaveButton}>
|
|
196
196
|
{renderStickySection ? (
|
|
197
197
|
renderStickySection(
|
|
198
|
-
|
|
198
|
+
handleSubmit(internalSubmit),
|
|
199
199
|
saveButtonLabel,
|
|
200
200
|
isSubmitting,
|
|
201
201
|
)
|
|
202
202
|
) : (
|
|
203
203
|
<FormSaveButton
|
|
204
|
-
primaryAction={
|
|
204
|
+
primaryAction={handleSubmit(internalSubmit)}
|
|
205
205
|
label={saveButtonLabel}
|
|
206
206
|
loading={isSubmitting}
|
|
207
207
|
secondaryActions={secondaryActions}
|
|
@@ -247,18 +247,6 @@ function InternalForm<T extends FieldValues, S>({
|
|
|
247
247
|
setKeyboardScreenY(0);
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
async function callHandleSubmit() {
|
|
251
|
-
let result: S | undefined;
|
|
252
|
-
|
|
253
|
-
await handleSubmit(async data => {
|
|
254
|
-
const saveResult = await internalSubmit(data);
|
|
255
|
-
result = saveResult as S;
|
|
256
|
-
})();
|
|
257
|
-
|
|
258
|
-
removeListenerRef.current?.();
|
|
259
|
-
onSubmitSuccess(result as S);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
250
|
async function internalSubmit(data: FormValues<T>) {
|
|
263
251
|
let performSubmit = true;
|
|
264
252
|
|
|
@@ -269,7 +257,12 @@ function InternalForm<T extends FieldValues, S>({
|
|
|
269
257
|
if (performSubmit) {
|
|
270
258
|
Keyboard.dismiss();
|
|
271
259
|
|
|
272
|
-
return onSubmit(data)
|
|
260
|
+
return onSubmit(data)
|
|
261
|
+
.then((result: S) => {
|
|
262
|
+
removeListenerRef.current?.();
|
|
263
|
+
onSubmitSuccess(result);
|
|
264
|
+
})
|
|
265
|
+
.catch(handleSubmitCatch);
|
|
273
266
|
}
|
|
274
267
|
}
|
|
275
268
|
|
|
@@ -296,7 +289,7 @@ function InternalForm<T extends FieldValues, S>({
|
|
|
296
289
|
function handleRetry() {
|
|
297
290
|
clearFormErrors();
|
|
298
291
|
|
|
299
|
-
return
|
|
292
|
+
return handleSubmit(internalSubmit)();
|
|
300
293
|
}
|
|
301
294
|
|
|
302
295
|
function calculateSaveButtonOffset() {
|
package/src/Select/Select.tsx
CHANGED
|
@@ -153,14 +153,15 @@ export function Select({
|
|
|
153
153
|
<View
|
|
154
154
|
style={[styles.container, (invalid || !!error) && styles.invalid]}
|
|
155
155
|
>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
{label && (
|
|
157
|
+
<Text
|
|
158
|
+
level="textSupporting"
|
|
159
|
+
variation={textVariation}
|
|
160
|
+
hideFromScreenReader={true}
|
|
161
|
+
>
|
|
162
|
+
{label}
|
|
163
|
+
</Text>
|
|
164
|
+
)}
|
|
164
165
|
<View style={styles.input}>
|
|
165
166
|
<View style={styles.value}>
|
|
166
167
|
<Text
|