@react-navigation/elements 3.0.0-alpha.4 → 3.0.0-alpha.40
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/module/ActivityView.js +90 -0
- package/lib/module/ActivityView.js.map +1 -0
- package/lib/module/ActivityView.native.js +67 -0
- package/lib/module/ActivityView.native.js.map +1 -0
- package/lib/module/Badge.js +5 -4
- package/lib/module/Badge.js.map +1 -1
- package/lib/module/BlurEffectBackground.js +3 -3
- package/lib/module/BlurEffectBackground.js.map +1 -1
- package/lib/module/Button.js +96 -14
- package/lib/module/Button.js.map +1 -1
- package/lib/module/Color.js +565 -4
- package/lib/module/Color.js.map +1 -1
- package/lib/module/Container.js +11 -1
- package/lib/module/Container.js.map +1 -1
- package/lib/module/Header/Header.js +29 -17
- package/lib/module/Header/Header.js.map +1 -1
- package/lib/module/Header/HeaderBackButton.js +27 -13
- package/lib/module/Header/HeaderBackButton.js.map +1 -1
- package/lib/module/Header/HeaderButton.js +4 -5
- package/lib/module/Header/HeaderButton.js.map +1 -1
- package/lib/module/Header/HeaderButtonBackground.js +1 -2
- package/lib/module/Header/HeaderButtonBackground.js.map +1 -1
- package/lib/module/Header/HeaderIcon.js +14 -17
- package/lib/module/Header/HeaderIcon.js.map +1 -1
- package/lib/module/Header/HeaderSearchBar.js +35 -25
- package/lib/module/Header/HeaderSearchBar.js.map +1 -1
- package/lib/module/Header/getHeaderTitle.js.map +1 -1
- package/lib/module/Header/useHeaderHeight.js +1 -1
- package/lib/module/Header/useHeaderHeight.js.map +1 -1
- package/lib/module/Label/getLabel.js.map +1 -1
- package/lib/module/LiquidGlassView.ios.js +1 -2
- package/lib/module/LiquidGlassView.ios.js.map +1 -1
- package/lib/module/LiquidGlassView.js +0 -4
- package/lib/module/LiquidGlassView.js.map +1 -1
- package/lib/module/PlatformColor.js +1 -0
- package/lib/module/PlatformColor.js.map +1 -1
- package/lib/module/PlatformColor.native.js +1 -1
- package/lib/module/PlatformColor.native.js.map +1 -1
- package/lib/module/PlatformIcon.js +46 -0
- package/lib/module/PlatformIcon.js.map +1 -0
- package/lib/module/PlatformPressable.js +56 -14
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/SafeAreaProviderCompat.js +1 -1
- package/lib/module/SafeAreaProviderCompat.js.map +1 -1
- package/lib/module/Screen.js +31 -18
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/index.js +2 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +1 -1
- package/lib/module/internal.js.map +1 -1
- package/lib/module/useFrameSize.js +6 -2
- package/lib/module/useFrameSize.js.map +1 -1
- package/lib/typescript/src/ActivityView.d.ts +31 -0
- package/lib/typescript/src/ActivityView.d.ts.map +1 -0
- package/lib/typescript/src/ActivityView.native.d.ts +3 -0
- package/lib/typescript/src/ActivityView.native.d.ts.map +1 -0
- package/lib/typescript/src/Badge.d.ts +6 -5
- package/lib/typescript/src/Badge.d.ts.map +1 -1
- package/lib/typescript/src/BlurEffectBackground.d.ts +2 -2
- package/lib/typescript/src/BlurEffectBackground.d.ts.map +1 -1
- package/lib/typescript/src/Button.d.ts +54 -6
- package/lib/typescript/src/Button.d.ts.map +1 -1
- package/lib/typescript/src/Color.d.ts +4 -4
- package/lib/typescript/src/Color.d.ts.map +1 -1
- package/lib/typescript/src/Container.d.ts +7 -4
- package/lib/typescript/src/Container.d.ts.map +1 -1
- package/lib/typescript/src/Header/Header.d.ts +5 -4
- package/lib/typescript/src/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackButton.d.ts +3 -2
- package/lib/typescript/src/Header/HeaderBackButton.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackground.d.ts +5 -5
- package/lib/typescript/src/Header/HeaderBackground.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderButton.d.ts +7 -2
- package/lib/typescript/src/Header/HeaderButton.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderButtonBackground.d.ts +1 -1
- package/lib/typescript/src/Header/HeaderButtonBackground.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderIcon.d.ts +9 -4
- package/lib/typescript/src/Header/HeaderIcon.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts +10 -7
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderTitle.d.ts +4 -4
- package/lib/typescript/src/Header/HeaderTitle.d.ts.map +1 -1
- package/lib/typescript/src/Header/getHeaderTitle.d.ts +2 -2
- package/lib/typescript/src/Header/getHeaderTitle.d.ts.map +1 -1
- package/lib/typescript/src/Label/Label.d.ts +1 -1
- package/lib/typescript/src/Label/Label.d.ts.map +1 -1
- package/lib/typescript/src/Label/getLabel.d.ts +2 -2
- package/lib/typescript/src/Label/getLabel.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.d.ts +7 -5
- package/lib/typescript/src/LiquidGlassView.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.ios.d.ts +4 -2
- package/lib/typescript/src/LiquidGlassView.ios.d.ts.map +1 -1
- package/lib/typescript/src/MissingIcon.d.ts +1 -1
- package/lib/typescript/src/MissingIcon.d.ts.map +1 -1
- package/lib/typescript/src/PlatformColor.d.ts +1 -0
- package/lib/typescript/src/PlatformColor.d.ts.map +1 -1
- package/lib/typescript/src/PlatformColor.native.d.ts +1 -1
- package/lib/typescript/src/PlatformColor.native.d.ts.map +1 -1
- package/lib/typescript/src/PlatformIcon.d.ts +10 -0
- package/lib/typescript/src/PlatformIcon.d.ts.map +1 -0
- package/lib/typescript/src/PlatformPressable.d.ts +12 -15
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts +1 -1
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts +7 -7
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/Text.d.ts +1 -1
- package/lib/typescript/src/Text.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +21 -21
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal.d.ts +6 -6
- package/lib/typescript/src/internal.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +120 -70
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useFrameSize.d.ts +1 -1
- package/lib/typescript/src/useFrameSize.d.ts.map +1 -1
- package/package.json +23 -22
- package/src/ActivityView.native.tsx +90 -0
- package/src/ActivityView.tsx +129 -0
- package/src/Badge.tsx +10 -8
- package/src/BlurEffectBackground.tsx +3 -3
- package/src/Button.tsx +173 -28
- package/src/Color.tsx +755 -8
- package/src/Container.tsx +20 -4
- package/src/Header/Header.tsx +46 -26
- package/src/Header/HeaderBackButton.tsx +31 -17
- package/src/Header/HeaderBackground.tsx +3 -3
- package/src/Header/HeaderButton.tsx +16 -18
- package/src/Header/HeaderButtonBackground.tsx +1 -4
- package/src/Header/HeaderIcon.tsx +27 -13
- package/src/Header/HeaderSearchBar.tsx +52 -44
- package/src/Header/HeaderTitle.tsx +3 -3
- package/src/Header/getHeaderTitle.tsx +4 -1
- package/src/Header/useHeaderHeight.tsx +1 -1
- package/src/Label/getLabel.tsx +1 -1
- package/src/LiquidGlassView.ios.tsx +14 -9
- package/src/LiquidGlassView.tsx +15 -11
- package/src/PlatformColor.native.tsx +1 -1
- package/src/PlatformColor.tsx +4 -0
- package/src/PlatformIcon.tsx +66 -0
- package/src/PlatformPressable.tsx +99 -41
- package/src/SafeAreaProviderCompat.tsx +1 -1
- package/src/Screen.tsx +40 -27
- package/src/index.tsx +2 -16
- package/src/internal.tsx +1 -1
- package/src/types.tsx +153 -76
- package/src/useFrameSize.tsx +9 -2
- package/lib/module/Lazy.js +0 -42
- package/lib/module/Lazy.js.map +0 -1
- package/lib/module/assets/back-icon.ios.svg +0 -4
- package/lib/module/assets/back-icon@1x.android.png +0 -0
- package/lib/module/assets/back-icon@1x.ios.png +0 -0
- package/lib/module/assets/back-icon@2x.android.png +0 -0
- package/lib/module/assets/back-icon@2x.ios.png +0 -0
- package/lib/module/assets/back-icon@3x.android.png +0 -0
- package/lib/module/assets/back-icon@3x.ios.png +0 -0
- package/lib/module/assets/back-icon@4x.android.png +0 -0
- package/lib/module/assets/back-icon@4x.ios.png +0 -0
- package/lib/module/assets/clear-icon@1x.png +0 -0
- package/lib/module/assets/clear-icon@2x.png +0 -0
- package/lib/module/assets/clear-icon@3x.png +0 -0
- package/lib/module/assets/clear-icon@4x.png +0 -0
- package/lib/module/assets/close-icon@1x.png +0 -0
- package/lib/module/assets/close-icon@2x.png +0 -0
- package/lib/module/assets/close-icon@3x.png +0 -0
- package/lib/module/assets/close-icon@4x.png +0 -0
- package/lib/module/assets/search-icon-legacy@1x.ios.png +0 -0
- package/lib/module/assets/search-icon-legacy@2x.ios.png +0 -0
- package/lib/module/assets/search-icon-legacy@3x.ios.png +0 -0
- package/lib/module/assets/search-icon-legacy@4x.ios.png +0 -0
- package/lib/module/assets/search-icon.ios.svg +0 -4
- package/lib/module/assets/search-icon@1x.android.png +0 -0
- package/lib/module/assets/search-icon@1x.ios.png +0 -0
- package/lib/module/assets/search-icon@2x.android.png +0 -0
- package/lib/module/assets/search-icon@2x.ios.png +0 -0
- package/lib/module/assets/search-icon@3x.android.png +0 -0
- package/lib/module/assets/search-icon@3x.ios.png +0 -0
- package/lib/module/assets/search-icon@4x.android.png +0 -0
- package/lib/module/assets/search-icon@4x.ios.png +0 -0
- package/lib/typescript/src/Lazy.d.ts +0 -31
- package/lib/typescript/src/Lazy.d.ts.map +0 -1
- package/src/Lazy.tsx +0 -59
- package/src/assets/back-icon.ios.svg +0 -4
- package/src/assets/back-icon@1x.android.png +0 -0
- package/src/assets/back-icon@1x.ios.png +0 -0
- package/src/assets/back-icon@2x.android.png +0 -0
- package/src/assets/back-icon@2x.ios.png +0 -0
- package/src/assets/back-icon@3x.android.png +0 -0
- package/src/assets/back-icon@3x.ios.png +0 -0
- package/src/assets/back-icon@4x.android.png +0 -0
- package/src/assets/back-icon@4x.ios.png +0 -0
- package/src/assets/clear-icon@1x.png +0 -0
- package/src/assets/clear-icon@2x.png +0 -0
- package/src/assets/clear-icon@3x.png +0 -0
- package/src/assets/clear-icon@4x.png +0 -0
- package/src/assets/close-icon@1x.png +0 -0
- package/src/assets/close-icon@2x.png +0 -0
- package/src/assets/close-icon@3x.png +0 -0
- package/src/assets/close-icon@4x.png +0 -0
- package/src/assets/search-icon-legacy@1x.ios.png +0 -0
- package/src/assets/search-icon-legacy@2x.ios.png +0 -0
- package/src/assets/search-icon-legacy@3x.ios.png +0 -0
- package/src/assets/search-icon-legacy@4x.ios.png +0 -0
- package/src/assets/search-icon.ios.svg +0 -4
- package/src/assets/search-icon@1x.android.png +0 -0
- package/src/assets/search-icon@1x.ios.png +0 -0
- package/src/assets/search-icon@2x.android.png +0 -0
- package/src/assets/search-icon@2x.ios.png +0 -0
- package/src/assets/search-icon@3x.android.png +0 -0
- package/src/assets/search-icon@3x.ios.png +0 -0
- package/src/assets/search-icon@4x.android.png +0 -0
- package/src/assets/search-icon@4x.ios.png +0 -0
package/src/LiquidGlassView.tsx
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LiquidGlassContainerViewProps,
|
|
3
|
+
LiquidGlassViewProps,
|
|
4
|
+
} from '@callstack/liquid-glass';
|
|
1
5
|
import { Animated, View } from 'react-native';
|
|
2
6
|
|
|
3
|
-
type
|
|
7
|
+
type AnimatedLiquidGlassViewProps =
|
|
8
|
+
Animated.AnimatedProps<LiquidGlassViewProps>;
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
type AnimatedLiquidGlassContainerViewProps =
|
|
11
|
+
Animated.AnimatedProps<LiquidGlassContainerViewProps>;
|
|
6
12
|
|
|
7
|
-
export const
|
|
13
|
+
export const LiquidGlassView: React.ComponentType<LiquidGlassViewProps> = View;
|
|
14
|
+
|
|
15
|
+
export const LiquidGlassContainerView: React.ComponentType<LiquidGlassContainerViewProps> =
|
|
8
16
|
View;
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
typeof LiquidGlassView
|
|
13
|
-
> = Animated.View;
|
|
18
|
+
export const AnimatedLiquidGlassView: React.ComponentType<AnimatedLiquidGlassViewProps> =
|
|
19
|
+
Animated.View;
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
typeof LiquidGlassContainerView
|
|
18
|
-
> = Animated.View;
|
|
21
|
+
export const AnimatedLiquidGlassContainerView: React.ComponentType<AnimatedLiquidGlassContainerViewProps> =
|
|
22
|
+
Animated.View;
|
|
19
23
|
|
|
20
24
|
export const isLiquidGlassSupported = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { PlatformColor } from 'react-native';
|
|
1
|
+
export { DynamicColorIOS, PlatformColor } from 'react-native';
|
package/src/PlatformColor.tsx
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MaterialSymbol, SFSymbol } from '@react-navigation/native';
|
|
2
|
+
import {
|
|
3
|
+
type ColorValue,
|
|
4
|
+
Image,
|
|
5
|
+
type ImageStyle,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
import type { Icon } from './types';
|
|
10
|
+
|
|
11
|
+
export type PlatformIconProps = {
|
|
12
|
+
icon: Icon;
|
|
13
|
+
size: number;
|
|
14
|
+
color?: ColorValue | undefined;
|
|
15
|
+
style?: StyleProp<ImageStyle> | undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function PlatformIcon({
|
|
19
|
+
icon,
|
|
20
|
+
color,
|
|
21
|
+
size,
|
|
22
|
+
style,
|
|
23
|
+
...rest
|
|
24
|
+
}: PlatformIconProps) {
|
|
25
|
+
switch (icon.type) {
|
|
26
|
+
case 'sfSymbol':
|
|
27
|
+
return (
|
|
28
|
+
<SFSymbol
|
|
29
|
+
name={icon.name}
|
|
30
|
+
color={color}
|
|
31
|
+
size={size}
|
|
32
|
+
style={style}
|
|
33
|
+
{...rest}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
case 'materialSymbol':
|
|
37
|
+
return (
|
|
38
|
+
<MaterialSymbol
|
|
39
|
+
name={icon.name}
|
|
40
|
+
variant={icon.variant}
|
|
41
|
+
weight={icon.weight}
|
|
42
|
+
size={size}
|
|
43
|
+
color={color}
|
|
44
|
+
style={style}
|
|
45
|
+
{...rest}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
case 'image':
|
|
49
|
+
return (
|
|
50
|
+
<Image
|
|
51
|
+
source={icon.source}
|
|
52
|
+
resizeMode="contain"
|
|
53
|
+
fadeDuration={0}
|
|
54
|
+
tintColor={icon.tinted === false ? undefined : color}
|
|
55
|
+
style={[
|
|
56
|
+
{
|
|
57
|
+
width: size,
|
|
58
|
+
height: size,
|
|
59
|
+
},
|
|
60
|
+
style,
|
|
61
|
+
]}
|
|
62
|
+
{...rest}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTheme } from '@react-navigation/native';
|
|
1
|
+
import { IsFocusedContext, useTheme } from '@react-navigation/native';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import {
|
|
4
4
|
Animated,
|
|
@@ -19,15 +19,20 @@ type HoverEffectProps = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export type Props = Omit<PressableProps, 'style' | 'onPress'> & {
|
|
22
|
-
href?: string;
|
|
23
|
-
pressColor?: ColorValue;
|
|
24
|
-
pressOpacity?: number;
|
|
25
|
-
hoverEffect?: HoverEffectProps;
|
|
26
|
-
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle
|
|
27
|
-
onPress?:
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
href?: string | undefined;
|
|
23
|
+
pressColor?: ColorValue | undefined;
|
|
24
|
+
pressOpacity?: number | undefined;
|
|
25
|
+
hoverEffect?: HoverEffectProps | undefined;
|
|
26
|
+
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>> | undefined;
|
|
27
|
+
onPress?:
|
|
28
|
+
| ((
|
|
29
|
+
e:
|
|
30
|
+
| React.MouseEvent<HTMLAnchorElement, MouseEvent>
|
|
31
|
+
| GestureResponderEvent
|
|
32
|
+
) => void)
|
|
33
|
+
| undefined;
|
|
30
34
|
children: React.ReactNode;
|
|
35
|
+
ref?: React.Ref<React.ComponentRef<typeof AnimatedPressable>> | undefined;
|
|
31
36
|
};
|
|
32
37
|
|
|
33
38
|
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
@@ -41,22 +46,20 @@ const useNativeDriver = Platform.OS !== 'web';
|
|
|
41
46
|
/**
|
|
42
47
|
* PlatformPressable provides an abstraction on top of Pressable to handle platform differences.
|
|
43
48
|
*/
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
ref: React.Ref<React.ComponentRef<typeof AnimatedPressable>>
|
|
59
|
-
) {
|
|
49
|
+
export function PlatformPressable({
|
|
50
|
+
disabled,
|
|
51
|
+
onPress,
|
|
52
|
+
onPressIn,
|
|
53
|
+
onPressOut,
|
|
54
|
+
android_ripple,
|
|
55
|
+
pressColor,
|
|
56
|
+
pressOpacity = 0.3,
|
|
57
|
+
hoverEffect,
|
|
58
|
+
style,
|
|
59
|
+
children,
|
|
60
|
+
ref,
|
|
61
|
+
...rest
|
|
62
|
+
}: Props) {
|
|
60
63
|
const { dark } = useTheme();
|
|
61
64
|
const [opacity] = React.useState(() => new Animated.Value(1));
|
|
62
65
|
|
|
@@ -76,7 +79,7 @@ function PlatformPressableInternal(
|
|
|
76
79
|
const handlePress = (
|
|
77
80
|
e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
|
|
78
81
|
) => {
|
|
79
|
-
if (Platform.OS === 'web' && rest.href
|
|
82
|
+
if (Platform.OS === 'web' && rest.href != null) {
|
|
80
83
|
// ignore clicks with modifier keys
|
|
81
84
|
const hasModifierKey =
|
|
82
85
|
('metaKey' in e && e.metaKey) ||
|
|
@@ -91,7 +94,7 @@ function PlatformPressableInternal(
|
|
|
91
94
|
// let browser handle "target=_blank" etc.
|
|
92
95
|
const isSelfTarget =
|
|
93
96
|
e.currentTarget && 'target' in e.currentTarget
|
|
94
|
-
? [undefined, null, '', '
|
|
97
|
+
? [undefined, null, '', '_self'].includes(e.currentTarget.target)
|
|
95
98
|
: true;
|
|
96
99
|
|
|
97
100
|
if (!hasModifierKey && isLeftClick && isSelfTarget) {
|
|
@@ -115,10 +118,69 @@ function PlatformPressableInternal(
|
|
|
115
118
|
onPressOut?.(e);
|
|
116
119
|
};
|
|
117
120
|
|
|
121
|
+
const elementRef = React.useRef<HTMLElement | null>(null);
|
|
122
|
+
|
|
123
|
+
const handleRef = React.useCallback(
|
|
124
|
+
(node: React.ComponentRef<typeof AnimatedPressable> | null) => {
|
|
125
|
+
elementRef.current =
|
|
126
|
+
Platform.OS === 'web' &&
|
|
127
|
+
typeof HTMLElement !== 'undefined' &&
|
|
128
|
+
node instanceof HTMLElement
|
|
129
|
+
? node
|
|
130
|
+
: null;
|
|
131
|
+
|
|
132
|
+
if (typeof ref === 'function') {
|
|
133
|
+
return ref(node);
|
|
134
|
+
} else if (ref != null) {
|
|
135
|
+
ref.current = node;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[ref]
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// React Native Web doesn't correctly handle ref cleanup functions
|
|
142
|
+
// So we use a `useEffect` for the listeners instead of the ref callback
|
|
143
|
+
React.useEffect(() => {
|
|
144
|
+
const element = elementRef.current;
|
|
145
|
+
|
|
146
|
+
if (rest.href == null || element == null || !disabled) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// On web, a disabled button prevents our onPress from being called
|
|
151
|
+
// But the link is still clickable, and will perform a full page navigation
|
|
152
|
+
// So we manually prevent the default behavior of the link when disabled
|
|
153
|
+
// The `href` is still set so regular link semantics are preserved
|
|
154
|
+
const preventNavigation = (event: Event) => {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
event.stopPropagation();
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
element.addEventListener('click', preventNavigation, true);
|
|
160
|
+
element.addEventListener('auxclick', preventNavigation, true);
|
|
161
|
+
|
|
162
|
+
return () => {
|
|
163
|
+
element.removeEventListener('click', preventNavigation, true);
|
|
164
|
+
element.removeEventListener('auxclick', preventNavigation, true);
|
|
165
|
+
};
|
|
166
|
+
}, [disabled, rest.href]);
|
|
167
|
+
|
|
168
|
+
let focusable: boolean | undefined;
|
|
169
|
+
|
|
170
|
+
if (disabled) {
|
|
171
|
+
focusable = false;
|
|
172
|
+
} else if (Platform.isTV) {
|
|
173
|
+
// On `react-native-tvos`, the focus engine doesn't respect `aria-hidden` on screens
|
|
174
|
+
// So we hide them from TV focus engine for unfocused screens
|
|
175
|
+
focusable = React.use(IsFocusedContext);
|
|
176
|
+
}
|
|
177
|
+
|
|
118
178
|
return (
|
|
119
179
|
<AnimatedPressable
|
|
120
|
-
ref={
|
|
180
|
+
ref={handleRef}
|
|
121
181
|
accessible
|
|
182
|
+
disabled={disabled}
|
|
183
|
+
focusable={focusable}
|
|
122
184
|
role={Platform.OS === 'web' && rest.href != null ? 'link' : 'button'}
|
|
123
185
|
onPress={disabled ? undefined : handlePress}
|
|
124
186
|
onPressIn={disabled ? undefined : handlePressIn}
|
|
@@ -156,10 +218,6 @@ function PlatformPressableInternal(
|
|
|
156
218
|
);
|
|
157
219
|
}
|
|
158
220
|
|
|
159
|
-
export const PlatformPressable = React.forwardRef(PlatformPressableInternal);
|
|
160
|
-
|
|
161
|
-
PlatformPressable.displayName = 'PlatformPressable';
|
|
162
|
-
|
|
163
221
|
const css = String.raw;
|
|
164
222
|
|
|
165
223
|
const CLASS_NAME = `__react-navigation_elements_Pressable_hover`;
|
|
@@ -196,20 +254,20 @@ const HoverEffect = ({
|
|
|
196
254
|
return null;
|
|
197
255
|
}
|
|
198
256
|
|
|
257
|
+
const style: React.CSSProperties & {
|
|
258
|
+
[key: `--${string}`]: string | number;
|
|
259
|
+
} = {
|
|
260
|
+
'--overlay-color': color,
|
|
261
|
+
'--overlay-hover-opacity': hoverOpacity,
|
|
262
|
+
'--overlay-active-opacity': activeOpacity,
|
|
263
|
+
};
|
|
264
|
+
|
|
199
265
|
return (
|
|
200
266
|
<>
|
|
201
267
|
<style href={CLASS_NAME} precedence="elements">
|
|
202
268
|
{CSS_TEXT}
|
|
203
269
|
</style>
|
|
204
|
-
<div
|
|
205
|
-
className={CLASS_NAME}
|
|
206
|
-
style={{
|
|
207
|
-
// @ts-expect-error: CSS variables are not typed
|
|
208
|
-
'--overlay-color': color,
|
|
209
|
-
'--overlay-hover-opacity': hoverOpacity,
|
|
210
|
-
'--overlay-active-opacity': activeOpacity,
|
|
211
|
-
}}
|
|
212
|
-
/>
|
|
270
|
+
<div className={CLASS_NAME} style={style} />
|
|
213
271
|
</>
|
|
214
272
|
);
|
|
215
273
|
};
|
|
@@ -34,7 +34,7 @@ const initialMetrics =
|
|
|
34
34
|
: initialWindowMetrics;
|
|
35
35
|
|
|
36
36
|
export function SafeAreaProviderCompat({ children, style }: Props) {
|
|
37
|
-
const insets = React.
|
|
37
|
+
const insets = React.use(SafeAreaInsetsContext);
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
40
|
<FrameSizeProvider
|
package/src/Screen.tsx
CHANGED
|
@@ -6,15 +6,10 @@ import {
|
|
|
6
6
|
useTheme,
|
|
7
7
|
} from '@react-navigation/native';
|
|
8
8
|
import * as React from 'react';
|
|
9
|
-
import {
|
|
10
|
-
Animated,
|
|
11
|
-
type StyleProp,
|
|
12
|
-
StyleSheet,
|
|
13
|
-
View,
|
|
14
|
-
type ViewStyle,
|
|
15
|
-
} from 'react-native';
|
|
9
|
+
import { StyleSheet, View } from 'react-native';
|
|
16
10
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
17
11
|
|
|
12
|
+
import { Container, type Props as ContainerProps } from './Container';
|
|
18
13
|
import { getDefaultHeaderHeight } from './Header/getDefaultHeaderHeight';
|
|
19
14
|
import { HeaderHeightContext } from './Header/HeaderHeightContext';
|
|
20
15
|
import { HeaderShownContext } from './Header/HeaderShownContext';
|
|
@@ -22,14 +17,14 @@ import { useFrameSize } from './useFrameSize';
|
|
|
22
17
|
|
|
23
18
|
type Props = {
|
|
24
19
|
focused: boolean;
|
|
25
|
-
modal?: boolean;
|
|
20
|
+
modal?: boolean | undefined;
|
|
26
21
|
navigation: NavigationProp<ParamListBase>;
|
|
27
22
|
route: RouteProp<ParamListBase>;
|
|
28
23
|
header: React.ReactNode;
|
|
29
|
-
headerShown?: boolean;
|
|
30
|
-
headerStatusBarHeight?: number;
|
|
31
|
-
headerTransparent?: boolean;
|
|
32
|
-
style?:
|
|
24
|
+
headerShown?: boolean | undefined;
|
|
25
|
+
headerStatusBarHeight?: number | undefined;
|
|
26
|
+
headerTransparent?: boolean | undefined;
|
|
27
|
+
style?: ContainerProps['style'] | undefined;
|
|
33
28
|
children: React.ReactNode;
|
|
34
29
|
};
|
|
35
30
|
|
|
@@ -37,8 +32,8 @@ export function Screen(props: Props) {
|
|
|
37
32
|
const insets = useSafeAreaInsets();
|
|
38
33
|
const { colors } = useTheme();
|
|
39
34
|
|
|
40
|
-
const isParentHeaderShown = React.
|
|
41
|
-
const parentHeaderHeight = React.
|
|
35
|
+
const isParentHeaderShown = React.use(HeaderShownContext);
|
|
36
|
+
const parentHeaderHeight = React.use(HeaderHeightContext);
|
|
42
37
|
|
|
43
38
|
const {
|
|
44
39
|
focused,
|
|
@@ -72,25 +67,43 @@ export function Screen(props: Props) {
|
|
|
72
67
|
}, [route.name]);
|
|
73
68
|
|
|
74
69
|
return (
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
style={
|
|
70
|
+
<Container
|
|
71
|
+
inert={!focused}
|
|
72
|
+
style={{
|
|
73
|
+
...styles.container,
|
|
74
|
+
backgroundColor: colors.background,
|
|
75
|
+
...style,
|
|
76
|
+
}}
|
|
78
77
|
// On Fabric we need to disable collapsing for the background to ensure
|
|
79
78
|
// that we won't render unnecessary views due to the view flattening.
|
|
80
|
-
collapsable
|
|
79
|
+
// Container sets `collapsable` to `false` internally
|
|
80
|
+
// This comment is left to make sure refactors don't remove it by mistake
|
|
81
81
|
>
|
|
82
82
|
{headerShown ? (
|
|
83
83
|
<NavigationProvider navigation={navigation} route={route}>
|
|
84
84
|
<View
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
style={[
|
|
86
|
+
styles.header,
|
|
87
|
+
headerTransparent
|
|
88
|
+
? [
|
|
89
|
+
styles.absolute,
|
|
90
|
+
// Specify an explicit min height for Android screen readers
|
|
91
|
+
{ minHeight: headerHeight },
|
|
92
|
+
]
|
|
93
|
+
: null,
|
|
94
|
+
]}
|
|
92
95
|
>
|
|
93
|
-
|
|
96
|
+
<View
|
|
97
|
+
ref={headerRef}
|
|
98
|
+
onLayout={(e) => {
|
|
99
|
+
const { height } = e.nativeEvent.layout;
|
|
100
|
+
|
|
101
|
+
setHeaderHeight(height);
|
|
102
|
+
}}
|
|
103
|
+
style={{ pointerEvents: 'box-none' }}
|
|
104
|
+
>
|
|
105
|
+
{header}
|
|
106
|
+
</View>
|
|
94
107
|
</View>
|
|
95
108
|
</NavigationProvider>
|
|
96
109
|
) : null}
|
|
@@ -105,7 +118,7 @@ export function Screen(props: Props) {
|
|
|
105
118
|
</HeaderHeightContext.Provider>
|
|
106
119
|
</HeaderShownContext.Provider>
|
|
107
120
|
</View>
|
|
108
|
-
</
|
|
121
|
+
</Container>
|
|
109
122
|
);
|
|
110
123
|
}
|
|
111
124
|
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import backIcon from './assets/back-icon.png';
|
|
2
|
-
import clearIcon from './assets/clear-icon.png';
|
|
3
|
-
import closeIcon from './assets/close-icon.png';
|
|
4
|
-
import searchIcon from './assets/search-icon.png';
|
|
5
|
-
import searchIconLegacy from './assets/search-icon-legacy.png';
|
|
6
|
-
|
|
7
1
|
export { Badge } from './Badge';
|
|
8
2
|
export { Button } from './Button';
|
|
9
3
|
export { getDefaultSidebarWidth } from './getDefaultSidebarWidth';
|
|
@@ -20,16 +14,8 @@ export { HeaderTitle } from './Header/HeaderTitle';
|
|
|
20
14
|
export { useHeaderHeight } from './Header/useHeaderHeight';
|
|
21
15
|
export { getLabel } from './Label/getLabel';
|
|
22
16
|
export { Label } from './Label/Label';
|
|
17
|
+
export { PlatformIcon } from './PlatformIcon';
|
|
23
18
|
export { PlatformPressable } from './PlatformPressable';
|
|
24
19
|
export { Text } from './Text';
|
|
25
|
-
export { useFrameSize } from './useFrameSize';
|
|
26
|
-
|
|
27
|
-
export const Assets = [
|
|
28
|
-
backIcon,
|
|
29
|
-
searchIcon,
|
|
30
|
-
searchIconLegacy,
|
|
31
|
-
closeIcon,
|
|
32
|
-
clearIcon,
|
|
33
|
-
];
|
|
34
|
-
|
|
35
20
|
export * from './types';
|
|
21
|
+
export { useFrameSize } from './useFrameSize';
|
package/src/internal.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
export { ActivityView } from './ActivityView';
|
|
1
2
|
export { Color } from './Color';
|
|
2
3
|
export { Container, type Props as ContainerProps } from './Container';
|
|
3
|
-
export { Lazy } from './Lazy';
|
|
4
4
|
export { isLiquidGlassSupported } from './LiquidGlassView';
|
|
5
5
|
export { MissingIcon } from './MissingIcon';
|
|
6
6
|
export { SafeAreaProviderCompat } from './SafeAreaProviderCompat';
|