react-native-cross-components
Version:
Beautiful React-Native components using RN Paper by Callstack
1 lines • 6.48 kB
Source Map (JSON)
{"file":"/Users/thomas/Source/react-native-core/source/components/labels/CrossLabel.tsx","mappings":";;;;;AAAA,kDAAyC;AACzC,+CAMsB;AACtB,2DAO4B;AAC5B,0DAAkC;AAClC,oDAAuB;AAiCvB;;GAEG;AACH,MAAM,aAAc,SAAQ,eAAK,CAAC,SAA2B;IAC3D,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,MAAM;QACJ,IAAI,KAAK,GAAc,IAAI,CAAC;QAC5B,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;YACzB,KAAK,GAAG,8BAAC,6BAAQ,oBAAK,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAY,CAAC;SACpE;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;YAC3B,KAAK,GAAG,8BAAC,+BAAU,oBAAK,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAc,CAAC;SACxE;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YACtB,KAAK,GAAG,8BAAC,0BAAK,oBAAK,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAS,CAAC;SAC9D;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;YACxB,KAAK,GAAG,8BAAC,4BAAO,oBAAK,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAW,CAAC;SAClE;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YAC1B,KAAK,GAAG,8BAAC,8BAAS,oBAAK,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAa,CAAC;SACtE;QAED,MAAM,GAAG,GAAG,gBAAC,CAAC,GAAG,CAAC,I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,CAAC,QAAQ,CACN,CACX,CACR,CAAC;IACJ,CAAC;CACF;AArBD,gCAqBC;AAED,MAAM,SAAS,GAAc;IAC3B,KAAK,EAAE,MAAM;IACb,UAAU,EAAE,MAAM;IAClB,eAAe,EAAE,aAAa;CAC/B,CAAC;AAEF,kBAAe,UAAU,CAAC","names":[],"sources":["/Users/thomas/Source/react-native-core/source/components/labels/CrossLabel.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport {\n View,\n TextProps,\n Linking,\n TouchableHighlight,\n TextStyle,\n} from 'react-native';\nimport {\n Text,\n Headline,\n Subheading,\n Title,\n Caption,\n Paragraph,\n} from 'react-native-paper';\nimport styles from '../../styles';\nimport _ from 'lodash';\n\nexport interface ICrossLabelProps extends TextProps {\n /**\n * An url to open when user clicks the label. Styles the label as a clickable \"link\"\n */\n onPressUrlTarget?: string;\n /**\n * Optional color for the link. Default is 'blue'. See also {@link onPressUrlTarget}\n */\n linkColor?: string | undefined;\n /**\n * Displays text as a {@link https://callstack.github.io/react-native-paper/headline.html react-native paper Headline component}\n */\n isHeadline?: boolean | undefined;\n /**\n * Displays text as a {@link https://callstack.github.io/react-native-paper/title.html react-native paper Title component}\n */\n isTitle?: boolean | undefined;\n /**\n * Displays text as a {@link https://callstack.github.io/react-native-paper/subheading.html react-native paper Subheading component}\n */\n isSubheading?: boolean | undefined;\n /**\n * Displays text as a {@link https://callstack.github.io/react-native-paper/paragraph.html react-native paper Paragraph component}\n */\n isParagraph?: boolean | undefined;\n /**\n * Displays text as a {@link https://callstack.github.io/react-native-paper/caption.html react-native paper Caption component}\n */\n isCaption?: boolean | undefined;\n}\n\n/**\n * Renders the relevant react-native-paper component based on props\n */\nclass TextComponent extends React.Component<ICrossLabelProps> {\n constructor(props: ICrossLabelProps) {\n super(props);\n }\n\n render() {\n let label: ReactNode = null;\n if (this.props.isHeadline) {\n label = <Headline {...this.props}>{this.props.children}</Headline>;\n }\n\n if (this.props.isSubheading) {\n label = <Subheading {...this.props}>{this.props.children}</Subheading>;\n }\n\n if (this.props.isTitle) {\n label = <Title {...this.props}>{this.props.children}</Title>;\n }\n\n if (this.props.isCaption) {\n label = <Caption {...this.props}>{this.props.children}</Caption>;\n }\n\n if (this.props.isParagraph) {\n label = <Paragraph {...this.props}>{this.props.children}</Paragraph>;\n }\n\n const url = _.get(this.props, ['onPressUrlTarget']);\n\n if (url && !label)\n return (\n <Text {...this.props} onPress={() => Linking.openURL(url.toString())}>\n {this.props.children}\n </Text>\n );\n\n if (url && label)\n return (\n <TouchableHighlight onPress={() => Linking.openURL(url.toString())}>\n {label}\n </TouchableHighlight>\n );\n\n return label ? (\n { ...label }\n ) : (\n <Text {...this.props}>{this.props.children}</Text>\n );\n }\n}\n\n/**\n * Wrapper for {@link https://callstack.github.io/react-native-paper/text.html react-native-paper Text} component\n * that displays as a clickable link if {@link ICrossLabelProps.onPressUrlTarget} is supplied.\n *\n * Link color can also be specified through {@link ICrossLabelProps.linkColor}.\n *\n * Properties are {@link ICrossLabelProps}\n *\n * @param param0 {@link ICrossLabelProps}\n * @returns {@link View}\n */\nexport class CrossLabel extends React.Component<ICrossLabelProps> {\n constructor(props: ICrossLabelProps) {\n super(props);\n }\n\n render() {\n return (\n <View style={styles.container}>\n <TextComponent\n {...this.props}\n style={[\n this.props.onPressUrlTarget ? linkStyle : {},\n this.props.style,\n this.props.linkColor ? { color: this.props.linkColor } : {},\n ]}\n >\n {this.props.children}\n </TextComponent>\n </View>\n );\n }\n}\n\nconst linkStyle: TextStyle = {\n color: 'blue',\n fontWeight: 'bold',\n backgroundColor: 'transparent',\n};\n\nexport default CrossLabel;\n"],"version":3}