react-native-tab-view 4.2.2 → 5.0.0-alpha.1

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.
Files changed (70) hide show
  1. package/lib/module/Pager.android.js +1 -1
  2. package/lib/module/Pager.android.js.map +1 -1
  3. package/lib/module/Pager.ios.js +1 -1
  4. package/lib/module/Pager.ios.js.map +1 -1
  5. package/lib/module/PagerViewAdapter.js +3 -127
  6. package/lib/module/PagerViewAdapter.js.map +1 -1
  7. package/lib/module/PagerViewAdapter.native.js +130 -0
  8. package/lib/module/PagerViewAdapter.native.js.map +1 -0
  9. package/lib/module/PanResponderAdapter.js +43 -31
  10. package/lib/module/PanResponderAdapter.js.map +1 -1
  11. package/lib/module/PlatformPressable.js.map +1 -1
  12. package/lib/module/SceneView.js +22 -31
  13. package/lib/module/SceneView.js.map +1 -1
  14. package/lib/module/ScrollViewAdapter.js +210 -0
  15. package/lib/module/ScrollViewAdapter.js.map +1 -0
  16. package/lib/module/TabBar.js +98 -61
  17. package/lib/module/TabBar.js.map +1 -1
  18. package/lib/module/TabBarIndicator.js +6 -9
  19. package/lib/module/TabBarIndicator.js.map +1 -1
  20. package/lib/module/TabBarItem.js +4 -4
  21. package/lib/module/TabBarItem.js.map +1 -1
  22. package/lib/module/TabView.js +65 -84
  23. package/lib/module/TabView.js.map +1 -1
  24. package/lib/module/index.js +3 -0
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/useMeasureLayout.js +36 -0
  27. package/lib/module/useMeasureLayout.js.map +1 -0
  28. package/lib/typescript/src/PagerViewAdapter.d.ts +3 -17
  29. package/lib/typescript/src/PagerViewAdapter.d.ts.map +1 -1
  30. package/lib/typescript/src/PagerViewAdapter.native.d.ts +6 -0
  31. package/lib/typescript/src/PagerViewAdapter.native.d.ts.map +1 -0
  32. package/lib/typescript/src/PanResponderAdapter.d.ts +3 -17
  33. package/lib/typescript/src/PanResponderAdapter.d.ts.map +1 -1
  34. package/lib/typescript/src/PlatformPressable.d.ts +2 -2
  35. package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
  36. package/lib/typescript/src/SceneView.d.ts +1 -1
  37. package/lib/typescript/src/SceneView.d.ts.map +1 -1
  38. package/lib/typescript/src/ScrollViewAdapter.d.ts +12 -0
  39. package/lib/typescript/src/ScrollViewAdapter.d.ts.map +1 -0
  40. package/lib/typescript/src/TabBar.d.ts +7 -7
  41. package/lib/typescript/src/TabBar.d.ts.map +1 -1
  42. package/lib/typescript/src/TabBarIndicator.d.ts +1 -1
  43. package/lib/typescript/src/TabBarIndicator.d.ts.map +1 -1
  44. package/lib/typescript/src/TabBarItem.d.ts +4 -4
  45. package/lib/typescript/src/TabBarItem.d.ts.map +1 -1
  46. package/lib/typescript/src/TabBarItemLabel.d.ts +2 -2
  47. package/lib/typescript/src/TabBarItemLabel.d.ts.map +1 -1
  48. package/lib/typescript/src/TabView.d.ts +99 -5
  49. package/lib/typescript/src/TabView.d.ts.map +1 -1
  50. package/lib/typescript/src/index.d.ts +4 -1
  51. package/lib/typescript/src/index.d.ts.map +1 -1
  52. package/lib/typescript/src/types.d.ts +64 -8
  53. package/lib/typescript/src/types.d.ts.map +1 -1
  54. package/lib/typescript/src/useMeasureLayout.d.ts +5 -0
  55. package/lib/typescript/src/useMeasureLayout.d.ts.map +1 -0
  56. package/package.json +8 -8
  57. package/src/PagerViewAdapter.native.tsx +174 -0
  58. package/src/PagerViewAdapter.tsx +8 -181
  59. package/src/PanResponderAdapter.tsx +64 -77
  60. package/src/PlatformPressable.tsx +2 -1
  61. package/src/SceneView.tsx +23 -45
  62. package/src/ScrollViewAdapter.tsx +268 -0
  63. package/src/TabBar.tsx +134 -133
  64. package/src/TabBarIndicator.tsx +7 -11
  65. package/src/TabBarItem.tsx +8 -6
  66. package/src/TabBarItemLabel.tsx +2 -2
  67. package/src/TabView.tsx +173 -100
  68. package/src/index.tsx +10 -0
  69. package/src/types.tsx +75 -17
  70. package/src/useMeasureLayout.tsx +34 -0
