@jobber/components-native 0.81.2-cleanup-fo-1e1db4e.33 → 0.81.2
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/Checkbox/Checkbox.js +3 -3
- package/dist/src/Checkbox/Checkbox.style.js +2 -1
- package/dist/src/Form/Form.js +10 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/Checkbox/Checkbox.style.d.ts +2 -1
- package/package.json +2 -2
- package/src/Checkbox/Checkbox.style.ts +2 -1
- package/src/Checkbox/Checkbox.tsx +9 -5
- package/src/Form/Form.test.tsx +0 -26
- package/src/Form/Form.tsx +10 -17
|
@@ -6,11 +6,12 @@ export declare const useStyles: () => {
|
|
|
6
6
|
width: "100%";
|
|
7
7
|
justifyContent: "space-between";
|
|
8
8
|
flexDirection: "row";
|
|
9
|
-
alignItems: "
|
|
9
|
+
alignItems: "flex-start";
|
|
10
10
|
paddingVertical: number;
|
|
11
11
|
};
|
|
12
12
|
label: {
|
|
13
13
|
flex: number;
|
|
14
|
+
gap: number;
|
|
14
15
|
};
|
|
15
16
|
checkbox: {
|
|
16
17
|
borderRadius: number;
|
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",
|
|
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": "cf3a355dd95152faff62049df5e68c70dba26d27"
|
|
84
84
|
}
|
|
@@ -12,12 +12,13 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
12
12
|
width: "100%",
|
|
13
13
|
justifyContent: "space-between",
|
|
14
14
|
flexDirection: "row",
|
|
15
|
-
alignItems: "
|
|
15
|
+
alignItems: "flex-start",
|
|
16
16
|
paddingVertical: tokens["space-small"],
|
|
17
17
|
},
|
|
18
18
|
|
|
19
19
|
label: {
|
|
20
20
|
flex: 1,
|
|
21
|
+
gap: tokens["space-smaller"],
|
|
21
22
|
},
|
|
22
23
|
|
|
23
24
|
checkbox: {
|
|
@@ -152,6 +152,15 @@ function CheckboxInternal({
|
|
|
152
152
|
<Text variation={textVariation} align="start">
|
|
153
153
|
{label}
|
|
154
154
|
</Text>
|
|
155
|
+
{assistiveText && (
|
|
156
|
+
<Text
|
|
157
|
+
level="textSupporting"
|
|
158
|
+
align="start"
|
|
159
|
+
variation={textVariation}
|
|
160
|
+
>
|
|
161
|
+
{assistiveText}
|
|
162
|
+
</Text>
|
|
163
|
+
)}
|
|
155
164
|
</View>
|
|
156
165
|
)}
|
|
157
166
|
<View
|
|
@@ -168,11 +177,6 @@ function CheckboxInternal({
|
|
|
168
177
|
)}
|
|
169
178
|
</View>
|
|
170
179
|
</View>
|
|
171
|
-
{assistiveText && (
|
|
172
|
-
<Text level="textSupporting" align="start" variation={textVariation}>
|
|
173
|
-
{assistiveText}
|
|
174
|
-
</Text>
|
|
175
|
-
)}
|
|
176
180
|
</Pressable>
|
|
177
181
|
);
|
|
178
182
|
}
|
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() {
|