text: "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));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 _getPrototypeOf3=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var React=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _color=_interopRequireDefault(require("color"));var _Icon=_interopRequireDefault(require("./Icon"));var _Surface=_interopRequireDefault(require("./Surface"));var _Text=_interopRequireDefault(require("./Typography/Text"));var _TouchableRipple=_interopRequireDefault(require("./TouchableRipple"));var _theming=require("../core/theming");var _colors=require("../styles/colors");var _jsxFileName="/Users/trensik/dev/react-native-paper/src/components/Chip.tsx";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}var Chip=function(_React$Component){(0,_inherits2.default)(Chip,_React$Component);function Chip(){var _getPrototypeOf2;var _this;(0,_classCallCheck2.default)(this,Chip);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=(0,_possibleConstructorReturn2.default)(this,(_getPrototypeOf2=(0,_getPrototypeOf3.default)(Chip)).call.apply(_getPrototypeOf2,[this].concat(args)));(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(_this),"state",{elevation:new _reactNative.Animated.Value(0)});(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(_this),"handlePressIn",function(){var scale=_this.props.theme.animation.scale;_reactNative.Animated.timing(_this.state.elevation,{toValue:4,duration:200*scale,useNativeDriver:false}).start();});(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(_this),"handlePressOut",function(){var scale=_this.props.theme.animation.scale;_reactNative.Animated.timing(_this.state.elevation,{toValue:0,duration:150*scale,useNativeDriver:false}).start();});return _this;}(0,_createClass2.default)(Chip,[{key:"render",value:function render(){var _this$props=this.props,mode=_this$props.mode,children=_this$props.children,icon=_this$props.icon,avatar=_this$props.avatar,selected=_this$props.selected,disabled=_this$props.disabled,accessibilityLabel=_this$props.accessibilityLabel,onPress=_this$props.onPress,onLongPress=_this$props.onLongPress,onClose=_this$props.onClose,textStyle=_this$props.textStyle,style=_this$props.style,theme=_this$props.theme,testID=_this$props.testID,selectedColor=_this$props.selectedColor,rest=(0,_objectWithoutProperties2.default)(_this$props,["mode","children","icon","avatar","selected","disabled","accessibilityLabel","onPress","onLongPress","onClose","textStyle","style","theme","testID","selectedColor"]);var dark=theme.dark,colors=theme.colors;var _ref=_reactNative.StyleSheet.flatten(style)||{},_ref$backgroundColor=_ref.backgroundColor,backgroundColor=_ref$backgroundColor===void 0?mode==='outlined'?colors.surface:dark?'#383838':'#ebebeb':_ref$backgroundColor,_ref$borderRadius=_ref.borderRadius,borderRadius=_ref$borderRadius===void 0?16:_ref$borderRadius;var borderColor=mode==='outlined'?(0,_color.default)(selectedColor!==undefined?selectedColor:(0,_color.default)(dark?_colors.white:_colors.black)).alpha(0.29).rgb().string():backgroundColor;var textColor=disabled?colors.disabled:(0,_color.default)(selectedColor!==undefined?selectedColor:colors.text).alpha(0.87).rgb().string();var iconColor=disabled?colors.disabled:(0,_color.default)(selectedColor!==undefined?selectedColor:colors.text).alpha(0.54).rgb().string();var selectedBackgroundColor=(dark?(0,_color.default)(backgroundColor).lighten(mode==='outlined'?0.2:0.4):(0,_color.default)(backgroundColor).darken(mode==='outlined'?0.08:0.2)).rgb().string();var underlayColor=selectedColor?(0,_color.default)(selectedColor).fade(0.5).rgb().string():selectedBackgroundColor;var accessibilityTraits=['button'];var accessibilityStates=[];if(selected){accessibilityTraits.push('selected');accessibilityStates.push('selected');}if(disabled){accessibilityTraits.push('disabled');accessibilityStates.push('disabled');}return React.createElement(_Surface.default,(0,_extends2.default)({style:[styles.container,{elevation:_reactNative.Platform.OS==='android'?this.state.elevation:0,backgroundColor:selected?selectedBackgroundColor:backgroundColor,borderColor:borderColor,borderRadius:borderRadius},style]},rest,{__source:{fileName:_jsxFileName,lineNumber:225}}),React.createElement(_TouchableRipple.default,{borderless:true,delayPressIn:0,style:{borderRadius:borderRadius},onPress:onPress,onLongPress:onLongPress,onPressIn:this.handlePressIn,onPressOut:this.handlePressOut,underlayColor:underlayColor,disabled:disabled,accessibilityLabel:accessibilityLabel,accessibilityTraits:accessibilityTraits,accessibilityComponentType:"button",accessibilityRole:"button",accessibilityStates:accessibilityStates,testID:testID,__source:{fileName:_jsxFileName,lineNumber:242}},React.createElement(_reactNative.View,{style:styles.content,__source:{fileName:_jsxFileName,lineNumber:259}},avatar&&!icon?React.createElement(_reactNative.View,{style:[styles.avatarWrapper,disabled&&{opacity:0.26}],__source:{fileName:_jsxFileName,lineNumber:261}},React.isValidElement(avatar)?React.cloneElement(avatar,{style:[styles.avatar,avatar.props.style]}):avatar):null,icon||selected?React.createElement(_reactNative.View,{style:[styles.icon,avatar?[styles.avatar,styles.avatarSelected]:null],__source:{fileName:_jsxFileName,lineNumber:274}},React.createElement(_Icon.default,{source:icon||'check',color:avatar?_colors.white:iconColor,size:18,__source:{fileName:_jsxFileName,lineNumber:280}})):null,React.createElement(_Text.default,{numberOfLines:1,style:[styles.text,_objectSpread({},theme.fonts.regular,{color:textColor,marginRight:onClose?4:8,marginLeft:avatar||icon||selected?4:8}),textStyle],__source:{fileName:_jsxFileName,lineNumber:287}},children),onClose?React.createElement(_reactNative.TouchableWithoutFeedback,{onPress:onClose,accessibilityTraits:"button",accessibilityComponentType:"button",__source:{fileName:_jsxFileName,lineNumber:303}},React.createElement(_reactNative.View,{style:styles.icon,__source:{fileName:_jsxFileName,lineNumber:308}},React.createElement(_Icon.default,{source:"close-circle",size:16,color:iconColor,__source:{fileName:_jsxFileName,lineNumber:309}}))):null)));}}]);return Chip;}(React.Component);(0,_defineProperty2.default)(Chip,"defaultProps",{mode:'flat',disabled:false,selected:false});var styles=_reactNative.StyleSheet.create({container:{borderWidth:_reactNative.StyleSheet.hairlineWidth,borderStyle:'solid'},content:{flexDirection:'row',alignItems:'center',paddingHorizontal:4},icon:{padding:4},text:{minHeight:24,lineHeight:24,textAlignVertical:'center',marginVertical:4},avatar:{width:24,height:24,borderRadius:12},avatarWrapper:{marginRight:4},avatarSelected:{position:'absolute',top:4,left:4,backgroundColor:'rgba(0, 0, 0, .29)'}});var _default=(0,_theming.withTheme)(Chip);exports.default=_default;
  //# sourceMappingURL=Chip.js.map