react-native-tab-view 3.1.1 → 3.2.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 (65) hide show
  1. package/README.md +13 -1
  2. package/lib/commonjs/Pager.android.js.map +1 -1
  3. package/lib/commonjs/Pager.ios.js.map +1 -1
  4. package/lib/commonjs/Pager.js.map +1 -1
  5. package/lib/commonjs/PagerViewAdapter.js +40 -22
  6. package/lib/commonjs/PagerViewAdapter.js.map +1 -1
  7. package/lib/commonjs/PanResponderAdapter.js +41 -29
  8. package/lib/commonjs/PanResponderAdapter.js.map +1 -1
  9. package/lib/commonjs/PlatformPressable.js +19 -15
  10. package/lib/commonjs/PlatformPressable.js.map +1 -1
  11. package/lib/commonjs/SceneMap.js +14 -11
  12. package/lib/commonjs/SceneMap.js.map +1 -1
  13. package/lib/commonjs/SceneView.js +2 -2
  14. package/lib/commonjs/SceneView.js.map +1 -1
  15. package/lib/commonjs/TabBar.js +124 -81
  16. package/lib/commonjs/TabBar.js.map +1 -1
  17. package/lib/commonjs/TabBarIndicator.js +7 -6
  18. package/lib/commonjs/TabBarIndicator.js.map +1 -1
  19. package/lib/commonjs/TabBarItem.js +7 -6
  20. package/lib/commonjs/TabBarItem.js.map +1 -1
  21. package/lib/commonjs/TabView.js +42 -33
  22. package/lib/commonjs/TabView.js.map +1 -1
  23. package/lib/commonjs/index.js +6 -6
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/types.js +4 -0
  26. package/lib/commonjs/types.js.map +1 -1
  27. package/lib/commonjs/useAnimatedValue.js.map +1 -1
  28. package/lib/module/Pager.android.js.map +1 -1
  29. package/lib/module/Pager.ios.js.map +1 -1
  30. package/lib/module/Pager.js.map +1 -1
  31. package/lib/module/PagerViewAdapter.js +40 -22
  32. package/lib/module/PagerViewAdapter.js.map +1 -1
  33. package/lib/module/PanResponderAdapter.js +41 -28
  34. package/lib/module/PanResponderAdapter.js.map +1 -1
  35. package/lib/module/PlatformPressable.js +19 -15
  36. package/lib/module/PlatformPressable.js.map +1 -1
  37. package/lib/module/SceneMap.js +14 -11
  38. package/lib/module/SceneMap.js.map +1 -1
  39. package/lib/module/SceneView.js +2 -2
  40. package/lib/module/SceneView.js.map +1 -1
  41. package/lib/module/TabBar.js +125 -81
  42. package/lib/module/TabBar.js.map +1 -1
  43. package/lib/module/TabBarIndicator.js +7 -6
  44. package/lib/module/TabBarIndicator.js.map +1 -1
  45. package/lib/module/TabBarItem.js +7 -6
  46. package/lib/module/TabBarItem.js.map +1 -1
  47. package/lib/module/TabView.js +41 -32
  48. package/lib/module/TabView.js.map +1 -1
  49. package/lib/module/index.js.map +1 -1
  50. package/lib/module/types.js +1 -1
  51. package/lib/module/types.js.map +1 -1
  52. package/lib/module/useAnimatedValue.js.map +1 -1
  53. package/lib/typescript/PagerViewAdapter.d.ts +1 -1
  54. package/lib/typescript/PanResponderAdapter.d.ts +1 -1
  55. package/lib/typescript/TabBar.d.ts +3 -1
  56. package/lib/typescript/TabBarIndicator.d.ts +1 -0
  57. package/lib/typescript/TabView.d.ts +2 -1
  58. package/lib/typescript/types.d.ts +1 -0
  59. package/package.json +19 -18
  60. package/src/PagerViewAdapter.tsx +23 -9
  61. package/src/PanResponderAdapter.tsx +23 -17
  62. package/src/TabBar.tsx +75 -31
  63. package/src/TabBarIndicator.tsx +14 -5
  64. package/src/TabView.tsx +5 -0
  65. package/src/types.tsx +1 -0
@@ -6,8 +6,8 @@ import PlatformPressable from './PlatformPressable';
6
6
  const DEFAULT_ACTIVE_COLOR = 'rgba(255, 255, 255, 1)';
7
7
  const DEFAULT_INACTIVE_COLOR = 'rgba(255, 255, 255, 0.7)';
