a76fcf81615df9f3b7d2bb04b17970e3.json
20.7 KB
{"ast":null,"code":"var _interopRequireWildcard=require(\"@babel/runtime/helpers/interopRequireWildcard\");var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require(\"@babel/runtime/helpers/classCallCheck\"));var _createClass2=_interopRequireDefault(require(\"@babel/runtime/helpers/createClass\"));var _possibleConstructorReturn2=_interopRequireDefault(require(\"@babel/runtime/helpers/possibleConstructorReturn\"));var _getPrototypeOf3=_interopRequireDefault(require(\"@babel/runtime/helpers/getPrototypeOf\"));var _inherits2=_interopRequireDefault(require(\"@babel/runtime/helpers/inherits\"));var React=_interopRequireWildcard(require(\"react\"));var _StyleSheet=_interopRequireDefault(require(\"react-native-web/dist/exports/StyleSheet\"));var _View=_interopRequireDefault(require(\"react-native-web/dist/exports/View\"));var _TouchableItem=_interopRequireDefault(require(\"./TouchableItem\"));var _reactNativeReanimated=_interopRequireDefault(require(\"react-native-reanimated\"));var _memoize=_interopRequireDefault(require(\"./memoize\"));var _jsxFileName=\"/Users/satya/Workspace/Projects/react-native-tab-view/src/TabBarItem.tsx\";var DEFAULT_ACTIVE_COLOR='rgba(255, 255, 255, 1)';var DEFAULT_INACTIVE_COLOR='rgba(255, 255, 255, 0.7)';var TabBarItem=function(_React$Component){(0,_inherits2.default)(TabBarItem,_React$Component);function TabBarItem(){var _getPrototypeOf2;var _this;(0,_classCallCheck2.default)(this,TabBarItem);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=(0,_possibleConstructorReturn2.default)(this,(_getPrototypeOf2=(0,_getPrototypeOf3.default)(TabBarItem)).call.apply(_getPrototypeOf2,[this].concat(args)));_this.getActiveOpacity=(0,_memoize.default)(function(position,routes,tabIndex){if(routes.length>1){var inputRange=routes.map(function(_,i){return i;});return _reactNativeReanimated.default.interpolate(position,{inputRange:inputRange,outputRange:inputRange.map(function(i){return i===tabIndex?1:0;})});}else{return 1;}});_this.getInactiveOpacity=(0,_memoize.default)(function(position,routes,tabIndex){if(routes.length>1){var inputRange=routes.map(function(_,i){return i;});return _reactNativeReanimated.default.interpolate(position,{inputRange:inputRange,outputRange:inputRange.map(function(i){return i===tabIndex?0:1;})});}else{return 0;}});return _this;}(0,_createClass2.default)(TabBarItem,[{key:\"render\",value:function render(){var _this$props=this.props,route=_this$props.route,position=_this$props.position,navigationState=_this$props.navigationState,renderLabelPassed=_this$props.renderLabel,renderIcon=_this$props.renderIcon,renderBadge=_this$props.renderBadge,getLabelText=_this$props.getLabelText,getTestID=_this$props.getTestID,getAccessibilityLabel=_this$props.getAccessibilityLabel,getAccessible=_this$props.getAccessible,_this$props$activeCol=_this$props.activeColor,activeColor=_this$props$activeCol===void 0?DEFAULT_ACTIVE_COLOR:_this$props$activeCol,_this$props$inactiveC=_this$props.inactiveColor,inactiveColor=_this$props$inactiveC===void 0?DEFAULT_INACTIVE_COLOR:_this$props$inactiveC,pressColor=_this$props.pressColor,pressOpacity=_this$props.pressOpacity,labelStyle=_this$props.labelStyle,style=_this$props.style,onLayout=_this$props.onLayout,onPress=_this$props.onPress,onLongPress=_this$props.onLongPress;var tabIndex=navigationState.routes.indexOf(route);var isFocused=navigationState.index===tabIndex;var activeOpacity=this.getActiveOpacity(position,navigationState.routes,tabIndex);var inactiveOpacity=this.getInactiveOpacity(position,navigationState.routes,tabIndex);var icon=null;var label=null;if(renderIcon){var activeIcon=renderIcon({route:route,focused:true,color:activeColor});var inactiveIcon=renderIcon({route:route,focused:false,color:inactiveColor});if(inactiveIcon!=null&&activeIcon!=null){icon=React.createElement(_View.default,{style:styles.icon,__source:{fileName:_jsxFileName,lineNumber:133}},React.createElement(_reactNativeReanimated.default.View,{style:{opacity:inactiveOpacity},__source:{fileName:_jsxFileName,lineNumber:134}},inactiveIcon),React.createElement(_reactNativeReanimated.default.View,{style:[_StyleSheet.default.absoluteFill,{opacity:activeOpacity}],__source:{fileName:_jsxFileName,lineNumber:137}},activeIcon));}}var renderLabel=renderLabelPassed!==undefined?renderLabelPassed:function(_ref){var route=_ref.route,color=_ref.color;var labelText=getLabelText({route:route});if(typeof labelText==='string'){return React.createElement(_reactNativeReanimated.default.Text,{style:[styles.label,icon?{marginTop:0}:null,{color:color},labelStyle],__source:{fileName:_jsxFileName,lineNumber:155}},labelText);}return labelText;};if(renderLabel){var activeLabel=renderLabel({route:route,focused:true,color:activeColor});var inactiveLabel=renderLabel({route:route,focused:false,color:inactiveColor});label=React.createElement(_View.default,{__source:{fileName:_jsxFileName,lineNumber:185}},React.createElement(_reactNativeReanimated.default.View,{style:{opacity:inactiveOpacity},__source:{fileName:_jsxFileName,lineNumber:186}},inactiveLabel),React.createElement(_reactNativeReanimated.default.View,{style:[_StyleSheet.default.absoluteFill,{opacity:activeOpacity}],__source:{fileName:_jsxFileName,lineNumber:189}},activeLabel));}var tabStyle=_StyleSheet.default.flatten(style);var isWidthSet=tabStyle&&tabStyle.width!==undefined;var tabContainerStyle=isWidthSet?null:{flex:1};var scene={route:route};var accessibilityLabel=getAccessibilityLabel(scene);accessibilityLabel=typeof accessibilityLabel!=='undefined'?accessibilityLabel:getLabelText(scene);var badge=renderBadge?renderBadge(scene):null;return React.createElement(_TouchableItem.default,{borderless:true,testID:getTestID(scene),accessible:getAccessible(scene),accessibilityLabel:accessibilityLabel,accessibilityTraits:isFocused?['button','selected']:'button',accessibilityComponentType:\"button\",accessibilityRole:\"button\",accessibilityStates:isFocused?['selected']:[],pressColor:pressColor,pressOpacity:pressOpacity,delayPressIn:0,onLayout:onLayout,onPress:onPress,onLongPress:onLongPress,style:tabContainerStyle,__source:{fileName:_jsxFileName,lineNumber:214}},React.createElement(_View.default,{pointerEvents:\"none\",style:[styles.item,tabStyle],__source:{fileName:_jsxFileName,lineNumber:231}},icon,label,badge!=null?React.createElement(_View.default,{style:styles.badge,__source:{fileName:_jsxFileName,lineNumber:234}},badge):null));}}]);return TabBarItem;}(React.Component);exports.default=TabBarItem;var styles=_StyleSheet.default.create({label:{margin:4,backgroundColor:'transparent'},icon:{margin:2},item:{flex:1,alignItems:'center',justifyContent:'center',padding:10,minHeight:48},badge:{position:'absolute',top:0,right:0}});","map":{"version":3,"sources":["TabBarItem.tsx"],"names":["DEFAULT_ACTIVE_COLOR","DEFAULT_INACTIVE_COLOR","TabBarItem","React","getActiveOpacity","memoize","routes","inputRange","Animated","outputRange","i","getInactiveOpacity","route","position","navigationState","renderLabelPassed","renderIcon","renderBadge","getLabelText","getTestID","getAccessibilityLabel","getAccessible","activeColor","inactiveColor","pressColor","pressOpacity","labelStyle","style","onLayout","onPress","onLongPress","tabIndex","isFocused","activeOpacity","inactiveOpacity","icon","label","activeIcon","focused","color","inactiveIcon","styles","opacity","StyleSheet","renderLabel","labelText","marginTop","activeLabel","inactiveLabel","tabStyle","isWidthSet","tabContainerStyle","flex","scene","accessibilityLabel","badge","margin","backgroundColor","item","alignItems","justifyContent","padding","minHeight","top","right"],"mappings":"ktBAAA,oD,4KASA,sEAEA,sFACA,0D,4FAgCA,GAAMA,CAAAA,oBAAoB,CAA1B,wBAAA,CACA,GAAMC,CAAAA,sBAAsB,CAA5B,0BAAA,CAEqBC,GAAAA,CAAAA,U,kcAGXE,gB,CAAmBC,qBACzB,SAAA,QAAA,CAAA,MAAA,CAAA,QAAA,CAAwE,CACtE,GAAIC,MAAM,CAANA,MAAAA,CAAJ,CAAA,CAAuB,CACrB,GAAMC,CAAAA,UAAU,CAAGD,MAAM,CAANA,GAAAA,CAAW,SAAA,CAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAA9B,CAAmBA,CAAnB,CAEA,MAAOE,gCAAAA,WAAAA,CAAAA,QAAAA,CAA+B,CACpCD,UAAU,CAD0B,UAAA,CAEpCE,WAAW,CAAEF,UAAU,CAAVA,GAAAA,CAAe,SAAA,CAAA,CAAC,CAAA,MAAKG,CAAAA,CAAC,GAADA,QAAAA,CAAAA,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AA,CAAA,QAAA,CAAA,YAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,CAAhBc,KAAgB,CAAhBA,CArBP,IAkBI,CAjBF,CADF,C,yBArKqDpD,KAAK,CAAzCD,S,CAAAA,C,2BAiMrB,GAAMuC,CAAAA,MAAM,CAAGE,oBAAAA,MAAAA,CAAkB,CAC/BP,KAAK,CAAE,CACLoB,MAAM,CADD,CAAA,CAELC,eAAe,CAHc,aACxB,CADwB,CAK/BtB,IAAI,CAAE,CACJqB,MAAM,CANuB,CAKzB,CALyB,CAQ/BE,IAAI,CAAE,CACJN,IAAI,CADA,CAAA,CAEJO,UAAU,CAFN,QAAA,CAGJC,cAAc,CAHV,QAAA,CAIJC,OAAO,CAJH,EAAA,CAKJC,SAAS,CAboB,EAQzB,CARyB,CAe/BP,KAAK,CAAE,CACL1C,QAAQ,CADH,UAAA,CAELkD,GAAG,CAFE,CAAA,CAGLC,KAAK,CAlBT,CAeS,CAfwB,CAAlBrB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n StyleSheet,\n View,\n StyleProp,\n LayoutChangeEvent,\n TextStyle,\n ViewStyle,\n} from 'react-native';\nimport TouchableItem from './TouchableItem';\nimport { Scene, Route, NavigationState } from './types';\nimport Animated from 'react-native-reanimated';\nimport memoize from './memoize';\n\ntype Props<T extends Route> = {\n position: Animated.Node<number>;\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 = memoize(\n (position: Animated.Node<number>, routes: Route[], tabIndex: number) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_, i) => i);\n\n return Animated.interpolate(position, {\n inputRange,\n outputRange: inputRange.map(i => (i === tabIndex ? 1 : 0)),\n });\n } else {\n return 1;\n }\n }\n );\n\n private getInactiveOpacity = memoize((position, routes, tabIndex) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_: Route, i: number) => i);\n\n return Animated.interpolate(position, {\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: renderLabelPassed,\n renderIcon,\n renderBadge,\n getLabelText,\n getTestID,\n getAccessibilityLabel,\n getAccessible,\n activeColor = DEFAULT_ACTIVE_COLOR,\n inactiveColor = DEFAULT_INACTIVE_COLOR,\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 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 renderLabelPassed !== undefined\n ? renderLabelPassed\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 // eslint-disable-next-line react-native/no-inline-styles\n icon ? { marginTop: 0 } : null,\n { color },\n labelStyle,\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 && 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 <TouchableItem\n borderless\n testID={getTestID(scene)}\n accessible={getAccessible(scene)}\n accessibilityLabel={accessibilityLabel}\n accessibilityTraits={isFocused ? ['button', 'selected'] : 'button'}\n accessibilityComponentType=\"button\"\n accessibilityRole=\"button\"\n accessibilityStates={isFocused ? ['selected'] : []}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n delayPressIn={0}\n onLayout={onLayout}\n onPress={onPress}\n onLongPress={onLongPress}\n style={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 </TouchableItem>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n label: {\n margin: 4,\n backgroundColor: 'transparent',\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});\n"]},"metadata":{},"sourceType":"script"}