UNPKG

5.95 kBSource Map (JSON)View Raw
1{"version":3,"sources":["AppbarContent.tsx"],"names":["React","Platform","StyleSheet","TouchableWithoutFeedback","View","color","Text","withTheme","white","AppbarContent","titleColor","subtitle","subtitleStyle","onPress","style","titleRef","titleStyle","theme","title","rest","fonts","subtitleColor","alpha","rgb","string","styles","container","OS","regular","medium","displayName","create","flex","paddingHorizontal","fontSize","AppbarContentWithTheme"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAGEC,UAHF,EAKEC,wBALF,EAMEC,IANF,QAQO,cARP;AASA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,IAAP,MAAiB,oBAAjB;AAEA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,KAAT,QAAsB,qBAAtB;;AAwCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,QAWT;AAAA,MAXU;AACrBJ,IAAAA,KAAK,EAAEK,UAAU,GAAGF,KADC;AAErBG,IAAAA,QAFqB;AAGrBC,IAAAA,aAHqB;AAIrBC,IAAAA,OAJqB;AAKrBC,IAAAA,KALqB;AAMrBC,IAAAA,QANqB;AAOrBC,IAAAA,UAPqB;AAQrBC,IAAAA,KARqB;AASrBC,IAAAA,KATqB;AAUrB,OAAGC;AAVkB,GAWV;AACX,QAAM;AAAEC,IAAAA;AAAF,MAAYH,KAAlB;AAEA,QAAMI,aAAa,GAAGhB,KAAK,CAACK,UAAD,CAAL,CAAkBY,KAAlB,CAAwB,GAAxB,EAA6BC,GAA7B,GAAmCC,MAAnC,EAAtB;AAEA,sBACE,oBAAC,wBAAD;AAA0B,IAAA,OAAO,EAAEX,OAAnC;AAA4C,IAAA,QAAQ,EAAE,CAACA;AAAvD,kBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE,CAACY,MAA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,CAAlB,CAAf;AAaA,eAAepB,SAAS,CAACE,aAAD,CAAxB,C,CAEA;;AACA,MAAM0B,sBAAsB,GAAG5B,SAAS,CAACE,aAAD,CAAxC,C,CACA;;AACA,SAAS0B,sBAAsB,IAAI1B,aAAnC","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n StyleProp,\n StyleSheet,\n TextStyle,\n TouchableWithoutFeedback,\n View,\n ViewStyle,\n} from 'react-native';\nimport color from 'color';\n\nimport Text from '../Typography/Text';\n\nimport { withTheme } from '../../core/theming';\nimport { white } from '../../styles/colors';\n\nimport type { $RemoveChildren } from '../../types';\n\ntype Props = $RemoveChildren<typeof View> & {\n /**\n * Custom color for the text.\n */\n color?: string;\n /**\n * Text for the title.\n */\n title: React.ReactNode;\n /**\n * Style for the title.\n */\n titleStyle?: StyleProp<TextStyle>;\n /**\n * Reference for the title.\n */\n titleRef?: React.RefObject<Text>;\n /**\n * Text for the subtitle.\n */\n subtitle?: React.ReactNode;\n /**\n * Style for the subtitle.\n */\n subtitleStyle?: StyleProp<TextStyle>;\n /**\n * Function to execute on press.\n */\n onPress?: () => void;\n style?: StyleProp<ViewStyle>;\n /**\n * @optional\n */\n theme: ReactNativePaper.Theme;\n};\n\n/**\n * A component used to display a title and optional subtitle in an appbar.\n *\n * <div class=\"screenshots\">\n * <figure>\n * <img class=\"medium\" src=\"screenshots/appbar-content.png\" />\n * </figure>\n * </div>\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { Appbar } from 'react-native-paper';\n *\n * const MyComponent = () => (\n * <Appbar.Header>\n * <Appbar.Content title=\"Title\" subtitle={'Subtitle'} />\n * </Appbar.Header>\n * );\n *\n * export default MyComponent;\n * ```\n */\nconst AppbarContent = ({\n color: titleColor = white,\n subtitle,\n subtitleStyle,\n onPress,\n style,\n titleRef,\n titleStyle,\n theme,\n title,\n ...rest\n}: Props) => {\n const { fonts } = theme;\n\n const subtitleColor = color(titleColor).alpha(0.7).rgb().string();\n\n return (\n <TouchableWithoutFeedback onPress={onPress} disabled={!onPress}>\n <View style={[styles.container, style]} {...rest}>\n <Text\n ref={titleRef}\n style={[\n {\n color: titleColor,\n ...(Platform.OS === 'ios' ? fonts.regular : fonts.medium),\n },\n styles.title,\n titleStyle,\n ]}\n numberOfLines={1}\n accessible\n accessibilityTraits=\"header\"\n // @ts-expect-error React Native doesn't accept 'heading' as it's web-only\n accessibilityRole={Platform.OS === 'web' ? 'heading' : 'header'}\n >\n {title}\n </Text>\n {subtitle ? (\n <Text\n style={[styles.subtitle, { color: subtitleColor }, subtitleStyle]}\n numberOfLines={1}\n >\n {subtitle}\n </Text>\n ) : null}\n </View>\n </TouchableWithoutFeedback>\n );\n};\n\nAppbarContent.displayName = 'Appbar.Content';\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n paddingHorizontal: 12,\n },\n title: {\n fontSize: Platform.OS === 'ios' ? 17 : 20,\n },\n subtitle: {\n fontSize: Platform.OS === 'ios' ? 11 : 14,\n },\n});\n\nexport default withTheme(AppbarContent);\n\n// @component-docs ignore-next-line\nconst AppbarContentWithTheme = withTheme(AppbarContent);\n// @component-docs ignore-next-line\nexport { AppbarContentWithTheme as AppbarContent };\n"]}
\No newline at end of file