@@ -1,12 +1,12 @@
1
- import { Animated, type LayoutChangeEvent, type PressableAndroidRippleConfig, type StyleProp, type ViewStyle } from 'react-native';
1
+ import { Animated, type ColorValue, type LayoutChangeEvent, type PressableAndroidRippleConfig, type StyleProp, type ViewStyle } from 'react-native';
2
2
  import type { NavigationState, Route, TabDescriptor } from './types';
3
3
  export type Props<T extends Route> = TabDescriptor<T> & {
4
4
  position: Animated.AnimatedInterpolation<number>;
5
5
  route: T;
6
6
  navigationState: NavigationState<T>;
7
- activeColor?: string;
8
- inactiveColor?: string;
9
- pressColor?: string;
7
+ activeColor?: ColorValue;
8
+ inactiveColor?: ColorValue;
9
+ pressColor?: ColorValue;
10
10
  pressOpacity?: number;
11
11
  onLayout?: (event: LayoutChangeEvent) => void;
12
12
  onPress: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"TabBarItem.d.ts","sourceRoot":"","sources":["../../../src/TabBarItem.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,KAAK,iBAAiB,EAEtB,KAAK,4BAA4B,EACjC,KAAK,SAAS,EAGd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAErE,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IACtD,QAAQ,EAAE,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC;IACT,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9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AA4B,CAAC;CAC/C,CAAC;AA+NF,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,2CAsB1D"}
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import type { StyleProp, ViewStyle } from 'react-native';
2
+ import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
3
3
  interface TabBarItemLabelProps {
4
- color: string;
4
+ color: ColorValue;
5
5
  label?: string;
6
6
  style: StyleProp<ViewStyle>;
7
7
  icon: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"TabBarItemLabel.d.ts","sourceRoot":"","sources":["../../../src/TabBarItemLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzD,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,4DACM,oBAAoB,oDAkBrD,CAAC"}
1
+ {"version":3,"file":"TabBarItemLabel.d.ts","sourceRoot":"","sources":["../../../src/TabBarItemLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrE,UAAU,oBAAoB;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,4DACM,oBAAoB,oDAkBrD,CAAC"}
@@ -1,33 +1,127 @@
1
1
  import * as React from 'react';
2
2
  import { type StyleProp, type ViewStyle } from 'react-native';
3
- import type { Layout, LocaleDirection, NavigationState, PagerProps, Route, SceneRendererProps, TabDescriptor } from './types';
4
- export type Props<T extends Route> = Omit<PagerProps, 'layoutDirection'> & {
3
+ import type { AdapterCommonProps, AdapterProps, EventEmitterProps, LocaleDirection, NavigationState, Route, SceneRendererProps, TabDescriptor } from './types';
4
+ export type Props<T extends Route> = AdapterCommonProps & {
5
+ /**
6
+ * Callback which is called when the index of the active tab changes.
7
+ * Must update the `navigationState.index` prop to the new index.
8
+ *
9
+ * Example:
10
+ * ```js
11
+ * onIndexChange={(index) => setState({ ...state, index })}
12
+ * ```
13
+ */
5
14
  onIndexChange: (index: number) => void;
15
+ /**
16
+ * Callback which is called when the tab navigation animation ends.
17
+ * Useful for side effects that should run after the tab change animation.
18
+ *
19
+ * Unlike `onIndexChange`, this is called regardless of whether the index changed or not.
20
+ */
6
21
  onTabSelect?: (props: {
7
22
  index: number;
8
23
  }) => void;
24
+ /**
25
+ * State for the tab view containing the current index and routes.
26
+ *
27
+ * Example:
28
+ * ```js
29
+ * {
30
+ * index: 0,
31
+ * routes: [
32
+ * { key: 'first' },
33
+ * { key: 'second' },
34
+ * ],
35
+ * }
36
+ * ```
37
+ */
9
38
  navigationState: NavigationState<T>;
39
+ /**
40
+ * Callback which returns a custom placeholder element.
41
+ * The placeholder is shown when a scene is not yet loaded when `lazy` is enabled.
42
+ */
10
43
  renderLazyPlaceholder?: (props: {
11
44
  route: T;
12
45
  }) => React.ReactNode;
13
- renderTabBar?: (props: SceneRendererProps & {
46
+ /**
47
+ * Callback which returns a custom tab bar element to display.
48
+ */
49
+ renderTabBar?: (props: SceneRendererProps & EventEmitterProps & {
14
50
  navigationState: NavigationState<T>;
15
51
  options: Record<string, TabDescriptor<T>> | undefined;
16
52
  }) => React.ReactNode;
53
+ /**
54
+ * Callback which returns a custom adapter to use for the tab view.
55
+ * Adapters are responsible for handling gestures and animations between tabs.
56
+ *
57
+ * The following adapters are provided out of the box:
58
+ * - `PagerViewAdapter`: Uses `react-native-pager-view` for native experience.
59
+ * - `PanResponderAdapter`: Uses `PanResponder` for a JS-based implementation.
60
+ * - `ScrollViewAdapter`: Uses `ScrollView` for an implementation based on `ScrollView`.
61
+ *
62
+ * Defaults to `PagerViewAdapter` on Android and iOS, and `PanResponderAdapter` on other platforms.
63
+ */
64
+ renderAdapter?: (props: AdapterProps) => React.ReactElement;
65
+ /**
66
+ * Position of the tab bar in the tab view.
67
+ * Defaults to `'top'`.
68
+ */
17
69
  tabBarPosition?: 'top' | 'bottom';
18
- initialLayout?: Partial<Layout>;
70
+ /**
71
+ * Whether to lazily render the scenes.
72
+ * When enabled, scenes are rendered only when they come into view.
73
+ *
74
+ * Can be a boolean or a function that receives the route and returns a boolean.
75
+ * Defaults to `false`.
76
+ */
19
77
  lazy?: ((props: {
20
78
  route: T;
21
79
  }) => boolean) | boolean;
80
+ /**
81
+ * How many screens to preload when `lazy` is enabled.
82
+ *
83
+ * Defaults to `0`.
84
+ */
22
85
  lazyPreloadDistance?: number;
86
+ /**
87
+ * The layout direction of the tab view.
88
+ *
89
+ * Defaults to the app's locale direction (RTL or LTR).
90
+ */
23
91
  direction?: LocaleDirection;
92
+ /**
93
+ * Style to apply to the pager container.
94
+ */
24
95
  pagerStyle?: StyleProp<ViewStyle>;
96
+ /**
97
+ * Style to apply to the tab view container.
98
+ */
25
99
  style?: StyleProp<ViewStyle>;
100
+ /**
101
+ * Callback which returns a React element to render for each route.
102
+ */
26
103
  renderScene: (props: SceneRendererProps & {
27
104
  route: T;
28
105
  }) => React.ReactNode;
106
+ /**
107
+ * Options for individual tabs, keyed by route key.
108
+ *
109
+ * Example:
110
+ * ```js
111
+ * {
112
+ * first: { labelText: 'First Tab' },
113
+ * second: { labelText: 'Second Tab' },
114
+ * }
115
+ *
116
+ * These options are merged with `commonOptions`.
117
+ */
29
118
  options?: Record<string, TabDescriptor<T>>;
119
+ /**
120
+ * Options that apply to all tabs.
121
+ *
122
+ * Individual tab options from `options` will override these.
123
+ */
30
124
  commonOptions?: TabDescriptor<T>;
31
125
  };
32
- export declare function TabView<T extends Route>({ onIndexChange, onTabSelect, navigationState, renderScene, initialLayout, keyboardDismissMode, lazy, lazyPreloadDistance, onSwipeStart, onSwipeEnd, renderLazyPlaceholder, renderTabBar, pagerStyle, style, direction, swipeEnabled, tabBarPosition, animationEnabled, overScrollMode, options: sceneOptions, commonOptions, }: Props<T>): import("react/jsx-runtime").JSX.Element;
126
+ export declare function TabView<T extends Route>({ onIndexChange, onTabSelect, navigationState, renderScene, keyboardDismissMode, lazy, lazyPreloadDistance, onSwipeStart, onSwipeEnd, renderLazyPlaceholder, renderTabBar, renderAdapter, pagerStyle, style, direction, swipeEnabled, tabBarPosition, animationEnabled, options: sceneOptions, commonOptions, }: Props<T>): import("react/jsx-runtime").JSX.Element;
33
127
  //# sourceMappingURL=TabView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../../src/TabView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIL,KAAK,SAAS,EAGd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EACV,MAAM,EACN,eAAe,EACf,eAAe,EACf,UAAU,EACV,KAAK,EACL,kBAAkB,EAClB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,iBAAiB,CAAC,GAAG;IACzE,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IACpC,qB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ps, } from './PagerViewAdapter';
2
+ export { PanResponderAdapter } from './PanResponderAdapter';
1
3
  export { SceneMap } from './SceneMap';
4
+ export { ScrollViewAdapter, type ScrollViewAdapterProps, } from './ScrollViewAdapter';
2
5
  export type { Props as TabBarProps } from './TabBar';
3
6
  export { TabBar } from './TabBar';
4
7
  export type { Props as TabBarIndicatorProps } from './TabBarIndicator';
@@ -7,5 +10,5 @@ export type { Props as TabBarItemProps } from './TabBarItem';
7
10
  export { TabBarItem } from './TabBarItem';
8
11
  export type { Props as TabViewProps } from './TabView';
9
12
  export { TabView } from './TabView';
10
- export type { NavigationState, Route, SceneRendererProps, TabDescriptor, } from './types';
13
+ export type { AdapterProps, NavigationState, Route, SceneRendererProps, TabDescriptor, } from './types';
11
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EACV,eAAe,EACf,KAAK,EACL,kBAAkB,EAClB,aAAa,GACd,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EACV,YAAY,EACZ,eAAe,EACf,KAAK,EACL,kBAAkB,EAClB,aAAa,GACd,MAAM,SAAS,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Animated, StyleProp, TextStyle, ViewStyle } from 'react-native';
2
- import type { PagerViewProps } from 'react-native-pager-view';
1
+ import * as React from 'react';
2
+ import type { Animated, ColorValue, StyleProp, TextStyle, ViewStyle } from 'react-native';
3
3
  export type TabDescriptor<T extends Route> = {
4
4
  accessibilityLabel?: string;
5
5
  accessible?: boolean;
@@ -11,7 +11,7 @@ export type TabDescriptor<T extends Route> = {
11
11
  route: T;
12
12
  labelText?: string;
13
13
  focused: boolean;
14
- color: string;
14
+ color: ColorValue;
15
15
  allowFontScaling?: boolean;
16
16
  style?: StyleProp<TextStyle>;
17
17
  }) => React.ReactNode;
@@ -19,7 +19,7 @@ export type TabDescriptor<T extends Route> = {
19
19
  icon?: (props: {
20
20
  route: T;
21
21
  focused: boolean;
22
- color: string;
22
+ color: ColorValue;
23
23
  size: number;
24
24
  }) => React.ReactNode;
25
25
  badge?: (props: {
@@ -51,20 +51,76 @@ export type Layout = {
51
51
  width: number;
52
52
  height: number;
53
53
  };
54
- export type Listener = (value: number) => void;
54
+ export type Listener = (event: {
55
+ type: 'enter';
56
+ index: number;
57
+ }) => void;
55
58
  export type SceneRendererProps = {
56
- layout: Layout;
57
59
  position: Animated.AnimatedInterpolation<number>;
58
60
  jumpTo: (key: string) => void;
59
61
  };
60
62
  export type EventEmitterProps = {
61
- addEnterListener: (listener: Listener) => () => void;
63
+ subscribe: (listener: Listener) => () => void;
62
64
  };
63
- export type PagerProps = Omit<PagerViewProps, 'initialPage' | 'scrollEnabled' | 'onPageScroll' | 'onPageSelected' | 'onPageScrollStateChanged' | 'keyboardDismissMode' | 'children'> & {
65
+ export type AdapterCommonProps = {
66
+ /**
67
+ * Determines whether the keyboard gets dismissed in response to a drag.
68
+ * - 'auto' (default) - the keyboard is dismissed on drag and tab changes
69
+ * - 'on-drag' - the keyboard is dismissed when a drag begins
70
+ * - 'none' - drags and tab changes do not dismiss the keyboard
71
+ */
64
72
  keyboardDismissMode?: 'none' | 'on-drag' | 'auto';
73
+ /**
74
+ * Whether swiping between tabs is enabled.
75
+ */
65
76
  swipeEnabled?: boolean;
77
+ /**
78
+ * Whether the tab switch animation is enabled.
79
+ * If set to false, the tab switch will happen immediately without animation.
80
+ */
66
81
  animationEnabled?: boolean;
82
+ /**
83
+ * Callback that is called when the swipe gesture starts.
84
+ */
67
85
  onSwipeStart?: () => void;
86
+ /**
87
+ * Callback that is called when the swipe gesture ends.
88
+ */
68
89
  onSwipeEnd?: () => void;
90
+ /**
91
+ * Callback that is called when a tab is selected.
92
+ * This is called regardless of whether the index has changed or not.
93
+ */
94
+ onTabSelect?: (props: {
95
+ index: number;
96
+ }) => void;
97
+ /**
98
+ * Style for the pager adapter.
99
+ */
100
+ style?: StyleProp<ViewStyle>;
101
+ };
102
+ export type AdapterRendererProps = {
103
+ /**
104
+ * Callback to call when the index changes.
105
+ */
106
+ onIndexChange: (index: number) => void;
107
+ /**
108
+ * The current navigation state of the tab view.
109
+ */
110
+ navigationState: NavigationState<Route>;
111
+ /**
112
+ * The writing direction of the layout.
113
+ * This can be 'ltr' or 'rtl' based on tab view's `direction` prop.
114
+ */
115
+ layoutDirection?: LocaleDirection;
116
+ /**
117
+ * Render callback that should render the pages of the tab view.
118
+ */
119
+ children: (props: EventEmitterProps & {
120
+ position: Animated.AnimatedInterpolation<number>;
121
+ render: (children: React.ReactElement[]) => React.ReactNode;
122
+ jumpTo: (key: string) => void;
123
+ }) => React.ReactElement;
69
124
  };
125
+ export type AdapterProps = AdapterRendererProps & AdapterCommonProps;
70
126
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,KAAK,IAAI;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE;QACd,KAAK,EAAE,CAAC,CAAC;QACT,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,gBAAgB,CAAC,EAAE,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C;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IACxC;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,QAAQ,EAAE,CACR,KAAK,EAAE,iBAAiB,GAAG;QAGzB,QAAQ,EAAE,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAGjD,MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC;QAG5D,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;KAC/B,KACE,KAAK,CAAC,YAAY,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,oBAAoB,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { type LayoutChangeEvent, type View } from 'react-native';
3
+ import type { Layout } from './types';
4
+ export declare function useMeasureLayout(ref: React.RefObject<View | null>, onMeasure?: (layout: Layout) => void): readonly [Layout, (event: LayoutChangeEvent) => void];
5
+ //# sourceMappingURL=useMeasureLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMeasureLayout.d.ts","sourceRoot":"","sources":["../../../src/useMeasureLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,EACjC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,6BAoBO,iBAAiB,WAK7D"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-tab-view",
3
3
  "description": "Tab view component for React Native",
4
- "version": "4.2.2",
4
+ "version": "5.0.0-alpha.1",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -44,23 +44,23 @@
44
44
  "clean": "del lib"
45
45
  },
46
46
  "dependencies": {
47
- "use-latest-callback": "^0.2.4"
47
+ "use-latest-callback": "^0.3.2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@jest/globals": "^30.0.0",
51
51
  "@testing-library/react-native": "^13.2.1",
52
52
  "del-cli": "^6.0.0",
53
53
  "react": "19.1.0",
54
- "react-native": "0.81.5",
55
- "react-native-builder-bob": "^0.40.17",
56
- "react-native-pager-view": "6.9.1",
54
+ "react-native": "0.81.4",
55
+ "react-native-builder-bob": "^0.40.12",
56
+ "react-native-pager-view": "^8.0.0",
57
57
  "react-test-renderer": "19.1.0",
58
58
  "typescript": "^5.9.2"
59
59
  },
60
60
  "peerDependencies": {
61
- "react": ">= 18.2.0",
61
+ "react": ">= 19.0.0",
62
62
  "react-native": "*",
63
- "react-native-pager-view": ">= 6.0.0"
63
+ "react-native-pager-view": ">= 7.0.0"
64
64
  },
65
65
  "react-native-builder-bob": {
66
66
  "source": "src",
@@ -80,5 +80,5 @@
80
80
  ]
81
81
  ]
82
82
  },
83
- "gitHead": "2b7ee0d2d1b1ef0390b690f59c0c1dd8bd57e9eb"
83
+ "gitHead": "4579b7cfdf8b149ef04cfb585e2cb6b35ded52d7"
84
84
  }
@@ -0,0 +1,174 @@
1
+ import * as React from 'react';
2
+ import { Animated, Keyboard, Platform, StyleSheet } from 'react-native';
3
+ import ViewPager, {
4
+ type PagerViewProps,
5
+ type PageScrollStateChangedNativeEvent,
6
+ } from 'react-native-pager-view';
7
+ import useLatestCallback from 'use-latest-callback';
8
+
9
+ import type { AdapterProps, Listener } from './types';
10
+ import { useAnimatedValue } from './useAnimatedValue';
11
+
12
+ const AnimatedViewPager = Animated.createAnimatedComponent(ViewPager);
13
+
14
+ export type PagerViewAdapterProps = AdapterProps &
15
+ Omit<
16
+ PagerViewProps,
17
+ | keyof AdapterProps
18
+ | 'initialPage'
19
+ | 'scrollEnabled'
20
+ | 'onPageScroll'
21
+ | 'onPageSelected'
22
+ | 'onPageScrollStateChanged'
23
+ | 'children'
24
+ >;
25
+
26
+ const useNativeDriver = Platform.OS !== 'web';
27
+
28
+ export function PagerViewAdapter({
29
+ keyboardDismissMode = 'auto',
30
+ swipeEnabled = true,
31
+ navigationState,
32
+ onIndexChange,
33
+ onTabSelect,
34
+ onSwipeStart,
35
+ onSwipeEnd,
36
+ children,
37
+ style,
38
+ animationEnabled,
39
+ ...rest
40
+ }: PagerViewAdapterProps) {
41
+ const { index } = navigationState;
42
+
43
+ const listeners = React.useRef<Set<Listener>>(new Set()).current;
44
+
45
+ const pagerRef = React.useRef<ViewPager>(null);
46
+ const indexRef = React.useRef<number>(index);
47
+ const navigationStateRef = React.useRef(navigationState);
48
+
49
+ const position = useAnimatedValue(index);
50
+ const offset = useAnimatedValue(0);
51
+
52
+ React.useEffect(() => {
53
+ navigationStateRef.current = navigationState;
54
+ });
55
+
56
+ const jumpTo = useLatestCallback((key: string) => {
57
+ const index = navigationStateRef.current.routes.findIndex(
58
+ (route: { key: string }) => route.key === key
59
+ );
60
+
61
+ if (animationEnabled) {
62
+ pagerRef.current?.setPage(index);
63
+ } else {
64
+ pagerRef.current?.setPageWithoutAnimation(index);
65
+ position.setValue(index);
66
+ }
67
+
68
+ onIndexChange(index);
69
+ });
70
+
71
+ React.useEffect(() => {
72
+ if (keyboardDismissMode === 'auto') {
73
+ Keyboard.dismiss();
74
+ }
75
+
76
+ if (indexRef.current !== index) {
77
+ if (animationEnabled) {
78
+ pagerRef.current?.setPage(index);
79
+ } else {
80
+ pagerRef.current?.setPageWithoutAnimation(index);
81
+ position.setValue(index);
82
+ }
83
+ }
84
+ }, [keyboardDismissMode, index, animationEnabled, position]);
85
+
86
+ const onPageScrollStateChanged = (
87
+ state: PageScrollStateChangedNativeEvent
88
+ ) => {
89
+ const { pageScrollState } = state.nativeEvent;
90
+
91
+ switch (pageScrollState) {
92
+ case 'idle':
93
+ onSwipeEnd?.();
94
+ return;
95
+ case 'dragging': {
96
+ const subscription = offset.addListener(({ value }) => {
97
+ const next =
98
+ index + (value > 0 ? Math.ceil(value) : Math.floor(value));
99
+
100
+ if (next !== index) {
101
+ listeners.forEach((listener) =>
102
+ listener({
103
+ type: 'enter',
104
+ index: next,
105
+ })
106
+ );
107
+ }
108
+
109
+ offset.removeListener(subscription);
110
+ });
111
+
112
+ onSwipeStart?.();
113
+ return;
114
+ }
115
+ }
116
+ };
117
+
118
+ const subscribe = useLatestCallback((listener: Listener) => {
119
+ listeners.add(listener);
120
+
121
+ return () => {
122
+ listeners.delete(listener);
123
+ };
124
+ });
125
+
126
+ const memoizedPosition = React.useMemo(
127
+ () => Animated.add(position, offset),
128
+ [offset, position]
129
+ );
130
+
131
+ return children({
132
+ position: memoizedPosition,
133
+ subscribe,
134
+ jumpTo,
135
+ render: (children) => (
136
+ <AnimatedViewPager
137
+ {...rest}
138
+ ref={pagerRef}
139
+ style={[styles.container, style]}
140
+ initialPage={index}
141
+ keyboardDismissMode={
142
+ keyboardDismissMode === 'auto' ? 'on-drag' : keyboardDismissMode
143
+ }
144
+ onPageScroll={Animated.event(
145
+ [
146
+ {
147
+ nativeEvent: {
148
+ position: position,
149
+ offset: offset,
150
+ },
151
+ },
152
+ ],
153
+ { useNativeDriver }
154
+ )}
155
+ onPageSelected={(e) => {
156
+ const index = e.nativeEvent.position;
157
+ indexRef.current = index;
158
+ onIndexChange(index);
159
+ onTabSelect?.({ index });
160
+ }}
161
+ onPageScrollStateChanged={onPageScrollStateChanged}
162
+ scrollEnabled={swipeEnabled}
163
+ >
164
+ {children}
165
+ </AnimatedViewPager>
166
+ ),
167
+ });
168
+ }
169
+
170
+ const styles = StyleSheet.create({
171
+ container: {
172
+ flex: 1,
173
+ },
174
+ });