@expo/react-native-action-sheet
Advanced tools
Comparing version 3.14.0 to 4.0.0-rc.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 _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var React=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _ActionGroup=_interopRequireDefault(require("./ActionGroup"));var _jsxFileName="/Users/bradley/Code/expo/react-native-action-sheet/src/ActionSheet/index.tsx";function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2.default)(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2.default)(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2.default)(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}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 ESCAPE_KEY='Escape';var ActionSheet=function(_React$Component){(0,_inherits2.default)(ActionSheet,_React$Component);var _super=_createSuper(ActionSheet);function ActionSheet(){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=_super.call.apply(_super,[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._deferAfterAnimation=undefined;_this._handleWebKeyDown=function(event){if(event.key===ESCAPE_KEY&&_this.state.isVisible){event.preventDefault();_this._selectCancelButton();}};_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){_this._deferAfterAnimation=_this.showActionSheetWithOptions.bind((0,_assertThisInitialized2.default)(_this),options,onSelect);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});_this._deferAfterAnimation=undefined;}});_reactNative.BackHandler.addEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);};_this._selectCancelButton=function(){var options=_this.state.options;if(!options){return false;}if(typeof options.cancelButtonIndex==='undefined'){return false;}else 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;}if(onSelect){_this._deferAfterAnimation=onSelect.bind((0,_assertThisInitialized2.default)(_this),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});if(_this._deferAfterAnimation){_this._deferAfterAnimation();}}});return true;};return _this;}(0,_createClass2.default)(ActionSheet,[{key:"componentDidMount",value:function componentDidMount(){if(_reactNative.Platform.OS==='web'){document.addEventListener('keydown',this._handleWebKeyDown);}}},{key:"componentWillUnmount",value:function componentWillUnmount(){if(_reactNative.Platform.OS==='web'){document.removeEventListener('keydown',this._handleWebKeyDown);}}},{key:"render",value:function render(){var _this$state4=this.state,isVisible=_this$state4.isVisible,overlayOpacity=_this$state4.overlayOpacity,options=_this$state4.options;var useModal=options?options.autoFocus||options.useModal===true:false;var overlay=isVisible?React.createElement(_reactNative.Animated.View,{style:[styles.overlay,{opacity:overlayOpacity}],__source:{fileName:_jsxFileName,lineNumber:82,columnNumber:7}}):null;var appContent=React.createElement(_reactNative.View,{style:styles.flexContainer,importantForAccessibility:isVisible?'no-hide-descendants':'auto',__source:{fileName:_jsxFileName,lineNumber:94,columnNumber:7}},React.Children.only(this.props.children));return React.createElement(_reactNative.View,{pointerEvents:this.props.pointerEvents,style:styles.flexContainer,__source:{fileName:_jsxFileName,lineNumber:102,columnNumber:7}},appContent,isVisible&&!useModal&&React.createElement(React.Fragment,null,overlay,this._renderSheet()),isVisible&&useModal&&React.createElement(_reactNative.Modal,{animationType:"none",transparent:true,onRequestClose:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:111,columnNumber:11}},overlay,this._renderSheet()));}},{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,disabledButtonIndices=options.disabledButtonIndices,destructiveColor=options.destructiveColor,textStyle=options.textStyle,tintColor=options.tintColor,title=options.title,titleTextStyle=options.titleTextStyle,message=options.message,messageTextStyle=options.messageTextStyle,autoFocus=options.autoFocus,showSeparators=options.showSeparators,containerStyle=options.containerStyle,separatorStyle=options.separatorStyle,cancelButtonIndex=options.cancelButtonIndex,cancelButtonTintColor=options.cancelButtonTintColor;return React.createElement(_reactNative.TouchableWithoutFeedback,{importantForAccessibility:"yes",onPress:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:148,columnNumber:7}},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:149,columnNumber:9}},React.createElement(_reactNative.View,{style:styles.sheet,onLayout:this._setActionSheetHeight,__source:{fileName:_jsxFileName,lineNumber:165,columnNumber:11}},React.createElement(_ActionGroup.default,{options:optionsArray,icons:icons,tintIcons:tintIcons===undefined?true:tintIcons,cancelButtonIndex:cancelButtonIndex,cancelButtonTintColor:cancelButtonTintColor,destructiveButtonIndex:destructiveButtonIndex,destructiveColor:destructiveColor,disabledButtonIndices:disabledButtonIndices,onSelect:this._onSelect,startIndex:0,length:optionsArray.length,textStyle:textStyle||{},tintColor:tintColor,title:title||undefined,titleTextStyle:titleTextStyle,message:message||undefined,messageTextStyle:messageTextStyle,autoFocus:autoFocus,showSeparators:showSeparators,containerStyle:containerStyle,separatorStyle:separatorStyle,__source:{fileName:_jsxFileName,lineNumber:166,columnNumber:13}}))));}}]);return ActionSheet;}(React.Component);exports.default=ActionSheet;ActionSheet.defaultProps={useNativeDriver:true};var styles=_reactNative.StyleSheet.create({flexContainer:{flex:1},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");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _CustomActionSheet=_interopRequireDefault(require("./CustomActionSheet"));var _default=_CustomActionSheet.default;exports.default=_default; | ||
//# 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=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var React=_interopRequireWildcard(require("react"));var _ActionSheet=_interopRequireDefault(require("./ActionSheet"));var _context=require("./context");var _jsxFileName="/Users/bradley/Code/expo/react-native-action-sheet/src/ActionSheetProvider.tsx";function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2.default)(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2.default)(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2.default)(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}var ActionSheetProvider=function(_React$Component){(0,_inherits2.default)(ActionSheetProvider,_React$Component);var _super=_createSuper(ActionSheetProvider);function ActionSheetProvider(props){var _this;(0,_classCallCheck2.default)(this,ActionSheetProvider);_this=_super.call(this,props);_this._actionSheetRef=React.createRef();_this._context={showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){if(_this._actionSheetRef.current!=null){_this._actionSheetRef.current.showActionSheetWithOptions(options,callback);}}};return _this;}(0,_createClass2.default)(ActionSheetProvider,[{key:"getContext",value:function getContext(){return this._context;}},{key:"render",value:function render(){return React.createElement(_context.Provider,{value:this._context,__source:{fileName:_jsxFileName,lineNumber:34,columnNumber:7}},React.createElement(_ActionSheet.default,{ref:this._actionSheetRef,useNativeDriver:this.props.useNativeDriver,__source:{fileName:_jsxFileName,lineNumber:35,columnNumber:9}},React.Children.only(this.props.children)));}}]);return ActionSheetProvider;}(React.Component);exports.default=ActionSheetProvider; | ||
var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=ActionSheetProvider;var React=_interopRequireWildcard(require("react"));var _ActionSheet=_interopRequireDefault(require("./ActionSheet"));var _CustomActionSheet=_interopRequireDefault(require("./ActionSheet/CustomActionSheet"));var _context=require("./context");var _jsxFileName="/Users/bradley/Code/expo/react-native-action-sheet/src/ActionSheetProvider.tsx";function ActionSheetProvider(_ref){var children=_ref.children,useNativeDriver=_ref.useNativeDriver,_ref$useCustomActionS=_ref.useCustomActionSheet,useCustomActionSheet=_ref$useCustomActionS===void 0?false:_ref$useCustomActionS;var actionSheetRef=React.useRef(null);var context=React.useMemo(function(){return{showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){if(actionSheetRef.current){actionSheetRef.current.showActionSheetWithOptions(options,callback);}}};},[actionSheetRef]);var ActionSheet=React.useMemo(function(){return useCustomActionSheet?_CustomActionSheet.default:_ActionSheet.default;},[_CustomActionSheet.default]);return React.createElement(_context.Provider,{value:context,__source:{fileName:_jsxFileName,lineNumber:38,columnNumber:5}},React.createElement(ActionSheet,{ref:actionSheetRef,useNativeDriver:useNativeDriver,__source:{fileName:_jsxFileName,lineNumber:39,columnNumber:7}},React.Children.only(children)));} | ||
//# sourceMappingURL=ActionSheetProvider.js.map |
@@ -1,2 +0,2 @@ | ||
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";var _jsxFileName="/Users/bradley/Code/expo/react-native-action-sheet/src/ActionSheet/index.tsx";function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}import*as React from'react';import{Animated,BackHandler,Easing,Modal,Platform,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 ESCAPE_KEY='Escape';var ActionSheet=function(_React$Component){_inherits(ActionSheet,_React$Component);var _super=_createSuper(ActionSheet);function ActionSheet(){var _this;_classCallCheck(this,ActionSheet);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_super.call.apply(_super,[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._deferAfterAnimation=undefined;_this._handleWebKeyDown=function(event){if(event.key===ESCAPE_KEY&&_this.state.isVisible){event.preventDefault();_this._selectCancelButton();}};_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){_this._deferAfterAnimation=_this.showActionSheetWithOptions.bind(_assertThisInitialized(_this),options,onSelect);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});_this._deferAfterAnimation=undefined;}});BackHandler.addEventListener('actionSheetHardwareBackPress',_this._selectCancelButton);};_this._selectCancelButton=function(){var options=_this.state.options;if(!options){return false;}if(typeof options.cancelButtonIndex==='undefined'){return false;}else 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;}if(onSelect){_this._deferAfterAnimation=onSelect.bind(_assertThisInitialized(_this),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});if(_this._deferAfterAnimation){_this._deferAfterAnimation();}}});return true;};return _this;}_createClass(ActionSheet,[{key:"componentDidMount",value:function componentDidMount(){if(Platform.OS==='web'){document.addEventListener('keydown',this._handleWebKeyDown);}}},{key:"componentWillUnmount",value:function componentWillUnmount(){if(Platform.OS==='web'){document.removeEventListener('keydown',this._handleWebKeyDown);}}},{key:"render",value:function render(){var _this$state4=this.state,isVisible=_this$state4.isVisible,overlayOpacity=_this$state4.overlayOpacity,options=_this$state4.options;var useModal=options?options.autoFocus||options.useModal===true:false;var overlay=isVisible?React.createElement(Animated.View,{style:[styles.overlay,{opacity:overlayOpacity}],__source:{fileName:_jsxFileName,lineNumber:82,columnNumber:7}}):null;var appContent=React.createElement(View,{style:styles.flexContainer,importantForAccessibility:isVisible?'no-hide-descendants':'auto',__source:{fileName:_jsxFileName,lineNumber:94,columnNumber:7}},React.Children.only(this.props.children));return React.createElement(View,{pointerEvents:this.props.pointerEvents,style:styles.flexContainer,__source:{fileName:_jsxFileName,lineNumber:102,columnNumber:7}},appContent,isVisible&&!useModal&&React.createElement(React.Fragment,null,overlay,this._renderSheet()),isVisible&&useModal&&React.createElement(Modal,{animationType:"none",transparent:true,onRequestClose:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:111,columnNumber:11}},overlay,this._renderSheet()));}},{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,disabledButtonIndices=options.disabledButtonIndices,destructiveColor=options.destructiveColor,textStyle=options.textStyle,tintColor=options.tintColor,title=options.title,titleTextStyle=options.titleTextStyle,message=options.message,messageTextStyle=options.messageTextStyle,autoFocus=options.autoFocus,showSeparators=options.showSeparators,containerStyle=options.containerStyle,separatorStyle=options.separatorStyle,cancelButtonIndex=options.cancelButtonIndex,cancelButtonTintColor=options.cancelButtonTintColor;return React.createElement(TouchableWithoutFeedback,{importantForAccessibility:"yes",onPress:this._selectCancelButton,__source:{fileName:_jsxFileName,lineNumber:148,columnNumber:7}},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:149,columnNumber:9}},React.createElement(View,{style:styles.sheet,onLayout:this._setActionSheetHeight,__source:{fileName:_jsxFileName,lineNumber:165,columnNumber:11}},React.createElement(ActionGroup,{options:optionsArray,icons:icons,tintIcons:tintIcons===undefined?true:tintIcons,cancelButtonIndex:cancelButtonIndex,cancelButtonTintColor:cancelButtonTintColor,destructiveButtonIndex:destructiveButtonIndex,destructiveColor:destructiveColor,disabledButtonIndices:disabledButtonIndices,onSelect:this._onSelect,startIndex:0,length:optionsArray.length,textStyle:textStyle||{},tintColor:tintColor,title:title||undefined,titleTextStyle:titleTextStyle,message:message||undefined,messageTextStyle:messageTextStyle,autoFocus:autoFocus,showSeparators:showSeparators,containerStyle:containerStyle,separatorStyle:separatorStyle,__source:{fileName:_jsxFileName,lineNumber:166,columnNumber:13}}))));}}]);return ActionSheet;}(React.Component);ActionSheet.defaultProps={useNativeDriver:true};export{ActionSheet as default};var styles=StyleSheet.create({flexContainer:{flex:1},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 CustomActionSheet from'./CustomActionSheet';export default CustomActionSheet; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";var _jsxFileName="/Users/bradley/Code/expo/react-native-action-sheet/src/ActionSheetProvider.tsx";function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}import*as React from'react';import ActionSheet from'./ActionSheet';import{Provider}from'./context';var ActionSheetProvider=function(_React$Component){_inherits(ActionSheetProvider,_React$Component);var _super=_createSuper(ActionSheetProvider);function ActionSheetProvider(props){var _this;_classCallCheck(this,ActionSheetProvider);_this=_super.call(this,props);_this._actionSheetRef=React.createRef();_this._context={showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){if(_this._actionSheetRef.current!=null){_this._actionSheetRef.current.showActionSheetWithOptions(options,callback);}}};return _this;}_createClass(ActionSheetProvider,[{key:"getContext",value:function getContext(){return this._context;}},{key:"render",value:function render(){return React.createElement(Provider,{value:this._context,__source:{fileName:_jsxFileName,lineNumber:34,columnNumber:7}},React.createElement(ActionSheet,{ref:this._actionSheetRef,useNativeDriver:this.props.useNativeDriver,__source:{fileName:_jsxFileName,lineNumber:35,columnNumber:9}},React.Children.only(this.props.children)));}}]);return ActionSheetProvider;}(React.Component);export{ActionSheetProvider as default}; | ||
var _jsxFileName="/Users/bradley/Code/expo/react-native-action-sheet/src/ActionSheetProvider.tsx";import*as React from'react';import NativeActionSheet from'./ActionSheet';import CustomActionSheet from'./ActionSheet/CustomActionSheet';import{Provider}from'./context';export default function ActionSheetProvider(_ref){var children=_ref.children,useNativeDriver=_ref.useNativeDriver,_ref$useCustomActionS=_ref.useCustomActionSheet,useCustomActionSheet=_ref$useCustomActionS===void 0?false:_ref$useCustomActionS;var actionSheetRef=React.useRef(null);var context=React.useMemo(function(){return{showActionSheetWithOptions:function showActionSheetWithOptions(options,callback){if(actionSheetRef.current){actionSheetRef.current.showActionSheetWithOptions(options,callback);}}};},[actionSheetRef]);var ActionSheet=React.useMemo(function(){return useCustomActionSheet?CustomActionSheet:NativeActionSheet;},[CustomActionSheet]);return React.createElement(Provider,{value:context,__source:{fileName:_jsxFileName,lineNumber:38,columnNumber:5}},React.createElement(ActionSheet,{ref:actionSheetRef,useNativeDriver:useNativeDriver,__source:{fileName:_jsxFileName,lineNumber:39,columnNumber:7}},React.Children.only(children)));} | ||
//# sourceMappingURL=ActionSheetProvider.js.map |
@@ -1,34 +0,2 @@ | ||
import * as React from 'react'; | ||
import { ViewProps } from 'react-native'; | ||
import { ActionSheetOptions } from '../types'; | ||
interface State { | ||
isVisible: boolean; | ||
isAnimating: boolean; | ||
options: ActionSheetOptions | null; | ||
onSelect: ((i: number) => void) | null; | ||
overlayOpacity: any; | ||
sheetOpacity: any; | ||
} | ||
interface Props { | ||
readonly useNativeDriver: boolean | undefined; | ||
readonly pointerEvents?: ViewProps['pointerEvents']; | ||
} | ||
export default class ActionSheet extends React.Component<Props, State> { | ||
static defaultProps: { | ||
useNativeDriver: boolean; | ||
}; | ||
_actionSheetHeight: number; | ||
state: State; | ||
_deferAfterAnimation?: () => void; | ||
componentDidMount(): void; | ||
componentWillUnmount(): void; | ||
_handleWebKeyDown: (event: KeyboardEvent) => void; | ||
_setActionSheetHeight: ({ nativeEvent }: any) => any; | ||
render(): JSX.Element; | ||
_renderSheet(): JSX.Element | null; | ||
showActionSheetWithOptions: (options: ActionSheetOptions, onSelect: (i: number) => void) => void; | ||
_selectCancelButton: () => boolean; | ||
_onSelect: (index: number) => boolean; | ||
_animateOut: () => boolean; | ||
} | ||
export {}; | ||
import CustomActionSheet from './CustomActionSheet'; | ||
export default CustomActionSheet; |
import * as React from 'react'; | ||
import ActionSheet from './ActionSheet'; | ||
import { ActionSheetProps } from './types'; | ||
interface Props { | ||
children: React.ReactNode; | ||
useNativeDriver?: boolean; | ||
useCustomActionSheet?: boolean; | ||
} | ||
export default class ActionSheetProvider extends React.Component<Props> { | ||
_actionSheetRef: React.RefObject<ActionSheet>; | ||
_context: ActionSheetProps; | ||
constructor(props: Props); | ||
getContext(): ActionSheetProps; | ||
render(): JSX.Element; | ||
} | ||
export default function ActionSheetProvider({ children, useNativeDriver, useCustomActionSheet, }: Props): JSX.Element; | ||
export {}; |
{ | ||
"name": "@expo/react-native-action-sheet", | ||
"version": "3.14.0", | ||
"version": "4.0.0-rc.0", | ||
"description": "A cross-platform ActionSheet for React Native", | ||
@@ -5,0 +5,0 @@ "react-native": "lib/module/index.js", |
211
README.md
@@ -1,2 +0,2 @@ | ||
# react-native-action-sheet | ||
# @expo/react-native-action-sheet | ||
@@ -7,3 +7,3 @@ [![npm](https://img.shields.io/npm/v/@expo/react-native-action-sheet.svg?style=flat-square)](https://www.npmjs.com/package/@expo/react-native-action-sheet) | ||
ActionSheet is a cross-platform React Native component that uses the native UIActionSheet on iOS and a JS implementation on Android. Almost a drop in replacement for [ActionSheetIOS](https://facebook.github.io/react-native/docs/actionsheetios.html) except it cannot be called statically. | ||
React Native Action Sheet is a cross-platform React Native component that uses the native UIActionSheet on iOS and a pure JS implementation on Android. | ||
@@ -14,6 +14,8 @@ | iOS | Android | Web | | ||
## <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAgVBMVEX///8AAACHh4fh4eGZmZl4eHj8/PwEBAT5+fkNDQ0JCQkTExPz8/Pv7+/n5+cQEBAlJSXKyspFRUUZGRnR0dEwMDArKyuAgIAgICA2NjZtbW1eXl5TU1PX19e5ubm/v7+jo6Ovr69ycnKQkJBISEhSUlI7OzuoqKiysrJcXFxlZWVHm5C5AAALb0lEQVR4nO2daXvqKhSFkzpHTR2rbY9Tbav1///ASyCJCWxgMyXtfVxf7j02RN7IsNhAiKKHHnrooYf+P0pvz/86bWfCXcPzKI7jpDdpOyOOus5ipuWx7ay4aPeZMbwcv7P/vM7bzo6tph8Dkv/ncz+KjssM5T1tO0s26nfHJO+D25T+a9JLyL9GT8OWc2Wuwzr7DRar8oPOV/bB7NpinizU+clyvb3UPty/ZB9+7lrKk4WGm6wcJRu+HPXPz1lp+5i2kitzXbbZk/+BOsHpLav/426/8UyZa8Xa2oPyz2vZn7VKV4f9YRW++Utvse6RK34wtYb7j9fnvH8dvX5cA5qFohKov0JWhdSav4/iupIf699VI3Sz1PlHG7UT/ta7ryL74/VivSz+UWne/Yl912yPuljoZpRKaRsRj99PHfYz9jvX2zi2LKJqTXrMj2DLS97xv2Ga4lNCDc6hXvH6B4qXHE2zqhQzUzeT1mT6hmyKN9ICu6NFtOevMZ+/Zjf8NrW3u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a+Nh0AcjnhuUJxrEUEcj3huTnXXwoMs3Y94bk5V11IHsTrfq03dXUsNxO4QkHZVuJYKyC8w6zbKXUu5YMDtoJxWlVYOTfpFZt1G5aoaL4eGt6pjtszJ8cWRv0OTRfLzC836Qw899NBDvvUfXky6QPNuFGIAAAAASUVORK5CYII=" height="20" width="20" /> [Check out the example snack here!](https://snack.expo.dev/@expo-action-sheet/example) | ||
## Installation | ||
``` | ||
$ npm install @expo/react-native-action-sheet -S | ||
npm install @expo/react-native-action-sheet | ||
``` | ||
@@ -24,3 +26,3 @@ | ||
``` | ||
$ yarn add @expo/react-native-action-sheet | ||
yarn add @expo/react-native-action-sheet | ||
``` | ||
@@ -32,63 +34,70 @@ | ||
```es6 | ||
ReactNativeActionSheet uses React context to allow your components to invoke the menu. This means your app needs to be wrapped with the `ActionSheetProvider` component first. | ||
```jsx | ||
import { ActionSheetProvider } from '@expo/react-native-action-sheet'; | ||
class AppContainer extends React.Component { | ||
render() { | ||
return ( | ||
<ActionSheetProvider> | ||
<ConnectedApp /> | ||
</ActionSheetProvider> | ||
); | ||
} | ||
export default function AppContainer() { | ||
return ( | ||
<ActionSheetProvider> | ||
<App /> | ||
</ActionSheetProvider> | ||
); | ||
} | ||
``` | ||
### 2. Connect your component which uses showActionSheetWithOptions. | ||
### 2. Call the `showActionSheetWithOptions` method with a hook or a higher order component. | ||
```es6 | ||
import { connectActionSheet } from '@expo/react-native-action-sheet'; | ||
```tsx | ||
// Using the provided hook | ||
import { useActionSheet } from '@expo/react-native-action-sheet'; | ||
class App extends React.Component { | ||
/* ... */ | ||
} | ||
export default Menu() { | ||
const { showActionSheetWithOptions } = useActionSheet(); | ||
const ConnectedApp = connectActionSheet(App); | ||
const onPress() => { | ||
const options = ['Delete', 'Save', 'Cancel']; | ||
const destructiveButtonIndex = 0; | ||
const cancelButtonIndex = 2; | ||
export default ConnectedApp; | ||
``` | ||
showActionSheetWithOptions({ | ||
options, | ||
cancelButtonIndex, | ||
destructiveButtonIndex | ||
}, (selectedIndex: number) => { | ||
switch (selectedIndex) { | ||
case 1: | ||
// Save | ||
break; | ||
`App` component can access the actionSheet method as `this.props.showActionSheetWithOptions` | ||
case destructiveButtonIndex: | ||
// Delete | ||
break; | ||
```es6 | ||
_onOpenActionSheet = () => { | ||
// Same interface as https://facebook.github.io/react-native/docs/actionsheetios.html | ||
const options = ['Delete', 'Save', 'Cancel']; | ||
const destructiveButtonIndex = 0; | ||
const cancelButtonIndex = 2; | ||
case cancelButtonIndex: | ||
// Canceled | ||
}}); | ||
} | ||
this.props.showActionSheetWithOptions( | ||
{ | ||
options, | ||
cancelButtonIndex, | ||
destructiveButtonIndex, | ||
}, | ||
(buttonIndex) => { | ||
// Do something here depending on the button index selected | ||
} | ||
); | ||
return ( | ||
<Button title="Menu" onPress={onPress}/> | ||
) | ||
}; | ||
``` | ||
You can use a hook instead of the higher order component if you are on React 16.8 or newer. | ||
Alternatively, any component can use the higher order component to access the context and pass the `showActionSheetWithOptions` as a prop. | ||
```es6 | ||
import { useActionSheet } from '@expo/react-native-action-sheet'; | ||
```tsx | ||
// Using a Higher Order Component to wrap your component | ||
import { connectActionSheet } from '@expo/react-native-action-sheet'; | ||
export default function App() { | ||
const { showActionSheetWithOptions } = useActionSheet(); | ||
function Menu({ showActionSheetWithOptions }) { | ||
/* ... */ | ||
} | ||
export default connectActionSheet(Menu); | ||
``` | ||
`Menu` component can now access the actionSheet prop as `showActionSheetWithOptions`. | ||
## Options | ||
@@ -102,19 +111,20 @@ | ||
The same options available on React Native's [ActionSheetIOS](https://reactnative.dev/docs/0.64/actionsheetios#showactionsheetwithoptions) component exist for both iOS and Android in this library. Note: `disabledButtonIndices` is only available for iOS in Expo 43+ or RN 0.64.0+. | ||
| Name | Type | Description | | ||
| ------------------------ | -------------------------- | ------------------------------------------------------------- | | ||
| `options` | array of strings | A list of button titles **(required)** | | ||
| `cancelButtonIndex` | number | Index of cancel button in options | | ||
| `cancelButtonTintColor` | string | Color used for the change the text color of the cancel button | | ||
| `destructiveButtonIndex` | number or array of numbers | Indices of destructive buttons in options | | ||
| `title` | string | Title to show above the action sheet | | ||
| `message` | string | Message to show below the title | | ||
| `tintColor` | string | Color used for non-destructive button titles | | ||
| `disabledButtonIndices` | array of numbers | Indices of disabled buttons in options | | ||
### iOS Only Props | ||
| Name | Type | Required | Default | | ||
| ------------------ | ------ | -------- | ------- | | ||
| anchor | number | No | | | ||
| userInterfaceStyle | string | No | | | ||
| Name | Type | Description | | ||
| -------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `anchor` | number | iPad only option that allows for docking the action sheet to a node. See [ShowActionSheetButton.tsx](/example/ShowActionSheetButton.tsx) for an example on how to implement this. | | ||
| `userInterfaceStyle` | string | The interface style used for the action sheet, can be set to `light` or `dark`, otherwise the default system style will be used. | | ||
#### `anchor` (optional) | ||
iPad only option that allows for docking the action sheet to a node. See [ShowActionSheetButton.tsx](/example/ShowActionSheetButton.tsx) for an example on how to implement this. | ||
#### `userInterfaceStyle` (optional) | ||
The interface style used for the action sheet, can be set to `light` or `dark`, otherwise the default system style will be used. | ||
### Android/Web-Only Props | ||
@@ -124,72 +134,37 @@ | ||
| Name | Type | Required | Default | | ||
| ---------------- | --------------------------------- | -------- | --------------------------------- | | ||
| icons | array of required images or icons | No | | | ||
| tintIcons | boolean | No | true | | ||
| textStyle | TextStyle | No | | | ||
| titleTextStyle | TextStyle | No | | | ||
| messageTextStyle | TextStyle | No | | | ||
| autoFocus | boolean | No | false | | ||
| showSeparators | boolean | No | false | | ||
| containerStyle | ViewStyle | No | | | ||
| separatorStyle | ViewStyle | No | | | ||
| useModal | boolean | No | false (true if autoFocus is true) | | ||
| destructiveColor | string | No | #d32f2f | | ||
| Name | Type | Description | | ||
| ------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `icons` | array of required images or icons | Show icons to go along with each option. If image source paths are provided via `require`, images will be rendered for you. Alternatively, you can provide an array of elements such as vector icons, pre-rendered Images, etc. | | ||
| `tintIcons` | boolean | Icons by default will be tinted to match the text color. When set to false, the icons will be the color of the source image. This is useful if you want to use multicolor icons. If you provide your own nodes/pre-rendered icons rather than required images in the `icons` array, you will need to tint them appropriately before providing them in the array of `icons`; `tintColor` will not be applied to icons unless they are images from a required source. | | ||
| `textStyle` | TextStyle | Apply any text style props to the options. If the `tintColor` option is provided, it takes precedence over a color text style prop. | | ||
| `titleTextStyle` | TextStyle | Apply any text style props to the title if present. | | ||
| `messageTextStyle` | TextStyle | Apply any text style props to the message if present. | | ||
| `autoFocus` | boolean | If `true`, this will give the first option screen reader focus automatically when the action sheet becomes visible. On iOS, this is the default behavior of the native action sheet. | | ||
| `showSeparators` | boolean | Show separators between items. On iOS, separators always show so this prop has no effect. | | ||
| `containerStyle` | ViewStyle | Apply any view style props to the container rather than use the default look (e.g. dark mode). | | ||
| `separatorStyle` | ViewStyle | Modify the look of the separators rather than use the default look. | | ||
| `useModal` | boolean | Defaults to `false` (`true` if autoFocus is also `true`) Wraps the ActionSheet with a Modal, in order to show in front of other Modals that were already opened ([issue reference](https://github.com/expo/react-native-action-sheet/issues/164)). | | ||
| `destructiveColor` | string | Modify color for text of destructive option. Defaults to `#d32f2f`. | | ||
#### `icons` (optional) | ||
## ActionSheetProvider Props | ||
Show icons to go along with each option. If image source paths are provided via `require`, images will be rendered for you. Alternatively, you can provide an array of elements such as vector icons, pre-rendered Images, etc. | ||
The following props can be set directly on the `ActionSheetProvider` | ||
#### `tintIcons` (optional) | ||
| Name | Type | Description | | ||
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| `useNativeDriver` | boolean | Windows only option that provides the option to disable the [native animation](https://reactnative.dev/docs/animated#using-the-native-driver) driver for React Native Windows projects targeting _Windows 10 Version-1809 ; Build-10.0.17763.0_ and earlier. `useNativeDriver` is [supported in Version-1903 and later](https://microsoft.github.io/react-native-windows/docs/win10-compat) so if your project is targeting that, you don't need to set this prop. | | ||
Icons by default will be tinted to match the text color. When set to false, the icons will be the color of the source image. This is useful if you want to use multicolor icons. If you provide your own nodes/pre-rendered icons rather than required images in the `icons` array, you will need to tint them appropriately before providing them in the array of `icons`; `tintColor` will not be applied to icons unless they are images from a required source. | ||
## Callback | ||
#### `textStyle` (optional) | ||
The second parameter of the `showActionSheetWithOptions` function is a callback for when a button is selected. The callback takes a single argument which will be the zero-based index of the pressed option. You can check the value against your `cancelButtonIndex` to determine if the action was cancelled or not. | ||
Apply any text style props to the options. If the `tintColor` option is provided, it takes precedence over a color text style prop. | ||
```tsx | ||
function onButtonPress(selectedIndex: number) { | ||
// handle it! | ||
} | ||
``` | ||
#### `titleTextStyle` (optional) | ||
Apply any text style props to the title if present. | ||
#### `messageTextStyle` (optional) | ||
Apply any text style props to the message if present. | ||
#### `autoFocus`: (optional) | ||
If true, will give the first option screen reader focus automatically when the action sheet becomes visible. | ||
On iOS, this is the default behavior of the native action sheet. | ||
#### `showSeparators`: (optional) | ||
Show separators between items. On iOS, separators always show so this prop has no effect. | ||
#### `containerStyle`: (optional) | ||
Apply any view style props to the container rather than use the default look (e.g. dark mode). | ||
#### `separatorStyle`: (optional) | ||
Modify the look of the separators rather than use the default look. | ||
#### `useModal`: (optional) | ||
Wrap the ActionSheet with a Modal, in order to show in front of other Modals that were already opened ([issue reference](https://github.com/expo/react-native-action-sheet/issues/164)). | ||
#### `destructiveColor`: (optional) | ||
Modify color for text of destructive option. | ||
## ActionSheetProvider Props | ||
The following props can be set directly on the `ActionSheetProvider` | ||
#### `useNativeDriver` (optional) | ||
Windows only option that provides the option to disable the [native animation](https://reactnative.dev/docs/animated#using-the-native-driver) driver for React Native Windows projects targeting _Windows 10 Version-1809 ; Build-10.0.17763.0_ and earlier. `useNativeDriver` is [supported in Version-1903 and later](https://microsoft.github.io/react-native-windows/docs/win10-compat) so if your project is targeting that, you don't need to set this prop. | ||
## Try it out | ||
Try it in Expo: https://expo.io/@community/react-native-action-sheet-example | ||
Try it in Expo Snack: https://snack.expo.dev/@expo-action-sheet/example. | ||
@@ -196,0 +171,0 @@ ## Example |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance 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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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 1 instance in 1 package
168775
53
0
355
9
210