edea2143d022c74d7878f2cfa288d859.json
7.55 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 _objectWithoutProperties2=_interopRequireDefault(require(\"@babel/runtime/helpers/objectWithoutProperties\"));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 _getPrototypeOf2=_interopRequireDefault(require(\"@babel/runtime/helpers/getPrototypeOf\"));var _inherits2=_interopRequireDefault(require(\"@babel/runtime/helpers/inherits\"));var React=_interopRequireWildcard(require(\"react\"));var _View=_interopRequireDefault(require(\"react-native-web/dist/exports/View\"));var _StyleSheet=_interopRequireDefault(require(\"react-native-web/dist/exports/StyleSheet\"));var _color=_interopRequireDefault(require(\"color\"));var _Text=_interopRequireDefault(require(\"../Typography/Text\"));var _theming=require(\"../../core/theming\");var _colors=require(\"../../styles/colors\");var _jsxFileName=\"/Users/satya/Workspace/Callstack/react-native-paper/src/components/Avatar/AvatarText.tsx\";var defaultSize=64;var AvatarText=function(_React$Component){(0,_inherits2.default)(AvatarText,_React$Component);function AvatarText(){(0,_classCallCheck2.default)(this,AvatarText);return(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(AvatarText).apply(this,arguments));}(0,_createClass2.default)(AvatarText,[{key:\"render\",value:function render(){var _this$props=this.props,label=_this$props.label,_this$props$size=_this$props.size,size=_this$props$size===void 0?defaultSize:_this$props$size,style=_this$props.style,theme=_this$props.theme,labelStyle=_this$props.labelStyle;var _ref=_StyleSheet.default.flatten(style)||{},_ref$backgroundColor=_ref.backgroundColor,backgroundColor=_ref$backgroundColor===void 0?theme.colors.primary:_ref$backgroundColor,restStyle=(0,_objectWithoutProperties2.default)(_ref,[\"backgroundColor\"]);var textColor=this.props.color||((0,_color.default)(backgroundColor).isLight()?'rgba(0, 0, 0, .54)':_colors.white);return React.createElement(_View.default,{style:[{width:size,height:size,borderRadius:size/2,backgroundColor:backgroundColor},styles.container,restStyle],__source:{fileName:_jsxFileName,lineNumber:80}},React.createElement(_Text.default,{style:[styles.text,{color:textColor,fontSize:size/2,lineHeight:size},labelStyle],numberOfLines:1,__source:{fileName:_jsxFileName,lineNumber:92}},label));}}]);return AvatarText;}(React.Component);AvatarText.displayName='Avatar.Text';AvatarText.defaultProps={size:defaultSize};var styles=_StyleSheet.default.create({container:{justifyContent:'center',alignItems:'center'},text:{textAlign:'center',textAlignVertical:'center'}});var _default=(0,_theming.withTheme)(AvatarText);exports.default=_default;","map":{"version":3,"sources":["AvatarText.tsx"],"names":["defaultSize","AvatarText","React","Component","displayName","defaultProps","size","label","style","theme","labelStyle","backgroundColor","restStyle","StyleSheet","textColor","color","width","height","borderRadius","styles","fontSize","lineHeight","container","justifyContent","alignItems","text","textAlign","textAlignVertical","withTheme"],"mappings":"k0BAAA,oD,4KAQA,oDACA,gEACA,2CACA,2C,4GAGA,GAAMA,CAAAA,WAAW,CAAjB,EAAA,CAgDMC,GAAAA,CAAAA,U,mVAOK,CAAA,GAAA,CAAA,WAAA,CACyD,KADzD,KAAA,CACCM,KADD,CAAA,WAAA,CAAA,KAAA,CAAA,gBAAA,CAAA,WAAA,CAAA,IAAA,CACQD,IADR,CAAA,gBAAA,GAAA,IAAA,EAAA,CAAA,WAAA,CAAA,gBAAA,CAC4BE,KAD5B,CAAA,WAAA,CAAA,KAAA,CACmCC,KADnC,CAAA,WAAA,CAAA,KAAA,CAC0CC,UAD1C,CAAA,WAAA,CAAA,UAAA,CAAA,GAAA,CAAA,IAAA,CAILG,oBAAAA,OAAAA,CAAAA,KAAAA,GAJK,EAAA,CAAA,oBAAA,CAAA,IAAA,CAAA,eAAA,CAGCF,eAHD,CAAA,oBAAA,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,QAKQ,CALyB,CAAlBd,CAAf,C,aAWee,uBAAf,UAAeA,C","sourcesContent":["import * as React from 'react';\nimport {\n View,\n ViewStyle,\n StyleSheet,\n StyleProp,\n TextStyle,\n} from 'react-native';\nimport color from 'color';\nimport Text from '../Typography/Text';\nimport { withTheme } from '../../core/theming';\nimport { white } from '../../styles/colors';\nimport { Theme } from '../../types';\n\nconst defaultSize = 64;\n\ntype Props = {\n /**\n * Initials to show as the text in the `Avatar`.\n */\n label: string;\n /**\n * Size of the avatar.\n */\n size?: number;\n /**\n * Custom color for the text.\n */\n color?: string;\n /**\n * Style for text container\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Style for the title.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * @optional\n */\n theme: Theme;\n};\n\n/**\n * Avatars can be used to represent people in a graphical way.\n *\n * <div class=\"screenshots\">\n * <figure>\n * <img class=\"medium\" src=\"screenshots/avatar-text.png\" />\n * </figure>\n * </div>\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { Avatar } from 'react-native-paper';\n *\n * const MyComponent = () => (\n * <Avatar.Text size={24} label=\"XD\" />\n * );\n * ```\n */\nclass AvatarText extends React.Component<Props> {\n static displayName = 'Avatar.Text';\n\n static defaultProps = {\n size: defaultSize,\n };\n\n render() {\n const { label, size = defaultSize, style, theme, labelStyle } = this.props;\n\n const { backgroundColor = theme.colors.primary, ...restStyle } =\n StyleSheet.flatten(style) || {};\n const textColor =\n this.props.color ||\n (color(backgroundColor).isLight() ? 'rgba(0, 0, 0, .54)' : white);\n\n return (\n <View\n style={[\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n backgroundColor,\n },\n styles.container,\n restStyle,\n ]}\n >\n <Text\n style={[\n styles.text,\n {\n color: textColor,\n fontSize: size / 2,\n lineHeight: size,\n },\n labelStyle,\n ]}\n numberOfLines={1}\n >\n {label}\n </Text>\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n justifyContent: 'center',\n alignItems: 'center',\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n },\n});\n\nexport default withTheme(AvatarText);\n"]},"metadata":{},"sourceType":"script"}