@momo-kits/tab-view 0.92.21-beta.2 → 0.92.21-beta.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/index.tsx +32 -13
- package/package.json +1 -1
- package/publish.sh +0 -1
- package/types.ts +4 -0
package/index.tsx
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
ForwardRefRenderFunction,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
2
10
|
import {Animated, LayoutChangeEvent, View} from 'react-native';
|
|
3
|
-
import {Tab, TabViewProps} from './types';
|
|
11
|
+
import {Tab, TabViewProps, TabViewRef} from './types';
|
|
4
12
|
import TabBar from './tabBar/TabBar';
|
|
5
13
|
import styles from './styles';
|
|
6
14
|
import CardTabBar from './tabBar/CardTabBar';
|
|
@@ -8,17 +16,20 @@ import ScrollableTabBar from './tabBar/SrollableTabBar';
|
|
|
8
16
|
import PagerView from 'react-native-pager-view';
|
|
9
17
|
import {ApplicationContext} from '@momo-kits/foundation';
|
|
10
18
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const TabComponent: ForwardRefRenderFunction<TabViewRef, TabViewProps> = (
|
|
20
|
+
{
|
|
21
|
+
scrollable = false,
|
|
22
|
+
tabs = [],
|
|
23
|
+
onPressTabItem,
|
|
24
|
+
type = 'default',
|
|
25
|
+
initialPage = 0,
|
|
26
|
+
pagerProps,
|
|
27
|
+
direction,
|
|
28
|
+
selectedColor,
|
|
29
|
+
unselectedColor,
|
|
30
|
+
},
|
|
31
|
+
ref
|
|
32
|
+
) => {
|
|
22
33
|
const startPage =
|
|
23
34
|
initialPage > tabs.length - 1 ? tabs.length - 1 : initialPage;
|
|
24
35
|
const [selectedIndex, setSelectedIndex] = useState(startPage);
|
|
@@ -69,6 +80,12 @@ const TabView: FC<TabViewProps> = ({
|
|
|
69
80
|
[tabs]
|
|
70
81
|
);
|
|
71
82
|
|
|
83
|
+
useImperativeHandle(ref, () => ({
|
|
84
|
+
goToPage: (page: number) => {
|
|
85
|
+
if (page >= 0 && page <= tabs.length) pagerRef.current?.setPage(page);
|
|
86
|
+
},
|
|
87
|
+
}));
|
|
88
|
+
|
|
72
89
|
return (
|
|
73
90
|
<View onLayout={onLayout} style={[styles.tabView, {flex: 1}]}>
|
|
74
91
|
<View>
|
|
@@ -97,5 +114,7 @@ const TabView: FC<TabViewProps> = ({
|
|
|
97
114
|
);
|
|
98
115
|
};
|
|
99
116
|
|
|
117
|
+
const TabView = forwardRef(TabComponent);
|
|
118
|
+
|
|
100
119
|
export {CardTabBar, ScrollableTabBar, TabBar, TabView};
|
|
101
120
|
export type {TabViewProps, Tab};
|
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -12,7 +12,6 @@ if [ "$1" == "stable" ]; then
|
|
|
12
12
|
npm publish --tag stable --access=public
|
|
13
13
|
elif [ "$1" == "latest" ]; then
|
|
14
14
|
npm version $(npm view @momo-kits/foundation@latest version)
|
|
15
|
-
npm version prerelease --preid=rc
|
|
16
15
|
npm publish --tag latest --access=public
|
|
17
16
|
else
|
|
18
17
|
npm version $(npm view @momo-kits/tab-view@beta version)
|