46ee110f9e1d6d92ebc9cc711b308291.json
15.8 KB
{"ast":null,"code":"var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});Object.defineProperty(exports,\"PureNativeButton\",{enumerable:true,get:function get(){return _GestureHandlerButton.default;}});exports.BorderlessButton=exports.RectButton=exports.BaseButton=exports.RawButton=void 0;var _defineProperty2=_interopRequireDefault(require(\"@babel/runtime/helpers/defineProperty\"));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 _getPrototypeOf2=_interopRequireDefault(require(\"@babel/runtime/helpers/getPrototypeOf\"));var _inherits2=_interopRequireDefault(require(\"@babel/runtime/helpers/inherits\"));var _propTypes=_interopRequireDefault(require(\"prop-types\"));var _react=_interopRequireDefault(require(\"react\"));var _Animated=_interopRequireDefault(require(\"react-native-web/dist/exports/Animated\"));var _Platform=_interopRequireDefault(require(\"react-native-web/dist/exports/Platform\"));var _processColor=_interopRequireDefault(require(\"react-native-web/dist/exports/processColor\"));var _StyleSheet=_interopRequireDefault(require(\"react-native-web/dist/exports/StyleSheet\"));var _createNativeWrapper=_interopRequireDefault(require(\"./createNativeWrapper\"));var _GestureHandlerButton=_interopRequireDefault(require(\"./GestureHandlerButton\"));var _State=_interopRequireDefault(require(\"./State\"));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(source,true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(source).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}var RawButton=(0,_createNativeWrapper.default)(_GestureHandlerButton.default,{shouldCancelWhenOutside:false,shouldActivateOnStart:false});exports.RawButton=RawButton;var BaseButton=function(_React$Component){(0,_inherits2.default)(BaseButton,_React$Component);function BaseButton(props){var _this;(0,_classCallCheck2.default)(this,BaseButton);_this=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(BaseButton).call(this,props));_this._handleEvent=function(_ref){var nativeEvent=_ref.nativeEvent;var state=nativeEvent.state,oldState=nativeEvent.oldState,pointerInside=nativeEvent.pointerInside;var active=pointerInside&&state===_State.default.ACTIVE;if(active!==_this._lastActive&&_this.props.onActiveStateChange){_this.props.onActiveStateChange(active);}if(oldState===_State.default.ACTIVE&&state!==_State.default.CANCELLED&&_this._lastActive&&_this.props.onPress){_this.props.onPress(active);}_this._lastActive=active;};_this._onHandlerStateChange=function(e){_this.props.onHandlerStateChange&&_this.props.onHandlerStateChange(e);_this._handleEvent(e);};_this._onGestureEvent=function(e){_this.props.onGestureEvent&&_this.props.onGestureEvent(e);_this._handleEvent(e);};_this._lastActive=false;return _this;}(0,_createClass2.default)(BaseButton,[{key:\"render\",value:function render(){var _this$props=this.props,style=_this$props.style,rippleColor=_this$props.rippleColor,rest=(0,_objectWithoutProperties2.default)(_this$props,[\"style\",\"rippleColor\"]);return _react.default.createElement(RawButton,(0,_extends2.default)({style:[{overflow:'hidden'},style],rippleColor:(0,_processColor.default)(rippleColor)},rest,{onGestureEvent:this._onGestureEvent,onHandlerStateChange:this._onHandlerStateChange}));}}]);return BaseButton;}(_react.default.Component);exports.BaseButton=BaseButton;BaseButton.propTypes=_objectSpread({},RawButton.propTypes,{onPress:_propTypes.default.func,onActiveStateChange:_propTypes.default.func});var AnimatedBaseButton=_Animated.default.createAnimatedComponent(BaseButton);var btnStyles=_StyleSheet.default.create({underlay:{position:'absolute',left:0,right:0,bottom:0,top:0}});var RectButton=function(_React$Component2){(0,_inherits2.default)(RectButton,_React$Component2);function RectButton(props){var _this2;(0,_classCallCheck2.default)(this,RectButton);_this2=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(RectButton).call(this,props));_this2._onActiveStateChange=function(active){if(_Platform.default.OS!=='android'){_this2._opacity.setValue(active?_this2.props.activeOpacity:0);}_this2.props.onActiveStateChange&&_this2.props.onActiveStateChange(active);};_this2._opacity=new _Animated.default.Value(0);return _this2;}(0,_createClass2.default)(RectButton,[{key:\"render\",value:function render(){var _this$props2=this.props,children=_this$props2.children,rest=(0,_objectWithoutProperties2.default)(_this$props2,[\"children\"]);return _react.default.createElement(BaseButton,(0,_extends2.default)({},rest,{onActiveStateChange:this._onActiveStateChange}),_react.default.createElement(_Animated.default.View,{style:[btnStyles.underlay,{opacity:this._opacity},{backgroundColor:this.props.underlayColor}]}),children);}}]);return RectButton;}(_react.default.Component);exports.RectButton=RectButton;RectButton.propTypes=BaseButton.propTypes;RectButton.defaultProps={activeOpacity:0.105,underlayColor:'black'};var BorderlessButton=function(_React$Component3){(0,_inherits2.default)(BorderlessButton,_React$Component3);function BorderlessButton(props){var _this3;(0,_classCallCheck2.default)(this,BorderlessButton);_this3=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(BorderlessButton).call(this,props));_this3._onActiveStateChange=function(active){if(_Platform.default.OS!=='android'){_this3._opacity.setValue(active?_this3.props.activeOpacity:1);}_this3.props.onActiveStateChange&&_this3.props.onActiveStateChange(active);};_this3._opacity=new _Animated.default.Value(1);return _this3;}(0,_createClass2.default)(BorderlessButton,[{key:\"render\",value:function render(){var _this$props3=this.props,children=_this$props3.children,style=_this$props3.style,rest=(0,_objectWithoutProperties2.default)(_this$props3,[\"children\",\"style\"]);return _react.default.createElement(AnimatedBaseButton,(0,_extends2.default)({},rest,{onActiveStateChange:this._onActiveStateChange,style:[style,_Platform.default.OS==='ios'&&{opacity:this._opacity}]}),children);}}]);return BorderlessButton;}(_react.default.Component);exports.BorderlessButton=BorderlessButton;BorderlessButton.propTypes=_objectSpread({},BaseButton.propTypes,{borderless:_propTypes.default.bool});BorderlessButton.defaultProps={activeOpacity:0.3,borderless:true};","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-gesture-handler/GestureButtons.js"],"names":["RawButton","GestureHandlerButton","shouldCancelWhenOutside","shouldActivateOnStart","BaseButton","props","_handleEvent","nativeEvent","state","oldState","pointerInside","active","State","ACTIVE","_lastActive","onActiveStateChange","CANCELLED","onPress","_onHandlerStateChange","e","onHandlerStateChange","_onGestureEvent","onGestureEvent","style","rippleColor","rest","overflow","React","Component","propTypes","PropTypes","func","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","RectButton","_onActiveStateChange","Platform","OS","_opacity","setValue","activeOpacity","Value","children","opacity","backgroundColor","underlayColor","defaultProps","BorderlessButton","borderless","bool"],"mappings":"0lCAAA,6DACA,oD,4WAGA,kFACA,oFACA,sD,yxBAEO,GAAMA,CAAAA,SAAS,CAAG,iCAAoBC,6BAApB,CAA0C,CACjEC,uBAAuB,CAAE,KADwC,CAEjEC,qBAAqB,CAAE,KAF0C,CAA1C,CAAlB,C,+BAOMC,CAAAA,U,gFAOX,oBAAYC,KAAZ,CAAmB,yDACjB,sGAAMA,KAAN,GADiB,MAKnBC,YALmB,CAKJ,cAAqB,IAAlBC,CAAAA,WAAkB,MAAlBA,WAAkB,IAC1BC,CAAAA,KAD0B,CACSD,WADT,CAC1BC,KAD0B,CACnBC,QADmB,CACSF,WADT,CACnBE,QADmB,CACTC,aADS,CACSH,WADT,CACTG,aADS,CAElC,GAAMC,CAA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Jf,S,CAAYzB,UAAU,CAACyB,S,CADnBe,U,CAGJY,Y,CAAe,CACpBN,aAAa,CAAE,KADK,CAEpBK,aAAa,CAAE,OAFK,C,IAoCXE,CAAAA,gB,wFAWX,0BAAYpD,KAAZ,CAAmB,gEACjB,6GAAMA,KAAN,GADiB,OAKnBwC,oBALmB,CAKI,SAAAlC,MAAM,CAAI,CAC/B,GAAImC,kBAASC,EAAT,GAAgB,SAApB,CAA+B,CAC7B,OAAKC,QAAL,CAAcC,QAAd,CAAuBtC,MAAM,CAAG,OAAKN,KAAL,CAAW6C,aAAd,CAA8B,CAA3D,EACD,CAED,OAAK7C,KAAL,CAAWU,mBAAX,EAAkC,OAAKV,KAAL,CAAWU,mBAAX,CAA+BJ,MAA/B,CAAlC,CACD,CAXkB,CAEjB,OAAKqC,QAAL,CAAgB,GAAIf,mBAASkB,KAAb,CAAmB,CAAnB,CAAhB,CAFiB,cAGlB,C,iFAUQ,kBAC8B,KAAK9C,KADnC,CACC+C,QADD,cACCA,QADD,CACW7B,KADX,cACWA,KADX,CACqBE,IADrB,0EAGP,MACE,8BAAC,kBAAD,0BACMA,IADN,EAEE,mBAAmB,CAAE,KAAKoB,oBAF5B,CAGE,KAAK,CAAE,CAACtB,KAAD,CAAQuB,kBAASC,EAAT,GAAgB,KAAhB,EAAyB,CAAEM,OAAO,CAAE,KAAKL,QAAhB,CAAjC,CAHT,GAIGI,QAJH,CADF,CAQD,C,8BAnCmCzB,eAAMC,S,4CAA/B6B,gB,CACJ5B,S,kBACFzB,UAAU,CAACyB,S,EACd6B,UAAU,CAAE5B,mBAAU6B,I,GAHbF,gB,CAMJD,Y,CAAe,CACpBN,aAAa,CAAE,GADK,CAEpBQ,UAAU,CAAE,IAFQ,C","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport { Animated, Platform, processColor, StyleSheet } from 'react-native';\n\nimport createNativeWrapper from './createNativeWrapper';\nimport GestureHandlerButton from './GestureHandlerButton';\nimport State from './State';\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\n/* Buttons */\n\nexport class BaseButton extends React.Component {\n static propTypes = {\n ...RawButton.propTypes,\n onPress: PropTypes.func,\n onActiveStateChange: PropTypes.func,\n };\n\n constructor(props) {\n super(props);\n this._lastActive = false;\n }\n\n _handleEvent = ({ nativeEvent }) => {\n const { state, oldState, pointerInside } = nativeEvent;\n const active = pointerInside && state === State.ACTIVE;\n\n if (active !== this._lastActive && this.props.onActiveStateChange) {\n this.props.onActiveStateChange(active);\n }\n\n if (\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this._lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n this._lastActive = active;\n };\n\n // Normally, the parent would execute it's handler first,\n // then forward the event to listeners. However, here our handler\n // is virtually only forwarding events to listeners, so we reverse the order\n // to keep the proper order of the callbacks (from \"raw\" ones to \"processed\").\n _onHandlerStateChange = e => {\n this.props.onHandlerStateChange && this.props.onHandlerStateChange(e);\n this._handleEvent(e);\n };\n\n _onGestureEvent = e => {\n this.props.onGestureEvent && this.props.onGestureEvent(e);\n this._handleEvent(e);\n };\n\n render() {\n const { style, rippleColor, ...rest } = this.props;\n\n return (\n <RawButton\n style={[{ overflow: 'hidden' }, style]}\n rippleColor={processColor(rippleColor)}\n {...rest}\n onGestureEvent={this._onGestureEvent}\n onHandlerStateChange={this._onHandlerStateChange}\n />\n );\n }\n}\n\nconst AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\n\nconst btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0,\n },\n});\n\nexport class RectButton extends React.Component {\n static propTypes = BaseButton.propTypes;\n\n static defaultProps = {\n activeOpacity: 0.105,\n underlayColor: 'black',\n };\n\n constructor(props) {\n super(props);\n this._opacity = new Animated.Value(0);\n }\n\n _onActiveStateChange = active => {\n if (Platform.OS !== 'android') {\n this._opacity.setValue(active ? this.props.activeOpacity : 0);\n }\n\n this.props.onActiveStateChange && this.props.onActiveStateChange(active);\n };\n\n render() {\n const { children, ...rest } = this.props;\n\n return (\n <BaseButton {...rest} onActiveStateChange={this._onActiveStateChange}>\n <Animated.View\n style={[\n btnStyles.underlay,\n { opacity: this._opacity },\n { backgroundColor: this.props.underlayColor },\n ]}\n />\n {children}\n </BaseButton>\n );\n }\n}\n\nexport class BorderlessButton extends React.Component {\n static propTypes = {\n ...BaseButton.propTypes,\n borderless: PropTypes.bool,\n };\n\n static defaultProps = {\n activeOpacity: 0.3,\n borderless: true,\n };\n\n constructor(props) {\n super(props);\n this._opacity = new Animated.Value(1);\n }\n\n _onActiveStateChange = active => {\n if (Platform.OS !== 'android') {\n this._opacity.setValue(active ? this.props.activeOpacity : 1);\n }\n\n this.props.onActiveStateChange && this.props.onActiveStateChange(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n return (\n <AnimatedBaseButton\n {...rest}\n onActiveStateChange={this._onActiveStateChange}\n style={[style, Platform.OS === 'ios' && { opacity: this._opacity }]}>\n {children}\n </AnimatedBaseButton>\n );\n }\n}\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n"]},"metadata":{},"sourceType":"script"}