@react-navigation/elements 2.0.0-alpha.1 → 2.0.0-alpha.3
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/lib/commonjs/Background.js +2 -2
- package/lib/commonjs/Background.js.map +1 -1
- package/lib/commonjs/Button.js +100 -0
- package/lib/commonjs/Button.js.map +1 -0
- package/lib/commonjs/Header/Header.js +8 -4
- package/lib/commonjs/Header/Header.js.map +1 -1
- package/lib/commonjs/Header/HeaderBackButton.js +17 -14
- package/lib/commonjs/Header/HeaderBackButton.js.map +1 -1
- package/lib/commonjs/Header/HeaderBackContext.js +1 -2
- package/lib/commonjs/Header/HeaderBackContext.js.map +1 -1
- package/lib/commonjs/Header/HeaderBackground.js +2 -2
- package/lib/commonjs/Header/HeaderBackground.js.map +1 -1
- package/lib/commonjs/Header/HeaderHeightContext.js +1 -2
- package/lib/commonjs/Header/HeaderHeightContext.js.map +1 -1
- package/lib/commonjs/Header/HeaderShownContext.js +1 -2
- package/lib/commonjs/Header/HeaderShownContext.js.map +1 -1
- package/lib/commonjs/Header/HeaderTitle.js +2 -2
- package/lib/commonjs/Header/HeaderTitle.js.map +1 -1
- package/lib/commonjs/Header/getDefaultHeaderHeight.js.map +1 -1
- package/lib/commonjs/Header/getHeaderTitle.js.map +1 -1
- package/lib/commonjs/Header/useHeaderHeight.js +2 -2
- package/lib/commonjs/Header/useHeaderHeight.js.map +1 -1
- package/lib/commonjs/Label/Label.js +6 -10
- package/lib/commonjs/Label/Label.js.map +1 -1
- package/lib/commonjs/Label/getLabel.js.map +1 -1
- package/lib/commonjs/MaskedView.android.js.map +1 -1
- package/lib/commonjs/MaskedView.ios.js.map +1 -1
- package/lib/commonjs/MaskedView.js.map +1 -1
- package/lib/commonjs/MaskedViewNative.js +3 -2
- package/lib/commonjs/MaskedViewNative.js.map +1 -1
- package/lib/commonjs/MissingIcon.js +2 -2
- package/lib/commonjs/MissingIcon.js.map +1 -1
- package/lib/commonjs/PlatformPressable.js +27 -4
- package/lib/commonjs/PlatformPressable.js.map +1 -1
- package/lib/commonjs/ResourceSavingView.js +2 -2
- package/lib/commonjs/ResourceSavingView.js.map +1 -1
- package/lib/commonjs/SafeAreaProviderCompat.js +2 -2
- package/lib/commonjs/SafeAreaProviderCompat.js.map +1 -1
- package/lib/commonjs/Screen.js +2 -2
- package/lib/commonjs/Screen.js.map +1 -1
- package/lib/commonjs/Text.js +28 -0
- package/lib/commonjs/Text.js.map +1 -0
- package/lib/commonjs/getDefaultSidebarWidth.js.map +1 -1
- package/lib/commonjs/getNamedContext.js +2 -2
- package/lib/commonjs/getNamedContext.js.map +1 -1
- package/lib/commonjs/index.js +18 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/Background.js.map +1 -1
- package/lib/module/Button.js +91 -0
- package/lib/module/Button.js.map +1 -0
- package/lib/module/Header/Header.js +6 -2
- package/lib/module/Header/Header.js.map +1 -1
- package/lib/module/Header/HeaderBackButton.js +15 -12
- package/lib/module/Header/HeaderBackButton.js.map +1 -1
- package/lib/module/Header/HeaderBackContext.js.map +1 -1
- package/lib/module/Header/HeaderBackground.js.map +1 -1
- package/lib/module/Header/HeaderHeightContext.js.map +1 -1
- package/lib/module/Header/HeaderShownContext.js.map +1 -1
- package/lib/module/Header/HeaderTitle.js.map +1 -1
- package/lib/module/Header/getDefaultHeaderHeight.js.map +1 -1
- package/lib/module/Header/getHeaderTitle.js.map +1 -1
- package/lib/module/Header/useHeaderHeight.js.map +1 -1
- package/lib/module/Label/Label.js +4 -8
- package/lib/module/Label/Label.js.map +1 -1
- package/lib/module/Label/getLabel.js.map +1 -1
- package/lib/module/MaskedView.android.js.map +1 -1
- package/lib/module/MaskedView.ios.js.map +1 -1
- package/lib/module/MaskedView.js.map +1 -1
- package/lib/module/MaskedViewNative.js +1 -0
- package/lib/module/MaskedViewNative.js.map +1 -1
- package/lib/module/MissingIcon.js.map +1 -1
- package/lib/module/PlatformPressable.js +25 -2
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/ResourceSavingView.js.map +1 -1
- package/lib/module/SafeAreaProviderCompat.js.map +1 -1
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/Text.js +20 -0
- package/lib/module/Text.js.map +1 -0
- package/lib/module/getDefaultSidebarWidth.js.map +1 -1
- package/lib/module/getNamedContext.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/Background.d.ts +2 -2
- package/lib/typescript/src/Background.d.ts.map +1 -1
- package/lib/typescript/src/Button.d.ts +12 -0
- package/lib/typescript/src/Button.d.ts.map +1 -0
- package/lib/typescript/src/Header/Header.d.ts +2 -1
- package/lib/typescript/src/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackButton.d.ts +2 -1
- package/lib/typescript/src/Header/HeaderBackButton.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackContext.d.ts +2 -1
- package/lib/typescript/src/Header/HeaderBackContext.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackground.d.ts +2 -2
- package/lib/typescript/src/Header/HeaderBackground.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderTitle.d.ts +3 -2
- package/lib/typescript/src/Header/HeaderTitle.d.ts.map +1 -1
- package/lib/typescript/src/Label/Label.d.ts +3 -2
- package/lib/typescript/src/Label/Label.d.ts.map +1 -1
- package/lib/typescript/src/MaskedViewNative.d.ts +1 -1
- package/lib/typescript/src/MaskedViewNative.d.ts.map +1 -1
- package/lib/typescript/src/MissingIcon.d.ts +3 -2
- package/lib/typescript/src/MissingIcon.d.ts.map +1 -1
- package/lib/typescript/src/PlatformPressable.d.ts +3 -2
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/ResourceSavingView.d.ts +2 -2
- package/lib/typescript/src/ResourceSavingView.d.ts.map +1 -1
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts +2 -2
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts +3 -3
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/Text.d.ts +4 -0
- package/lib/typescript/src/Text.d.ts.map +1 -0
- package/lib/typescript/src/getNamedContext.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +4 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +14 -12
- package/src/Background.tsx +6 -1
- package/src/Button.tsx +97 -0
- package/src/Header/Header.tsx +13 -3
- package/src/Header/HeaderBackButton.tsx +11 -8
- package/src/Header/HeaderBackContext.tsx +3 -4
- package/src/Header/HeaderBackground.tsx +3 -3
- package/src/Header/HeaderTitle.tsx +3 -3
- package/src/Label/Label.tsx +6 -13
- package/src/MaskedViewNative.tsx +1 -0
- package/src/MissingIcon.tsx +1 -1
- package/src/PlatformPressable.tsx +32 -4
- package/src/ResourceSavingView.tsx +7 -1
- package/src/SafeAreaProviderCompat.tsx +2 -2
- package/src/Screen.tsx +10 -4
- package/src/Text.tsx +14 -0
- package/src/getNamedContext.tsx +1 -0
- package/src/index.tsx +2 -0
- package/src/types.tsx +4 -0
package/src/Label/Label.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useTheme } from '@react-navigation/native';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import {
|
|
4
|
-
StyleProp,
|
|
3
|
+
type StyleProp,
|
|
5
4
|
StyleSheet,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
TextStyle,
|
|
5
|
+
type TextProps,
|
|
6
|
+
type TextStyle,
|
|
9
7
|
} from 'react-native';
|
|
10
8
|
|
|
9
|
+
import { Text } from '../Text';
|
|
10
|
+
|
|
11
11
|
type Props = Omit<TextProps, 'style'> & {
|
|
12
12
|
tintColor?: string;
|
|
13
13
|
children?: string;
|
|
@@ -15,18 +15,11 @@ type Props = Omit<TextProps, 'style'> & {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export function Label({ tintColor, style, ...rest }: Props) {
|
|
18
|
-
const { colors, fonts } = useTheme();
|
|
19
|
-
|
|
20
18
|
return (
|
|
21
19
|
<Text
|
|
22
20
|
numberOfLines={1}
|
|
23
21
|
{...rest}
|
|
24
|
-
style={[
|
|
25
|
-
fonts.regular,
|
|
26
|
-
styles.label,
|
|
27
|
-
{ color: tintColor === undefined ? colors.text : tintColor },
|
|
28
|
-
style,
|
|
29
|
-
]}
|
|
22
|
+
style={[styles.label, tintColor != null && { color: tintColor }, style]}
|
|
30
23
|
/>
|
|
31
24
|
);
|
|
32
25
|
}
|
package/src/MaskedViewNative.tsx
CHANGED
|
@@ -16,6 +16,7 @@ let RNCMaskedView: MaskedViewType | undefined;
|
|
|
16
16
|
try {
|
|
17
17
|
// Add try/catch to support usage even if it's not installed, since it's optional.
|
|
18
18
|
// Newer versions of Metro will handle it properly.
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
19
20
|
RNCMaskedView = require('@react-native-masked-view/masked-view').default;
|
|
20
21
|
} catch (e) {
|
|
21
22
|
// Ignore
|
package/src/MissingIcon.tsx
CHANGED
|
@@ -3,18 +3,19 @@ import * as React from 'react';
|
|
|
3
3
|
import {
|
|
4
4
|
Animated,
|
|
5
5
|
Easing,
|
|
6
|
-
GestureResponderEvent,
|
|
6
|
+
type GestureResponderEvent,
|
|
7
7
|
Platform,
|
|
8
8
|
Pressable,
|
|
9
|
-
PressableProps,
|
|
10
|
-
StyleProp,
|
|
11
|
-
ViewStyle,
|
|
9
|
+
type PressableProps,
|
|
10
|
+
type StyleProp,
|
|
11
|
+
type ViewStyle,
|
|
12
12
|
} from 'react-native';
|
|
13
13
|
|
|
14
14
|
export type Props = Omit<PressableProps, 'style'> & {
|
|
15
15
|
pressColor?: string;
|
|
16
16
|
pressOpacity?: number;
|
|
17
17
|
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
18
|
+
href?: string;
|
|
18
19
|
children: React.ReactNode;
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -28,6 +29,8 @@ const ANDROID_SUPPORTS_RIPPLE =
|
|
|
28
29
|
* PlatformPressable provides an abstraction on top of Pressable to handle platform differences.
|
|
29
30
|
*/
|
|
30
31
|
export function PlatformPressable({
|
|
32
|
+
disabled,
|
|
33
|
+
onPress,
|
|
31
34
|
onPressIn,
|
|
32
35
|
onPressOut,
|
|
33
36
|
android_ripple,
|
|
@@ -52,6 +55,26 @@ export function PlatformPressable({
|
|
|
52
55
|
}).start();
|
|
53
56
|
};
|
|
54
57
|
|
|
58
|
+
const handlePress = (e: GestureResponderEvent) => {
|
|
59
|
+
// @ts-expect-error: these properties exist on web, but not in React Native
|
|
60
|
+
const hasModifierKey = e.metaKey || e.altKey || e.ctrlKey || e.shiftKey; // ignore clicks with modifier keys
|
|
61
|
+
// @ts-expect-error: these properties exist on web, but not in React Native
|
|
62
|
+
const isLeftClick = e.button == null || e.button === 0; // only handle left clicks
|
|
63
|
+
const isSelfTarget = [undefined, null, '', 'self'].includes(
|
|
64
|
+
// @ts-expect-error: these properties exist on web, but not in React Native
|
|
65
|
+
e.currentTarget?.target
|
|
66
|
+
); // let browser handle "target=_blank" etc.
|
|
67
|
+
|
|
68
|
+
if (Platform.OS === 'web' && rest.href != null) {
|
|
69
|
+
if (!hasModifierKey && isLeftClick && isSelfTarget) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
onPress?.(e);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
onPress?.(e);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
55
78
|
const handlePressIn = (e: GestureResponderEvent) => {
|
|
56
79
|
animateTo(pressOpacity, 0);
|
|
57
80
|
onPressIn?.(e);
|
|
@@ -64,6 +87,11 @@ export function PlatformPressable({
|
|
|
64
87
|
|
|
65
88
|
return (
|
|
66
89
|
<AnimatedPressable
|
|
90
|
+
accessible
|
|
91
|
+
accessibilityRole={
|
|
92
|
+
Platform.OS === 'web' && rest.href != null ? 'link' : 'button'
|
|
93
|
+
}
|
|
94
|
+
onPress={disabled ? undefined : handlePress}
|
|
67
95
|
onPressIn={handlePressIn}
|
|
68
96
|
onPressOut={handlePressOut}
|
|
69
97
|
android_ripple={
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Platform,
|
|
4
|
+
type StyleProp,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
View,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
3
9
|
|
|
4
10
|
type Props = {
|
|
5
11
|
visible: boolean;
|
package/src/Screen.tsx
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NavigationContext,
|
|
3
|
-
NavigationProp,
|
|
3
|
+
type NavigationProp,
|
|
4
4
|
NavigationRouteContext,
|
|
5
|
-
ParamListBase,
|
|
6
|
-
RouteProp,
|
|
5
|
+
type ParamListBase,
|
|
6
|
+
type RouteProp,
|
|
7
7
|
} from '@react-navigation/native';
|
|
8
8
|
import * as React from 'react';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
Animated,
|
|
11
|
+
type StyleProp,
|
|
12
|
+
StyleSheet,
|
|
13
|
+
View,
|
|
14
|
+
type ViewStyle,
|
|
15
|
+
} from 'react-native';
|
|
10
16
|
import {
|
|
11
17
|
useSafeAreaFrame,
|
|
12
18
|
useSafeAreaInsets,
|
package/src/Text.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useTheme } from '@react-navigation/native';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Text as NativeText, type TextProps } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export function Text({ style, ...rest }: TextProps) {
|
|
6
|
+
const { colors, fonts } = useTheme();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<NativeText
|
|
10
|
+
{...rest}
|
|
11
|
+
style={[{ color: colors.text }, fonts.regular, style]}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
package/src/getNamedContext.tsx
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Background } from './Background';
|
|
2
|
+
export { Button } from './Button';
|
|
2
3
|
export { getDefaultSidebarWidth } from './getDefaultSidebarWidth';
|
|
3
4
|
export { getDefaultHeaderHeight } from './Header/getDefaultHeaderHeight';
|
|
4
5
|
export { getHeaderTitle } from './Header/getHeaderTitle';
|
|
@@ -17,6 +18,7 @@ export { PlatformPressable } from './PlatformPressable';
|
|
|
17
18
|
export { ResourceSavingView } from './ResourceSavingView';
|
|
18
19
|
export { SafeAreaProviderCompat } from './SafeAreaProviderCompat';
|
|
19
20
|
export { Screen } from './Screen';
|
|
21
|
+
export { Text } from './Text';
|
|
20
22
|
|
|
21
23
|
export const Assets = [
|
|
22
24
|
// eslint-disable-next-line import/no-commonjs
|
package/src/types.tsx
CHANGED
|
@@ -179,6 +179,10 @@ export type HeaderBackButtonProps = HeaderButtonProps & {
|
|
|
179
179
|
* Function which returns a React Element to display custom image in header's back button.
|
|
180
180
|
*/
|
|
181
181
|
backImage?: (props: { tintColor: string }) => React.ReactNode;
|
|
182
|
+
/**
|
|
183
|
+
* The `href` to use for the anchor tag on web
|
|
184
|
+
*/
|
|
185
|
+
href?: string;
|
|
182
186
|
/**
|
|
183
187
|
* Label text for the button. Usually the title of the previous screen.
|
|
184
188
|
* By default, this is only shown on iOS.
|