@amazon-devices/react-navigation__react-native-tab-view 7.0.1759135970 → 8.0.9000000000
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/README.md +2 -646
- package/SystemBundles/6f915df16edbc21a601928d99e844a99397b9428146027dcf0d86b2a798f21f4.bundle +8563 -0
- package/SystemBundles/6f915df16edbc21a601928d99e844a99397b9428146027dcf0d86b2a798f21f4.map +3217 -0
- package/SystemModules/amzn__react-navigation__react-native-tab-view-8.modules.txt +12 -0
- package/SystemModules/amzn__react-navigation__react-native-tab-view-8.private.modules.txt +63 -0
- package/SystemModules/keplerscript-system-bundle-config.json +4 -4
- package/kepler-compatibility.json +2 -2
- package/lib/module/Pager.android.js +3 -1
- package/lib/module/Pager.android.js.map +1 -1
- package/lib/module/Pager.ios.js +3 -1
- package/lib/module/Pager.ios.js.map +1 -1
- package/lib/module/Pager.js +3 -1
- package/lib/module/Pager.js.map +1 -1
- package/lib/module/PagerViewAdapter.js +29 -22
- package/lib/module/PagerViewAdapter.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +46 -32
- package/lib/module/PanResponderAdapter.js.map +1 -1
- package/lib/module/PlatformPressable.js +38 -12
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/SceneMap.js +7 -4
- package/lib/module/SceneMap.js.map +1 -1
- package/lib/module/SceneView.js +16 -14
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/TabBar.js +232 -156
- package/lib/module/TabBar.js.map +1 -1
- package/lib/module/TabBarIndicator.js +47 -26
- package/lib/module/TabBarIndicator.js.map +1 -1
- package/lib/module/TabBarItem.js +106 -107
- package/lib/module/TabBarItem.js.map +1 -1
- package/lib/module/TabBarItemLabel.js +33 -0
- package/lib/module/TabBarItemLabel.js.map +1 -0
- package/lib/module/TabView.js +91 -63
- package/lib/module/TabView.js.map +1 -1
- package/lib/module/index.js +7 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useAnimatedValue.js +4 -2
- package/lib/module/useAnimatedValue.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Pager.android.d.ts +1 -1
- package/lib/typescript/src/Pager.android.d.ts.map +1 -1
- package/lib/typescript/src/Pager.d.ts +1 -1
- package/lib/typescript/src/Pager.d.ts.map +1 -1
- package/lib/typescript/src/Pager.ios.d.ts +1 -1
- package/lib/typescript/src/Pager.ios.d.ts.map +1 -1
- package/lib/typescript/src/PagerViewAdapter.d.ts +4 -1
- package/lib/typescript/src/PagerViewAdapter.d.ts.map +1 -1
- package/lib/typescript/src/PanResponderAdapter.d.ts +4 -1
- package/lib/typescript/src/PanResponderAdapter.d.ts.map +1 -1
- package/lib/typescript/src/PlatformPressable.d.ts +6 -8
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/SceneMap.d.ts +2 -2
- package/lib/typescript/src/SceneMap.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts +2 -2
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/TabBar.d.ts +7 -19
- package/lib/typescript/src/TabBar.d.ts.map +1 -1
- package/lib/typescript/src/TabBarIndicator.d.ts +8 -6
- package/lib/typescript/src/TabBarIndicator.d.ts.map +1 -1
- package/lib/typescript/src/TabBarItem.d.ts +4 -22
- package/lib/typescript/src/TabBarItem.d.ts.map +1 -1
- package/lib/typescript/src/TabBarItemLabel.d.ts +11 -0
- package/lib/typescript/src/TabBarItemLabel.d.ts.map +1 -0
- package/lib/typescript/src/TabView.d.ts +14 -8
- package/lib/typescript/src/TabView.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +29 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useAnimatedValue.d.ts +1 -1
- package/lib/typescript/src/useAnimatedValue.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Pager.android.tsx +1 -1
- package/src/Pager.ios.tsx +1 -1
- package/src/Pager.tsx +1 -1
- package/src/PagerViewAdapter.tsx +26 -21
- package/src/PanResponderAdapter.tsx +32 -28
- package/src/PlatformPressable.tsx +59 -10
- package/src/SceneMap.tsx +3 -3
- package/src/SceneView.tsx +6 -7
- package/src/TabBar.tsx +282 -193
- package/src/TabBarIndicator.tsx +65 -28
- package/src/TabBarItem.tsx +119 -130
- package/src/TabBarItemLabel.tsx +42 -0
- package/src/TabView.tsx +59 -16
- package/src/index.tsx +11 -6
- package/src/types.tsx +29 -1
- package/src/useAnimatedValue.tsx +2 -2
- package/SystemBundles/0c296a88d0023a3995e190db70259767d1ef39c9da6cd47f3d76cd128687f1f6.bundle +0 -14497
- package/SystemBundles/0c296a88d0023a3995e190db70259767d1ef39c9da6cd47f3d76cd128687f1f6.map +0 -1
- package/SystemModules/amzn__react-navigation__react-native-tab-view-7.modules.txt +0 -41
- package/SystemModules/amzn__react-navigation__react-native-tab-view-7.private.modules.txt +0 -98
- package/THIRD_PARTY_NOTICES.txt +0 -24
- package/lib/commonjs/Pager.android.js +0 -14
- package/lib/commonjs/Pager.android.js.map +0 -1
- package/lib/commonjs/Pager.ios.js +0 -14
- package/lib/commonjs/Pager.ios.js.map +0 -1
- package/lib/commonjs/Pager.js +0 -14
- package/lib/commonjs/Pager.js.map +0 -1
- package/lib/commonjs/PagerViewAdapter.js +0 -132
- package/lib/commonjs/PagerViewAdapter.js.map +0 -1
- package/lib/commonjs/PanResponderAdapter.js +0 -204
- package/lib/commonjs/PanResponderAdapter.js.map +0 -1
- package/lib/commonjs/PlatformPressable.js +0 -43
- package/lib/commonjs/PlatformPressable.js.map +0 -1
- package/lib/commonjs/SceneMap.js +0 -29
- package/lib/commonjs/SceneMap.js.map +0 -1
- package/lib/commonjs/SceneView.js +0 -78
- package/lib/commonjs/SceneView.js.map +0 -1
- package/lib/commonjs/TabBar.js +0 -405
- package/lib/commonjs/TabBar.js.map +0 -1
- package/lib/commonjs/TabBarIndicator.js +0 -110
- package/lib/commonjs/TabBarIndicator.js.map +0 -1
- package/lib/commonjs/TabBarItem.js +0 -227
- package/lib/commonjs/TabBarItem.js.map +0 -1
- package/lib/commonjs/TabView.js +0 -122
- package/lib/commonjs/TabView.js.map +0 -1
- package/lib/commonjs/index.js +0 -42
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/types.js +0 -6
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/useAnimatedValue.js +0 -18
- package/lib/commonjs/useAnimatedValue.js.map +0 -1
package/src/TabView.tsx
CHANGED
|
@@ -1,42 +1,55 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
I18nManager,
|
|
4
|
+
type LayoutChangeEvent,
|
|
5
|
+
Platform,
|
|
6
|
+
type StyleProp,
|
|
5
7
|
StyleSheet,
|
|
6
8
|
View,
|
|
7
|
-
ViewStyle,
|
|
9
|
+
type ViewStyle,
|
|
8
10
|
} from 'react-native';
|
|
9
11
|
|
|
10
|
-
import Pager from './Pager';
|
|
11
|
-
import SceneView from './SceneView';
|
|
12
|
-
import TabBar from './TabBar';
|
|
12
|
+
import { Pager } from './Pager';
|
|
13
|
+
import { SceneView } from './SceneView';
|
|
14
|
+
import { TabBar } from './TabBar';
|
|
13
15
|
import type {
|
|
14
16
|
Layout,
|
|
17
|
+
LocaleDirection,
|
|
15
18
|
NavigationState,
|
|
16
19
|
PagerProps,
|
|
17
20
|
Route,
|
|
18
21
|
SceneRendererProps,
|
|
22
|
+
TabDescriptor,
|
|
19
23
|
} from './types';
|
|
20
24
|
|
|
21
|
-
export type Props<T extends Route> = PagerProps & {
|
|
25
|
+
export type Props<T extends Route> = Omit<PagerProps, 'layoutDirection'> & {
|
|
22
26
|
onIndexChange: (index: number) => void;
|
|
27
|
+
onTabSelect?: (props: { index: number }) => void;
|
|
23
28
|
navigationState: NavigationState<T>;
|
|
24
|
-
renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;
|
|
25
29
|
renderLazyPlaceholder?: (props: { route: T }) => React.ReactNode;
|
|
26
30
|
renderTabBar?: (
|
|
27
|
-
props: SceneRendererProps & {
|
|
31
|
+
props: SceneRendererProps & {
|
|
32
|
+
navigationState: NavigationState<T>;
|
|
33
|
+
options: Record<string, TabDescriptor<T>> | undefined;
|
|
34
|
+
}
|
|
28
35
|
) => React.ReactNode;
|
|
29
36
|
tabBarPosition?: 'top' | 'bottom';
|
|
30
37
|
initialLayout?: Partial<Layout>;
|
|
31
38
|
lazy?: ((props: { route: T }) => boolean) | boolean;
|
|
32
39
|
lazyPreloadDistance?: number;
|
|
33
|
-
|
|
40
|
+
direction?: LocaleDirection;
|
|
34
41
|
pagerStyle?: StyleProp<ViewStyle>;
|
|
35
42
|
style?: StyleProp<ViewStyle>;
|
|
43
|
+
renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;
|
|
44
|
+
options?: Record<string, TabDescriptor<T>>;
|
|
45
|
+
commonOptions?: TabDescriptor<T>;
|
|
36
46
|
};
|
|
37
47
|
|
|
38
|
-
|
|
48
|
+
const renderLazyPlaceholderDefault = () => null;
|
|
49
|
+
|
|
50
|
+
export function TabView<T extends Route>({
|
|
39
51
|
onIndexChange,
|
|
52
|
+
onTabSelect,
|
|
40
53
|
navigationState,
|
|
41
54
|
renderScene,
|
|
42
55
|
initialLayout,
|
|
@@ -45,16 +58,30 @@ export default function TabView<T extends Route>({
|
|
|
45
58
|
lazyPreloadDistance = 0,
|
|
46
59
|
onSwipeStart,
|
|
47
60
|
onSwipeEnd,
|
|
48
|
-
renderLazyPlaceholder =
|
|
61
|
+
renderLazyPlaceholder = renderLazyPlaceholderDefault,
|
|
62
|
+
// eslint-disable-next-line @eslint-react/no-unstable-default-props
|
|
49
63
|
renderTabBar = (props) => <TabBar {...props} />,
|
|
50
|
-
sceneContainerStyle,
|
|
51
64
|
pagerStyle,
|
|
52
65
|
style,
|
|
66
|
+
direction = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr',
|
|
53
67
|
swipeEnabled = true,
|
|
54
68
|
tabBarPosition = 'top',
|
|
55
69
|
animationEnabled = true,
|
|
56
70
|
overScrollMode,
|
|
71
|
+
options: sceneOptions,
|
|
72
|
+
commonOptions,
|
|
57
73
|
}: Props<T>) {
|
|
74
|
+
if (
|
|
75
|
+
Platform.OS !== 'web' &&
|
|
76
|
+
direction !== (I18nManager.getConstants().isRTL ? 'rtl' : 'ltr')
|
|
77
|
+
) {
|
|
78
|
+
console.warn(
|
|
79
|
+
`The 'direction' prop is set to '${direction}' but the effective value is '${
|
|
80
|
+
I18nManager.getConstants().isRTL ? 'rtl' : 'ltr'
|
|
81
|
+
}'. This is not supported. Make sure to match the 'direction' prop with the writing direction of the app.`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
58
85
|
const [layout, setLayout] = React.useState({
|
|
59
86
|
width: 0,
|
|
60
87
|
height: 0,
|
|
@@ -79,6 +106,16 @@ export default function TabView<T extends Route>({
|
|
|
79
106
|
});
|
|
80
107
|
};
|
|
81
108
|
|
|
109
|
+
const options = Object.fromEntries(
|
|
110
|
+
navigationState.routes.map((route) => [
|
|
111
|
+
route.key,
|
|
112
|
+
{
|
|
113
|
+
...commonOptions,
|
|
114
|
+
...sceneOptions?.[route.key],
|
|
115
|
+
},
|
|
116
|
+
])
|
|
117
|
+
);
|
|
118
|
+
|
|
82
119
|
return (
|
|
83
120
|
<View onLayout={handleLayout} style={[styles.pager, style]}>
|
|
84
121
|
<Pager
|
|
@@ -89,12 +126,14 @@ export default function TabView<T extends Route>({
|
|
|
89
126
|
onSwipeStart={onSwipeStart}
|
|
90
127
|
onSwipeEnd={onSwipeEnd}
|
|
91
128
|
onIndexChange={jumpToIndex}
|
|
129
|
+
onTabSelect={onTabSelect}
|
|
92
130
|
animationEnabled={animationEnabled}
|
|
93
131
|
overScrollMode={overScrollMode}
|
|
94
132
|
style={pagerStyle}
|
|
133
|
+
layoutDirection={direction}
|
|
95
134
|
>
|
|
96
135
|
{({ position, render, addEnterListener, jumpTo }) => {
|
|
97
|
-
// All
|
|
136
|
+
// All the props here must not change between re-renders
|
|
98
137
|
// This is crucial to optimizing the routes with PureComponent
|
|
99
138
|
const sceneRendererProps = {
|
|
100
139
|
position,
|
|
@@ -107,20 +146,23 @@ export default function TabView<T extends Route>({
|
|
|
107
146
|
{tabBarPosition === 'top' &&
|
|
108
147
|
renderTabBar({
|
|
109
148
|
...sceneRendererProps,
|
|
149
|
+
options,
|
|
110
150
|
navigationState,
|
|
111
151
|
})}
|
|
112
152
|
{render(
|
|
113
153
|
navigationState.routes.map((route, i) => {
|
|
154
|
+
const { sceneStyle } = options?.[route.key] ?? {};
|
|
155
|
+
|
|
114
156
|
return (
|
|
115
157
|
<SceneView
|
|
158
|
+
key={route.key}
|
|
116
159
|
{...sceneRendererProps}
|
|
117
160
|
addEnterListener={addEnterListener}
|
|
118
|
-
key={route.key}
|
|
119
161
|
index={i}
|
|
120
162
|
lazy={typeof lazy === 'function' ? lazy({ route }) : lazy}
|
|
121
163
|
lazyPreloadDistance={lazyPreloadDistance}
|
|
122
164
|
navigationState={navigationState}
|
|
123
|
-
style={
|
|
165
|
+
style={sceneStyle}
|
|
124
166
|
>
|
|
125
167
|
{({ loading }) =>
|
|
126
168
|
loading
|
|
@@ -137,6 +179,7 @@ export default function TabView<T extends Route>({
|
|
|
137
179
|
{tabBarPosition === 'bottom' &&
|
|
138
180
|
renderTabBar({
|
|
139
181
|
...sceneRendererProps,
|
|
182
|
+
options,
|
|
140
183
|
navigationState,
|
|
141
184
|
})}
|
|
142
185
|
</React.Fragment>
|
package/src/index.tsx
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { SceneMap } from './SceneMap';
|
|
2
2
|
export type { Props as TabBarProps } from './TabBar';
|
|
3
|
-
export {
|
|
3
|
+
export { TabBar } from './TabBar';
|
|
4
4
|
export type { Props as TabBarIndicatorProps } from './TabBarIndicator';
|
|
5
|
-
export {
|
|
5
|
+
export { TabBarIndicator } from './TabBarIndicator';
|
|
6
6
|
export type { Props as TabBarItemProps } from './TabBarItem';
|
|
7
|
-
export {
|
|
7
|
+
export { TabBarItem } from './TabBarItem';
|
|
8
8
|
export type { Props as TabViewProps } from './TabView';
|
|
9
|
-
export {
|
|
10
|
-
export type {
|
|
9
|
+
export { TabView } from './TabView';
|
|
10
|
+
export type {
|
|
11
|
+
NavigationState,
|
|
12
|
+
Route,
|
|
13
|
+
SceneRendererProps,
|
|
14
|
+
TabDescriptor,
|
|
15
|
+
} from './types';
|
package/src/types.tsx
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
import type { Animated } from 'react-native';
|
|
1
|
+
import type { Animated, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
2
|
import type { PagerViewProps } from 'react-native-pager-view';
|
|
3
3
|
|
|
4
|
+
export type TabDescriptor<T extends Route> = {
|
|
5
|
+
accessibilityLabel?: string;
|
|
6
|
+
accessible?: boolean;
|
|
7
|
+
testID?: string;
|
|
8
|
+
labelText?: string;
|
|
9
|
+
labelAllowFontScaling?: boolean;
|
|
10
|
+
href?: string;
|
|
11
|
+
label?: (props: {
|
|
12
|
+
route: T;
|
|
13
|
+
labelText?: string;
|
|
14
|
+
focused: boolean;
|
|
15
|
+
color: string;
|
|
16
|
+
allowFontScaling?: boolean;
|
|
17
|
+
style?: StyleProp<TextStyle>;
|
|
18
|
+
}) => React.ReactNode;
|
|
19
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
20
|
+
icon?: (props: {
|
|
21
|
+
route: T;
|
|
22
|
+
focused: boolean;
|
|
23
|
+
color: string;
|
|
24
|
+
size: number;
|
|
25
|
+
}) => React.ReactNode;
|
|
26
|
+
badge?: (props: { route: T }) => React.ReactElement;
|
|
27
|
+
sceneStyle?: StyleProp<ViewStyle>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type LocaleDirection = 'ltr' | 'rtl';
|
|
31
|
+
|
|
4
32
|
export type Route = {
|
|
5
33
|
key: string;
|
|
6
34
|
icon?: string;
|
package/src/useAnimatedValue.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
const lazyRef = React.useRef<Animated.Value>();
|
|
4
|
+
export function useAnimatedValue(initialValue: number) {
|
|
5
|
+
const lazyRef = React.useRef<Animated.Value>(undefined);
|
|
6
6
|
|
|
7
7
|
if (lazyRef.current === undefined) {
|
|
8
8
|
lazyRef.current = new Animated.Value(initialValue);
|