75381718a82a6cfcdfe8e2839e299563.json 9.57 KB
{"ast":null,"code":"var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.useScreens=useScreens;exports.screensEnabled=screensEnabled;exports.NativeScreenContainer=exports.NativeScreen=exports.ScreenContainer=exports.Screen=void 0;var _extends2=_interopRequireDefault(require(\"@babel/runtime/helpers/extends\"));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 _debounce=_interopRequireDefault(require(\"debounce\"));var _react=_interopRequireDefault(require(\"react\"));var _Animated=_interopRequireDefault(require(\"react-native-web/dist/exports/Animated\"));var _View=_interopRequireDefault(require(\"react-native-web/dist/exports/View\"));var _shouldUseScreens=true;function useScreens(){var shouldUseScreens=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;if(shouldUseScreens){console.warn('react-native-screens is not fully supported on this platform yet.');}_shouldUseScreens=shouldUseScreens;}function screensEnabled(){return _shouldUseScreens;}function isAnimatedValue(value){return value&&value.__getValue&&value.addListener;}function isPropTruthy(prop){var activeValue=prop;if(isAnimatedValue(prop)){activeValue=prop.__getValue();}return!!activeValue;}var Screen=function(_React$Component){(0,_inherits2.default)(Screen,_React$Component);function Screen(props){var _this;(0,_classCallCheck2.default)(this,Screen);_this=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(Screen).call(this,props));_this.listenerId=null;_this._addListener=function(possibleListener){if(_this.listenerId)throw new Error('Screen: Attempting to observe an animated value while another value is already observed.');if(isAnimatedValue(possibleListener)){_this.listenerId=possibleListener.addListener(_this._onAnimatedValueUpdated);}};_this._removeListener=function(possibleListener){if(isAnimatedValue(possibleListener)){possibleListener.removeListener(_this.listenerId);_this.listenerId=null;}};_this._onAnimatedValueUpdated=function(_ref){var value=_ref.value;_this._updateDisplay(!!value);};_this._updateDisplay=function(isActive){if(isActive===undefined){isActive=isPropTruthy(_this.props.active);}var display=isActive?'flex':'none';_this.setNativeProps({style:{display:display}});};_this.setNativeProps=function(nativeProps){if(_this._view){_this._view.setNativeProps(nativeProps);}};_this._setRef=function(view){_this._view=view;_this._updateDisplay();};_this._onAnimatedValueUpdated=(0,_debounce.default)(_this._onAnimatedValueUpdated,10);_this._addListener(props.active);return _this;}(0,_createClass2.default)(Screen,[{key:\"componentWillUnmount\",value:function componentWillUnmount(){this._removeListener(this.props.active);}},{key:\"shouldComponentUpdate\",value:function shouldComponentUpdate(_ref2){var nextActive=_ref2.active;var active=this.props.active;if(nextActive!==active){this._removeListener(active);this._addListener(nextActive);this._updateDisplay(isPropTruthy(nextActive));return false;}return true;}},{key:\"render\",value:function render(){return _react.default.createElement(_Animated.default.View,(0,_extends2.default)({},this.props,{ref:this._setRef}));}}]);return Screen;}(_react.default.Component);exports.Screen=Screen;Screen.defaultProps={active:true};var ScreenContainer=_View.default;exports.ScreenContainer=ScreenContainer;var NativeScreen=_View.default;exports.NativeScreen=NativeScreen;var NativeScreenContainer=_View.default;exports.NativeScreenContainer=NativeScreenContainer;","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-screens/src/screens.web.js"],"names":["_shouldUseScreens","useScreens","shouldUseScreens","console","warn","screensEnabled","isAnimatedValue","value","__getValue","addListener","isPropTruthy","prop","activeValue","Screen","props","listenerId","_addListener","possibleListener","Error","_onAnimatedValueUpdated","_removeListener","removeListener","_updateDisplay","isActive","undefined","active","display","setNativeProps","style","nativeProps","_view","_setRef","view","nextActive","React","Component","defaultProps","ScreenContainer","View","NativeScreen","NativeScreenContainer"],"mappings":"21BAAA,0DACA,oD,wKAGA,GAAIA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AxB,EAA+B,GAAG,CAAE,KAAKiB,OAAzC,GAAP,CACD,C,oBAzEyBG,eAAMC,S,wBAArBtB,M,CACJuB,Y,CAAe,CACpBX,MAAM,CAAE,IADY,C,CA2EjB,GAAMY,CAAAA,eAAe,CAAGC,aAAxB,C,wCAEA,GAAMC,CAAAA,YAAY,CAAGD,aAArB,C,kCAEA,GAAME,CAAAA,qBAAqB,CAAGF,aAA9B,C","sourcesContent":["import debounce from 'debounce';\nimport React from 'react';\nimport { Animated, View } from 'react-native';\n\nlet _shouldUseScreens = true;\n\nexport function useScreens(shouldUseScreens = true) {\n  if (shouldUseScreens) {\n    console.warn(\n      'react-native-screens is not fully supported on this platform yet.'\n    );\n  }\n  _shouldUseScreens = shouldUseScreens;\n}\n\nexport function screensEnabled() {\n  return _shouldUseScreens;\n}\n\nfunction isAnimatedValue(value) {\n  return value && value.__getValue && value.addListener;\n}\n\nfunction isPropTruthy(prop) {\n  let activeValue = prop;\n  if (isAnimatedValue(prop)) {\n    activeValue = prop.__getValue();\n  }\n\n  return !!activeValue;\n}\n\nexport class Screen extends React.Component {\n  static defaultProps = {\n    active: true,\n  };\n\n  listenerId = null;\n\n  constructor(props) {\n    super(props);\n\n    this._onAnimatedValueUpdated = debounce(this._onAnimatedValueUpdated, 10);\n    this._addListener(props.active);\n  }\n\n  componentWillUnmount() {\n    this._removeListener(this.props.active);\n  }\n\n  _addListener = possibleListener => {\n    if (this.listenerId)\n      throw new Error(\n        'Screen: Attempting to observe an animated value while another value is already observed.'\n      );\n    if (isAnimatedValue(possibleListener)) {\n      this.listenerId = possibleListener.addListener(\n        this._onAnimatedValueUpdated\n      );\n    }\n  };\n\n  _removeListener = possibleListener => {\n    if (isAnimatedValue(possibleListener)) {\n      possibleListener.removeListener(this.listenerId);\n      this.listenerId = null;\n    }\n  };\n\n  shouldComponentUpdate({ active: nextActive }) {\n    const { active } = this.props;\n    if (nextActive !== active) {\n      this._removeListener(active);\n      this._addListener(nextActive);\n      this._updateDisplay(isPropTruthy(nextActive));\n      return false;\n    }\n    return true;\n  }\n\n  _onAnimatedValueUpdated = ({ value }) => {\n    this._updateDisplay(!!value);\n  };\n\n  _updateDisplay = isActive => {\n    if (isActive === undefined) {\n      isActive = isPropTruthy(this.props.active);\n    }\n    const display = isActive ? 'flex' : 'none';\n    this.setNativeProps({ style: { display } });\n  };\n\n  setNativeProps = nativeProps => {\n    if (this._view) {\n      this._view.setNativeProps(nativeProps);\n    }\n  };\n\n  _setRef = view => {\n    this._view = view;\n    this._updateDisplay();\n  };\n\n  render() {\n    return <Animated.View {...this.props} ref={this._setRef} />;\n  }\n}\n\nexport const ScreenContainer = View;\n\nexport const NativeScreen = View;\n\nexport const NativeScreenContainer = View;\n"]},"metadata":{},"sourceType":"script"}