react-native-multiple-modals
Version:
Native implementation with the ability to display multiple Modals
129 lines • 6.42 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = function(target, value) {
return __defProp(target, "name", {
value: value,
configurable: true
});
};
var __require = /* @__PURE__ */ function(x) {
return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: function(a, b) {
return (typeof require !== "undefined" ? require : a)[b];
}
}) : x;
}(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
// src/ModalView.tsx
import { Platform, Pressable, StatusBar, StyleSheet, View } from "react-native";
// src/ScrollContextResetter.tsx
import { VirtualizedListContextResetter } from "@react-native/virtualized-lists";
import ScrollViewContext from "react-native/Libraries/Components/ScrollView/ScrollViewContext";
var ScrollContextResetter = /* @__PURE__ */ __name(function(param) {
var children = param.children;
return /* @__PURE__ */ React.createElement(VirtualizedListContextResetter, null, /* @__PURE__ */ React.createElement(ScrollViewContext.Provider, {
value: null
}, children));
}, "ScrollContextResetter");
// src/integrations/GestureHandlerRootView.tsx
var importGestureHandlerRootView = /* @__PURE__ */ __name(function() {
var Errors = {
GestureHandlerRootViewNotFound: new Error("GestureHandlerRootView not found. Please report the issue: https://github.com/paufau/react-native-multiple-modals/issues")
};
try {
var GestureHandlerRootViewComponent = __require("react-native-gesture-handler").GestureHandlerRootView;
if (!GestureHandlerRootViewComponent) {
throw Errors.GestureHandlerRootViewNotFound;
}
return GestureHandlerRootViewComponent;
} catch (e) {
if (e === Errors.GestureHandlerRootViewNotFound) {
console.error(e);
}
return function(param) {
var children = param.children;
return children;
};
}
}, "importGestureHandlerRootView");
var GestureHandlerRootView = importGestureHandlerRootView();
// src/newarch/NativeRNTModalView.ts
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
var NativeRNTModalView_default = codegenNativeComponent("RNTModalView", {
interfaceOnly: true
});
// src/ModalView.tsx
var DismissalSource = /* @__PURE__ */ function(DismissalSource2) {
DismissalSource2["BackButton"] = "BackButton";
DismissalSource2["Backdrop"] = "Backdrop";
return DismissalSource2;
}({});
var backdropAccessibilityLabel = "Backdrop";
var backdropAccessibilityHint = "Double-tap to close the modal";
var defaultBackdropColor = "rgba(0, 0, 0, 0.3)";
var isIOS = Platform.OS === "ios";
var ModalView = /* @__PURE__ */ __name(function(param) {
var children = param.children, renderBackdrop = param.renderBackdrop, onRequestDismiss = param.onRequestDismiss, contentContainerStyle = param.contentContainerStyle, statusBar = param.statusBar, _param_BackdropPressableComponent = param.BackdropPressableComponent, BackdropPressableComponent = _param_BackdropPressableComponent === void 0 ? Pressable : _param_BackdropPressableComponent, _param_backdropColor = param.backdropColor, backdropColor = _param_backdropColor === void 0 ? defaultBackdropColor : _param_backdropColor, _param_disableDefaultStatusBarIOS = param.disableDefaultStatusBarIOS, disableDefaultStatusBarIOS = _param_disableDefaultStatusBarIOS === void 0 ? false : _param_disableDefaultStatusBarIOS, _param_animationType = param.animationType, animationType = _param_animationType === void 0 ? "none" : _param_animationType, statusBarTranslucent = param.statusBarTranslucent;
var _statusBar_translucent, _statusBar_barStyle;
return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(NativeRNTModalView_default, {
style: styles.container,
statusBarTranslucent: (_statusBar_translucent = statusBar === null || statusBar === void 0 ? void 0 : statusBar.translucent) !== null && _statusBar_translucent !== void 0 ? _statusBar_translucent : statusBarTranslucent,
statusBarIconsStyle: (_statusBar_barStyle = statusBar === null || statusBar === void 0 ? void 0 : statusBar.barStyle) !== null && _statusBar_barStyle !== void 0 ? _statusBar_barStyle : void 0,
onPressBackAndroid: /* @__PURE__ */ __name(function() {
return onRequestDismiss === null || onRequestDismiss === void 0 ? void 0 : onRequestDismiss("BackButton");
}, "onPressBackAndroid"),
animationType: animationType
}, /* @__PURE__ */ React.createElement(View, {
collapsable: false,
style: styles.flex
}, isIOS && statusBar && !disableDefaultStatusBarIOS ? /* @__PURE__ */ React.createElement(StatusBar, statusBar) : null, /* @__PURE__ */ React.createElement(GestureHandlerRootView, {
style: styles.flex
}, /* @__PURE__ */ React.createElement(View, {
style: [
styles.backdropContainer
]
}, /* @__PURE__ */ React.createElement(BackdropPressableComponent, {
accessibilityLabel: backdropAccessibilityLabel,
accessibilityHint: backdropAccessibilityHint,
style: styles.flex,
onPress: /* @__PURE__ */ __name(function() {
return onRequestDismiss === null || onRequestDismiss === void 0 ? void 0 : onRequestDismiss("Backdrop");
}, "onPress")
}, renderBackdrop ? renderBackdrop() : /* @__PURE__ */ React.createElement(View, {
style: [
styles.flex,
{
backgroundColor: backdropColor
}
]
}))), /* @__PURE__ */ React.createElement(ScrollContextResetter, null, /* @__PURE__ */ React.createElement(View, {
pointerEvents: "box-none",
style: [
styles.content,
contentContainerStyle
]
}, children))))));
}, "ModalView");
var styles = StyleSheet.create({
container: {
position: "absolute"
},
flex: {
flex: 1
},
content: {
zIndex: 1,
flex: 1
},
backdropContainer: {
position: "absolute",
zIndex: 0,
top: 0,
bottom: 0,
left: 0,
right: 0
}
});
export { DismissalSource, ModalView };
//# sourceMappingURL=index.mjs.map