react-native-multiple-modals
Version:
Native implementation with the ability to display multiple Modals
196 lines • 9.15 kB
JavaScript
;
function _type_of(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = function(target, value) {
return __defProp(target, "name", {
value: value,
configurable: true
});
};
var __export = function(target, all) {
for(var name in all)__defProp(target, name, {
get: all[name],
enumerable: true
});
};
var __copyProps = function(to, from, except, desc) {
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
try {
var _loop = function() {
var key = _step.value;
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: function() {
return from[key];
},
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
};
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally{
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally{
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return to;
};
var __toESM = function(mod, isNodeMode, target) {
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod);
};
var __toCommonJS = function(mod) {
return __copyProps(__defProp({}, "__esModule", {
value: true
}), mod);
};
// src/index.ts
var index_exports = {};
__export(index_exports, {
DismissalSource: function() {
return DismissalSource;
},
ModalView: function() {
return ModalView;
}
});
module.exports = __toCommonJS(index_exports);
// src/ModalView.tsx
var import_react_native = require("react-native");
// src/ScrollContextResetter.tsx
var import_virtualized_lists = require("@react-native/virtualized-lists");
var import_ScrollViewContext = __toESM(require("react-native/Libraries/Components/ScrollView/ScrollViewContext"));
var ScrollContextResetter = /* @__PURE__ */ __name(function(param) {
var children = param.children;
return /* @__PURE__ */ React.createElement(import_virtualized_lists.VirtualizedListContextResetter, null, /* @__PURE__ */ React.createElement(import_ScrollViewContext.default.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
var import_codegenNativeComponent = __toESM(require("react-native/Libraries/Utilities/codegenNativeComponent"));
var NativeRNTModalView_default = (0, import_codegenNativeComponent.default)("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 = import_react_native.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 ? import_react_native.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(import_react_native.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(import_react_native.View, {
collapsable: false,
style: styles.flex
}, isIOS && statusBar && !disableDefaultStatusBarIOS ? /* @__PURE__ */ React.createElement(import_react_native.StatusBar, statusBar) : null, /* @__PURE__ */ React.createElement(GestureHandlerRootView, {
style: styles.flex
}, /* @__PURE__ */ React.createElement(import_react_native.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(import_react_native.View, {
style: [
styles.flex,
{
backgroundColor: backdropColor
}
]
}))), /* @__PURE__ */ React.createElement(ScrollContextResetter, null, /* @__PURE__ */ React.createElement(import_react_native.View, {
pointerEvents: "box-none",
style: [
styles.content,
contentContainerStyle
]
}, children))))));
}, "ModalView");
var styles = import_react_native.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
}
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DismissalSource: DismissalSource,
ModalView: ModalView
});
//# sourceMappingURL=index.js.map