@jobber/components-native 0.67.3 → 0.67.5
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/InputDate/InputDate.js +2 -1
- package/dist/src/InputTime/InputTime.js +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/Form/types.d.ts +4 -1
- package/package.json +2 -2
- package/src/Form/types.ts +4 -1
- package/src/InputDate/InputDate.test.tsx +8 -0
- package/src/InputDate/InputDate.tsx +2 -1
- package/src/InputTime/InputTime.test.tsx +8 -0
- package/src/InputTime/InputTime.tsx +2 -1
|
@@ -51,7 +51,10 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
|
51
51
|
*/
|
|
52
52
|
onBeforeSubmit?: (data: FormValues<T>) => Promise<boolean>;
|
|
53
53
|
/**
|
|
54
|
-
* A callback function that handles the submission of form data
|
|
54
|
+
* A callback function that handles the submission of form data.
|
|
55
|
+
* If an error occurs during submission, it should not be caught and handled silently; the error must be thrown again.
|
|
56
|
+
* If the submission is successful and no error is thrown, the `onSubmitSuccess` callback will be called.
|
|
57
|
+
* If an error is thrown, the `onSubmitError` callback will be called.
|
|
55
58
|
*/
|
|
56
59
|
onSubmit: (data: FormValues<T>) => Promise<SubmitResponseType>;
|
|
57
60
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.67.
|
|
3
|
+
"version": "0.67.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"react-native-safe-area-context": "^4.5.2",
|
|
85
85
|
"react-native-svg": ">=12.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "b402581a5a67e7ac3c59e8a9610b11b067636493"
|
|
88
88
|
}
|
package/src/Form/types.ts
CHANGED
|
@@ -73,7 +73,10 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
|
73
73
|
onBeforeSubmit?: (data: FormValues<T>) => Promise<boolean>;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* A callback function that handles the submission of form data
|
|
76
|
+
* A callback function that handles the submission of form data.
|
|
77
|
+
* If an error occurs during submission, it should not be caught and handled silently; the error must be thrown again.
|
|
78
|
+
* If the submission is successful and no error is thrown, the `onSubmitSuccess` callback will be called.
|
|
79
|
+
* If an error is thrown, the `onSubmitError` callback will be called.
|
|
77
80
|
*/
|
|
78
81
|
onSubmit: (data: FormValues<T>) => Promise<SubmitResponseType>;
|
|
79
82
|
|
|
@@ -2,10 +2,13 @@ import React from "react";
|
|
|
2
2
|
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
3
3
|
import { Host } from "react-native-portalize";
|
|
4
4
|
import { FormProvider, useForm } from "react-hook-form";
|
|
5
|
+
import { Keyboard } from "react-native";
|
|
5
6
|
import { InputDate } from "./InputDate";
|
|
6
7
|
import { Button } from "../Button";
|
|
7
8
|
import * as atlantisContext from "../AtlantisContext/AtlantisContext";
|
|
8
9
|
|
|
10
|
+
const keyboardDismissSpy = jest.spyOn(Keyboard, "dismiss");
|
|
11
|
+
|
|
9
12
|
describe("InputDate", () => {
|
|
10
13
|
describe("Visuals", () => {
|
|
11
14
|
const placeholder = "Start time";
|
|
@@ -134,6 +137,11 @@ describe("InputDate", () => {
|
|
|
134
137
|
fireEvent.press(screen.getByLabelText("Confirm"));
|
|
135
138
|
expect(handleChange).toHaveBeenCalledWith(expect.any(Date));
|
|
136
139
|
});
|
|
140
|
+
|
|
141
|
+
it("should dismiss the keyboard when the date picker is opened", () => {
|
|
142
|
+
renderDatePicker();
|
|
143
|
+
expect(keyboardDismissSpy).toHaveBeenCalled();
|
|
144
|
+
});
|
|
137
145
|
});
|
|
138
146
|
const mockOnSubmit = jest.fn();
|
|
139
147
|
const saveButtonText = "Submit";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useState } from "react";
|
|
2
2
|
import DateTimePicker from "react-native-modal-datetime-picker";
|
|
3
|
-
import { Platform } from "react-native";
|
|
3
|
+
import { Keyboard, Platform } from "react-native";
|
|
4
4
|
import { FieldError, UseControllerProps } from "react-hook-form";
|
|
5
5
|
import { XOR } from "ts-xor";
|
|
6
6
|
import { Clearable } from "@jobber/hooks";
|
|
@@ -204,6 +204,7 @@ function InternalInputDate({
|
|
|
204
204
|
);
|
|
205
205
|
|
|
206
206
|
function showDatePicker() {
|
|
207
|
+
Keyboard.dismiss();
|
|
207
208
|
setShowPicker(true);
|
|
208
209
|
}
|
|
209
210
|
|
|
@@ -2,10 +2,12 @@ import React from "react";
|
|
|
2
2
|
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
3
3
|
import { Host } from "react-native-portalize";
|
|
4
4
|
import { FormProvider, useForm } from "react-hook-form";
|
|
5
|
+
import { Keyboard } from "react-native";
|
|
5
6
|
import { InputTime } from "./InputTime";
|
|
6
7
|
import * as atlantisContext from "../AtlantisContext/AtlantisContext";
|
|
7
8
|
import { Button } from "../Button";
|
|
8
9
|
|
|
10
|
+
const keyboardDismissSpy = jest.spyOn(Keyboard, "dismiss");
|
|
9
11
|
afterEach(() => {
|
|
10
12
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockRestore();
|
|
11
13
|
});
|
|
@@ -102,6 +104,7 @@ describe("With emptyValueLabel", () => {
|
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
|
|
107
|
+
// eslint-disable-next-line max-statements
|
|
105
108
|
describe("Time picker", () => {
|
|
106
109
|
const placeholder = "Tap me";
|
|
107
110
|
const handleChange = jest.fn();
|
|
@@ -143,6 +146,11 @@ describe("Time picker", () => {
|
|
|
143
146
|
expect(handleChange).toHaveBeenCalledWith(expect.any(Date));
|
|
144
147
|
});
|
|
145
148
|
|
|
149
|
+
it("should dismiss the keyboard when the time picker is opened", () => {
|
|
150
|
+
renderTimePicker();
|
|
151
|
+
expect(keyboardDismissSpy).toHaveBeenCalled();
|
|
152
|
+
});
|
|
153
|
+
|
|
146
154
|
it("should be a time picker", () => {
|
|
147
155
|
const screen = renderTimePicker();
|
|
148
156
|
expect(screen.getByTestId("inputTime-Picker").props.mode).toBe("time");
|
|
@@ -2,7 +2,7 @@ import React, { useMemo, useState } from "react";
|
|
|
2
2
|
import { FieldError, UseControllerProps } from "react-hook-form";
|
|
3
3
|
import { XOR } from "ts-xor";
|
|
4
4
|
import DateTimePicker from "react-native-modal-datetime-picker";
|
|
5
|
-
import { View } from "react-native";
|
|
5
|
+
import { Keyboard, View } from "react-native";
|
|
6
6
|
import { Clearable } from "@jobber/hooks";
|
|
7
7
|
import { styles } from "./InputTime.style";
|
|
8
8
|
import { getTimeZoneOffsetInMinutes, roundUpToNearestMinutes } from "./utils";
|
|
@@ -182,6 +182,7 @@ function InternalInputTime({
|
|
|
182
182
|
);
|
|
183
183
|
|
|
184
184
|
function showDatePicker() {
|
|
185
|
+
Keyboard.dismiss();
|
|
185
186
|
setShowPicker(true);
|
|
186
187
|
}
|
|
187
188
|
|