8
8
  export default class TabBarItem extends React.Component {
9
- constructor(...args) {
10
- super(...args);
9
+ constructor() {
10
+ super(...arguments);
11
11
 
12
12
  _defineProperty(this, "getActiveOpacity", (position, routes, tabIndex) => {
13
13
  if (routes.length > 1) {
@@ -93,10 +93,11 @@ export default class TabBarItem extends React.Component {
93
93
  }
94
94
  }
95
95
 
96
- const renderLabel = renderLabelCustom !== undefined ? renderLabelCustom : ({
97
- route,
98
- color
99
- }) => {
96
+ const renderLabel = renderLabelCustom !== undefined ? renderLabelCustom : _ref => {
97
+ let {
98
+ route,
99
+ color
100
+ } = _ref;
100
101
  const labelText = getLabelText({
101
102
  route
102
103
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["TabBarItem.tsx"],"names":["React","Animated","StyleSheet","View","PlatformPressable","DEFAULT_ACTIVE_COLOR","DEFAULT_INACTIVE_COLOR","TabBarItem","Component","position","routes","tabIndex","length","inputRange","map","_","i","interpolate","outputRange","render","route","navigationState","renderLabel","renderLabelCustom","renderIcon","renderBadge","getLabelText","getTestID","getAccessibilityLabel","getAccessible","activeColor","activeColorCustom","inactiveColor","inactiveColorCustom","pressColor","pressOpacity","labelStyle","style","onLayout","onPress","onLongPress","props","indexOf","isFocused","index","labelColorFromStyle","flatten","color","undefined","activeOpacity","getActiveOpacity","inactiveOpacity","getInactiveOpacity","icon","label","activeIcon","focused","inactiveIcon","styles","opacity","absoluteFill","labelText","marginTop","activeLabel","inactiveLabel","tabStyle","isWidthSet","width","tabContainerStyle","flex","scene","accessibilityLabel","badge","borderless","selected","pressable","item","create","margin","backgroundColor","textTransform","alignItems","justifyContent","padding","minHeight","top","right"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,UAFF,EAGEC,IAHF,QAQO,cARP;AASA,OAAOC,iBAAP,MAA8B,qBAA9B;AAiCA,MAAMC,oBAAoB,GAAG,wBAA7B;AACA,MAAMC,sBAAsB,GAAG,0BAA/B;AAEA,eAAe,MAAMC,UAAN,SAA0CP,KAAK,CAACQ,SAAhD,CAEb;AAAA;AAAA;;AAAA,8CAC2B,CACzBC,QADyB,EAEzBC,MAFyB,EAGzBC,QAHyB,KAItB;AACH,UAAID,MAAM,CAACE,MAAP,GAAgB,CAApB,EAAuB;AACrB,cAAMC,U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,SAAS,EAAE;AACT;AACA;AACAI,IAAAA,eAAe,EAAE;AAHR;AArBoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n StyleProp,\n LayoutChangeEvent,\n TextStyle,\n ViewStyle,\n} from 'react-native';\nimport PlatformPressable from './PlatformPressable';\nimport type { Scene, Route, NavigationState } from './types';\n\nexport type Props<T extends Route> = {\n position: Animated.AnimatedInterpolation;\n route: T;\n navigationState: NavigationState<T>;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n pressOpacity?: number;\n getLabelText: (scene: Scene<T>) => string | undefined;\n getAccessible: (scene: Scene<T>) => boolean | undefined;\n getAccessibilityLabel: (scene: Scene<T>) => string | undefined;\n getTestID: (scene: Scene<T>) => string | undefined;\n renderLabel?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderIcon?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderBadge?: (scene: Scene<T>) => React.ReactNode;\n onLayout?: (event: LayoutChangeEvent) => void;\n onPress: () => void;\n onLongPress: () => void;\n labelStyle?: StyleProp<TextStyle>;\n style: StyleProp<ViewStyle>;\n};\n\nconst DEFAULT_ACTIVE_COLOR = 'rgba(255, 255, 255, 1)';\nconst DEFAULT_INACTIVE_COLOR = 'rgba(255, 255, 255, 0.7)';\n\nexport default class TabBarItem<T extends Route> extends React.Component<\n Props<T>\n> {\n private getActiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_, i) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i) => (i === tabIndex ? 1 : 0)),\n });\n } else {\n return 1;\n }\n };\n\n private getInactiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_: Route, i: number) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i: number) => (i === tabIndex ? 0 : 1)),\n });\n } else {\n return 0;\n }\n };\n\n render() {\n const {\n route,\n position,\n navigationState,\n renderLabel: renderLabelCustom,\n renderIcon,\n renderBadge,\n getLabelText,\n getTestID,\n getAccessibilityLabel,\n getAccessible,\n activeColor: activeColorCustom,\n inactiveColor: inactiveColorCustom,\n pressColor,\n pressOpacity,\n labelStyle,\n style,\n onLayout,\n onPress,\n onLongPress,\n } = this.props;\n\n const tabIndex = navigationState.routes.indexOf(route);\n const isFocused = navigationState.index === tabIndex;\n\n const labelColorFromStyle = StyleSheet.flatten(labelStyle || {}).color;\n\n const activeColor =\n activeColorCustom !== undefined\n ? activeColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_ACTIVE_COLOR;\n const inactiveColor =\n inactiveColorCustom !== undefined\n ? inactiveColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_INACTIVE_COLOR;\n\n const activeOpacity = this.getActiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n const inactiveOpacity = this.getInactiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n\n let icon: React.ReactNode | null = null;\n let label: React.ReactNode | null = null;\n\n if (renderIcon) {\n const activeIcon = renderIcon({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveIcon = renderIcon({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n if (inactiveIcon != null && activeIcon != null) {\n icon = (\n <View style={styles.icon}>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveIcon}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeIcon}\n </Animated.View>\n </View>\n );\n }\n }\n\n const renderLabel =\n renderLabelCustom !== undefined\n ? renderLabelCustom\n : ({ route, color }: { route: T; color: string }) => {\n const labelText = getLabelText({ route });\n\n if (typeof labelText === 'string') {\n return (\n <Animated.Text\n style={[\n styles.label,\n icon ? { marginTop: 0 } : null,\n labelStyle,\n { color },\n ]}\n >\n {labelText}\n </Animated.Text>\n );\n }\n\n return labelText;\n };\n\n if (renderLabel) {\n const activeLabel = renderLabel({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveLabel = renderLabel({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n label = (\n <View>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveLabel}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeLabel}\n </Animated.View>\n </View>\n );\n }\n\n const tabStyle = StyleSheet.flatten(style);\n const isWidthSet = tabStyle?.width !== undefined;\n const tabContainerStyle: ViewStyle | null = isWidthSet ? null : { flex: 1 };\n\n const scene = { route };\n\n let accessibilityLabel = getAccessibilityLabel(scene);\n\n accessibilityLabel =\n typeof accessibilityLabel !== 'undefined'\n ? accessibilityLabel\n : getLabelText(scene);\n\n const badge = renderBadge ? renderBadge(scene) : null;\n\n return (\n <PlatformPressable\n android_ripple={{ borderless: true }}\n testID={getTestID(scene)}\n accessible={getAccessible(scene)}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: isFocused }}\n // @ts-ignore: this is to support older React Native versions\n accessibilityStates={isFocused ? ['selected'] : []}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n delayPressIn={0}\n onLayout={onLayout}\n onPress={onPress}\n onLongPress={onLongPress}\n style={[styles.pressable, tabContainerStyle]}\n >\n <View pointerEvents=\"none\" style={[styles.item, tabStyle]}>\n {icon}\n {label}\n {badge != null ? <View style={styles.badge}>{badge}</View> : null}\n </View>\n </PlatformPressable>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n label: {\n margin: 4,\n backgroundColor: 'transparent',\n textTransform: 'uppercase',\n },\n icon: {\n margin: 2,\n },\n item: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 10,\n minHeight: 48,\n },\n badge: {\n position: 'absolute',\n top: 0,\n right: 0,\n },\n pressable: {\n // The label is not pressable on Windows\n // Adding backgroundColor: 'transparent' seems to fix it\n backgroundColor: 'transparent',\n },\n});\n"]}
1
+ {"version":3,"names":["React","Animated","StyleSheet","View","PlatformPressable","DEFAULT_ACTIVE_COLOR","DEFAULT_INACTIVE_COLOR","TabBarItem","Component","position","routes","tabIndex","length","inputRange","map","_","i","interpolate","outputRange","render","route","navigationState","renderLabel","renderLabelCustom","renderIcon","renderBadge","getLabelText","getTestID","getAccessibilityLabel","getAccessible","activeColor","activeColorCustom","inactiveColor","inactiveColorCustom","pressColor","pressOpacity","labelStyle","style","onLayout","onPress","onLongPress","props","indexOf","isFocused","index","labelColorFromStyle","flatten","color","undefined","activeOpacity","getActiveOpacity","inactiveOpacity","getInactiveOpacity","icon","label","activeIcon","focused","inactiveIcon","styles","opacity","absoluteFill","labelText","marginTop","activeLabel","inactiveLabel","tabStyle","isWidthSet","width","tabContainerStyle","flex","scene","accessibilityLabel","badge","borderless","selected","pressable","item","create","margin","backgroundColor","textTransform","alignItems","justifyContent","padding","minHeight","top","right"],"sources":["TabBarItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n StyleProp,\n LayoutChangeEvent,\n TextStyle,\n ViewStyle,\n} from 'react-native';\nimport PlatformPressable from './PlatformPressable';\nimport type { Scene, Route, NavigationState } from './types';\n\nexport type Props<T extends Route> = {\n position: Animated.AnimatedInterpolation;\n route: T;\n navigationState: NavigationState<T>;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n pressOpacity?: number;\n getLabelText: (scene: Scene<T>) => string | undefined;\n getAccessible: (scene: Scene<T>) => boolean | undefined;\n getAccessibilityLabel: (scene: Scene<T>) => string | undefined;\n getTestID: (scene: Scene<T>) => string | undefined;\n renderLabel?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderIcon?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderBadge?: (scene: Scene<T>) => React.ReactNode;\n onLayout?: (event: LayoutChangeEvent) => void;\n onPress: () => void;\n onLongPress: () => void;\n labelStyle?: StyleProp<TextStyle>;\n style: StyleProp<ViewStyle>;\n};\n\nconst DEFAULT_ACTIVE_COLOR = 'rgba(255, 255, 255, 1)';\nconst DEFAULT_INACTIVE_COLOR = 'rgba(255, 255, 255, 0.7)';\n\nexport default class TabBarItem<T extends Route> extends React.Component<\n Props<T>\n> {\n private getActiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_, i) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i) => (i === tabIndex ? 1 : 0)),\n });\n } else {\n return 1;\n }\n };\n\n private getInactiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_: Route, i: number) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i: number) => (i === tabIndex ? 0 : 1)),\n });\n } else {\n return 0;\n }\n };\n\n render() {\n const {\n route,\n position,\n navigationState,\n renderLabel: renderLabelCustom,\n renderIcon,\n renderBadge,\n getLabelText,\n getTestID,\n getAccessibilityLabel,\n getAccessible,\n activeColor: activeColorCustom,\n inactiveColor: inactiveColorCustom,\n pressColor,\n pressOpacity,\n labelStyle,\n style,\n onLayout,\n onPress,\n onLongPress,\n } = this.props;\n\n const tabIndex = navigationState.routes.indexOf(route);\n const isFocused = navigationState.index === tabIndex;\n\n const labelColorFromStyle = StyleSheet.flatten(labelStyle || {}).color;\n\n const activeColor =\n activeColorCustom !== undefined\n ? activeColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_ACTIVE_COLOR;\n const inactiveColor =\n inactiveColorCustom !== undefined\n ? inactiveColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_INACTIVE_COLOR;\n\n const activeOpacity = this.getActiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n const inactiveOpacity = this.getInactiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n\n let icon: React.ReactNode | null = null;\n let label: React.ReactNode | null = null;\n\n if (renderIcon) {\n const activeIcon = renderIcon({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveIcon = renderIcon({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n if (inactiveIcon != null && activeIcon != null) {\n icon = (\n <View style={styles.icon}>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveIcon}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeIcon}\n </Animated.View>\n </View>\n );\n }\n }\n\n const renderLabel =\n renderLabelCustom !== undefined\n ? renderLabelCustom\n : ({ route, color }: { route: T; color: string }) => {\n const labelText = getLabelText({ route });\n\n if (typeof labelText === 'string') {\n return (\n <Animated.Text\n style={[\n styles.label,\n icon ? { marginTop: 0 } : null,\n labelStyle,\n { color },\n ]}\n >\n {labelText}\n </Animated.Text>\n );\n }\n\n return labelText;\n };\n\n if (renderLabel) {\n const activeLabel = renderLabel({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveLabel = renderLabel({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n label = (\n <View>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveLabel}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeLabel}\n </Animated.View>\n </View>\n );\n }\n\n const tabStyle = StyleSheet.flatten(style);\n const isWidthSet = tabStyle?.width !== undefined;\n const tabContainerStyle: ViewStyle | null = isWidthSet ? null : { flex: 1 };\n\n const scene = { route };\n\n let accessibilityLabel = getAccessibilityLabel(scene);\n\n accessibilityLabel =\n typeof accessibilityLabel !== 'undefined'\n ? accessibilityLabel\n : getLabelText(scene);\n\n const badge = renderBadge ? renderBadge(scene) : null;\n\n return (\n <PlatformPressable\n android_ripple={{ borderless: true }}\n testID={getTestID(scene)}\n accessible={getAccessible(scene)}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: isFocused }}\n // @ts-ignore: this is to support older React Native versions\n accessibilityStates={isFocused ? ['selected'] : []}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n delayPressIn={0}\n onLayout={onLayout}\n onPress={onPress}\n onLongPress={onLongPress}\n style={[styles.pressable, tabContainerStyle]}\n >\n <View pointerEvents=\"none\" style={[styles.item, tabStyle]}>\n {icon}\n {label}\n {badge != null ? <View style={styles.badge}>{badge}</View> : null}\n </View>\n </PlatformPressable>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n label: {\n margin: 4,\n backgroundColor: 'transparent',\n textTransform: 'uppercase',\n },\n icon: {\n margin: 2,\n },\n item: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 10,\n minHeight: 48,\n },\n badge: {\n position: 'absolute',\n top: 0,\n right: 0,\n },\n pressable: {\n // The label is not pressable on Windows\n // Adding backgroundColor: 'transparent' seems to fix it\n backgroundColor: 'transparent',\n },\n});\n"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,UAFF,EAGEC,IAHF,QAQO,cARP;AASA,OAAOC,iBAAP,MAA8B,qBAA9B;AAiCA,MAAMC,oBAAoB,GAAG,wBAA7B;AACA,MAAMC,sBAAsB,GAAG,0BAA/B;AAEA,eAAe,MAAMC,UAAN,SAA0CP,KAAK,CAACQ,SAAhD,CAEb;EAAA;IAAA;;IAAA,0CAC2B,CACzBC,QADyB,EAEzBC,MAFyB,EAGzBC,QAHyB,KAItB;MACH,IAAID,MAAM,CAACE,MAAP,GAAgB,CAApB,EAAuB;QACrB,MAAMC,UAAU,GAAGH,MAAM,CAACI,GAAP,CAAW,CAACC,CAAD,EAAIC,CAAJ,KAAUA,CAArB,CAA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AhB,GAA4D,IAH/D,CAjBF,CADF;EAyBD;;AAhND;AAmNF,MAAMd,MAAM,GAAGxD,UAAU,CAAC2E,MAAX,CAAkB;EAC/BvB,KAAK,EAAE;IACLwB,MAAM,EAAE,CADH;IAELC,eAAe,EAAE,aAFZ;IAGLC,aAAa,EAAE;EAHV,CADwB;EAM/B3B,IAAI,EAAE;IACJyB,MAAM,EAAE;EADJ,CANyB;EAS/BF,IAAI,EAAE;IACJP,IAAI,EAAE,CADF;IAEJY,UAAU,EAAE,QAFR;IAGJC,cAAc,EAAE,QAHZ;IAIJC,OAAO,EAAE,EAJL;IAKJC,SAAS,EAAE;EALP,CATyB;EAgB/BZ,KAAK,EAAE;IACL/D,QAAQ,EAAE,UADL;IAEL4E,GAAG,EAAE,CAFA;IAGLC,KAAK,EAAE;EAHF,CAhBwB;EAqB/BX,SAAS,EAAE;IACT;IACA;IACAI,eAAe,EAAE;EAHR;AArBoB,CAAlB,CAAf"}
@@ -1,27 +1,30 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import * as React from 'react';
4
4
  import { StyleSheet, View } from 'react-native';
5
5
  import TabBar from './TabBar';
6
6
  import SceneView from './SceneView';
7
7
  import Pager from './Pager';
8
- export default function TabView({
9
- onIndexChange,
10
- navigationState,
11
- renderScene,
12
- initialLayout,
13
- keyboardDismissMode = 'auto',
14
- lazy = false,
15
- lazyPreloadDistance = 0,
16
- onSwipeStart,
17
- onSwipeEnd,
18
- renderLazyPlaceholder = () => null,
19
- renderTabBar = props => /*#__PURE__*/React.createElement(TabBar, props),
20
- sceneContainerStyle,
21
- style,
22
- swipeEnabled = true,
23
- tabBarPosition = 'top'
24
- }) {
8
+ export default function TabView(_ref) {
9
+ let {
10
+ onIndexChange,
11
+ navigationState,
12
+ renderScene,
13
+ initialLayout,
14
+ keyboardDismissMode = 'auto',
15
+ lazy = false,
16
+ lazyPreloadDistance = 0,
17
+ onSwipeStart,
18
+ onSwipeEnd,
19
+ renderLazyPlaceholder = () => null,
20
+ renderTabBar = props => /*#__PURE__*/React.createElement(TabBar, props),
21
+ sceneContainerStyle,
22
+ pagerStyle,
23
+ style,
24
+ swipeEnabled = true,
25
+ tabBarPosition = 'top',
26
+ animationEnabled = true
27
+ } = _ref;
25
28
  const [layout, setLayout] = React.useState({
26
29
  width: 0,
27
30
  height: 0,
@@ -61,13 +64,16 @@ export default function TabView({
61
64
  swipeEnabled: swipeEnabled,
62
65
  onSwipeStart: onSwipeStart,
63
66
  onSwipeEnd: onSwipeEnd,
64
- onIndexChange: jumpToIndex
65
- }, ({
66
- position,
67
- render,
68
- addEnterListener,
69
- jumpTo
70
- }) => {
67
+ onIndexChange: jumpToIndex,
68
+ animationEnabled: animationEnabled,
69
+ style: pagerStyle
70
+ }, _ref2 => {
71
+ let {
72
+ position,
73
+ render,
74
+ addEnterListener,
75
+ jumpTo
76
+ } = _ref2;
71
77
  // All of the props here must not change between re-renders
72
78
  // This is crucial to optimizing the routes with PureComponent
73
79
  const sceneRendererProps = {
@@ -88,13 +94,16 @@ export default function TabView({
88
94
  lazyPreloadDistance: lazyPreloadDistance,
89
95
  navigationState: navigationState,
90
96
  style: sceneContainerStyle
91
- }), ({
92
- loading
93
- }) => loading ? renderLazyPlaceholder({
94
- route
95
- }) : renderScene({ ...sceneRendererProps,
96
- route
97
- }));
97
+ }), _ref3 => {
98
+ let {
99
+ loading
100
+ } = _ref3;
101
+ return loading ? renderLazyPlaceholder({
102
+ route
103
+ }) : renderScene({ ...sceneRendererProps,
104
+ route
105
+ });
106
+ });
98
107
  })), tabBarPosition === 'bottom' && renderTabBar({ ...sceneRendererProps,
99
108
  navigationState
100
109
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["TabView.tsx"],"names":["React","StyleSheet","View","TabBar","SceneView","Pager","TabView","onIndexChange","navigationState","renderScene","initialLayout","keyboardDismissMode","lazy","lazyPreloadDistance","onSwipeStart","onSwipeEnd","renderLazyPlaceholder","renderTabBar","props","sceneContainerStyle","style","swipeEnabled","tabBarPosition","layout","setLayout","useState","width","height","jumpToIndex","index","handleLayout","e","nativeEvent","prevLayout","styles","pager","position","render","addEnterListener","jumpTo","sceneRendererProps","routes","map","route","i","key","loading","create","flex","overflow"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,UADF,EAEEC,IAFF,QAMO,cANP;AAOA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AAyBA,eAAe,SAASC,OAAT,CAAkC;AAC/CC,EAAAA,aAD+C;AAE/CC,EAAAA,eAF+C;AAG/CC,EAAAA,WAH+C;AAI/CC,EAAAA,aAJ+C;AAK/CC,EAAAA,mBAAmB,GAAG,MALyB;AAM/CC,EAAAA,IAAI,GAAG,KANwC;AAO/CC,EAAAA,mBAAmB,GAAG,CAPyB;AAQ/CC,EAAAA,YAR+C;AAS/CC,EAAAA,UAT+C;AAU/CC,EAAAA,qBAAqB,GAAG,MAAM,IAViB;AAW/CC,EAAAA,YAAY,GAAIC,KAAD,iBAAW,oBAAC,MAAD,EAAYA,KAAZ,CAXqB;AAY/CC,EAAAA,mBAZ+C;AAa/CC,EAAAA,KAb+C;AAc/CC,EAAAA,YAAY,GAAG,IAdgC;AAe/CC,EAAAA,cAAc,GAAG;AAf8B,CAAlC,EAgBF;AACX,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsBxB,KAAK,CAACyB,QAAN,CAAe;AACzCC,IAAAA,KAAK,EAAE,CAD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D,CAAO,QAAP,QACGjB,cAAc,KAAK,KAAnB,IACCL,YAAY,CAAC,EACX,GAAGuB,kBADQ;AAEXhC,MAAAA;AAFW,KAAD,CAFhB,EAMG6B,MAAM,CACL7B,eAAe,CAACiC,MAAhB,CAAuBC,GAAvB,CAA2B,CAACC,KAAD,EAAQC,CAAR,KAAc;AACvC,0BACE,oBAAC,SAAD,eACMJ,kBADN;AAEE,QAAA,gBAAgB,EAAEF,gBAFpB;AAGE,QAAA,GAAG,EAAEK,KAAK,CAACE,GAHb;AAIE,QAAA,KAAK,EAAED,CAJT;AAKE,QAAA,IAAI,EAAE,OAAOhC,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,CAAC;AAAE+B,UAAAA;AAAF,SAAD,CAAjC,GAA+C/B,IALvD;AAME,QAAA,mBAAmB,EAAEC,mBANvB;AAOE,QAAA,eAAe,EAAEL,eAPnB;AAQE,QAAA,KAAK,EAAEW;AART,UAUG,CAAC;AAAE2B,QAAAA;AAAF,OAAD,KACCA,OAAO,GACH9B,qBAAqB,CAAC;AAAE2B,QAAAA;AAAF,OAAD,CADlB,GAEHlC,WAAW,CAAC,EACV,GAAG+B,kBADO;AAEVG,QAAAA;AAFU,OAAD,CAbnB,CADF;AAqBD,KAtBD,CADK,CANT,EA+BGrB,cAAc,KAAK,QAAnB,IACCL,YAAY,CAAC,EACX,GAAGuB,kBADQ;AAEXhC,MAAAA;AAFW,KAAD,CAhChB,CADF;AAuCD,GAzDH,CADF,CADF;AA+DD;AAED,MAAM0B,MAAM,GAAGjC,UAAU,CAAC8C,MAAX,CAAkB;AAC/BZ,EAAAA,KAAK,EAAE;AACLa,IAAAA,IAAI,EAAE,CADD;AAELC,IAAAA,QAAQ,EAAE;AAFL;AADwB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n StyleSheet,\n View,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n} from 'react-native';\nimport TabBar from './TabBar';\nimport SceneView from './SceneView';\nimport Pager from './Pager';\nimport type {\n Layout,\n NavigationState,\n Route,\n SceneRendererProps,\n PagerProps,\n} from './types';\n\nexport type Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;\n renderLazyPlaceholder?: (props: { route: T }) => React.ReactNode;\n renderTabBar?: (\n props: SceneRendererProps & { navigationState: NavigationState<T> }\n ) => React.ReactNode;\n tabBarPosition?: 'top' | 'bottom';\n initialLayout?: Partial<Layout>;\n lazy?: ((props: { route: T }) => boolean) | boolean;\n lazyPreloadDistance?: number;\n sceneContainerStyle?: StyleProp<ViewStyle>;\n style?: StyleProp<ViewStyle>;\n};\n\nexport default function TabView<T extends Route>({\n onIndexChange,\n navigationState,\n renderScene,\n initialLayout,\n keyboardDismissMode = 'auto',\n lazy = false,\n lazyPreloadDistance = 0,\n onSwipeStart,\n onSwipeEnd,\n renderLazyPlaceholder = () => null,\n renderTabBar = (props) => <TabBar {...props} />,\n sceneContainerStyle,\n style,\n swipeEnabled = true,\n tabBarPosition = 'top',\n}: Props<T>) {\n const [layout, setLayout] = React.useState({\n width: 0,\n height: 0,\n ...initialLayout,\n });\n\n const jumpToIndex = (index: number) => {\n if (index !== navigationState.index) {\n onIndexChange(index);\n }\n };\n\n const handleLayout = (e: LayoutChangeEvent) => {\n const { height, width } = e.nativeEvent.layout;\n\n setLayout((prevLayout) => {\n if (prevLayout.width === width && prevLayout.height === height) {\n return prevLayout;\n }\n\n return { height, width };\n });\n };\n\n return (\n <View onLayout={handleLayout} style={[styles.pager, style]}>\n <Pager\n layout={layout}\n navigationState={navigationState}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n onSwipeStart={onSwipeStart}\n onSwipeEnd={onSwipeEnd}\n onIndexChange={jumpToIndex}\n >\n {({ position, render, addEnterListener, jumpTo }) => {\n // All of the props here must not change between re-renders\n // This is crucial to optimizing the routes with PureComponent\n const sceneRendererProps = {\n position,\n layout,\n jumpTo,\n };\n\n return (\n <React.Fragment>\n {tabBarPosition === 'top' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n {render(\n navigationState.routes.map((route, i) => {\n return (\n <SceneView\n {...sceneRendererProps}\n addEnterListener={addEnterListener}\n key={route.key}\n index={i}\n lazy={typeof lazy === 'function' ? lazy({ route }) : lazy}\n lazyPreloadDistance={lazyPreloadDistance}\n navigationState={navigationState}\n style={sceneContainerStyle}\n >\n {({ loading }) =>\n loading\n ? renderLazyPlaceholder({ route })\n : renderScene({\n ...sceneRendererProps,\n route,\n })\n }\n </SceneView>\n );\n })\n )}\n {tabBarPosition === 'bottom' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n </React.Fragment>\n );\n }}\n </Pager>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n pager: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"]}
1
+ {"version":3,"names":["React","StyleSheet","View","TabBar","SceneView","Pager","TabView","onIndexChange","navigationState","renderScene","initialLayout","keyboardDismissMode","lazy","lazyPreloadDistance","onSwipeStart","onSwipeEnd","renderLazyPlaceholder","renderTabBar","props","sceneContainerStyle","pagerStyle","style","swipeEnabled","tabBarPosition","animationEnabled","layout","setLayout","useState","width","height","jumpToIndex","index","handleLayout","e","nativeEvent","prevLayout","styles","pager","position","render","addEnterListener","jumpTo","sceneRendererProps","routes","map","route","i","key","loading","create","flex","overflow"],"sources":["TabView.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n StyleSheet,\n View,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n} from 'react-native';\nimport TabBar from './TabBar';\nimport SceneView from './SceneView';\nimport Pager from './Pager';\nimport type {\n Layout,\n NavigationState,\n Route,\n SceneRendererProps,\n PagerProps,\n} from './types';\n\nexport type Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;\n renderLazyPlaceholder?: (props: { route: T }) => React.ReactNode;\n renderTabBar?: (\n props: SceneRendererProps & { navigationState: NavigationState<T> }\n ) => React.ReactNode;\n tabBarPosition?: 'top' | 'bottom';\n initialLayout?: Partial<Layout>;\n lazy?: ((props: { route: T }) => boolean) | boolean;\n lazyPreloadDistance?: number;\n sceneContainerStyle?: StyleProp<ViewStyle>;\n pagerStyle?: StyleProp<ViewStyle>;\n style?: StyleProp<ViewStyle>;\n};\n\nexport default function TabView<T extends Route>({\n onIndexChange,\n navigationState,\n renderScene,\n initialLayout,\n keyboardDismissMode = 'auto',\n lazy = false,\n lazyPreloadDistance = 0,\n onSwipeStart,\n onSwipeEnd,\n renderLazyPlaceholder = () => null,\n renderTabBar = (props) => <TabBar {...props} />,\n sceneContainerStyle,\n pagerStyle,\n style,\n swipeEnabled = true,\n tabBarPosition = 'top',\n animationEnabled = true,\n}: Props<T>) {\n const [layout, setLayout] = React.useState({\n width: 0,\n height: 0,\n ...initialLayout,\n });\n\n const jumpToIndex = (index: number) => {\n if (index !== navigationState.index) {\n onIndexChange(index);\n }\n };\n\n const handleLayout = (e: LayoutChangeEvent) => {\n const { height, width } = e.nativeEvent.layout;\n\n setLayout((prevLayout) => {\n if (prevLayout.width === width && prevLayout.height === height) {\n return prevLayout;\n }\n\n return { height, width };\n });\n };\n\n return (\n <View onLayout={handleLayout} style={[styles.pager, style]}>\n <Pager\n layout={layout}\n navigationState={navigationState}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n onSwipeStart={onSwipeStart}\n onSwipeEnd={onSwipeEnd}\n onIndexChange={jumpToIndex}\n animationEnabled={animationEnabled}\n style={pagerStyle}\n >\n {({ position, render, addEnterListener, jumpTo }) => {\n // All of the props here must not change between re-renders\n // This is crucial to optimizing the routes with PureComponent\n const sceneRendererProps = {\n position,\n layout,\n jumpTo,\n };\n\n return (\n <React.Fragment>\n {tabBarPosition === 'top' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n {render(\n navigationState.routes.map((route, i) => {\n return (\n <SceneView\n {...sceneRendererProps}\n addEnterListener={addEnterListener}\n key={route.key}\n index={i}\n lazy={typeof lazy === 'function' ? lazy({ route }) : lazy}\n lazyPreloadDistance={lazyPreloadDistance}\n navigationState={navigationState}\n style={sceneContainerStyle}\n >\n {({ loading }) =>\n loading\n ? renderLazyPlaceholder({ route })\n : renderScene({\n ...sceneRendererProps,\n route,\n })\n }\n </SceneView>\n );\n })\n )}\n {tabBarPosition === 'bottom' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n </React.Fragment>\n );\n }}\n </Pager>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n pager: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,UADF,EAEEC,IAFF,QAMO,cANP;AAOA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AA0BA,eAAe,SAASC,OAAT,OAkBF;EAAA,IAlBoC;IAC/CC,aAD+C;IAE/CC,eAF+C;IAG/CC,WAH+C;IAI/CC,aAJ+C;IAK/CC,mBAAmB,GAAG,MALyB;IAM/CC,IAAI,GAAG,KANwC;IAO/CC,mBAAmB,GAAG,CAPyB;IAQ/CC,YAR+C;IAS/CC,UAT+C;IAU/CC,qBAAqB,GAAG,MAAM,IAViB;IAW/CC,YAAY,GAAIC,KAAD,iBAAW,oBAAC,MAAD,EAAYA,KAAZ,CAXqB;IAY/CC,mBAZ+C;IAa/CC,UAb+C;IAc/CC,KAd+C;IAe/CC,YAAY,GAAG,IAfgC;IAgB/CC,cAAc,GAAG,KAhB8B;IAiB/CC,gBAAgB,GAAG;EAjB4B,CAkBpC;EACX,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB1B,KAAK,CAAC2B,QAAN,CAAe;IACzCC,KAAK,EAAE,CADkC;IAEzCC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FhB,EAMG+B,MAAM,CACL/B,eAAe,CAACmC,MAAhB,CAAuBC,GAAvB,CAA2B,CAACC,KAAD,EAAQC,CAAR,KAAc;MACvC,oBACE,oBAAC,SAAD,eACMJ,kBADN;QAEE,gBAAgB,EAAEF,gBAFpB;QAGE,GAAG,EAAEK,KAAK,CAACE,GAHb;QAIE,KAAK,EAAED,CAJT;QAKE,IAAI,EAAE,OAAOlC,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,CAAC;UAAEiC;QAAF,CAAD,CAAjC,GAA+CjC,IALvD;QAME,mBAAmB,EAAEC,mBANvB;QAOE,eAAe,EAAEL,eAPnB;QAQE,KAAK,EAAEW;MART,IAUG;QAAA,IAAC;UAAE6B;QAAF,CAAD;QAAA,OACCA,OAAO,GACHhC,qBAAqB,CAAC;UAAE6B;QAAF,CAAD,CADlB,GAEHpC,WAAW,CAAC,EACV,GAAGiC,kBADO;UAEVG;QAFU,CAAD,CAHhB;MAAA,CAVH,CADF;IAqBD,CAtBD,CADK,CANT,EA+BGtB,cAAc,KAAK,QAAnB,IACCN,YAAY,CAAC,EACX,GAAGyB,kBADQ;MAEXlC;IAFW,CAAD,CAhChB,CADF;EAuCD,CA3DH,CADF,CADF;AAiED;AAED,MAAM4B,MAAM,GAAGnC,UAAU,CAACgD,MAAX,CAAkB;EAC/BZ,KAAK,EAAE;IACLa,IAAI,EAAE,CADD;IAELC,QAAQ,EAAE;EAFL;AADwB,CAAlB,CAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["default","TabBar","TabView","TabBarIndicator","TabBarItem","SceneMap"],"mappings":"AAAA,SAASA,OAAO,IAAIC,MAApB,QAAkC,UAAlC;AAGA,SAASD,OAAO,IAAIE,OAApB,QAAmC,WAAnC;AAGA,SAASF,OAAO,IAAIG,eAApB,QAA2C,mBAA3C;AAGA,SAASH,OAAO,IAAII,UAApB,QAAsC,cAAtC;AAGA,SAASJ,OAAO,IAAIK,QAApB,QAAoC,YAApC","sourcesContent":["export { default as TabBar } from './TabBar';\nexport type { Props as TabBarProps } from './TabBar';\n\nexport { default as TabView } from './TabView';\nexport type { Props as TabViewProps } from './TabView';\n\nexport { default as TabBarIndicator } from './TabBarIndicator';\nexport type { Props as TabBarIndicatorProps } from './TabBarIndicator';\n\nexport { default as TabBarItem } from './TabBarItem';\nexport type { Props as TabBarItemProps } from './TabBarItem';\n\nexport { default as SceneMap } from './SceneMap';\n\nexport type { Route, NavigationState, SceneRendererProps } from './types';\n"]}
1
+ {"version":3,"names":["default","TabBar","TabView","TabBarIndicator","TabBarItem","SceneMap"],"sources":["index.tsx"],"sourcesContent":["export { default as TabBar } from './TabBar';\nexport type { Props as TabBarProps } from './TabBar';\n\nexport { default as TabView } from './TabView';\nexport type { Props as TabViewProps } from './TabView';\n\nexport { default as TabBarIndicator } from './TabBarIndicator';\nexport type { Props as TabBarIndicatorProps } from './TabBarIndicator';\n\nexport { default as TabBarItem } from './TabBarItem';\nexport type { Props as TabBarItemProps } from './TabBarItem';\n\nexport { default as SceneMap } from './SceneMap';\n\nexport type { Route, NavigationState, SceneRendererProps } from './types';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,MAApB,QAAkC,UAAlC;AAGA,SAASD,OAAO,IAAIE,OAApB,QAAmC,WAAnC;AAGA,SAASF,OAAO,IAAIG,eAApB,QAA2C,mBAA3C;AAGA,SAASH,OAAO,IAAII,UAApB,QAAsC,cAAtC;AAGA,SAASJ,OAAO,IAAIK,QAApB,QAAoC,YAApC"}
@@ -1,2 +1,2 @@
1
-
1
+ export {};
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["types.tsx"],"sourcesContent":["import type { Animated } from 'react-native';\nimport type { PagerViewProps } from 'react-native-pager-view';\n\nexport type Route = {\n key: string;\n icon?: string;\n title?: string;\n accessible?: boolean;\n accessibilityLabel?: string;\n testID?: string;\n};\n\nexport type Event = {\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nexport type Scene<T extends Route> = {\n route: T;\n};\n\nexport type NavigationState<T extends Route> = {\n index: number;\n routes: T[];\n};\n\nexport type Layout = {\n width: number;\n height: number;\n};\n\nexport type Listener = (value: number) => void;\n\nexport type SceneRendererProps = {\n layout: Layout;\n position: Animated.AnimatedInterpolation;\n jumpTo: (key: string) => void;\n};\n\nexport type EventEmitterProps = {\n addEnterListener: (listener: Listener) => () => void;\n};\n\nexport type PagerProps = Omit<\n PagerViewProps,\n | 'initialPage'\n | 'scrollEnabled'\n | 'onPageScroll'\n | 'onPageSelected'\n | 'onPageScrollStateChanged'\n | 'keyboardDismissMode'\n | 'children'\n> & {\n keyboardDismissMode?: 'none' | 'on-drag' | 'auto';\n swipeEnabled?: boolean;\n animationEnabled?: boolean;\n onSwipeStart?: () => void;\n onSwipeEnd?: () => void;\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["useAnimatedValue.tsx"],"names":["React","Animated","useAnimatedValue","initialValue","lazyRef","useRef","current","undefined","Value"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,eAAe,SAASC,gBAAT,CAA0BC,YAA1B,EAAgD;AAC7D,QAAMC,OAAO,GAAGJ,KAAK,CAACK,MAAN,EAAhB;;AAEA,MAAID,OAAO,CAACE,OAAR,KAAoBC,SAAxB,EAAmC;AACjCH,IAAAA,OAAO,CAACE,OAAR,GAAkB,IAAIL,QAAQ,CAACO,KAAb,CAAmBL,YAAnB,CAAlB;AACD;;AAED,SAAOC,OAAO,CAACE,OAAf;AACD","sourcesContent":["import * as React from 'react';\nimport { Animated } from 'react-native';\n\nexport default function useAnimatedValue(initialValue: number) {\n const lazyRef = React.useRef<Animated.Value>();\n\n if (lazyRef.current === undefined) {\n lazyRef.current = new Animated.Value(initialValue);\n }\n\n return lazyRef.current as Animated.Value;\n}\n"]}
1
+ {"version":3,"names":["React","Animated","useAnimatedValue","initialValue","lazyRef","useRef","current","undefined","Value"],"sources":["useAnimatedValue.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Animated } from 'react-native';\n\nexport default function useAnimatedValue(initialValue: number) {\n const lazyRef = React.useRef<Animated.Value>();\n\n if (lazyRef.current === undefined) {\n lazyRef.current = new Animated.Value(initialValue);\n }\n\n return lazyRef.current as Animated.Value;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,eAAe,SAASC,gBAAT,CAA0BC,YAA1B,EAAgD;EAC7D,MAAMC,OAAO,GAAGJ,KAAK,CAACK,MAAN,EAAhB;;EAEA,IAAID,OAAO,CAACE,OAAR,KAAoBC,SAAxB,EAAmC;IACjCH,OAAO,CAACE,OAAR,GAAkB,IAAIL,QAAQ,CAACO,KAAb,CAAmBL,YAAnB,CAAlB;EACD;;EAED,OAAOC,OAAO,CAACE,OAAf;AACD"}
@@ -10,5 +10,5 @@ declare type Props<T extends Route> = PagerProps & {
10
10
  jumpTo: (key: string) => void;
11
11
  }) => React.ReactElement;
12
12
  };
13
- export default function PagerViewAdapter<T extends Route>({ keyboardDismissMode, swipeEnabled, navigationState, onIndexChange, onSwipeStart, onSwipeEnd, children, style, ...rest }: Props<T>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
13
+ export default function PagerViewAdapter<T extends Route>({ keyboardDismissMode, swipeEnabled, navigationState, onIndexChange, onSwipeStart, onSwipeEnd, children, style, animationEnabled, ...rest }: Props<T>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
14
14
  export {};
@@ -11,5 +11,5 @@ declare type Props<T extends Route> = PagerProps & {
11
11
  jumpTo: (key: string) => void;
12
12
  }) => React.ReactElement;
13
13
  };
14
- export default function PanResponderAdapter<T extends Route>({ layout, keyboardDismissMode, swipeEnabled, navigationState, onIndexChange, onSwipeStart, onSwipeEnd, children, style, }: Props<T>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
14
+ export default function PanResponderAdapter<T extends Route>({ layout, keyboardDismissMode, swipeEnabled, navigationState, onIndexChange, onSwipeStart, onSwipeEnd, children, style, animationEnabled, }: Props<T>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
15
15
  export {};
@@ -36,6 +36,7 @@ export declare type Props<T extends Route> = SceneRendererProps & {
36
36
  labelStyle?: StyleProp<TextStyle>;
37
37
  contentContainerStyle?: StyleProp<ViewStyle>;
38
38
  style?: StyleProp<ViewStyle>;
39
+ gap?: number;
39
40
  };
40
41
  declare type State = {
41
42
  layout: Layout;
@@ -50,12 +51,13 @@ export default class TabBar<T extends Route> extends React.Component<Props<T>, S
50
51
  getAccessibilityLabel: ({ route }: Scene<Route>) => string | undefined;
51
52
  getTestID: ({ route }: Scene<Route>) => string | undefined;
52
53
  renderIndicator: (props: IndicatorProps<Route>) => JSX.Element;
54
+ gap: number;
53
55
  };
54
56
  state: State;
55
57
  componentDidUpdate(prevProps: Props<T>, prevState: State): void;
56
58
  private measuredTabWidths;
57
59
  private scrollAmount;
58
- private scrollViewRef;
60
+ private flatListRef;
59
61
  private getFlattenedTabWidth;
60
62
  private getComputedTabWidth;
61
63
  private getMaxScrollDistance;
@@ -7,6 +7,7 @@ export declare type Props<T extends Route> = SceneRendererProps & {
7
7
  width: string | number;
8
8
  style?: StyleProp<ViewStyle>;
9
9
  getTabWidth: GetTabWidth;
10
+ gap?: number;
10
11
  };
11
12
  export default class TabBarIndicator<T extends Route> extends React.Component<Props<T>> {
12
13
  componentDidMount(): void;
@@ -20,6 +20,7 @@ export declare type Props<T extends Route> = PagerProps & {
20
20
  }) => boolean) | boolean;
21
21
  lazyPreloadDistance?: number;
22
22
  sceneContainerStyle?: StyleProp<ViewStyle>;
23
+ pagerStyle?: StyleProp<ViewStyle>;
23
24
  style?: StyleProp<ViewStyle>;
24
25
  };
25
- export default function TabView<T extends Route>({ onIndexChange, navigationState, renderScene, initialLayout, keyboardDismissMode, lazy, lazyPreloadDistance, onSwipeStart, onSwipeEnd, renderLazyPlaceholder, renderTabBar, sceneContainerStyle, style, swipeEnabled, tabBarPosition, }: Props<T>): JSX.Element;
26
+ export default function TabView<T extends Route>({ onIndexChange, navigationState, renderScene, initialLayout, keyboardDismissMode, lazy, lazyPreloadDistance, onSwipeStart, onSwipeEnd, renderLazyPlaceholder, renderTabBar, sceneContainerStyle, pagerStyle, style, swipeEnabled, tabBarPosition, animationEnabled, }: Props<T>): JSX.Element;
@@ -35,6 +35,7 @@ export declare type EventEmitterProps = {
35
35
  export declare type PagerProps = Omit<PagerViewProps, 'initialPage' | 'scrollEnabled' | 'onPageScroll' | 'onPageSelected' | 'onPageScrollStateChanged' | 'keyboardDismissMode' | 'children'> & {
36
36
  keyboardDismissMode?: 'none' | 'on-drag' | 'auto';
37
37
  swipeEnabled?: boolean;
38
+ animationEnabled?: boolean;
38
39
  onSwipeStart?: () => void;
39
40
  onSwipeEnd?: () => void;
40
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-tab-view",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "description": "Tab view component for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "react-native": "src/index.tsx",
@@ -44,26 +44,27 @@
44
44
  },
45
45
  "homepage": "https://github.com/satya164/react-native-tab-view#readme",
46
46
  "devDependencies": {
47
- "@commitlint/config-conventional": "^13.1.0",
48
- "@expo/vector-icons": "^12.0.5",
49
- "@release-it/conventional-changelog": "^3.0.1",
50
- "@types/react": "^17.0.15",
51
- "@types/react-native": "0.64.12",
52
- "babel-jest": "^27.0.6",
47
+ "@commitlint/config-conventional": "^17.1.0",
48
+ "@expo/vector-icons": "^13.0.0",
49
+ "@release-it/conventional-changelog": "^5.1.0",
50
+ "@types/react": "^18.0.14",
51
+ "@types/react-native": "0.69.5",
52
+ "babel-jest": "^29.0.1",
53
+ "babel-loader": "^8.2.5",
53
54
  "babel-preset-react-native": "^4.0.0",
54
- "commitlint": "^13.1.0",
55
- "eslint": "^7.31.0",
56
- "eslint-config-satya164": "^3.1.10",
55
+ "commitlint": "^17.1.2",
56
+ "eslint": "^8.23.0",
57
+ "eslint-config-satya164": "^3.1.11",
57
58
  "eslint-plugin-react-native-globals": "^0.1.2",
58
59
  "husky": "^4.2.5",
59
- "jest": "^27.0.6",
60
- "prettier": "^2.3.2",
61
- "react": "~16.13.1",
62
- "react-native": "~0.63.4",
63
- "react-native-builder-bob": "^0.18.1",
64
- "react-native-pager-view": "^5.0.12",
65
- "release-it": "^14.10.1",
66
- "typescript": "^4.3.5"
60
+ "jest": "^29.0.1",
61
+ "prettier": "^2.7.1",
62
+ "react": "18.0.0",
63
+ "react-native": "0.69.5",
64
+ "react-native-builder-bob": "^0.18.3",
65
+ "react-native-pager-view": "5.4.24",
66
+ "release-it": "^15.4.0",
67
+ "typescript": "^4.8.2"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "react": "*",
@@ -41,6 +41,7 @@ export default function PagerViewAdapter<T extends Route>({
41
41
  onSwipeEnd,
42
42
  children,
43
43
  style,
44
+ animationEnabled,
44
45
  ...rest
45
46
  }: Props<T>) {
46
47
  const { index } = navigationState;
@@ -58,13 +59,21 @@ export default function PagerViewAdapter<T extends Route>({
58
59
  navigationStateRef.current = navigationState;
59
60
  });
60
61
 
61
- const jumpTo = React.useCallback((key: string) => {
62
- const index = navigationStateRef.current.routes.findIndex(
63
- (route: { key: string }) => route.key === key
64
- );
65
-
66
- pagerRef.current?.setPage(index);
67
- }, []);
62
+ const jumpTo = React.useCallback(
63
+ (key: string) => {
64
+ const index = navigationStateRef.current.routes.findIndex(
65
+ (route: { key: string }) => route.key === key
66
+ );
67
+
68
+ if (animationEnabled) {
69
+ pagerRef.current?.setPage(index);
70
+ } else {
71
+ pagerRef.current?.setPageWithoutAnimation(index);
72
+ position.setValue(index);
73
+ }
74
+ },
75
+ [animationEnabled, position]
76
+ );
68
77
 
69
78
  React.useEffect(() => {
70
79
  if (keyboardDismissMode === 'auto') {
@@ -72,9 +81,14 @@ export default function PagerViewAdapter<T extends Route>({
72
81
  }
73
82
 
74
83
  if (indexRef.current !== index) {
75
- pagerRef.current?.setPage(index);
84
+ if (animationEnabled) {
85
+ pagerRef.current?.setPage(index);
86
+ } else {
87
+ pagerRef.current?.setPageWithoutAnimation(index);
88
+ position.setValue(index);
89
+ }
76
90
  }
77
- }, [keyboardDismissMode, index]);
91
+ }, [keyboardDismissMode, index, animationEnabled, position]);
78
92
 
79
93
  const onPageScrollStateChanged = (
80
94
  state: PageScrollStateChangedNativeEvent
@@ -58,6 +58,7 @@ export default function PanResponderAdapter<T extends Route>({
58
58
  onSwipeEnd,
59
59
  children,
60
60
  style,
61
+ animationEnabled = false,
61
62
  }: Props<T>) {
62
63
  const { routes, index } = navigationState;
63
64
 
@@ -76,27 +77,32 @@ export default function PanResponderAdapter<T extends Route>({
76
77
  const swipeDistanceThreshold = layout.width / 1.75;
77
78
 
78
79
  const jumpToIndex = React.useCallback(
79
- (index: number) => {
80
+ (index: number, animate = animationEnabled) => {
80
81
  const offset = -index * layoutRef.current.width;
81
82
 
82
83
  const { timing, ...transitionConfig } = DefaultTransitionSpec;
83
84
 
84
- Animated.parallel([
85
- timing(panX, {
86
- ...transitionConfig,
87
- toValue: offset,
88
- useNativeDriver: false,
89
- }),
90
- ]).start(({ finished }) => {
91
- if (finished) {
92
- onIndexChangeRef.current(index);
93
- pendingIndexRef.current = undefined;
94
- }
95
- });
96
-
97
- pendingIndexRef.current = index;
85
+ if (animate) {
86
+ Animated.parallel([
87
+ timing(panX, {
88
+ ...transitionConfig,
89
+ toValue: offset,
90
+ useNativeDriver: false,
91
+ }),
92
+ ]).start(({ finished }) => {
93
+ if (finished) {
94
+ onIndexChangeRef.current(index);
95
+ pendingIndexRef.current = undefined;
96
+ }
97
+ });
98
+ pendingIndexRef.current = index;
99
+ } else {
100
+ panX.setValue(offset);
101
+ onIndexChangeRef.current(index);
102
+ pendingIndexRef.current = undefined;
103
+ }
98
104
  },
99
- [panX]
105
+ [animationEnabled, panX]
100
106
  );
101
107
 
102
108
  React.useEffect(() => {
@@ -230,7 +236,7 @@ export default function PanResponderAdapter<T extends Route>({
230
236
  nextIndex = currentIndex;
231
237
  }
232
238
 
233
- jumpToIndex(nextIndex);
239
+ jumpToIndex(nextIndex, true);
234
240
  };
235
241
 
236
242
  // TODO: use the listeners