You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
18 KiB

{"ast":null,"code":"import _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nvar _excluded = [\"children\", \"style\", \"onPress\", \"to\", \"accessibilityRole\"];\nfunction _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport React from 'react';\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport Pressable from \"react-native-web/dist/exports/Pressable\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport Text from \"react-native-web/dist/exports/Text\";\nimport TabBarIcon from \"./TabBarIcon\";\nexport default function BottomTabBarItem(_ref) {\n var focused = _ref.focused,\n route = _ref.route,\n descriptor = _ref.descriptor,\n label = _ref.label,\n icon = _ref.icon,\n badge = _ref.badge,\n badgeStyle = _ref.badgeStyle,\n to = _ref.to,\n _ref$button = _ref.button,\n button = _ref$button === void 0 ? function (_ref2) {\n var children = _ref2.children,\n style = _ref2.style,\n _onPress = _ref2.onPress,\n to = _ref2.to,\n accessibilityRole = _ref2.accessibilityRole,\n rest = _objectWithoutProperties(_ref2, _excluded);\n if (Platform.OS === 'web' && to) {\n return React.createElement(Link, _extends({}, rest, {\n to: to,\n style: [styles.button, style],\n onPress: function onPress(e) {\n if (!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && (e.button == null || e.button === 0)) {\n e.preventDefault();\n _onPress === null || _onPress === void 0 ? void 0 : _onPress(e);\n }\n }\n }), children);\n } else {\n return React.createElement(Pressable, _extends({}, rest, {\n accessibilityRole: accessibilityRole,\n onPress: _onPress,\n style: style\n }), children);\n }\n } : _ref$button,\n accessibilityLabel = _ref.accessibilityLabel,\n testID = _ref.testID,\n onPress = _ref.onPress,\n onLongPress = _ref.onLongPress,\n horizontal = _ref.horizontal,\n customActiveTintColor = _ref.activeTintColor,\n customInactiveTintColor = _ref.inactiveTintColor,\n _ref$activeBackground = _ref.activeBackgroundColor,\n activeBackgroundColor = _ref$activeBackground === void 0 ? 'transparent' : _ref$activeBackground,\n _ref$inactiveBackgrou = _ref.inactiveBackgroundColor,\n inactiveBackgroundColor = _ref$inactiveBackgrou === void 0 ? 'transparent' : _ref$inactiveBackgrou,\n _ref$showLabel = _ref.showLabel,\n showLabel = _ref$showLabel === void 0 ? true : _ref$showLabel,\n allowFontScaling = _ref.allowFontScaling,\n labelStyle = _ref.labelStyle,\n iconStyle = _ref.iconStyle,\n style = _ref.style;\n var _useTheme = useTheme(),\n colors = _useTheme.colors;\n var activeTintColor = customActiveTintColor === undefined ? colors.primary : customActiveTintColor;\n var inactiveTintColor = customInactiveTintColor === undefined ? Color(colors.text).mix(Color(colors.card), 0.5).hex() : customInactiveTintColor;\n var renderLabel = function renderLabel(_ref3) {\n var focused = _ref3.focused;\n if (showLabel === false) {\n return null;\n }\n var color = focused ? activeTintColor : inactiveTintColor;\n if (typeof label === 'string') {\n return React.createElement(Text, {\n numberOfLines: 1,\n style: [styles.label, {\n color: color\n }, horizontal ? styles.labelBeside : styles.labelBeneath, labelStyle],\n allowFontScaling: allowFontScaling\n }, label);\n }\n var options = descriptor.options;\n var children = typeof options.tabBarLabel === 'string' ? options.tabBarLabel : options.title !== undefined ? options.title : route.name;\n return label({\n focused: focused,\n color: color,\n position: horizontal ? 'beside-icon' : 'below-icon',\n children: children\n });\n };\n var renderIcon = function renderIcon(_ref4) {\n var focused = _ref4.focused;\n if (icon === undefined) {\n return null;\n }\n var activeOpacity = focused ? 1 : 0;\n var inactiveOpacity = focused ? 0 : 1;\n return React.createElement(TabBarIcon, {\n route: route,\n horizontal: horizontal,\n badge: badge,\n badgeStyle: badgeStyle,\n activeOpacity: activeOpacity,\n inactiveOpacity: inactiveOpacity,\n activeTintColor: activeTintColor,\n inactiveTintColor: inactiveTintColor,\n renderIcon: icon,\n style: iconStyle\n });\n };\n var scene = {\n route: route,\n focused: focused\n };\n var backgroundColor = focused ? activeBackgroundColor : inactiveBackgroundColor;\n return button({\n to: to,\n onPress: onPress,\n onLongPress: onLongPress,\n testID: testID,\n accessibilityLabel: accessibilityLabel,\n accessibilityRole: Platform.select({\n ios: 'button',\n default: 'tab'\n }),\n accessibilityState: {\n selected: focused\n },\n accessibilityStates: focused ? ['selected'] : [],\n style: [styles.tab, {\n backgroundColor: backgroundColor\n }, horizontal ? styles.tabLandscape : styles.tabPortrait, style],\n children: React.createElement(React.Fragment, null, renderIcon(scene), renderLabel(scene))\n });\n}\nvar 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});","map":{"version":3,"sources":["BottomTabItem.tsx"],"names":["Link","useTheme","Color","React","TabBarIcon","BottomTabBarItem","focused","route","descriptor","label","icon","badge","badgeStyle","to","button","children","style","onPress","accessibilityRole","rest","Platform","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","options","tabBarLabel","title","name","position","renderIcon","activeOpacity","inactiveOpacity","scene","backgroundColor","select","ios","default","accessibilityState","selected","accessibilityStates","tab","tabLandscape","tabPortrait","StyleSheet","create","flex","alignIt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AO,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE;IAChDU,KAAK,EAAE,CACLM,MAAM,CAACgD,GAAG,EACV;MAAEP,eAAAA,EAAAA;IAAgB,CAAC,EACnB/B,UAAU,GAAGV,MAAM,CAACiD,YAAY,GAAGjD,MAAM,CAACkD,WAAW,EACrDxD,KAAK,CACN;IACDD,QAAQ,EACN,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,QAAQ,EAAA,IAAA,EACZ4C,UAAU,CAACG,KAAK,CAAC,EACjBZ,WAAW,CAACY,KAAK,CAAC;EAGzB,CAAC,CAAC;AACJ;AAEA,IAAMxC,MAAM,GAAGmD,UAAU,CAACC,MAAM,CAAC;EAC/BJ,GAAG,EAAE;IACHK,IAAI,EAAE,CAAC;IACPC,UAAU,EAAE;EACd,CAAC;EACDJ,WAAW,EAAE;IACXK,cAAc,EAAE,UAAU;IAC1BC,aAAa,EAAE;EACjB,CAAC;EACDP,YAAY,EAAE;IACZM,cAAc,EAAE,QAAQ;IACxBC,aAAa,EAAE;EACjB,CAAC;EACDrE,KAAK,EAAE;IACLsE,SAAS,EAAE,QAAQ;IACnBhB,eAAe,EAAE;EACnB,CAAC;EACDV,YAAY,EAAE;IACZ2B,QAAQ,EAAE;EACZ,CAAC;EACD5B,WAAW,EAAE;IACX4B,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,EAAE;IACdC,SAAS,EAAE;EACb,CAAC;EACDpE,MAAM,EAAE;IACNqE,OAAO,EAAE;EACX;AACF,CAAC,CAAC","sourceRoot":"../../src","sourcesContent":["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); }\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport React from 'react';\nimport { Platform, Pressable, StyleSheet, Text } from 'react-native';\nimport TabBarIcon from './TabBarIcon';\nexport default function BottomTabBarItem(_ref) {\n let {\n focused,\n route,\n descriptor,\n label,\n icon,\n badge,\n badgeStyle,\n to,\n button = _ref2 => {\n let {\n children,\n style,\n onPress,\n to,\n accessibilityRole,\n ...rest\n } = _ref2;\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 /*#__PURE__*/React.createElement(Link, _extends({}, rest, {\n to: to,\n style: [styles.button, style],\n onPress: e => {\n if (!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && (\n // ignore clicks with modifier keys\n e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress === null || onPress === void 0 ? void 0 : onPress(e);\n }\n }\n }), children);\n } else {\n return /*#__PURE__*/React.createElement(Pressable, _extends({}, rest, {\n accessibilityRole: accessibilityRole,\n onPress: onPress,\n style: style\n }), children);\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 } = _ref;\n const {\n colors\n } = useTheme();\n const activeTintColor = customActiveTintColor === undefined ? colors.primary : customActiveTintColor;\n const inactiveTintColor = customInactiveTintColor === undefined ? Color(colors.text).mix(Color(colors.card), 0.5).hex() : customInactiveTintColor;\n const renderLabel = _ref3 => {\n let {\n focused\n } = _ref3;\n if (showLabel === false) {\n return null;\n }\n const color = focused ? activeTintColor : inactiveTintColor;\n if (typeof label === 'string') {\n return /*#__PURE__*/React.createElement(Text, {\n numberOfLines: 1,\n style: [styles.label, {\n color\n }, horizontal ? styles.labelBeside : styles.labelBeneath, labelStyle],\n allowFontScaling: allowFontScaling\n }, label);\n }\n const {\n options\n } = descriptor;\n const children = typeof options.tabBarLabel === 'string' ? options.tabBarLabel : options.title !== undefined ? options.title : route.name;\n return label({\n focused,\n color,\n position: horizontal ? 'beside-icon' : 'below-icon',\n children\n });\n };\n const renderIcon = _ref4 => {\n let {\n focused\n } = _ref4;\n if (icon === undefined) {\n return null;\n }\n const activeOpacity = focused ? 1 : 0;\n const inactiveOpacity = focused ? 0 : 1;\n return /*#__PURE__*/React.createElement(TabBarIcon, {\n route: route,\n horizontal: horizontal,\n badge: badge,\n badgeStyle: badgeStyle,\n activeOpacity: activeOpacity,\n inactiveOpacity: inactiveOpacity,\n activeTintColor: activeTintColor,\n inactiveTintColor: inactiveTintColor,\n renderIcon: icon,\n style: iconStyle\n });\n };\n const scene = {\n route,\n focused\n };\n const backgroundColor = focused ? activeBackgroundColor : inactiveBackgroundColor;\n return button({\n to,\n onPress,\n onLongPress,\n testID,\n accessibilityLabel,\n // FIXME: accessibilityRole: 'tab' doesn't seem to work as expected on iOS\n accessibilityRole: Platform.select({\n ios: 'button',\n default: 'tab'\n }),\n accessibilityState: {\n selected: focused\n },\n // @ts-expect-error: keep for compatibility with older React Native versions\n accessibilityStates: focused ? ['selected'] : [],\n style: [styles.tab, {\n backgroundColor\n }, horizontal ? styles.tabLandscape : styles.tabPortrait, style],\n children: /*#__PURE__*/React.createElement(React.Fragment, null, renderIcon(scene), renderLabel(scene))\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//# sourceMappingURL=BottomTabItem.js.map"]},"metadata":{},"sourceType":"module"}