{"version":3,"sources":["BottomTabItem.tsx"],"names":["React","View","Text","TouchableWithoutFeedback","StyleSheet","Platform","Link","useTheme","Color","TabBarIcon","BottomTabBarItem","focused","route","label","icon","badge","badgeStyle","to","button","children","style","onPress","accessibilityRole","rest","OS","styles","e","metaKey","altKey","ctrlKey","shiftKey","preventDefault","accessibilityLabel","testID","onLongPress","horizontal","activeTintColor","customActiveTintColor","inactiveTintColor","customInactiveTintColor","activeBackgroundColor","inactiveBackgroundColor","showLabel","allowFontScaling","labelStyle","iconStyle","colors","undefined","primary","text","mix","card","hex","renderLabel","color","labelBeside","labelBeneath","position","renderIcon","activeOpacity","inactiveOpacity","scene","backgroundColor","accessibilityState","selected","accessibilityStates","tab","tabLandscape","tabPortrait","create","flex","alignItems","justifyContent","flexDirection","textAlign","fontSize","marginLeft","marginTop","display"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SACEC,IADF,EAEEC,IAFF,EAGEC,wBAHF,EAIEC,UAJF,EAKEC,QALF,QAUO,cAVP;AAWA,SAASC,IAAT,EAAsBC,QAAtB,QAAsC,0BAAtC;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,UAAP,MAAuB,cAAvB;AA2GA,eAAe,SAASC,gBAAT,CAA0B;AACvCC,EAAAA,OADuC;AAEvCC,EAAAA,KAFuC;AAGvCC,EAAAA,KAHuC;AAIvCC,EAAAA,IAJuC;AAKvCC,EAAAA,KALuC;AAMvCC,EAAAA,UANuC;AAOvCC,EAAAA,EAPuC;AAQvCC,EAAAA,MAAM,GAAG,CAAC;AACRC,IAAAA,QADQ;AAERC,IAAAA,KAFQ;AAGRC,IAAAA,OAHQ;AAIRJ,IAAAA,EAJQ;AAKRK,IAAAA,iBALQ;AAMR,OAAGC;AANK,GAAD,KAOsB;AAC7B,QAAIlB,QAAQ,CAACmB,EAAT,KAAgB,KAAhB,IAAyBP,EAA7B,EAAiC;AAC/B;AACA;AACA,0BACE,oBAAC,IAAD,eACMM,IADN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IAAI,EAAE,CADH;AAEHC,IAAAA,UAAU,EAAE;AAFT,GAD0B;AAK/BH,EAAAA,WAAW,EAAE;AACXI,IAAAA,cAAc,EAAE,UADL;AAEXC,IAAAA,aAAa,EAAE;AAFJ,GALkB;AAS/BN,EAAAA,YAAY,EAAE;AACZK,IAAAA,cAAc,EAAE,QADJ;AAEZC,IAAAA,aAAa,EAAE;AAFH,GATiB;AAa/B5D,EAAAA,KAAK,EAAE;AACL6D,IAAAA,SAAS,EAAE,QADN;AAELZ,IAAAA,eAAe,EAAE;AAFZ,GAbwB;AAiB/BN,EAAAA,YAAY,EAAE;AACZmB,IAAAA,QAAQ,EAAE;AADE,GAjBiB;AAoB/BpB,EAAAA,WAAW,EAAE;AACXoB,IAAAA,QAAQ,EAAE,EADC;AAEXC,IAAAA,UAAU,EAAE,EAFD;AAGXC,IAAAA,SAAS,EAAE;AAHA,GApBkB;AAyB/B3D,EAAAA,MAAM,EAAE;AACN4D,IAAAA,OAAO,EAAE;AADH;AAzBuB,CAAlB,CAAf","sourcesContent":["import React from 'react';\nimport {\n View,\n Text,\n TouchableWithoutFeedback,\n StyleSheet,\n Platform,\n StyleProp,\n ViewStyle,\n TextStyle,\n GestureResponderEvent,\n} from 'react-native';\nimport { Link, Route, useTheme } from '@react-navigation/native';\nimport Color from 'color';\n\nimport TabBarIcon from './TabBarIcon';\nimport type { BottomTabBarButtonProps, LabelPosition } from '../types';\n\ntype Props = {\n /**\n * Whether the tab is focused.\n */\n focused: boolean;\n /**\n * The route object which should be specified by the tab.\n */\n route: Route;\n /**\n * The label text of the tab.\n */\n label:\n | string\n | ((props: {\n focused: boolean;\n color: string;\n position: LabelPosition;\n }) => React.ReactNode);\n /**\n * Icon to display for the tab.\n */\n icon?: (props: {\n focused: boolean;\n size: number;\n color: string;\n }) => React.ReactNode;\n /**\n * Text to show in a badge on the tab icon.\n */\n badge?: number | string;\n /**\n * Custom style for the badge.\n */\n badgeStyle?: StyleProp;\n /**\n * URL to use for the link to the tab.\n */\n to?: string;\n /**\n * The button for the tab. Uses a `TouchableWithoutFeedback` by default.\n */\n button?: (props: BottomTabBarButtonProps) => React.ReactNode;\n /**\n * The accessibility label for the tab.\n */\n accessibilityLabel?: string;\n /**\n * An unique ID for testing for the tab.\n */\n testID?: string;\n /**\n * Function to execute on press in React Native.\n * On the web, this will use onClick.\n */\n onPress: (\n e: React.MouseEvent | GestureResponderEvent\n ) => void;\n /**\n * Function to execute on long press.\n */\n onLongPress: (e: GestureResponderEvent) => void;\n /**\n * Whether the label should be aligned with the icon horizontally.\n */\n horizontal: boolean;\n /**\n * Color for the icon and label when the item is active.\n */\n activeTintColor?: string;\n /**\n * Color for the icon and label when the item is inactive.\n */\n inactiveTintColor?: string;\n /**\n * Background color for item when its active.\n */\n activeBackgroundColor?: string;\n /**\n * Background color for item when its inactive.\n */\n inactiveBackgroundColor?: string;\n /**\n * Whether to show the label text for the tab.\n */\n showLabel?: boolean;\n /**\n * Whether to allow scaling the font for the label for accessibility purposes.\n */\n allowFontScaling?: boolean;\n /**\n * Style object for the label element.\n */\n labelStyle?: StyleProp;\n /**\n * Style object for the icon element.\n */\n iconStyle?: StyleProp;\n /**\n * Style object for the wrapper element.\n */\n style?: StyleProp;\n};\n\nexport default function BottomTabBarItem({\n focused,\n route,\n label,\n icon,\n badge,\n badgeStyle,\n to,\n button = ({\n children,\n style,\n onPress,\n to,\n accessibilityRole,\n ...rest\n }: BottomTabBarButtonProps) => {\n if (Platform.OS === 'web' && to) {\n // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.\n // We need to use `onClick` to be able to prevent default browser handling of links.\n return (\n {\n if (\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n (e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress?.(e);\n }\n }}\n >\n {children}\n \n );\n } else {\n return (\n \n {children}\n \n );\n }\n },\n accessibilityLabel,\n testID,\n onPress,\n onLongPress,\n horizontal,\n activeTintColor: customActiveTintColor,\n inactiveTintColor: customInactiveTintColor,\n activeBackgroundColor = 'transparent',\n inactiveBackgroundColor = 'transparent',\n showLabel = true,\n allowFontScaling,\n labelStyle,\n iconStyle,\n style,\n}: Props) {\n const { colors } = useTheme();\n\n const activeTintColor =\n customActiveTintColor === undefined\n ? colors.primary\n : customActiveTintColor;\n\n const inactiveTintColor =\n customInactiveTintColor === undefined\n ? Color(colors.text).mix(Color(colors.card), 0.5).hex()\n : customInactiveTintColor;\n\n const renderLabel = ({ focused }: { focused: boolean }) => {\n if (showLabel === false) {\n return null;\n }\n\n const color = focused ? activeTintColor : inactiveTintColor;\n\n if (typeof label === 'string') {\n return (\n \n {label}\n \n );\n }\n\n return label({\n focused,\n color,\n position: horizontal ? 'beside-icon' : 'below-icon',\n });\n };\n\n const renderIcon = ({ focused }: { focused: boolean }) => {\n if (icon === undefined) {\n return null;\n }\n\n const activeOpacity = focused ? 1 : 0;\n const inactiveOpacity = focused ? 0 : 1;\n\n return (\n \n );\n };\n\n const scene = { route, focused };\n\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n\n return button({\n to,\n onPress,\n onLongPress,\n testID,\n accessibilityLabel,\n accessibilityRole: 'button',\n accessibilityState: { selected: focused },\n // @ts-expect-error: keep for compatibility with older React Native versions\n accessibilityStates: focused ? ['selected'] : [],\n style: [\n styles.tab,\n { backgroundColor },\n horizontal ? styles.tabLandscape : styles.tabPortrait,\n style,\n ],\n children: (\n \n {renderIcon(scene)}\n {renderLabel(scene)}\n \n ),\n }) as React.ReactElement;\n}\n\nconst styles = StyleSheet.create({\n tab: {\n flex: 1,\n alignItems: 'center',\n },\n tabPortrait: {\n justifyContent: 'flex-end',\n flexDirection: 'column',\n },\n tabLandscape: {\n justifyContent: 'center',\n flexDirection: 'row',\n },\n label: {\n textAlign: 'center',\n backgroundColor: 'transparent',\n },\n labelBeneath: {\n fontSize: 10,\n },\n labelBeside: {\n fontSize: 13,\n marginLeft: 20,\n marginTop: 3,\n },\n button: {\n display: 'flex',\n },\n});\n"]}