@expo/react-native-action-sheet
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -1,2 +0,2 @@ | ||
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 _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 _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var React=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _ActionGroup=_interopRequireDefault(require("./ActionGroup"));var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/ActionSheet/index.tsx";var OPACITY_ANIMATION_IN_TIME=225;var OPACITY_ANIMATION_OUT_TIME=195;var EASING_OUT=_reactNative.Easing.bezier(0.25,0.46,0.45,0.94);var EASING_IN=_reactNative.Easing.out(EASING_OUT);var ActionSheet=function(_React$Component){(0,_inherits2.default)(ActionSheet,_React$Component);function ActionSheet(){var _getPrototypeOf2;var _this;(0,_classCallCheck2.default)(this,ActionSheet);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)(ActionSheet)).call.apply(_getPrototypeOf2,[this].concat(args)));_this._actionSheetHeight=360;_this.state={isVisible:false,isAnimating:false,options:null,onSelect:null,overlayOpacity:new _reactNative.Animated.Value(0),sheetOpacity:new _reactNative.Animated.Value(0)};_this._setActionSheetHeight=function(_ref){var nativeEvent=_ref.nativeEvent;return _this._actionSheetHeight=nativeEvent.layout.height;};_this._selectCancelButton=function(){var options=_this.state.options;if(!options){return false;}if(typeof options.cancelButtonIndex==='number'){return _this._onSelect(options.cancelButtonIndex);}else{return _this._animateOut();}};_this._onSelect=function(index){var _this$state=_this.state,isAnimating=_this$state.isAnimating,onSelect=_this$state.onSelect;if(isAnimating){return false;}onSelect&&onSelect(index);return _this._animateOut();};_this._animateOut=function(){var _this$state2=_this.state,isAnimating=_this$state2.isAnimating,overlayOpacity=_this$state2.overlayOpacity,sheetOpacity=_this$state2.sheetOpacity;if(isAnimating){return false;}_reactNative.BackHandler.removeEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);_this.setState({isAnimating:true});_reactNative.Animated.parallel([_reactNative.Animated.timing(overlayOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver}),_reactNative.Animated.timing(sheetOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver})]).start(function(result){if(result.finished){_this.setState({isVisible:false,isAnimating:false});}});return true;};return _this;}(0,_createClass2.default)(ActionSheet,[{key:"render",value:function render(){var _this$state3=this.state,isVisible=_this$state3.isVisible,overlayOpacity=_this$state3.overlayOpacity;var overlay=isVisible?React.createElement(_reactNative.Animated.View,{style:[styles.overlay,{opacity:overlayOpacity}],__source:{fileName:_jsxFileName,lineNumber:54}}):null;return React.createElement(_reactNative.View,{style:{flex:1},__source:{fileName:_jsxFileName,lineNumber:64}},React.Children.only(this.props.children),overlay,isVisible?this._renderSheet():null);}},{key:"_renderSheet",value:function _renderSheet(){var _this$state4=this.state,options=_this$state4.options,isAnimating=_this$state4.isAnimating,sheetOpacity=_this$state4.sheetOpacity;if(!options){return null;}var optionsArray=options.options,icons=options.icons,tintIcons=options.tintIcons,destructiveButtonIndex=options.destructiveButtonIndex,textStyle=options.textStyle,tintColor=options.tintColor,title=options.title,titleTextStyle=options.titleTextStyle,message=options.message,messageTextStyle=options.messageTextStyle,showSeparators=options.showSeparators,separatorStyle=options.separatorStyle;return React.createElement(_reactNative.TouchableWithoutFeedback,{onPress:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:97}},React.createElement(_reactNative.Animated.View,{needsOffscreenAlphaCompositing:isAnimating,style:[styles.sheetContainer,{opacity:sheetOpacity,transform:[{translateY:sheetOpacity.interpolate({inputRange:[0,1],outputRange:[this._actionSheetHeight,0]})}]}],__source:{fileName:_jsxFileName,lineNumber:98}},React.createElement(_reactNative.View,{style:styles.sheet,onLayout:this._setActionSheetHeight,__source:{fileName:_jsxFileName,lineNumber:114}},React.createElement(_ActionGroup.default,{options:optionsArray,icons:icons,tintIcons:tintIcons===undefined?true:tintIcons,destructiveButtonIndex:destructiveButtonIndex,onSelect:this._onSelect,startIndex:0,length:optionsArray.length,textStyle:textStyle||{},tintColor:tintColor,title:title||undefined,titleTextStyle:titleTextStyle,message:message||undefined,messageTextStyle:messageTextStyle,showSeparators:showSeparators,separatorStyle:separatorStyle,__source:{fileName:_jsxFileName,lineNumber:115}}))));}},{key:"showActionSheetWithOptions",value:function showActionSheetWithOptions(options,onSelect){var _this2=this;var _this$state5=this.state,isVisible=_this$state5.isVisible,overlayOpacity=_this$state5.overlayOpacity,sheetOpacity=_this$state5.sheetOpacity;if(isVisible){return;}this.setState({options:options,onSelect:onSelect,isVisible:true,isAnimating:true});overlayOpacity.setValue(0);sheetOpacity.setValue(0);_reactNative.Animated.parallel([_reactNative.Animated.timing(overlayOpacity,{toValue:0.32,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:this.props.useNativeDriver}),_reactNative.Animated.timing(sheetOpacity,{toValue:1,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:this.props.useNativeDriver})]).start(function(result){if(result.finished){_this2.setState({isAnimating:false});}});_reactNative.BackHandler.addEventListener('actionSheetHardwareBackPress',this._selectCancelButton);}}]);return ActionSheet;}(React.Component);exports.default=ActionSheet;ActionSheet.defaultProps={useNativeDriver:true};var styles=_reactNative.StyleSheet.create({overlay:{position:'absolute',top:0,right:0,bottom:0,left:0,backgroundColor:'black'},sheetContainer:{position:'absolute',left:0,right:0,bottom:0,top:0,backgroundColor:'transparent',alignItems:'flex-end',justifyContent:'center',flexDirection:'row'},sheet:{flex:1,backgroundColor:'transparent'}}); | ||
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 _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 _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var React=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _ActionGroup=_interopRequireDefault(require("./ActionGroup"));var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/ActionSheet/index.tsx";var OPACITY_ANIMATION_IN_TIME=225;var OPACITY_ANIMATION_OUT_TIME=195;var EASING_OUT=_reactNative.Easing.bezier(0.25,0.46,0.45,0.94);var EASING_IN=_reactNative.Easing.out(EASING_OUT);var ActionSheet=function(_React$Component){(0,_inherits2.default)(ActionSheet,_React$Component);function ActionSheet(){var _getPrototypeOf2;var _this;(0,_classCallCheck2.default)(this,ActionSheet);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)(ActionSheet)).call.apply(_getPrototypeOf2,[this].concat(args)));_this._actionSheetHeight=360;_this.state={isVisible:false,isAnimating:false,options:null,onSelect:null,overlayOpacity:new _reactNative.Animated.Value(0),sheetOpacity:new _reactNative.Animated.Value(0)};_this._setActionSheetHeight=function(_ref){var nativeEvent=_ref.nativeEvent;return _this._actionSheetHeight=nativeEvent.layout.height;};_this.showActionSheetWithOptions=function(options,onSelect){var _this$state=_this.state,isVisible=_this$state.isVisible,overlayOpacity=_this$state.overlayOpacity,sheetOpacity=_this$state.sheetOpacity;if(isVisible){return;}_this.setState({options:options,onSelect:onSelect,isVisible:true,isAnimating:true});overlayOpacity.setValue(0);sheetOpacity.setValue(0);_reactNative.Animated.parallel([_reactNative.Animated.timing(overlayOpacity,{toValue:0.32,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:_this.props.useNativeDriver}),_reactNative.Animated.timing(sheetOpacity,{toValue:1,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:_this.props.useNativeDriver})]).start(function(result){if(result.finished){_this.setState({isAnimating:false});}});_reactNative.BackHandler.addEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);};_this._selectCancelButton=function(){var options=_this.state.options;if(!options){return false;}if(typeof options.cancelButtonIndex==='number'){return _this._onSelect(options.cancelButtonIndex);}else{return _this._animateOut();}};_this._onSelect=function(index){var _this$state2=_this.state,isAnimating=_this$state2.isAnimating,onSelect=_this$state2.onSelect;if(isAnimating){return false;}onSelect&&onSelect(index);return _this._animateOut();};_this._animateOut=function(){var _this$state3=_this.state,isAnimating=_this$state3.isAnimating,overlayOpacity=_this$state3.overlayOpacity,sheetOpacity=_this$state3.sheetOpacity;if(isAnimating){return false;}_reactNative.BackHandler.removeEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);_this.setState({isAnimating:true});_reactNative.Animated.parallel([_reactNative.Animated.timing(overlayOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver}),_reactNative.Animated.timing(sheetOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver})]).start(function(result){if(result.finished){_this.setState({isVisible:false,isAnimating:false});}});return true;};return _this;}(0,_createClass2.default)(ActionSheet,[{key:"render",value:function render(){var _this$state4=this.state,isVisible=_this$state4.isVisible,overlayOpacity=_this$state4.overlayOpacity;var overlay=isVisible?React.createElement(_reactNative.Animated.View,{style:[styles.overlay,{opacity:overlayOpacity}],__source:{fileName:_jsxFileName,lineNumber:54}}):null;return React.createElement(_reactNative.View,{style:{flex:1},__source:{fileName:_jsxFileName,lineNumber:64}},React.Children.only(this.props.children),overlay,isVisible?this._renderSheet():null);}},{key:"_renderSheet",value:function _renderSheet(){var _this$state5=this.state,options=_this$state5.options,isAnimating=_this$state5.isAnimating,sheetOpacity=_this$state5.sheetOpacity;if(!options){return null;}var optionsArray=options.options,icons=options.icons,tintIcons=options.tintIcons,destructiveButtonIndex=options.destructiveButtonIndex,textStyle=options.textStyle,tintColor=options.tintColor,title=options.title,titleTextStyle=options.titleTextStyle,message=options.message,messageTextStyle=options.messageTextStyle,showSeparators=options.showSeparators,separatorStyle=options.separatorStyle;return React.createElement(_reactNative.TouchableWithoutFeedback,{onPress:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:97}},React.createElement(_reactNative.Animated.View,{needsOffscreenAlphaCompositing:isAnimating,style:[styles.sheetContainer,{opacity:sheetOpacity,transform:[{translateY:sheetOpacity.interpolate({inputRange:[0,1],outputRange:[this._actionSheetHeight,0]})}]}],__source:{fileName:_jsxFileName,lineNumber:98}},React.createElement(_reactNative.View,{style:styles.sheet,onLayout:this._setActionSheetHeight,__source:{fileName:_jsxFileName,lineNumber:114}},React.createElement(_ActionGroup.default,{options:optionsArray,icons:icons,tintIcons:tintIcons===undefined?true:tintIcons,destructiveButtonIndex:destructiveButtonIndex,onSelect:this._onSelect,startIndex:0,length:optionsArray.length,textStyle:textStyle||{},tintColor:tintColor,title:title||undefined,titleTextStyle:titleTextStyle,message:message||undefined,messageTextStyle:messageTextStyle,showSeparators:showSeparators,separatorStyle:separatorStyle,__source:{fileName:_jsxFileName,lineNumber:115}}))));}}]);return ActionSheet;}(React.Component);exports.default=ActionSheet;ActionSheet.defaultProps={useNativeDriver:true};var styles=_reactNative.StyleSheet.create({overlay:{position:'absolute',top:0,right:0,bottom:0,left:0,backgroundColor:'black'},sheetContainer:{position:'absolute',left:0,right:0,bottom:0,top:0,backgroundColor:'transparent',alignItems:'flex-end',justifyContent:'center',flexDirection:'row'},sheet:{flex:1,backgroundColor:'transparent'}}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(exports,"__esModule",{value:true});exports.default=connectActionSheet;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var React=_interopRequireWildcard(require("react"));var _context=require("./context");var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/connectActionSheet.tsx";function connectActionSheet(WrappedComponent){return function(props){return React.createElement(_context.Consumer,{__source:{fileName:_jsxFileName,lineNumber:9}},function(_ref){var showActionSheetWithOptions=_ref.showActionSheetWithOptions;return React.createElement(WrappedComponent,(0,_extends2.default)({},props,{showActionSheetWithOptions:showActionSheetWithOptions,__source:{fileName:_jsxFileName,lineNumber:12}}));});};} | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(exports,"__esModule",{value:true});exports.default=connectActionSheet;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var React=_interopRequireWildcard(require("react"));var _context=require("./context");var _hoistNonReactStatics=_interopRequireDefault(require("hoist-non-react-statics"));var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/connectActionSheet.tsx";function connectActionSheet(WrappedComponent){var ConnectedActionSheet=function ConnectedActionSheet(props){return React.createElement(_context.Consumer,{__source:{fileName:_jsxFileName,lineNumber:10}},function(_ref){var showActionSheetWithOptions=_ref.showActionSheetWithOptions;return React.createElement(WrappedComponent,(0,_extends2.default)({},props,{showActionSheetWithOptions:showActionSheetWithOptions,__source:{fileName:_jsxFileName,lineNumber:13}}));});};return(0,_hoistNonReactStatics.default)(ConnectedActionSheet,WrappedComponent);} | ||
//# sourceMappingURL=connectActionSheet.js.map |
@@ -1,2 +0,2 @@ | ||
var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(exports,"__esModule",{value:true});exports.Consumer=exports.Provider=void 0;var React=_interopRequireWildcard(require("react"));var _React$createContext=React.createContext({showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){}}),Provider=_React$createContext.Provider,Consumer=_React$createContext.Consumer;exports.Consumer=Consumer;exports.Provider=Provider; | ||
var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(exports,"__esModule",{value:true});exports.useActionSheet=useActionSheet;exports.Consumer=exports.Provider=void 0;var React=_interopRequireWildcard(require("react"));var context=React.createContext({showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){}});function useActionSheet(){return React.useContext(context);}var Provider=context.Provider,Consumer=context.Consumer;exports.Consumer=Consumer;exports.Provider=Provider; | ||
//# sourceMappingURL=context.js.map |
@@ -1,2 +0,2 @@ | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={ActionSheetProvider:true,connectActionSheet:true};Object.defineProperty(exports,"ActionSheetProvider",{enumerable:true,get:function get(){return _ActionSheetProvider.default;}});Object.defineProperty(exports,"connectActionSheet",{enumerable:true,get:function get(){return _connectActionSheet.default;}});var _ActionSheetProvider=_interopRequireDefault(require("./ActionSheetProvider"));var _connectActionSheet=_interopRequireDefault(require("./connectActionSheet"));var _types=require("./types");Object.keys(_types).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _types[key];}});}); | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={ActionSheetProvider:true,connectActionSheet:true,useActionSheet:true};Object.defineProperty(exports,"ActionSheetProvider",{enumerable:true,get:function get(){return _ActionSheetProvider.default;}});Object.defineProperty(exports,"connectActionSheet",{enumerable:true,get:function get(){return _connectActionSheet.default;}});Object.defineProperty(exports,"useActionSheet",{enumerable:true,get:function get(){return _context.useActionSheet;}});var _ActionSheetProvider=_interopRequireDefault(require("./ActionSheetProvider"));var _connectActionSheet=_interopRequireDefault(require("./connectActionSheet"));var _context=require("./context");var _types=require("./types");Object.keys(_types).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _types[key];}});}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/ActionSheet/index.tsx";import*as React from'react';import{Animated,BackHandler,Easing,StyleSheet,TouchableWithoutFeedback,View}from'react-native';import ActionGroup from'./ActionGroup';var OPACITY_ANIMATION_IN_TIME=225;var OPACITY_ANIMATION_OUT_TIME=195;var EASING_OUT=Easing.bezier(0.25,0.46,0.45,0.94);var EASING_IN=Easing.out(EASING_OUT);var ActionSheet=function(_React$Component){_inherits(ActionSheet,_React$Component);function ActionSheet(){var _getPrototypeOf2;var _this;_classCallCheck(this,ActionSheet);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_possibleConstructorReturn(this,(_getPrototypeOf2=_getPrototypeOf(ActionSheet)).call.apply(_getPrototypeOf2,[this].concat(args)));_this._actionSheetHeight=360;_this.state={isVisible:false,isAnimating:false,options:null,onSelect:null,overlayOpacity:new Animated.Value(0),sheetOpacity:new Animated.Value(0)};_this._setActionSheetHeight=function(_ref){var nativeEvent=_ref.nativeEvent;return _this._actionSheetHeight=nativeEvent.layout.height;};_this._selectCancelButton=function(){var options=_this.state.options;if(!options){return false;}if(typeof options.cancelButtonIndex==='number'){return _this._onSelect(options.cancelButtonIndex);}else{return _this._animateOut();}};_this._onSelect=function(index){var _this$state=_this.state,isAnimating=_this$state.isAnimating,onSelect=_this$state.onSelect;if(isAnimating){return false;}onSelect&&onSelect(index);return _this._animateOut();};_this._animateOut=function(){var _this$state2=_this.state,isAnimating=_this$state2.isAnimating,overlayOpacity=_this$state2.overlayOpacity,sheetOpacity=_this$state2.sheetOpacity;if(isAnimating){return false;}BackHandler.removeEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);_this.setState({isAnimating:true});Animated.parallel([Animated.timing(overlayOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver}),Animated.timing(sheetOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver})]).start(function(result){if(result.finished){_this.setState({isVisible:false,isAnimating:false});}});return true;};return _this;}_createClass(ActionSheet,[{key:"render",value:function render(){var _this$state3=this.state,isVisible=_this$state3.isVisible,overlayOpacity=_this$state3.overlayOpacity;var overlay=isVisible?React.createElement(Animated.View,{style:[styles.overlay,{opacity:overlayOpacity}],__source:{fileName:_jsxFileName,lineNumber:54}}):null;return React.createElement(View,{style:{flex:1},__source:{fileName:_jsxFileName,lineNumber:64}},React.Children.only(this.props.children),overlay,isVisible?this._renderSheet():null);}},{key:"_renderSheet",value:function _renderSheet(){var _this$state4=this.state,options=_this$state4.options,isAnimating=_this$state4.isAnimating,sheetOpacity=_this$state4.sheetOpacity;if(!options){return null;}var optionsArray=options.options,icons=options.icons,tintIcons=options.tintIcons,destructiveButtonIndex=options.destructiveButtonIndex,textStyle=options.textStyle,tintColor=options.tintColor,title=options.title,titleTextStyle=options.titleTextStyle,message=options.message,messageTextStyle=options.messageTextStyle,showSeparators=options.showSeparators,separatorStyle=options.separatorStyle;return React.createElement(TouchableWithoutFeedback,{onPress:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:97}},React.createElement(Animated.View,{needsOffscreenAlphaCompositing:isAnimating,style:[styles.sheetContainer,{opacity:sheetOpacity,transform:[{translateY:sheetOpacity.interpolate({inputRange:[0,1],outputRange:[this._actionSheetHeight,0]})}]}],__source:{fileName:_jsxFileName,lineNumber:98}},React.createElement(View,{style:styles.sheet,onLayout:this._setActionSheetHeight,__source:{fileName:_jsxFileName,lineNumber:114}},React.createElement(ActionGroup,{options:optionsArray,icons:icons,tintIcons:tintIcons===undefined?true:tintIcons,destructiveButtonIndex:destructiveButtonIndex,onSelect:this._onSelect,startIndex:0,length:optionsArray.length,textStyle:textStyle||{},tintColor:tintColor,title:title||undefined,titleTextStyle:titleTextStyle,message:message||undefined,messageTextStyle:messageTextStyle,showSeparators:showSeparators,separatorStyle:separatorStyle,__source:{fileName:_jsxFileName,lineNumber:115}}))));}},{key:"showActionSheetWithOptions",value:function showActionSheetWithOptions(options,onSelect){var _this2=this;var _this$state5=this.state,isVisible=_this$state5.isVisible,overlayOpacity=_this$state5.overlayOpacity,sheetOpacity=_this$state5.sheetOpacity;if(isVisible){return;}this.setState({options:options,onSelect:onSelect,isVisible:true,isAnimating:true});overlayOpacity.setValue(0);sheetOpacity.setValue(0);Animated.parallel([Animated.timing(overlayOpacity,{toValue:0.32,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:this.props.useNativeDriver}),Animated.timing(sheetOpacity,{toValue:1,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:this.props.useNativeDriver})]).start(function(result){if(result.finished){_this2.setState({isAnimating:false});}});BackHandler.addEventListener('actionSheetHardwareBackPress',this._selectCancelButton);}}]);return ActionSheet;}(React.Component);ActionSheet.defaultProps={useNativeDriver:true};export{ActionSheet as default};var styles=StyleSheet.create({overlay:{position:'absolute',top:0,right:0,bottom:0,left:0,backgroundColor:'black'},sheetContainer:{position:'absolute',left:0,right:0,bottom:0,top:0,backgroundColor:'transparent',alignItems:'flex-end',justifyContent:'center',flexDirection:'row'},sheet:{flex:1,backgroundColor:'transparent'}}); | ||
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/ActionSheet/index.tsx";import*as React from'react';import{Animated,BackHandler,Easing,StyleSheet,TouchableWithoutFeedback,View}from'react-native';import ActionGroup from'./ActionGroup';var OPACITY_ANIMATION_IN_TIME=225;var OPACITY_ANIMATION_OUT_TIME=195;var EASING_OUT=Easing.bezier(0.25,0.46,0.45,0.94);var EASING_IN=Easing.out(EASING_OUT);var ActionSheet=function(_React$Component){_inherits(ActionSheet,_React$Component);function ActionSheet(){var _getPrototypeOf2;var _this;_classCallCheck(this,ActionSheet);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_possibleConstructorReturn(this,(_getPrototypeOf2=_getPrototypeOf(ActionSheet)).call.apply(_getPrototypeOf2,[this].concat(args)));_this._actionSheetHeight=360;_this.state={isVisible:false,isAnimating:false,options:null,onSelect:null,overlayOpacity:new Animated.Value(0),sheetOpacity:new Animated.Value(0)};_this._setActionSheetHeight=function(_ref){var nativeEvent=_ref.nativeEvent;return _this._actionSheetHeight=nativeEvent.layout.height;};_this.showActionSheetWithOptions=function(options,onSelect){var _this$state=_this.state,isVisible=_this$state.isVisible,overlayOpacity=_this$state.overlayOpacity,sheetOpacity=_this$state.sheetOpacity;if(isVisible){return;}_this.setState({options:options,onSelect:onSelect,isVisible:true,isAnimating:true});overlayOpacity.setValue(0);sheetOpacity.setValue(0);Animated.parallel([Animated.timing(overlayOpacity,{toValue:0.32,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:_this.props.useNativeDriver}),Animated.timing(sheetOpacity,{toValue:1,easing:EASING_OUT,duration:OPACITY_ANIMATION_IN_TIME,useNativeDriver:_this.props.useNativeDriver})]).start(function(result){if(result.finished){_this.setState({isAnimating:false});}});BackHandler.addEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);};_this._selectCancelButton=function(){var options=_this.state.options;if(!options){return false;}if(typeof options.cancelButtonIndex==='number'){return _this._onSelect(options.cancelButtonIndex);}else{return _this._animateOut();}};_this._onSelect=function(index){var _this$state2=_this.state,isAnimating=_this$state2.isAnimating,onSelect=_this$state2.onSelect;if(isAnimating){return false;}onSelect&&onSelect(index);return _this._animateOut();};_this._animateOut=function(){var _this$state3=_this.state,isAnimating=_this$state3.isAnimating,overlayOpacity=_this$state3.overlayOpacity,sheetOpacity=_this$state3.sheetOpacity;if(isAnimating){return false;}BackHandler.removeEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);_this.setState({isAnimating:true});Animated.parallel([Animated.timing(overlayOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver}),Animated.timing(sheetOpacity,{toValue:0,easing:EASING_IN,duration:OPACITY_ANIMATION_OUT_TIME,useNativeDriver:_this.props.useNativeDriver})]).start(function(result){if(result.finished){_this.setState({isVisible:false,isAnimating:false});}});return true;};return _this;}_createClass(ActionSheet,[{key:"render",value:function render(){var _this$state4=this.state,isVisible=_this$state4.isVisible,overlayOpacity=_this$state4.overlayOpacity;var overlay=isVisible?React.createElement(Animated.View,{style:[styles.overlay,{opacity:overlayOpacity}],__source:{fileName:_jsxFileName,lineNumber:54}}):null;return React.createElement(View,{style:{flex:1},__source:{fileName:_jsxFileName,lineNumber:64}},React.Children.only(this.props.children),overlay,isVisible?this._renderSheet():null);}},{key:"_renderSheet",value:function _renderSheet(){var _this$state5=this.state,options=_this$state5.options,isAnimating=_this$state5.isAnimating,sheetOpacity=_this$state5.sheetOpacity;if(!options){return null;}var optionsArray=options.options,icons=options.icons,tintIcons=options.tintIcons,destructiveButtonIndex=options.destructiveButtonIndex,textStyle=options.textStyle,tintColor=options.tintColor,title=options.title,titleTextStyle=options.titleTextStyle,message=options.message,messageTextStyle=options.messageTextStyle,showSeparators=options.showSeparators,separatorStyle=options.separatorStyle;return React.createElement(TouchableWithoutFeedback,{onPress:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:97}},React.createElement(Animated.View,{needsOffscreenAlphaCompositing:isAnimating,style:[styles.sheetContainer,{opacity:sheetOpacity,transform:[{translateY:sheetOpacity.interpolate({inputRange:[0,1],outputRange:[this._actionSheetHeight,0]})}]}],__source:{fileName:_jsxFileName,lineNumber:98}},React.createElement(View,{style:styles.sheet,onLayout:this._setActionSheetHeight,__source:{fileName:_jsxFileName,lineNumber:114}},React.createElement(ActionGroup,{options:optionsArray,icons:icons,tintIcons:tintIcons===undefined?true:tintIcons,destructiveButtonIndex:destructiveButtonIndex,onSelect:this._onSelect,startIndex:0,length:optionsArray.length,textStyle:textStyle||{},tintColor:tintColor,title:title||undefined,titleTextStyle:titleTextStyle,message:message||undefined,messageTextStyle:messageTextStyle,showSeparators:showSeparators,separatorStyle:separatorStyle,__source:{fileName:_jsxFileName,lineNumber:115}}))));}}]);return ActionSheet;}(React.Component);ActionSheet.defaultProps={useNativeDriver:true};export{ActionSheet as default};var styles=StyleSheet.create({overlay:{position:'absolute',top:0,right:0,bottom:0,left:0,backgroundColor:'black'},sheetContainer:{position:'absolute',left:0,right:0,bottom:0,top:0,backgroundColor:'transparent',alignItems:'flex-end',justifyContent:'center',flexDirection:'row'},sheet:{flex:1,backgroundColor:'transparent'}}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import _extends from"@babel/runtime/helpers/extends";var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/connectActionSheet.tsx";import*as React from'react';import{Consumer}from'./context';export default function connectActionSheet(WrappedComponent){return function(props){return React.createElement(Consumer,{__source:{fileName:_jsxFileName,lineNumber:9}},function(_ref){var showActionSheetWithOptions=_ref.showActionSheetWithOptions;return React.createElement(WrappedComponent,_extends({},props,{showActionSheetWithOptions:showActionSheetWithOptions,__source:{fileName:_jsxFileName,lineNumber:12}}));});};} | ||
import _extends from"@babel/runtime/helpers/extends";var _jsxFileName="/Users/brentvatne/coding/react-native-action-sheet/src/connectActionSheet.tsx";import*as React from'react';import{Consumer}from'./context';import hoistNonReactStatic from'hoist-non-react-statics';export default function connectActionSheet(WrappedComponent){var ConnectedActionSheet=function ConnectedActionSheet(props){return React.createElement(Consumer,{__source:{fileName:_jsxFileName,lineNumber:10}},function(_ref){var showActionSheetWithOptions=_ref.showActionSheetWithOptions;return React.createElement(WrappedComponent,_extends({},props,{showActionSheetWithOptions:showActionSheetWithOptions,__source:{fileName:_jsxFileName,lineNumber:13}}));});};return hoistNonReactStatic(ConnectedActionSheet,WrappedComponent);} | ||
//# sourceMappingURL=connectActionSheet.js.map |
@@ -1,2 +0,2 @@ | ||
import*as React from'react';var _React$createContext=React.createContext({showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){}}),Provider=_React$createContext.Provider,Consumer=_React$createContext.Consumer;export{Provider,Consumer}; | ||
import*as React from'react';var context=React.createContext({showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){}});export function useActionSheet(){return React.useContext(context);}var Provider=context.Provider,Consumer=context.Consumer;export{Provider,Consumer}; | ||
//# sourceMappingURL=context.js.map |
@@ -1,2 +0,2 @@ | ||
export{default as ActionSheetProvider}from'./ActionSheetProvider';export{default as connectActionSheet}from'./connectActionSheet';export*from'./types'; | ||
export{default as ActionSheetProvider}from'./ActionSheetProvider';export{default as connectActionSheet}from'./connectActionSheet';export{useActionSheet}from'./context';export*from'./types'; | ||
//# sourceMappingURL=index.js.map |
@@ -23,3 +23,3 @@ import * as React from 'react'; | ||
_renderSheet(): JSX.Element | null; | ||
showActionSheetWithOptions(options: ActionSheetOptions, onSelect: (i: number) => void): void; | ||
showActionSheetWithOptions: (options: ActionSheetOptions, onSelect: (i: number) => void) => void; | ||
_selectCancelButton: () => boolean; | ||
@@ -26,0 +26,0 @@ _onSelect: (index: number) => boolean; |
import * as React from 'react'; | ||
import { Context } from './context'; | ||
export default function connectActionSheet<OwnProps = any>(WrappedComponent: React.ComponentType<OwnProps & Context>): (props: OwnProps) => JSX.Element; | ||
import hoistNonReactStatic from 'hoist-non-react-statics'; | ||
export default function connectActionSheet<OwnProps = any>(WrappedComponent: React.ComponentType<OwnProps & Context>): ((props: OwnProps) => JSX.Element) & hoistNonReactStatic.NonReactStatics<React.ComponentType<OwnProps & Context>, {}>; |
@@ -6,3 +6,4 @@ import * as React from 'react'; | ||
} | ||
export declare function useActionSheet(): Context; | ||
declare const Provider: React.ProviderExoticComponent<React.ProviderProps<Context>>, Consumer: React.ExoticComponent<React.ConsumerProps<Context>>; | ||
export { Provider, Consumer }; |
export { default as ActionSheetProvider } from './ActionSheetProvider'; | ||
export { default as connectActionSheet } from './connectActionSheet'; | ||
export { useActionSheet } from './context'; | ||
export * from './types'; |
{ | ||
"name": "@expo/react-native-action-sheet", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "A cross-platform ActionSheet for React Native", | ||
@@ -13,2 +13,3 @@ "react-native": "lib/module/index.js", | ||
"scripts": { | ||
"prepare": "bob build", | ||
"build": "bob build", | ||
@@ -74,3 +75,7 @@ "type-check": "tsc --noEmit", | ||
] | ||
}, | ||
"dependencies": { | ||
"@types/hoist-non-react-statics": "^3.3.1", | ||
"hoist-non-react-statics": "^3.3.0" | ||
} | ||
} |
@@ -19,3 +19,3 @@ # react-native-action-sheet | ||
``` | ||
or | ||
or | ||
``` | ||
@@ -27,3 +27,3 @@ $ yarn add @expo/react-native-action-sheet | ||
### 1. Connect your component which uses showActionSheetWithOptions. | ||
### 1. Connect your component which uses showActionSheetWithOptions. | ||
```es6 | ||
@@ -63,2 +63,13 @@ import { connectActionSheet } from '@expo/react-native-action-sheet' | ||
You can use a hook instead of the higher order component if you are on React 16.8 or newer. | ||
```es6 | ||
import { useActionSheet } from '@expo/react-native-action-sheet' | ||
export default function App () { | ||
const { showActionSheetWithOptions } = useActionSheet(); | ||
/* ... */ | ||
} | ||
``` | ||
### 2. Wrap your top-level component with `<ActionSheetProvider />` | ||
@@ -134,3 +145,3 @@ | ||
See the [example app](https://github.com/expo/react-native-action-sheet/tree/master/example). | ||
See the [example app](https://github.com/expo/react-native-action-sheet/tree/master/example). | ||
@@ -160,3 +171,3 @@ ### Usage | ||
### Build | ||
We use [bob](https://github.com/react-native-community/bob). | ||
We use [bob](https://github.com/react-native-community/bob). | ||
``` | ||
@@ -176,2 +187,2 @@ $ yarn build | ||
$ yarn fmt | ||
``` | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
120638
296
183
0
3
+ Added@types/hoist-non-react-statics@3.3.6(transitive)
+ Added@types/react@19.0.10(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addedhoist-non-react-statics@3.3.2(transitive)
+ Addedreact-is@16.13.1(transitive)