@react-navigation/elements 3.0.0-alpha.11 → 3.0.0-alpha.13
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/Container.js +3 -0
- package/lib/module/Container.js.map +1 -1
- package/lib/module/Header/Header.js +5 -2
- package/lib/module/Header/Header.js.map +1 -1
- package/lib/module/Header/getHeaderTitle.js.map +1 -1
- package/lib/module/Label/getLabel.js.map +1 -1
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/Screen.js +1 -1
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/internal.js +1 -1
- package/lib/module/internal.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 +3 -3
- package/lib/typescript/src/Badge.d.ts.map +1 -1
- package/lib/typescript/src/Button.d.ts +2 -2
- package/lib/typescript/src/Button.d.ts.map +1 -1
- package/lib/typescript/src/Container.d.ts +7 -6
- package/lib/typescript/src/Container.d.ts.map +1 -1
- package/lib/typescript/src/Header/Header.d.ts +2 -2
- package/lib/typescript/src/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackground.d.ts +3 -3
- package/lib/typescript/src/Header/HeaderBackground.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts +4 -4
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderTitle.d.ts +3 -3
- package/lib/typescript/src/Header/HeaderTitle.d.ts.map +1 -1
- package/lib/typescript/src/Header/getHeaderTitle.d.ts +1 -1
- package/lib/typescript/src/Header/getHeaderTitle.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/PlatformPressable.d.ts +12 -12
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts +6 -6
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/internal.d.ts +1 -1
- package/lib/typescript/src/internal.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +65 -65
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/ActivityView.native.tsx +90 -0
- package/src/ActivityView.tsx +129 -0
- package/src/Badge.tsx +3 -3
- package/src/Button.tsx +2 -2
- package/src/Container.tsx +11 -6
- package/src/Header/Header.tsx +19 -12
- package/src/Header/HeaderBackButton.tsx +3 -3
- package/src/Header/HeaderBackground.tsx +3 -3
- package/src/Header/HeaderSearchBar.tsx +4 -4
- package/src/Header/HeaderTitle.tsx +3 -3
- package/src/Header/getHeaderTitle.tsx +4 -1
- package/src/Label/getLabel.tsx +1 -1
- package/src/PlatformPressable.tsx +12 -8
- package/src/Screen.tsx +6 -6
- package/src/internal.tsx +1 -1
- package/src/types.tsx +96 -75
- package/lib/module/Lazy.js +0 -42
- package/lib/module/Lazy.js.map +0 -1
- 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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Activity, useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Platform, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Container } from './Container';
|
|
5
|
+
|
|
6
|
+
export type Props = {
|
|
7
|
+
/**
|
|
8
|
+
* Mode of the activity view
|
|
9
|
+
* - `normal`: The view renders normally
|
|
10
|
+
* - `inert`: Content is not interactive
|
|
11
|
+
* - `paused`: Effects are unmounted and content is not interactive
|
|
12
|
+
*/
|
|
13
|
+
mode: 'normal' | 'inert' | 'paused';
|
|
14
|
+
/**
|
|
15
|
+
* Whether the content is visible or not
|
|
16
|
+
*/
|
|
17
|
+
visible: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Delay before pausing effects.
|
|
20
|
+
* So pending animations have time to finish.
|
|
21
|
+
*
|
|
22
|
+
* Defaults to 500ms.
|
|
23
|
+
*/
|
|
24
|
+
delay?: number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The style for the container view
|
|
27
|
+
*/
|
|
28
|
+
style?: Omit<React.CSSProperties & ViewStyle, 'display'> | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The content of the activity view
|
|
31
|
+
*/
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function ActivityView({
|
|
36
|
+
mode,
|
|
37
|
+
visible,
|
|
38
|
+
delay = 500,
|
|
39
|
+
style,
|
|
40
|
+
children,
|
|
41
|
+
}: Props) {
|
|
42
|
+
const [delayedMode, setDelayedMode] = useState(mode);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!delay) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const timer = setTimeout(() => {
|
|
50
|
+
setDelayedMode(mode);
|
|
51
|
+
}, delay);
|
|
52
|
+
|
|
53
|
+
return () => clearTimeout(timer);
|
|
54
|
+
}, [delay, mode]);
|
|
55
|
+
|
|
56
|
+
const display = visible ? 'flex' : 'none';
|
|
57
|
+
const activityMode =
|
|
58
|
+
mode !== 'paused' || (delay && delayedMode !== 'paused')
|
|
59
|
+
? 'visible'
|
|
60
|
+
: 'hidden';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Activity has 2 modes, visible and hidden - hidden unmounts effects
|
|
64
|
+
* But what we want is to unmount effects, without hiding content
|
|
65
|
+
* So we use hidden mode, but unset display: none to make content visible
|
|
66
|
+
*/
|
|
67
|
+
const onRef = useCallback(
|
|
68
|
+
(node: HTMLDivElement | View | null) => {
|
|
69
|
+
if (Platform.OS !== 'web' || !(node && node instanceof HTMLElement)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const observers: MutationObserver[] = [];
|
|
74
|
+
|
|
75
|
+
const observe = () => {
|
|
76
|
+
// Remove previous observers
|
|
77
|
+
observers.forEach((o) => o.disconnect());
|
|
78
|
+
observers.length = 0;
|
|
79
|
+
|
|
80
|
+
const children = node.childNodes;
|
|
81
|
+
|
|
82
|
+
// When the style attribute for children is updated by React
|
|
83
|
+
// We observe it and update display to make content visible
|
|
84
|
+
children.forEach((child) => {
|
|
85
|
+
if (child instanceof HTMLElement) {
|
|
86
|
+
child.style.display = display;
|
|
87
|
+
|
|
88
|
+
const o = new MutationObserver(() => {
|
|
89
|
+
child.style.display = display;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
o.observe(child, {
|
|
93
|
+
attributes: true,
|
|
94
|
+
attributeFilter: ['style'],
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
observers.push(o);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
observe();
|
|
103
|
+
|
|
104
|
+
// React removes refs when `Activity` is hidden
|
|
105
|
+
// So we render outside of the `Activity` and observer child list
|
|
106
|
+
const observer = new MutationObserver(observe);
|
|
107
|
+
|
|
108
|
+
observer.observe(node, {
|
|
109
|
+
childList: true,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return () => {
|
|
113
|
+
observer.disconnect();
|
|
114
|
+
observers.forEach((o) => o.disconnect());
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
[display]
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<Container ref={onRef} style={{ display: 'contents' }}>
|
|
122
|
+
<Activity mode={activityMode}>
|
|
123
|
+
<Container inert={mode !== 'normal'} style={{ ...style, display }}>
|
|
124
|
+
{children}
|
|
125
|
+
</Container>
|
|
126
|
+
</Activity>
|
|
127
|
+
</Container>
|
|
128
|
+
);
|
|
129
|
+
}
|
package/src/Badge.tsx
CHANGED
|
@@ -19,15 +19,15 @@ type Props = TextProps & {
|
|
|
19
19
|
/**
|
|
20
20
|
* Content of the `Badge`.
|
|
21
21
|
*/
|
|
22
|
-
children?: string | number;
|
|
22
|
+
children?: string | number | undefined;
|
|
23
23
|
/**
|
|
24
24
|
* Size of the `Badge`.
|
|
25
25
|
*/
|
|
26
|
-
size?: number;
|
|
26
|
+
size?: number | undefined;
|
|
27
27
|
/**
|
|
28
28
|
* Style object for the tab bar container.
|
|
29
29
|
*/
|
|
30
|
-
style?: Animated.WithAnimatedValue<StyleProp<TextStyle
|
|
30
|
+
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>> | undefined;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
const useNativeDriver = Platform.OS !== 'web';
|
package/src/Button.tsx
CHANGED
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
import { Text } from './Text';
|
|
16
16
|
|
|
17
17
|
type ButtonBaseProps = Omit<PlatformPressableProps, 'children'> & {
|
|
18
|
-
variant?: 'plain' | 'tinted' | 'filled';
|
|
19
|
-
color?: ColorValue;
|
|
18
|
+
variant?: 'plain' | 'tinted' | 'filled' | undefined;
|
|
19
|
+
color?: ColorValue | undefined;
|
|
20
20
|
children: string | string[];
|
|
21
21
|
};
|
|
22
22
|
|
package/src/Container.tsx
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { Platform, View, type ViewStyle } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export type Props = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
ref?: React.Ref<HTMLDivElement | View> | undefined;
|
|
5
|
+
inert?: boolean | undefined;
|
|
6
|
+
style?:
|
|
7
|
+
| (ViewStyle &
|
|
8
|
+
Omit<React.CSSProperties, 'backgroundColor'> & {
|
|
9
|
+
backgroundColor?: ViewStyle['backgroundColor'] | undefined;
|
|
10
|
+
})
|
|
11
|
+
| undefined;
|
|
9
12
|
children: React.ReactNode;
|
|
10
13
|
};
|
|
11
14
|
|
|
12
|
-
export function Container({ inert, children, style }: Props) {
|
|
15
|
+
export function Container({ ref, inert, children, style }: Props) {
|
|
13
16
|
if (Platform.OS === 'web') {
|
|
14
17
|
const { backgroundColor, ...rest } = style ?? {};
|
|
15
18
|
|
|
16
19
|
return (
|
|
17
20
|
<div
|
|
21
|
+
ref={ref as React.Ref<HTMLDivElement> | undefined}
|
|
18
22
|
inert={inert}
|
|
19
23
|
aria-hidden={inert}
|
|
20
24
|
style={{
|
|
@@ -32,6 +36,7 @@ export function Container({ inert, children, style }: Props) {
|
|
|
32
36
|
|
|
33
37
|
return (
|
|
34
38
|
<View
|
|
39
|
+
ref={ref as React.Ref<View> | undefined}
|
|
35
40
|
aria-hidden={inert}
|
|
36
41
|
style={[{ pointerEvents: inert ? 'none' : 'box-none' }, style]}
|
|
37
42
|
collapsable={false}
|
package/src/Header/Header.tsx
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
UNSTABLE_CornerInset,
|
|
3
|
+
useNavigation,
|
|
4
|
+
useTheme,
|
|
5
|
+
} from '@react-navigation/native';
|
|
2
6
|
import * as React from 'react';
|
|
3
7
|
import {
|
|
4
8
|
Animated,
|
|
@@ -30,20 +34,22 @@ type Props = HeaderOptions & {
|
|
|
30
34
|
/**
|
|
31
35
|
* Options for the back button.
|
|
32
36
|
*/
|
|
33
|
-
back?:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
back?:
|
|
38
|
+
| {
|
|
39
|
+
/**
|
|
40
|
+
* Title of the previous screen.
|
|
41
|
+
*/
|
|
42
|
+
title: string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The `href` to use for the anchor tag on web
|
|
45
|
+
*/
|
|
46
|
+
href: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
| undefined;
|
|
43
49
|
/**
|
|
44
50
|
* Whether the header is in a modal
|
|
45
51
|
*/
|
|
46
|
-
modal?: boolean;
|
|
52
|
+
modal?: boolean | undefined;
|
|
47
53
|
/**
|
|
48
54
|
* Title text for the header.
|
|
49
55
|
*/
|
|
@@ -402,6 +408,7 @@ export function Header(props: Props) {
|
|
|
402
408
|
},
|
|
403
409
|
]}
|
|
404
410
|
>
|
|
411
|
+
<UNSTABLE_CornerInset direction="horizontal" edge="left" />
|
|
405
412
|
<View
|
|
406
413
|
style={[
|
|
407
414
|
styles.start,
|
|
@@ -119,11 +119,11 @@ function HeaderBackLabel({
|
|
|
119
119
|
truncatedLabel,
|
|
120
120
|
onMeasureMinimal,
|
|
121
121
|
}: {
|
|
122
|
-
allowFontScaling?: boolean;
|
|
122
|
+
allowFontScaling?: boolean | undefined;
|
|
123
123
|
displayMode: HeaderBackButtonDisplayMode;
|
|
124
124
|
label: string | undefined;
|
|
125
|
-
labelStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle
|
|
126
|
-
tintColor?: ColorValue;
|
|
125
|
+
labelStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle>> | undefined;
|
|
126
|
+
tintColor?: ColorValue | undefined;
|
|
127
127
|
truncatedLabel: string | undefined;
|
|
128
128
|
onMeasureMinimal: () => void;
|
|
129
129
|
}) {
|
|
@@ -12,9 +12,9 @@ import { BlurEffectBackground } from '../BlurEffectBackground';
|
|
|
12
12
|
import { type BlurEffectType } from '../getBlurBackgroundColor';
|
|
13
13
|
|
|
14
14
|
type Props = Omit<ViewProps, 'style'> & {
|
|
15
|
-
blurEffect?: BlurEffectType | 'none';
|
|
16
|
-
style?: StyleProp<ViewStyle
|
|
17
|
-
children?: React.ReactNode;
|
|
15
|
+
blurEffect?: BlurEffectType | 'none' | undefined;
|
|
16
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
17
|
+
children?: React.ReactNode | undefined;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export function HeaderBackground({
|
|
@@ -30,11 +30,11 @@ import { HeaderIcon } from './HeaderIcon';
|
|
|
30
30
|
type Props = Omit<HeaderSearchBarOptions, 'ref'> & {
|
|
31
31
|
visible: boolean;
|
|
32
32
|
onClose: () => void;
|
|
33
|
-
tintColor?: ColorValue;
|
|
34
|
-
pressColor?: ColorValue;
|
|
35
|
-
pressOpacity?: number;
|
|
33
|
+
tintColor?: ColorValue | undefined;
|
|
34
|
+
pressColor?: ColorValue | undefined;
|
|
35
|
+
pressOpacity?: number | undefined;
|
|
36
36
|
statusBarHeight: number;
|
|
37
|
-
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle
|
|
37
|
+
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>> | undefined;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const INPUT_TYPE_TO_MODE = {
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
|
|
12
12
|
type Props = Omit<TextProps, 'style'> & {
|
|
13
|
-
tintColor?: ColorValue;
|
|
14
|
-
children?: string;
|
|
15
|
-
style?: Animated.WithAnimatedValue<StyleProp<TextStyle
|
|
13
|
+
tintColor?: ColorValue | undefined;
|
|
14
|
+
children?: string | undefined;
|
|
15
|
+
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>> | undefined;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export function HeaderTitle({ tintColor, style, ...rest }: Props) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { HeaderOptions } from '../types';
|
|
2
2
|
|
|
3
3
|
export function getHeaderTitle(
|
|
4
|
-
options: {
|
|
4
|
+
options: {
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
headerTitle?: HeaderOptions['headerTitle'];
|
|
7
|
+
},
|
|
5
8
|
fallback: string
|
|
6
9
|
): string {
|
|
7
10
|
return typeof options.headerTitle === 'string'
|
package/src/Label/getLabel.tsx
CHANGED
|
@@ -19,14 +19,18 @@ 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;
|
|
31
35
|
};
|
|
32
36
|
|
package/src/Screen.tsx
CHANGED
|
@@ -9,22 +9,22 @@ import * as React from 'react';
|
|
|
9
9
|
import { StyleSheet, View } from 'react-native';
|
|
10
10
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
11
11
|
|
|
12
|
+
import { Container } from './Container';
|
|
12
13
|
import { getDefaultHeaderHeight } from './Header/getDefaultHeaderHeight';
|
|
13
14
|
import { HeaderHeightContext } from './Header/HeaderHeightContext';
|
|
14
15
|
import { HeaderShownContext } from './Header/HeaderShownContext';
|
|
15
|
-
import { Container } from './internal';
|
|
16
16
|
import { useFrameSize } from './useFrameSize';
|
|
17
17
|
|
|
18
18
|
type Props = {
|
|
19
19
|
focused: boolean;
|
|
20
|
-
modal?: boolean;
|
|
20
|
+
modal?: boolean | undefined;
|
|
21
21
|
navigation: NavigationProp<ParamListBase>;
|
|
22
22
|
route: RouteProp<ParamListBase>;
|
|
23
23
|
header: React.ReactNode;
|
|
24
|
-
headerShown?: boolean;
|
|
25
|
-
headerStatusBarHeight?: number;
|
|
26
|
-
headerTransparent?: boolean;
|
|
27
|
-
style?: React.ComponentProps<typeof Container>['style'];
|
|
24
|
+
headerShown?: boolean | undefined;
|
|
25
|
+
headerStatusBarHeight?: number | undefined;
|
|
26
|
+
headerTransparent?: boolean | undefined;
|
|
27
|
+
style?: React.ComponentProps<typeof Container>['style'] | undefined;
|
|
28
28
|
children: React.ReactNode;
|
|
29
29
|
};
|
|
30
30
|
|
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';
|