@jobber/components-native 0.98.5 → 0.99.0
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/AtlantisOverlayProvider/AtlantisOverlayProvider.js +5 -0
- package/dist/src/AtlantisOverlayProvider/index.js +1 -0
- package/dist/src/BottomSheet/BottomSheet.js +9 -11
- package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +2 -2
- package/dist/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.js +9 -11
- package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +7 -9
- package/dist/src/index.js +1 -0
- package/dist/src/utils/meta/meta.json +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisOverlayProvider/AtlantisOverlayProvider.d.ts +6 -0
- package/dist/types/src/AtlantisOverlayProvider/index.d.ts +1 -0
- package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/AtlantisOverlayProvider/AtlantisOverlayProvider.tsx +12 -0
- package/src/AtlantisOverlayProvider/index.ts +1 -0
- package/src/BottomSheet/BottomSheet.tsx +13 -13
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +10 -10
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +4 -4
- package/src/ButtonGroup/ButtonGroup.stories.tsx +10 -8
- package/src/ButtonGroup/ButtonGroup.test.tsx +7 -10
- package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +26 -29
- package/src/Form/Form.stories.tsx +8 -4
- package/src/Form/Form.test.tsx +51 -54
- package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +7 -10
- package/src/FormatFile/FormatFile.stories.tsx +3 -4
- package/src/FormatFile/FormatFile.test.tsx +11 -14
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +6 -9
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +21 -24
- package/src/InputDate/InputDate.test.tsx +5 -8
- package/src/InputTime/InputTime.stories.tsx +8 -4
- package/src/InputTime/InputTime.test.tsx +5 -8
- package/src/ThumbnailList/ThumbnailList.stories.tsx +6 -4
- package/src/ThumbnailList/ThumbnailList.test.tsx +5 -8
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +101 -150
- package/src/index.ts +1 -0
- package/src/utils/meta/meta.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AtlantisOverlayProvider } from "./AtlantisOverlayProvider";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { BottomSheetModal } from "@gorhom/bottom-sheet";
|
|
2
2
|
/**
|
|
3
|
-
* Hook that
|
|
3
|
+
* Hook that dismisses the bottom sheet modal on the hardware back button press if it is visible
|
|
4
4
|
* @param bottomSheetRef ref to the bottom sheet component
|
|
5
5
|
*/
|
|
6
|
-
export declare function useBottomSheetBackHandler(bottomSheetRef: React.RefObject<
|
|
6
|
+
export declare function useBottomSheetBackHandler(bottomSheetRef: React.RefObject<BottomSheetModal | null>): {
|
|
7
7
|
handleSheetPositionChange: (index: number) => void;
|
|
8
8
|
};
|
|
@@ -2,6 +2,7 @@ export * from "./ActionItem";
|
|
|
2
2
|
export * from "./ActionLabel";
|
|
3
3
|
export * from "./ActivityIndicator";
|
|
4
4
|
export * from "./AtlantisContext";
|
|
5
|
+
export * from "./AtlantisOverlayProvider";
|
|
5
6
|
export * from "./AtlantisThemeContext";
|
|
6
7
|
export * from "./AutoLink";
|
|
7
8
|
export * from "./Banner";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.0",
|
|
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": "c92c33f8e0a06cbc2addce9eca3005c1231a9202"
|
|
100
100
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BottomSheetModalProvider } from "@gorhom/bottom-sheet";
|
|
3
|
+
|
|
4
|
+
interface AtlantisOverlayProviderProps {
|
|
5
|
+
readonly children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function AtlantisOverlayProvider({
|
|
9
|
+
children,
|
|
10
|
+
}: AtlantisOverlayProviderProps) {
|
|
11
|
+
return <BottomSheetModalProvider>{children}</BottomSheetModalProvider>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AtlantisOverlayProvider } from "./AtlantisOverlayProvider";
|
|
@@ -2,8 +2,9 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import React, { useCallback, useImperativeHandle, useRef } from "react";
|
|
3
3
|
import { Keyboard, View } from "react-native";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
-
import
|
|
5
|
+
import {
|
|
6
6
|
BottomSheetBackdrop,
|
|
7
|
+
BottomSheetModal,
|
|
7
8
|
BottomSheetView,
|
|
8
9
|
} from "@gorhom/bottom-sheet";
|
|
9
10
|
import type { BottomSheetBackdropProps } from "@gorhom/bottom-sheet";
|
|
@@ -67,13 +68,14 @@ export function BottomSheet({
|
|
|
67
68
|
const { t } = useAtlantisI18n();
|
|
68
69
|
const insets = useSafeAreaInsets();
|
|
69
70
|
const previousIndexRef = useRef(-1);
|
|
70
|
-
const bottomSheetRef = useRef<
|
|
71
|
+
const bottomSheetRef = useRef<BottomSheetModal>(null);
|
|
71
72
|
const { handleSheetPositionChange } =
|
|
72
73
|
useBottomSheetBackHandler(bottomSheetRef);
|
|
73
74
|
|
|
74
75
|
useImperativeHandle(ref, () => ({
|
|
75
76
|
open: () => {
|
|
76
|
-
|
|
77
|
+
dismissKeyboard();
|
|
78
|
+
bottomSheetRef.current?.present();
|
|
77
79
|
},
|
|
78
80
|
close: () => {
|
|
79
81
|
close();
|
|
@@ -81,7 +83,7 @@ export function BottomSheet({
|
|
|
81
83
|
}));
|
|
82
84
|
|
|
83
85
|
const close = useCallback(() => {
|
|
84
|
-
bottomSheetRef.current?.
|
|
86
|
+
bottomSheetRef.current?.dismiss();
|
|
85
87
|
}, []);
|
|
86
88
|
|
|
87
89
|
const handleChange = (index: number) => {
|
|
@@ -91,26 +93,24 @@ export function BottomSheet({
|
|
|
91
93
|
const previousIndex = previousIndexRef.current;
|
|
92
94
|
|
|
93
95
|
if (previousIndex === -1 && index >= 0) {
|
|
94
|
-
// Transitioned from closed to open
|
|
95
|
-
dismissKeyboard();
|
|
96
96
|
onOpen?.();
|
|
97
|
-
} else if (previousIndex >= 0 && index === -1) {
|
|
98
|
-
// Transitioned from open to closed
|
|
99
|
-
dismissKeyboard();
|
|
100
|
-
onClose?.();
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
previousIndexRef.current = index;
|
|
104
100
|
};
|
|
105
101
|
|
|
106
102
|
return (
|
|
107
|
-
<
|
|
103
|
+
<BottomSheetModal
|
|
108
104
|
ref={bottomSheetRef}
|
|
109
|
-
index={-1}
|
|
110
105
|
backdropComponent={Backdrop}
|
|
111
106
|
backgroundStyle={styles.background}
|
|
112
107
|
enablePanDownToClose={true}
|
|
113
108
|
onChange={handleChange}
|
|
109
|
+
onDismiss={() => {
|
|
110
|
+
previousIndexRef.current = -1;
|
|
111
|
+
dismissKeyboard();
|
|
112
|
+
onClose?.();
|
|
113
|
+
}}
|
|
114
114
|
keyboardBlurBehavior="restore"
|
|
115
115
|
handleStyle={styles.handle}
|
|
116
116
|
>
|
|
@@ -126,7 +126,7 @@ export function BottomSheet({
|
|
|
126
126
|
<Footer styles={styles} close={close} cancelLabel={t("cancel")} />
|
|
127
127
|
)}
|
|
128
128
|
</BottomSheetView>
|
|
129
|
-
</
|
|
129
|
+
</BottomSheetModal>
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -2,7 +2,7 @@ import { createRef } from "react";
|
|
|
2
2
|
import type { RefObject } from "react";
|
|
3
3
|
import { act, renderHook } from "@testing-library/react-native";
|
|
4
4
|
import { BackHandler } from "react-native";
|
|
5
|
-
import type
|
|
5
|
+
import type { BottomSheetModal } from "@gorhom/bottom-sheet";
|
|
6
6
|
import { useBottomSheetBackHandler } from "./useBottomSheetBackHandler";
|
|
7
7
|
|
|
8
8
|
describe("useBottomSheetBackHandler", () => {
|
|
@@ -20,7 +20,7 @@ describe("useBottomSheetBackHandler", () => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it("should register BackHandler listener when sheet becomes visible", async () => {
|
|
23
|
-
const bottomSheetRef = createRef<
|
|
23
|
+
const bottomSheetRef = createRef<BottomSheetModal | null>();
|
|
24
24
|
const { result } = renderHook(() =>
|
|
25
25
|
useBottomSheetBackHandler(bottomSheetRef),
|
|
26
26
|
);
|
|
@@ -35,13 +35,13 @@ describe("useBottomSheetBackHandler", () => {
|
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it("should call
|
|
39
|
-
const
|
|
38
|
+
it("should call dismiss() when back button is pressed", async () => {
|
|
39
|
+
const mockDismiss = jest.fn();
|
|
40
40
|
const bottomSheetRef = {
|
|
41
41
|
current: {
|
|
42
|
-
|
|
43
|
-
} as unknown as
|
|
44
|
-
} as RefObject<
|
|
42
|
+
dismiss: mockDismiss,
|
|
43
|
+
} as unknown as BottomSheetModal,
|
|
44
|
+
} as RefObject<BottomSheetModal | null>;
|
|
45
45
|
|
|
46
46
|
const { result } = renderHook(() =>
|
|
47
47
|
useBottomSheetBackHandler(bottomSheetRef),
|
|
@@ -54,12 +54,12 @@ describe("useBottomSheetBackHandler", () => {
|
|
|
54
54
|
const registeredCallback = mockAddEventListener.mock.calls[0][1];
|
|
55
55
|
const returnValue = registeredCallback();
|
|
56
56
|
|
|
57
|
-
expect(
|
|
57
|
+
expect(mockDismiss).toHaveBeenCalled();
|
|
58
58
|
expect(returnValue).toBe(true);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it("should remove listener when sheet is dismissed", async () => {
|
|
62
|
-
const bottomSheetRef = createRef<
|
|
62
|
+
const bottomSheetRef = createRef<BottomSheetModal | null>();
|
|
63
63
|
const { result } = renderHook(() =>
|
|
64
64
|
useBottomSheetBackHandler(bottomSheetRef),
|
|
65
65
|
);
|
|
@@ -76,7 +76,7 @@ describe("useBottomSheetBackHandler", () => {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it("should not register listener when index is negative", async () => {
|
|
79
|
-
const bottomSheetRef = createRef<
|
|
79
|
+
const bottomSheetRef = createRef<BottomSheetModal | null>();
|
|
80
80
|
const { result } = renderHook(() =>
|
|
81
81
|
useBottomSheetBackHandler(bottomSheetRef),
|
|
82
82
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useCallback, useRef } from "react";
|
|
2
2
|
import { BackHandler, type NativeEventSubscription } from "react-native";
|
|
3
|
-
import type
|
|
3
|
+
import type { BottomSheetModal } from "@gorhom/bottom-sheet";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Hook that
|
|
6
|
+
* Hook that dismisses the bottom sheet modal on the hardware back button press if it is visible
|
|
7
7
|
* @param bottomSheetRef ref to the bottom sheet component
|
|
8
8
|
*/
|
|
9
9
|
export function useBottomSheetBackHandler(
|
|
10
|
-
bottomSheetRef: React.RefObject<
|
|
10
|
+
bottomSheetRef: React.RefObject<BottomSheetModal | null>,
|
|
11
11
|
): {
|
|
12
12
|
handleSheetPositionChange: (index: number) => void;
|
|
13
13
|
} {
|
|
@@ -24,7 +24,7 @@ export function useBottomSheetBackHandler(
|
|
|
24
24
|
backHandlerSubscriptionRef.current = BackHandler.addEventListener(
|
|
25
25
|
"hardwareBackPress",
|
|
26
26
|
() => {
|
|
27
|
-
bottomSheetRef.current?.
|
|
27
|
+
bottomSheetRef.current?.dismiss();
|
|
28
28
|
|
|
29
29
|
return true;
|
|
30
30
|
},
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
|
|
3
|
-
import { Host } from "react-native-portalize";
|
|
4
3
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AtlantisOverlayProvider,
|
|
6
|
+
ButtonGroup,
|
|
7
|
+
} from "@jobber/components-native";
|
|
6
8
|
|
|
7
9
|
const meta = {
|
|
8
10
|
title: "Components/Actions/ButtonGroup",
|
|
@@ -31,7 +33,7 @@ type SecondaryActionStory = StoryObj<
|
|
|
31
33
|
export const Basic: ButtonGroupStory = {
|
|
32
34
|
render: args => (
|
|
33
35
|
<SafeAreaProvider>
|
|
34
|
-
<
|
|
36
|
+
<AtlantisOverlayProvider>
|
|
35
37
|
<ButtonGroup {...args}>
|
|
36
38
|
<ButtonGroup.PrimaryAction
|
|
37
39
|
label={"Create"}
|
|
@@ -49,7 +51,7 @@ export const Basic: ButtonGroupStory = {
|
|
|
49
51
|
onPress={() => console.log("delete")}
|
|
50
52
|
/>
|
|
51
53
|
</ButtonGroup>
|
|
52
|
-
</
|
|
54
|
+
</AtlantisOverlayProvider>
|
|
53
55
|
</SafeAreaProvider>
|
|
54
56
|
),
|
|
55
57
|
args: {},
|
|
@@ -58,7 +60,7 @@ export const Basic: ButtonGroupStory = {
|
|
|
58
60
|
export const Primary: PrimaryActionStory = {
|
|
59
61
|
render: args => (
|
|
60
62
|
<SafeAreaProvider>
|
|
61
|
-
<
|
|
63
|
+
<AtlantisOverlayProvider>
|
|
62
64
|
<ButtonGroup>
|
|
63
65
|
<ButtonGroup.PrimaryAction {...args} />
|
|
64
66
|
<ButtonGroup.SecondaryAction
|
|
@@ -72,7 +74,7 @@ export const Primary: PrimaryActionStory = {
|
|
|
72
74
|
onPress={() => console.log("delete")}
|
|
73
75
|
/>
|
|
74
76
|
</ButtonGroup>
|
|
75
|
-
</
|
|
77
|
+
</AtlantisOverlayProvider>
|
|
76
78
|
</SafeAreaProvider>
|
|
77
79
|
),
|
|
78
80
|
args: {
|
|
@@ -85,7 +87,7 @@ export const Primary: PrimaryActionStory = {
|
|
|
85
87
|
export const Secondary: SecondaryActionStory = {
|
|
86
88
|
render: args => (
|
|
87
89
|
<SafeAreaProvider>
|
|
88
|
-
<
|
|
90
|
+
<AtlantisOverlayProvider>
|
|
89
91
|
<ButtonGroup
|
|
90
92
|
bottomSheetHeading="What would you like to do"
|
|
91
93
|
showCancelInBottomSheet={true}
|
|
@@ -97,7 +99,7 @@ export const Secondary: SecondaryActionStory = {
|
|
|
97
99
|
/>
|
|
98
100
|
<ButtonGroup.SecondaryAction {...args} />
|
|
99
101
|
</ButtonGroup>
|
|
100
|
-
</
|
|
102
|
+
</AtlantisOverlayProvider>
|
|
101
103
|
</SafeAreaProvider>
|
|
102
104
|
),
|
|
103
105
|
args: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
3
|
-
import { Host } from "react-native-portalize";
|
|
4
3
|
import { Alert } from "react-native";
|
|
5
4
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
|
6
5
|
import { ButtonGroup } from "./ButtonGroup";
|
|
@@ -12,15 +11,13 @@ const mockOnOpen = jest.fn();
|
|
|
12
11
|
|
|
13
12
|
function ButtonGroupForTest(props: ButtonGroupProps) {
|
|
14
13
|
return (
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</ButtonGroup>
|
|
23
|
-
</Host>
|
|
14
|
+
<ButtonGroup
|
|
15
|
+
bottomSheetHeading={props.bottomSheetHeading}
|
|
16
|
+
showCancelInBottomSheet={props.showCancelInBottomSheet}
|
|
17
|
+
onOpenBottomSheet={mockOnOpen}
|
|
18
|
+
>
|
|
19
|
+
{props.children}
|
|
20
|
+
</ButtonGroup>
|
|
24
21
|
);
|
|
25
22
|
}
|
|
26
23
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
|
-
import { Portal } from "react-native-portalize";
|
|
5
4
|
import type { ButtonGroupSecondaryActionProps } from "../../types";
|
|
6
5
|
import { BottomSheetOption } from "../../../BottomSheet/components/BottomSheetOption";
|
|
7
6
|
import type { BottomSheetRef } from "../../../BottomSheet/BottomSheet";
|
|
@@ -25,34 +24,32 @@ export function SecondaryActionSheet({
|
|
|
25
24
|
onCloseBottomSheet,
|
|
26
25
|
}: SecondaryActionSheetProps) {
|
|
27
26
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
>
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
const { label, onPress, icon, iconColor, destructive } = action;
|
|
27
|
+
<BottomSheet
|
|
28
|
+
heading={heading}
|
|
29
|
+
showCancel={showCancel}
|
|
30
|
+
ref={secondaryActionsRef}
|
|
31
|
+
onOpen={onOpenBottomSheet}
|
|
32
|
+
onClose={onCloseBottomSheet}
|
|
33
|
+
>
|
|
34
|
+
<View>
|
|
35
|
+
{actions.map((action, index) => {
|
|
36
|
+
const { label, onPress, icon, iconColor, destructive } = action;
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</Portal>
|
|
38
|
+
return (
|
|
39
|
+
<BottomSheetOption
|
|
40
|
+
destructive={destructive}
|
|
41
|
+
key={index}
|
|
42
|
+
text={label}
|
|
43
|
+
onPress={() => {
|
|
44
|
+
secondaryActionsRef?.current?.close();
|
|
45
|
+
onPress();
|
|
46
|
+
}}
|
|
47
|
+
icon={icon}
|
|
48
|
+
iconColor={iconColor}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
})}
|
|
52
|
+
</View>
|
|
53
|
+
</BottomSheet>
|
|
57
54
|
);
|
|
58
55
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
|
|
3
|
-
import { Host } from "react-native-portalize";
|
|
4
3
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AtlantisOverlayProvider,
|
|
6
|
+
Content,
|
|
7
|
+
Form,
|
|
8
|
+
InputText,
|
|
9
|
+
} from "@jobber/components-native";
|
|
6
10
|
|
|
7
11
|
const meta = {
|
|
8
12
|
title: "Components/Forms and Inputs/Form",
|
|
@@ -26,7 +30,7 @@ type Story = StoryObj<NativeFormStoryArgs>;
|
|
|
26
30
|
|
|
27
31
|
const BasicTemplate = (args: Story["args"]) => (
|
|
28
32
|
<SafeAreaProvider>
|
|
29
|
-
<
|
|
33
|
+
<AtlantisOverlayProvider>
|
|
30
34
|
<Form
|
|
31
35
|
initialValues={args?.initialValues}
|
|
32
36
|
secondaryActions={args?.secondaryActions}
|
|
@@ -59,7 +63,7 @@ const BasicTemplate = (args: Story["args"]) => (
|
|
|
59
63
|
/>
|
|
60
64
|
</Content>
|
|
61
65
|
</Form>
|
|
62
|
-
</
|
|
66
|
+
</AtlantisOverlayProvider>
|
|
63
67
|
</SafeAreaProvider>
|
|
64
68
|
);
|
|
65
69
|
|
package/src/Form/Form.test.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { type ReactElement } from "react";
|
|
2
2
|
import { act, fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
3
3
|
import { Alert, Keyboard } from "react-native";
|
|
4
|
-
import { Host } from "react-native-portalize";
|
|
5
4
|
import type { FormBannerMessage } from ".";
|
|
6
5
|
import { Form, FormBannerMessageType } from ".";
|
|
7
6
|
import type { FormBannerErrors } from "./types";
|
|
@@ -139,61 +138,59 @@ function MockForm({
|
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
return (
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
UNSAFE_allowDiscardLocalCacheWhenOffline
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
141
|
+
<Form
|
|
142
|
+
onSubmit={onSubmit}
|
|
143
|
+
onSubmitError={onErrorMock}
|
|
144
|
+
onSubmitSuccess={onSuccessMock}
|
|
145
|
+
bannerErrors={formErrors}
|
|
146
|
+
bannerMessages={bannerMessages}
|
|
147
|
+
saveButtonLabel={saveLabel}
|
|
148
|
+
renderStickySection={renderStickySection}
|
|
149
|
+
initialLoading={initialLoading}
|
|
150
|
+
initialValues={initialValues}
|
|
151
|
+
localCacheKey={localCacheKey}
|
|
152
|
+
localCacheExclude={localCacheExclude}
|
|
153
|
+
localCacheId={localCacheId}
|
|
154
|
+
onBeforeSubmit={onBeforeSubmit}
|
|
155
|
+
renderFooter={renderFooter}
|
|
156
|
+
saveButtonOffset={saveButtonOffset}
|
|
157
|
+
UNSAFE_allowDiscardLocalCacheWhenOffline={
|
|
158
|
+
UNSAFE_allowDiscardLocalCacheWhenOffline
|
|
159
|
+
}
|
|
160
|
+
>
|
|
161
|
+
<InputText
|
|
162
|
+
name={testInputTextName}
|
|
163
|
+
placeholder={testInputTextPlaceholder}
|
|
164
|
+
onChangeText={onChangeMock}
|
|
165
|
+
accessibilityLabel={testInputTextPlaceholder}
|
|
166
|
+
validations={{
|
|
167
|
+
required: requiredInputText,
|
|
168
|
+
minLength: { value: 3, message: minLengthText },
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
{Array.isArray(localCacheExclude) && localCacheExclude.length > 0 && (
|
|
163
172
|
<InputText
|
|
164
|
-
name={
|
|
165
|
-
placeholder={
|
|
166
|
-
onChangeText={onChangeMock}
|
|
167
|
-
accessibilityLabel={testInputTextPlaceholder}
|
|
168
|
-
validations={{
|
|
169
|
-
required: requiredInputText,
|
|
170
|
-
minLength: { value: 3, message: minLengthText },
|
|
171
|
-
}}
|
|
172
|
-
/>
|
|
173
|
-
{Array.isArray(localCacheExclude) && localCacheExclude.length > 0 && (
|
|
174
|
-
<InputText
|
|
175
|
-
name={testInputTextNameExclude}
|
|
176
|
-
placeholder={testInputTextPlaceholderExclude}
|
|
177
|
-
/>
|
|
178
|
-
)}
|
|
179
|
-
<Select
|
|
180
|
-
onChange={onChangeSelectMock}
|
|
181
|
-
label={selectLabel}
|
|
182
|
-
name={testSelectName}
|
|
183
|
-
>
|
|
184
|
-
<Option value={"1"}>1</Option>
|
|
185
|
-
<Option value={"2"}>2</Option>
|
|
186
|
-
</Select>
|
|
187
|
-
<Switch
|
|
188
|
-
name={testSwitchName}
|
|
189
|
-
label="Test Switch"
|
|
190
|
-
accessibilityLabel={switchLabel}
|
|
191
|
-
onValueChange={onChangeSwitchMock}
|
|
173
|
+
name={testInputTextNameExclude}
|
|
174
|
+
placeholder={testInputTextPlaceholderExclude}
|
|
192
175
|
/>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
176
|
+
)}
|
|
177
|
+
<Select
|
|
178
|
+
onChange={onChangeSelectMock}
|
|
179
|
+
label={selectLabel}
|
|
180
|
+
name={testSelectName}
|
|
181
|
+
>
|
|
182
|
+
<Option value={"1"}>1</Option>
|
|
183
|
+
<Option value={"2"}>2</Option>
|
|
184
|
+
</Select>
|
|
185
|
+
<Switch
|
|
186
|
+
name={testSwitchName}
|
|
187
|
+
label="Test Switch"
|
|
188
|
+
accessibilityLabel={switchLabel}
|
|
189
|
+
onValueChange={onChangeSwitchMock}
|
|
190
|
+
/>
|
|
191
|
+
<InputNumber name={testInputNumberName} placeholder="Test Num" />
|
|
192
|
+
<Checkbox name={testCheckboxName} accessibilityLabel={checkboxLabel} />
|
|
193
|
+
</Form>
|
|
197
194
|
);
|
|
198
195
|
}
|
|
199
196
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
3
|
-
import { Host } from "react-native-portalize";
|
|
4
3
|
import type { IconNames } from "@jobber/design";
|
|
5
4
|
import { FormSaveButton } from "./FormSaveButton";
|
|
6
5
|
|
|
@@ -31,15 +30,13 @@ jest.mock("react-hook-form", () => ({
|
|
|
31
30
|
|
|
32
31
|
function ButtonGroupForTest(props: TestFormSaveButtonProps) {
|
|
33
32
|
return (
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/>
|
|
42
|
-
</Host>
|
|
33
|
+
<FormSaveButton
|
|
34
|
+
primaryAction={props.primaryAction}
|
|
35
|
+
loading={props.loading}
|
|
36
|
+
label={props.label}
|
|
37
|
+
setSecondaryActionLoading={props.setSecondaryActionLoading}
|
|
38
|
+
secondaryActions={props.secondaryAction}
|
|
39
|
+
/>
|
|
43
40
|
);
|
|
44
41
|
}
|
|
45
42
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
|
|
3
|
-
import { Host } from "react-native-portalize";
|
|
4
3
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
5
|
-
import { FormatFile } from "@jobber/components-native";
|
|
4
|
+
import { AtlantisOverlayProvider, FormatFile } from "@jobber/components-native";
|
|
6
5
|
|
|
7
6
|
const meta = {
|
|
8
7
|
title: "Components/Images and Icons/FormatFile",
|
|
@@ -17,7 +16,7 @@ type Story = StoryObj<Partial<React.ComponentProps<typeof FormatFile>>>;
|
|
|
17
16
|
|
|
18
17
|
const BasicTemplate = (args: Story["args"]) => (
|
|
19
18
|
<SafeAreaProvider>
|
|
20
|
-
<
|
|
19
|
+
<AtlantisOverlayProvider>
|
|
21
20
|
<FormatFile
|
|
22
21
|
file={
|
|
23
22
|
args?.file ?? {
|
|
@@ -39,7 +38,7 @@ const BasicTemplate = (args: Story["args"]) => (
|
|
|
39
38
|
showFileTypeIndicator={args?.showFileTypeIndicator}
|
|
40
39
|
createThumbnail={args?.createThumbnail}
|
|
41
40
|
/>
|
|
42
|
-
</
|
|
41
|
+
</AtlantisOverlayProvider>
|
|
43
42
|
</SafeAreaProvider>
|
|
44
43
|
);
|
|
45
44
|
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import type { RenderAPI } from "@testing-library/react-native";
|
|
3
3
|
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
4
4
|
import { Alert } from "react-native";
|
|
5
|
-
import { Host } from "react-native-portalize";
|
|
6
5
|
import type { File } from ".";
|
|
7
6
|
import { FormatFile } from ".";
|
|
8
7
|
import {
|
|
@@ -42,19 +41,17 @@ const renderFormatFile = (
|
|
|
42
41
|
showFileTypeIndicator?: boolean,
|
|
43
42
|
) => {
|
|
44
43
|
return render(
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/>
|
|
57
|
-
</Host>,
|
|
44
|
+
<FormatFile
|
|
45
|
+
file={file}
|
|
46
|
+
accessibilityLabel="Custom Label"
|
|
47
|
+
accessibilityHint="Custom Hint Text"
|
|
48
|
+
onTap={() => Alert.alert("alert")}
|
|
49
|
+
onRemove={onRemove}
|
|
50
|
+
bottomSheetOptionsSuffix={bottomSheetOptionsSuffix}
|
|
51
|
+
showFileTypeIndicator={showFileTypeIndicator}
|
|
52
|
+
onPreviewPress={mockOnPreview}
|
|
53
|
+
createThumbnail={mockCreateThumbnail}
|
|
54
|
+
/>,
|
|
58
55
|
);
|
|
59
56
|
};
|
|
60
57
|
|