@jobber/components-native 0.92.0 → 0.94.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 +4 -2
- package/dist/src/BottomSheet/BottomSheet.js +58 -32
- package/dist/src/BottomSheet/BottomSheet.style.js +8 -9
- package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +26 -0
- package/dist/src/Content/ContentHorizontal.style.js +15 -0
- package/dist/src/Content/ContentSpaceAround.style.js +15 -0
- package/dist/src/Content/ContentVertical.style.js +15 -0
- package/dist/src/InputText/InputText.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/BottomSheet/BottomSheet.d.ts +7 -3
- package/dist/types/src/BottomSheet/BottomSheet.style.d.ts +7 -14
- package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
- package/dist/types/src/Content/Content.d.ts +1 -1
- package/dist/types/src/Content/ContentHorizontal.style.d.ts +15 -0
- package/dist/types/src/Content/ContentSpaceAround.style.d.ts +15 -0
- package/dist/types/src/Content/ContentVertical.style.d.ts +15 -0
- package/dist/types/src/InputText/InputText.d.ts +1 -1
- package/package.json +4 -2
- package/src/BottomSheet/BottomSheet.stories.tsx +128 -0
- package/src/BottomSheet/BottomSheet.style.ts +7 -14
- package/src/BottomSheet/BottomSheet.test.tsx +19 -24
- package/src/BottomSheet/BottomSheet.tsx +112 -93
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +90 -0
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +41 -0
- package/src/Content/Content.tsx +6 -1
- package/src/Content/ContentHorizontal.style.ts +20 -0
- package/src/Content/ContentSpaceAround.style.ts +20 -0
- package/src/Content/ContentVertical.style.ts +20 -0
- package/src/InputText/InputText.tsx +3 -3
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +199 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type { Modalize } from "react-native-modalize";
|
|
4
3
|
export interface BottomSheetProps {
|
|
5
4
|
readonly children: ReactNode;
|
|
6
5
|
/**
|
|
@@ -24,5 +23,10 @@ export interface BottomSheetProps {
|
|
|
24
23
|
*/
|
|
25
24
|
readonly onClose?: () => void;
|
|
26
25
|
}
|
|
27
|
-
export
|
|
28
|
-
|
|
26
|
+
export interface BottomSheetRef {
|
|
27
|
+
open: () => void;
|
|
28
|
+
close: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function BottomSheet({ children, showCancel, loading, heading, onOpen, onClose, ref, }: BottomSheetProps & {
|
|
31
|
+
readonly ref?: React.Ref<BottomSheetRef>;
|
|
32
|
+
}): React.JSX.Element;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
export declare const useStyles: () => {
|
|
2
|
-
|
|
2
|
+
backdrop: {
|
|
3
3
|
backgroundColor: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
6
|
-
backgroundColor: string;
|
|
7
|
-
height: number;
|
|
8
|
-
position: "absolute";
|
|
9
|
-
left: 0;
|
|
10
|
-
right: 0;
|
|
11
|
-
top: 0;
|
|
12
|
-
bottom: 0;
|
|
13
|
-
};
|
|
14
|
-
modal: {
|
|
5
|
+
background: {
|
|
15
6
|
borderTopLeftRadius: number;
|
|
16
7
|
borderTopRightRadius: number;
|
|
17
|
-
paddingTop: number;
|
|
18
8
|
};
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
footerContainer: {
|
|
10
|
+
backgroundColor: string;
|
|
21
11
|
};
|
|
22
12
|
header: {
|
|
23
13
|
paddingHorizontal: number;
|
|
@@ -29,4 +19,7 @@ export declare const useStyles: () => {
|
|
|
29
19
|
marginTop: number;
|
|
30
20
|
marginBottom: number;
|
|
31
21
|
};
|
|
22
|
+
handle: {
|
|
23
|
+
display: "none";
|
|
24
|
+
};
|
|
32
25
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type BottomSheet from "@gorhom/bottom-sheet";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that closes the bottom sheet on the hardware back button press if it is visible
|
|
4
|
+
* @param bottomSheetRef ref to the bottom sheet component
|
|
5
|
+
*/
|
|
6
|
+
export declare function useBottomSheetBackHandler(bottomSheetRef: React.RefObject<BottomSheet | null>): {
|
|
7
|
+
handleSheetPositionChange: (index: number) => void;
|
|
8
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
4
|
-
export type Spacing = "none" | "base" | "small" | "smaller" | "smallest" | "large";
|
|
4
|
+
export type Spacing = "none" | "base" | "slim" | "small" | "smaller" | "smallest" | "minuscule" | "large" | "larger" | "largest" | "extravagant";
|
|
5
5
|
export interface ContentUnsafeStyle {
|
|
6
6
|
container?: StyleProp<ViewStyle>;
|
|
7
7
|
childWrapper?: StyleProp<ViewStyle>;
|
|
@@ -10,6 +10,9 @@ export declare const useHorizontalStyles: () => {
|
|
|
10
10
|
noneChildSpace: {
|
|
11
11
|
padding: number;
|
|
12
12
|
};
|
|
13
|
+
minusculeChildSpace: {
|
|
14
|
+
paddingLeft: number;
|
|
15
|
+
};
|
|
13
16
|
smallestChildSpace: {
|
|
14
17
|
paddingLeft: number;
|
|
15
18
|
};
|
|
@@ -19,10 +22,22 @@ export declare const useHorizontalStyles: () => {
|
|
|
19
22
|
smallChildSpace: {
|
|
20
23
|
paddingLeft: number;
|
|
21
24
|
};
|
|
25
|
+
slimChildSpace: {
|
|
26
|
+
paddingLeft: number;
|
|
27
|
+
};
|
|
22
28
|
baseChildSpace: {
|
|
23
29
|
paddingLeft: number;
|
|
24
30
|
};
|
|
25
31
|
largeChildSpace: {
|
|
26
32
|
paddingLeft: number;
|
|
27
33
|
};
|
|
34
|
+
largerChildSpace: {
|
|
35
|
+
paddingLeft: number;
|
|
36
|
+
};
|
|
37
|
+
largestChildSpace: {
|
|
38
|
+
paddingLeft: number;
|
|
39
|
+
};
|
|
40
|
+
extravagantChildSpace: {
|
|
41
|
+
paddingLeft: number;
|
|
42
|
+
};
|
|
28
43
|
};
|
|
@@ -2,6 +2,9 @@ export declare const useSpaceAroundStyles: () => {
|
|
|
2
2
|
noneSpace: {
|
|
3
3
|
padding: number;
|
|
4
4
|
};
|
|
5
|
+
minusculeSpace: {
|
|
6
|
+
padding: number;
|
|
7
|
+
};
|
|
5
8
|
smallestSpace: {
|
|
6
9
|
padding: number;
|
|
7
10
|
};
|
|
@@ -11,10 +14,22 @@ export declare const useSpaceAroundStyles: () => {
|
|
|
11
14
|
smallSpace: {
|
|
12
15
|
padding: number;
|
|
13
16
|
};
|
|
17
|
+
slimSpace: {
|
|
18
|
+
padding: number;
|
|
19
|
+
};
|
|
14
20
|
baseSpace: {
|
|
15
21
|
padding: number;
|
|
16
22
|
};
|
|
17
23
|
largeSpace: {
|
|
18
24
|
padding: number;
|
|
19
25
|
};
|
|
26
|
+
largerSpace: {
|
|
27
|
+
padding: number;
|
|
28
|
+
};
|
|
29
|
+
largestSpace: {
|
|
30
|
+
padding: number;
|
|
31
|
+
};
|
|
32
|
+
extravagantSpace: {
|
|
33
|
+
padding: number;
|
|
34
|
+
};
|
|
20
35
|
};
|
|
@@ -4,6 +4,9 @@ export declare const useVerticalStyles: () => {
|
|
|
4
4
|
noneChildSpace: {
|
|
5
5
|
padding: number;
|
|
6
6
|
};
|
|
7
|
+
minusculeChildSpace: {
|
|
8
|
+
paddingTop: number;
|
|
9
|
+
};
|
|
7
10
|
smallestChildSpace: {
|
|
8
11
|
paddingTop: number;
|
|
9
12
|
};
|
|
@@ -13,10 +16,22 @@ export declare const useVerticalStyles: () => {
|
|
|
13
16
|
smallChildSpace: {
|
|
14
17
|
paddingTop: number;
|
|
15
18
|
};
|
|
19
|
+
slimChildSpace: {
|
|
20
|
+
paddingTop: number;
|
|
21
|
+
};
|
|
16
22
|
baseChildSpace: {
|
|
17
23
|
paddingTop: number;
|
|
18
24
|
};
|
|
19
25
|
largeChildSpace: {
|
|
20
26
|
paddingTop: number;
|
|
21
27
|
};
|
|
28
|
+
largerChildSpace: {
|
|
29
|
+
paddingTop: number;
|
|
30
|
+
};
|
|
31
|
+
largestChildSpace: {
|
|
32
|
+
paddingTop: number;
|
|
33
|
+
};
|
|
34
|
+
extravagantChildSpace: {
|
|
35
|
+
paddingTop: number;
|
|
36
|
+
};
|
|
22
37
|
};
|
|
@@ -77,7 +77,7 @@ export interface InputTextProps extends Pick<InputFieldWrapperProps, "toolbar" |
|
|
|
77
77
|
/**
|
|
78
78
|
* Callback that is called when the text input is blurred
|
|
79
79
|
*/
|
|
80
|
-
readonly onBlur?: () => void;
|
|
80
|
+
readonly onBlur?: (event?: FocusEvent) => void;
|
|
81
81
|
/**
|
|
82
82
|
* VoiceOver will read this string when a user selects the associated element
|
|
83
83
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.94.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"ts-xor": "^1.1.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
+
"@gorhom/bottom-sheet": "^5.2.8",
|
|
56
57
|
"@react-native-community/datetimepicker": "^8.4.5",
|
|
57
58
|
"@react-native/babel-preset": "^0.82.1",
|
|
58
59
|
"@storybook/addon-a11y": "^9.1.2",
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
},
|
|
79
80
|
"peerDependencies": {
|
|
80
81
|
"@babel/core": "^7.4.5",
|
|
82
|
+
"@gorhom/bottom-sheet": "^5.2.8",
|
|
81
83
|
"@jobber/design": "*",
|
|
82
84
|
"@react-native-community/datetimepicker": ">=6.7.0",
|
|
83
85
|
"date-fns": "^2.30.0",
|
|
@@ -94,5 +96,5 @@
|
|
|
94
96
|
"react-native-safe-area-context": "^5.4.0",
|
|
95
97
|
"react-native-svg": ">=12.0.0"
|
|
96
98
|
},
|
|
97
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "c781bba08e241b32046afba42dff63d213e4a7fd"
|
|
98
100
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
5
|
+
import { Button, Heading, Text } from "@jobber/components-native";
|
|
6
|
+
import { BottomSheet } from "./BottomSheet";
|
|
7
|
+
import type { BottomSheetRef } from "./BottomSheet";
|
|
8
|
+
import { BottomSheetOption } from "./components/BottomSheetOption";
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
title: "Components/Selections/BottomSheet",
|
|
12
|
+
component: BottomSheet,
|
|
13
|
+
} satisfies Meta<typeof BottomSheet>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const BasicTemplate = () => {
|
|
19
|
+
const bottomSheetRef = useRef<BottomSheetRef>(null);
|
|
20
|
+
|
|
21
|
+
const openBottomSheet = () => {
|
|
22
|
+
bottomSheetRef.current?.open();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const closeBottomSheet = () => {
|
|
26
|
+
bottomSheetRef.current?.close();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<SafeAreaProvider>
|
|
31
|
+
<View style={{ display: "flex", flexDirection: "column", gap: 16 }}>
|
|
32
|
+
<Heading>Basic BottomSheet</Heading>
|
|
33
|
+
<Text>
|
|
34
|
+
Note that due to the differences between React Native Web and React
|
|
35
|
+
Native, this does not render 100% properly
|
|
36
|
+
</Text>
|
|
37
|
+
<Button label="Open Bottom Sheet" onPress={openBottomSheet} />
|
|
38
|
+
<Button label="Close Bottom Sheet" onPress={closeBottomSheet} />
|
|
39
|
+
</View>
|
|
40
|
+
<BottomSheet
|
|
41
|
+
ref={bottomSheetRef}
|
|
42
|
+
onClose={() => console.log("closed bottom sheet")}
|
|
43
|
+
onOpen={() => console.log("opened bottom sheet")}
|
|
44
|
+
>
|
|
45
|
+
<BottomSheetOption
|
|
46
|
+
icon="sendMessage"
|
|
47
|
+
iconColor="greyBlue"
|
|
48
|
+
text="Send message"
|
|
49
|
+
onPress={() => alert("send message")}
|
|
50
|
+
/>
|
|
51
|
+
<BottomSheetOption
|
|
52
|
+
icon="phone"
|
|
53
|
+
iconColor="greyBlue"
|
|
54
|
+
text="Call a friend"
|
|
55
|
+
onPress={() => alert("Calling a friend")}
|
|
56
|
+
/>
|
|
57
|
+
<BottomSheetOption
|
|
58
|
+
destructive={true}
|
|
59
|
+
icon="trash"
|
|
60
|
+
text="Remove"
|
|
61
|
+
onPress={() => alert("Removed")}
|
|
62
|
+
/>
|
|
63
|
+
</BottomSheet>
|
|
64
|
+
</SafeAreaProvider>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const HeaderFooterInputTextTemplate = () => {
|
|
69
|
+
const bottomSheetRef = useRef<BottomSheetRef>(null);
|
|
70
|
+
|
|
71
|
+
const openBottomSheet = () => {
|
|
72
|
+
bottomSheetRef.current?.open();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const closeBottomSheet = () => {
|
|
76
|
+
bottomSheetRef.current?.close();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<SafeAreaProvider>
|
|
81
|
+
<View style={{ display: "flex", flexDirection: "column", gap: 16 }}>
|
|
82
|
+
<Heading>Basic BottomSheet</Heading>
|
|
83
|
+
<Text>
|
|
84
|
+
Note that due to the differences between React Native Web and React
|
|
85
|
+
Native, this does not render 100% properly
|
|
86
|
+
</Text>
|
|
87
|
+
<Button label="Open Bottom Sheet" onPress={openBottomSheet} />
|
|
88
|
+
<Button label="Close Bottom Sheet" onPress={closeBottomSheet} />
|
|
89
|
+
</View>
|
|
90
|
+
<BottomSheet
|
|
91
|
+
ref={bottomSheetRef}
|
|
92
|
+
showCancel={true}
|
|
93
|
+
heading="BottomSheet Header"
|
|
94
|
+
onClose={() => console.log("closed bottom sheet")}
|
|
95
|
+
onOpen={() => console.log("opened bottom sheet")}
|
|
96
|
+
>
|
|
97
|
+
<BottomSheetOption
|
|
98
|
+
icon="sendMessage"
|
|
99
|
+
iconColor="greyBlue"
|
|
100
|
+
text="Send message"
|
|
101
|
+
onPress={() => alert("send message")}
|
|
102
|
+
/>
|
|
103
|
+
<BottomSheetOption
|
|
104
|
+
icon="phone"
|
|
105
|
+
iconColor="greyBlue"
|
|
106
|
+
text="Call a friend"
|
|
107
|
+
onPress={() => alert("Calling a friend")}
|
|
108
|
+
/>
|
|
109
|
+
<BottomSheetOption
|
|
110
|
+
destructive={true}
|
|
111
|
+
icon="trash"
|
|
112
|
+
text="Remove"
|
|
113
|
+
onPress={() => alert("Removed")}
|
|
114
|
+
/>
|
|
115
|
+
</BottomSheet>
|
|
116
|
+
</SafeAreaProvider>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const Basic: Story = {
|
|
121
|
+
render: BasicTemplate,
|
|
122
|
+
args: {} as Story["args"],
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const HeaderFooterInputText: Story = {
|
|
126
|
+
render: HeaderFooterInputTextTemplate,
|
|
127
|
+
args: {} as Story["args"],
|
|
128
|
+
};
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import { Dimensions, StyleSheet } from "react-native";
|
|
2
1
|
import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
3
2
|
|
|
4
|
-
const { height } = Dimensions.get("window");
|
|
5
|
-
|
|
6
3
|
export const useStyles = buildThemedStyles(tokens => {
|
|
7
4
|
const modalBorderRadius = tokens["radius-larger"];
|
|
8
5
|
|
|
9
6
|
return {
|
|
10
|
-
|
|
11
|
-
backgroundColor: "transparent",
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
overlay: {
|
|
15
|
-
...StyleSheet.absoluteFillObject,
|
|
7
|
+
backdrop: {
|
|
16
8
|
backgroundColor: tokens["color-overlay"],
|
|
17
|
-
height,
|
|
18
9
|
},
|
|
19
|
-
|
|
10
|
+
background: {
|
|
20
11
|
borderTopLeftRadius: modalBorderRadius,
|
|
21
12
|
borderTopRightRadius: modalBorderRadius,
|
|
22
|
-
paddingTop: tokens["space-small"],
|
|
23
13
|
},
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
footerContainer: {
|
|
15
|
+
backgroundColor: tokens["color-surface"],
|
|
26
16
|
},
|
|
27
17
|
header: {
|
|
28
18
|
paddingHorizontal: tokens["space-base"],
|
|
@@ -34,5 +24,8 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
34
24
|
marginTop: tokens["space-small"],
|
|
35
25
|
marginBottom: tokens["space-smaller"],
|
|
36
26
|
},
|
|
27
|
+
handle: {
|
|
28
|
+
display: "none",
|
|
29
|
+
},
|
|
37
30
|
};
|
|
38
31
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { createRef } from "react";
|
|
2
|
-
import { act,
|
|
2
|
+
import { act, render, userEvent, waitFor } from "@testing-library/react-native";
|
|
3
3
|
import { AccessibilityInfo, View } from "react-native";
|
|
4
|
-
import { Host, Portal } from "react-native-portalize";
|
|
5
4
|
import { BottomSheet } from ".";
|
|
6
5
|
import type { BottomSheetRef } from "./BottomSheet";
|
|
7
6
|
import { waitForUntestableRender } from "../utils/test/wait";
|
|
@@ -23,22 +22,18 @@ function setup({
|
|
|
23
22
|
loading?: boolean;
|
|
24
23
|
}) {
|
|
25
24
|
return render(
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</View>
|
|
39
|
-
</BottomSheet>
|
|
40
|
-
</Portal>
|
|
41
|
-
</Host>,
|
|
25
|
+
<BottomSheet
|
|
26
|
+
ref={ref}
|
|
27
|
+
heading={heading}
|
|
28
|
+
showCancel={showCancel}
|
|
29
|
+
loading={loading}
|
|
30
|
+
onClose={mockOnClose}
|
|
31
|
+
onOpen={mockOnOpen}
|
|
32
|
+
>
|
|
33
|
+
<View>
|
|
34
|
+
<Text>BottomSheet</Text>
|
|
35
|
+
</View>
|
|
36
|
+
</BottomSheet>,
|
|
42
37
|
);
|
|
43
38
|
}
|
|
44
39
|
|
|
@@ -78,7 +73,8 @@ it("BottomSheet can be closed with the cancel action", async () => {
|
|
|
78
73
|
ref.current?.open();
|
|
79
74
|
});
|
|
80
75
|
|
|
81
|
-
|
|
76
|
+
const cancelButton = await findByLabelText("Cancel");
|
|
77
|
+
await userEvent.press(cancelButton);
|
|
82
78
|
|
|
83
79
|
await waitFor(() => {
|
|
84
80
|
expect(queryByText("BottomSheet")).toBeNull();
|
|
@@ -134,15 +130,14 @@ describe("when there is a screen reader enabled", () => {
|
|
|
134
130
|
|
|
135
131
|
const { findByLabelText, queryByText } = setup({});
|
|
136
132
|
|
|
137
|
-
await waitForUntestableRender(
|
|
138
|
-
"Wait for AccessibilityInfo.isScreenReaderEnabled to resolve",
|
|
139
|
-
);
|
|
140
|
-
|
|
141
133
|
await act(async () => {
|
|
142
134
|
ref.current?.open();
|
|
143
135
|
});
|
|
144
136
|
|
|
145
|
-
|
|
137
|
+
const cancelButton = await findByLabelText("Cancel");
|
|
138
|
+
expect(cancelButton).toBeDefined();
|
|
139
|
+
|
|
140
|
+
await userEvent.press(cancelButton);
|
|
146
141
|
|
|
147
142
|
await waitFor(() => {
|
|
148
143
|
expect(queryByText("BottomSheet")).toBeNull();
|